@fruga/sdk 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/relay.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";var os=Object.create;var Kt=Object.defineProperty;var as=Object.getOwnPropertyDescriptor;var is=Object.getOwnPropertyNames;var ss=Object.getPrototypeOf,ns=Object.prototype.hasOwnProperty;var Wo=t=>{throw TypeError(t)};var ls=(t,e,r)=>e in t?Kt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var cs=(t,e)=>{for(var r in e)Kt(t,r,{get:e[r],enumerable:!0})},jo=(t,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of is(e))!ns.call(t,a)&&a!==r&&Kt(t,a,{get:()=>e[a],enumerable:!(o=as(e,a))||o.enumerable});return t};var we=(t,e,r)=>(r=t!=null?os(ss(t)):{},jo(e||!t||!t.__esModule?Kt(r,"default",{value:t,enumerable:!0}):r,t)),ds=t=>jo(Kt({},"__esModule",{value:!0}),t);var $o=(t,e,r)=>ls(t,typeof e!="symbol"?e+"":e,r),io=(t,e,r)=>e.has(t)||Wo("Cannot "+r);var i=(t,e,r)=>(io(t,e,"read from private field"),r?r.call(t):e.get(t)),g=(t,e,r)=>e.has(t)?Wo("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),h=(t,e,r,o)=>(io(t,e,"write to private field"),o?o.call(t,r):e.set(t,r),r),y=(t,e,r)=>(io(t,e,"access private method"),r);var Gt=(t,e,r,o)=>({set _(a){h(t,e,a,r)},get _(){return i(t,e,o)}});var Hs={};cs(Hs,{default:()=>Qs,init:()=>Qo});module.exports=ds(Hs);var ts=we(require("react-dom/client"));var vr=require("react");var ue=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(){}};var tt,Qe,bt,qo,ps=(qo=class extends ue{constructor(){super();g(this,tt);g(this,Qe);g(this,bt);h(this,bt,e=>{if(typeof window<"u"&&window.addEventListener){let r=()=>e();return window.addEventListener("visibilitychange",r,!1),()=>{window.removeEventListener("visibilitychange",r)}}})}onSubscribe(){i(this,Qe)||this.setEventListener(i(this,bt))}onUnsubscribe(){var e;this.hasListeners()||((e=i(this,Qe))==null||e.call(this),h(this,Qe,void 0))}setEventListener(e){var r;h(this,bt,e),(r=i(this,Qe))==null||r.call(this),h(this,Qe,e(o=>{typeof o=="boolean"?this.setFocused(o):this.onFocus()}))}setFocused(e){i(this,tt)!==e&&(h(this,tt,e),this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(r=>{r(e)})}isFocused(){return typeof i(this,tt)=="boolean"?i(this,tt):globalThis.document?.visibilityState!=="hidden"}},tt=new WeakMap,Qe=new WeakMap,bt=new WeakMap,qo),yt=new ps;var us={setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},He,so,Ko,hs=(Ko=class{constructor(){g(this,He,us);g(this,so,!1)}setTimeoutProvider(t){h(this,He,t)}setTimeout(t,e){return i(this,He).setTimeout(t,e)}clearTimeout(t){i(this,He).clearTimeout(t)}setInterval(t,e){return i(this,He).setInterval(t,e)}clearInterval(t){i(this,He).clearInterval(t)}},He=new WeakMap,so=new WeakMap,Ko),xe=new hs;function Go(t){setTimeout(t,0)}var lo=typeof window>"u"||"Deno"in globalThis;function D(){}function Zo(t,e){return typeof t=="function"?t(e):t}function Vt(t){return typeof t=="number"&&t>=0&&t!==1/0}function xr(t,e){return Math.max(t+(e||0)-Date.now(),0)}function ve(t,e){return typeof t=="function"?t(e):t}function Z(t,e){return typeof t=="function"?t(e):t}function kr(t,e){let{type:r="all",exact:o,fetchStatus:a,predicate:s,queryKey:n,stale:l}=t;if(n){if(o){if(e.queryHash!==Yt(n,e.options))return!1}else if(!rt(e.queryKey,n))return!1}if(r!=="all"){let c=e.isActive();if(r==="active"&&!c||r==="inactive"&&c)return!1}return!(typeof l=="boolean"&&e.isStale()!==l||a&&a!==e.state.fetchStatus||s&&!s(e))}function Pr(t,e){let{exact:r,status:o,predicate:a,mutationKey:s}=t;if(s){if(!e.options.mutationKey)return!1;if(r){if(ke(e.options.mutationKey)!==ke(s))return!1}else if(!rt(e.options.mutationKey,s))return!1}return!(o&&e.state.status!==o||a&&!a(e))}function Yt(t,e){return(e?.queryKeyHashFn||ke)(t)}function ke(t){return JSON.stringify(t,(e,r)=>no(r)?Object.keys(r).sort().reduce((o,a)=>(o[a]=r[a],o),{}):r)}function rt(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?Object.keys(e).every(r=>rt(t[r],e[r])):!1}var ms=Object.prototype.hasOwnProperty;function co(t,e,r=0){if(t===e)return t;if(r>500)return e;let o=Vo(t)&&Vo(e);if(!o&&!(no(t)&&no(e)))return e;let s=(o?t:Object.keys(t)).length,n=o?e:Object.keys(e),l=n.length,c=o?new Array(l):{},d=0;for(let p=0;p<l;p++){let u=o?p:n[p],v=t[u],f=e[u];if(v===f){c[u]=v,(o?p<s:ms.call(t,u))&&d++;continue}if(v===null||f===null||typeof v!="object"||typeof f!="object"){c[u]=f;continue}let b=co(v,f,r+1);c[u]=b,b===v&&d++}return s===l&&d===s?t:c}function wt(t,e){if(!e||Object.keys(t).length!==Object.keys(e).length)return!1;for(let r in t)if(t[r]!==e[r])return!1;return!0}function Vo(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function no(t){if(!Yo(t))return!1;let e=t.constructor;if(e===void 0)return!0;let r=e.prototype;return!(!Yo(r)||!r.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}function Yo(t){return Object.prototype.toString.call(t)==="[object Object]"}function Jo(t){return new Promise(e=>{xe.setTimeout(e,t)})}function Zt(t,e,r){return typeof r.structuralSharing=="function"?r.structuralSharing(t,e):r.structuralSharing!==!1?co(t,e):e}function Xo(t,e,r=0){let o=[...t,e];return r&&o.length>r?o.slice(1):o}function ea(t,e,r=0){let o=[e,...t];return r&&o.length>r?o.slice(0,-1):o}var xt=Symbol();function Nr(t,e){return!t.queryFn&&e?.initialPromise?()=>e.initialPromise:!t.queryFn||t.queryFn===xt?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function kt(t,e){return typeof t=="function"?t(...e):!!t}function ta(t,e,r){let o=!1,a;return Object.defineProperty(t,"signal",{enumerable:!0,get:()=>(a??(a=e()),o||(o=!0,a.aborted?r():a.addEventListener("abort",r,{once:!0})),a)}),t}var Pe=(()=>{let t=()=>lo;return{isServer(){return t()},setIsServer(e){t=e}}})();function Jt(){let t,e,r=new Promise((a,s)=>{t=a,e=s});r.status="pending",r.catch(()=>{});function o(a){Object.assign(r,a),delete r.resolve,delete r.reject}return r.resolve=a=>{o({status:"fulfilled",value:a}),t(a)},r.reject=a=>{o({status:"rejected",reason:a}),e(a)},r}var ra=Go;function fs(){let t=[],e=0,r=l=>{l()},o=l=>{l()},a=ra,s=l=>{e?t.push(l):a(()=>{r(l)})},n=()=>{let l=t;t=[],l.length&&a(()=>{o(()=>{l.forEach(c=>{r(c)})})})};return{batch:l=>{let c;e++;try{c=l()}finally{e--,e||n()}return c},batchCalls:l=>(...c)=>{s(()=>{l(...c)})},schedule:s,setNotifyFunction:l=>{r=l},setBatchNotifyFunction:l=>{o=l},setScheduler:l=>{a=l}}}var C=fs();var Pt,We,Nt,oa,gs=(oa=class extends ue{constructor(){super();g(this,Pt,!0);g(this,We);g(this,Nt);h(this,Nt,e=>{if(typeof window<"u"&&window.addEventListener){let r=()=>e(!0),o=()=>e(!1);return window.addEventListener("online",r,!1),window.addEventListener("offline",o,!1),()=>{window.removeEventListener("online",r),window.removeEventListener("offline",o)}}})}onSubscribe(){i(this,We)||this.setEventListener(i(this,Nt))}onUnsubscribe(){var e;this.hasListeners()||((e=i(this,We))==null||e.call(this),h(this,We,void 0))}setEventListener(e){var r;h(this,Nt,e),(r=i(this,We))==null||r.call(this),h(this,We,e(this.setOnline.bind(this)))}setOnline(e){i(this,Pt)!==e&&(h(this,Pt,e),this.listeners.forEach(o=>{o(e)}))}isOnline(){return i(this,Pt)}},Pt=new WeakMap,We=new WeakMap,Nt=new WeakMap,oa),Tt=new gs;function vs(t){return Math.min(1e3*2**t,3e4)}function po(t){return(t??"online")==="online"?Tt.isOnline():!0}var Tr=class extends Error{constructor(t){super("CancelledError"),this.revert=t?.revert,this.silent=t?.silent}};function Sr(t){let e=!1,r=0,o,a=Jt(),s=()=>a.status!=="pending",n=w=>{if(!s()){let N=new Tr(w);v(N),t.onCancel?.(N)}},l=()=>{e=!0},c=()=>{e=!1},d=()=>yt.isFocused()&&(t.networkMode==="always"||Tt.isOnline())&&t.canRun(),p=()=>po(t.networkMode)&&t.canRun(),u=w=>{s()||(o?.(),a.resolve(w))},v=w=>{s()||(o?.(),a.reject(w))},f=()=>new Promise(w=>{o=N=>{(s()||d())&&w(N)},t.onPause?.()}).then(()=>{o=void 0,s()||t.onContinue?.()}),b=()=>{if(s())return;let w,N=r===0?t.initialPromise:void 0;try{w=N??t.fn()}catch(T){w=Promise.reject(T)}Promise.resolve(w).then(u).catch(T=>{if(s())return;let R=t.retry??(Pe.isServer()?0:3),I=t.retryDelay??vs,ce=typeof I=="function"?I(r,T):I,de=R===!0||typeof R=="number"&&r<R||typeof R=="function"&&R(r,T);if(e||!de){v(T);return}r++,t.onFail?.(r,T),Jo(ce).then(()=>d()?void 0:f()).then(()=>{e?v(T):b()})})};return{promise:a,status:()=>a.status,cancel:n,continue:()=>(o?.(),a),cancelRetry:l,continueRetry:c,canStart:p,start:()=>(p()?b():f().then(b),a)}}var ot,aa,Cr=(aa=class{constructor(){g(this,ot)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Vt(this.gcTime)&&h(this,ot,xe.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(Pe.isServer()?1/0:300*1e3))}clearGcTimeout(){i(this,ot)&&(xe.clearTimeout(i(this,ot)),h(this,ot,void 0))}},ot=new WeakMap,aa);var at,St,he,it,z,Xt,st,oe,ca,Ae,na,la=(na=class extends Cr{constructor(e){super();g(this,oe);g(this,at);g(this,St);g(this,he);g(this,it);g(this,z);g(this,Xt);g(this,st);h(this,st,!1),h(this,Xt,e.defaultOptions),this.setOptions(e.options),this.observers=[],h(this,it,e.client),h(this,he,i(this,it).getQueryCache()),this.queryKey=e.queryKey,this.queryHash=e.queryHash,h(this,at,sa(this.options)),this.state=e.state??i(this,at),this.scheduleGc()}get meta(){return this.options.meta}get promise(){return i(this,z)?.promise}setOptions(e){if(this.options={...i(this,Xt),...e},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let r=sa(this.options);r.data!==void 0&&(this.setState(ia(r.data,r.dataUpdatedAt)),h(this,at,r))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&i(this,he).remove(this)}setData(e,r){let o=Zt(this.state.data,e,this.options);return y(this,oe,Ae).call(this,{data:o,type:"success",dataUpdatedAt:r?.updatedAt,manual:r?.manual}),o}setState(e,r){y(this,oe,Ae).call(this,{type:"setState",state:e,setStateOptions:r})}cancel(e){let r=i(this,z)?.promise;return i(this,z)?.cancel(e),r?r.then(D).catch(D):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return i(this,at)}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>Z(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===xt||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>ve(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:!xr(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(r=>r.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),i(this,z)?.continue()}onOnline(){this.observers.find(r=>r.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),i(this,z)?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),i(this,he).notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(r=>r!==e),this.observers.length||(i(this,z)&&(i(this,st)||y(this,oe,ca).call(this)?i(this,z).cancel({revert:!0}):i(this,z).cancelRetry()),this.scheduleGc()),i(this,he).notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||y(this,oe,Ae).call(this,{type:"invalidate"})}async fetch(e,r){if(this.state.fetchStatus!=="idle"&&i(this,z)?.status()!=="rejected"){if(this.state.data!==void 0&&r?.cancelRefetch)this.cancel({silent:!0});else if(i(this,z))return i(this,z).continueRetry(),i(this,z).promise}if(e&&this.setOptions(e),!this.options.queryFn){let c=this.observers.find(d=>d.options.queryFn);c&&this.setOptions(c.options)}let o=new AbortController,a=c=>{Object.defineProperty(c,"signal",{enumerable:!0,get:()=>(h(this,st,!0),o.signal)})},s=()=>{let c=Nr(this.options,r),p=(()=>{let u={client:i(this,it),queryKey:this.queryKey,meta:this.meta};return a(u),u})();return h(this,st,!1),this.options.persister?this.options.persister(c,p,this):c(p)},l=(()=>{let c={fetchOptions:r,options:this.options,queryKey:this.queryKey,client:i(this,it),state:this.state,fetchFn:s};return a(c),c})();this.options.behavior?.onFetch(l,this),h(this,St,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==l.fetchOptions?.meta)&&y(this,oe,Ae).call(this,{type:"fetch",meta:l.fetchOptions?.meta}),h(this,z,Sr({initialPromise:r?.initialPromise,fn:l.fetchFn,onCancel:c=>{c instanceof Tr&&c.revert&&this.setState({...i(this,St),fetchStatus:"idle"}),o.abort()},onFail:(c,d)=>{y(this,oe,Ae).call(this,{type:"failed",failureCount:c,error:d})},onPause:()=>{y(this,oe,Ae).call(this,{type:"pause"})},onContinue:()=>{y(this,oe,Ae).call(this,{type:"continue"})},retry:l.options.retry,retryDelay:l.options.retryDelay,networkMode:l.options.networkMode,canRun:()=>!0}));try{let c=await i(this,z).start();if(c===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(c),i(this,he).config.onSuccess?.(c,this),i(this,he).config.onSettled?.(c,this.state.error,this),c}catch(c){if(c instanceof Tr){if(c.silent)return i(this,z).promise;if(c.revert){if(this.state.data===void 0)throw c;return this.state.data}}throw y(this,oe,Ae).call(this,{type:"error",error:c}),i(this,he).config.onError?.(c,this),i(this,he).config.onSettled?.(this.state.data,c,this),c}finally{this.scheduleGc()}}},at=new WeakMap,St=new WeakMap,he=new WeakMap,it=new WeakMap,z=new WeakMap,Xt=new WeakMap,st=new WeakMap,oe=new WeakSet,ca=function(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"},Ae=function(e){let r=o=>{switch(e.type){case"failed":return{...o,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...o,fetchStatus:"paused"};case"continue":return{...o,fetchStatus:"fetching"};case"fetch":return{...o,...uo(o.data,this.options),fetchMeta:e.meta??null};case"success":let a={...o,...ia(e.data,e.dataUpdatedAt),dataUpdateCount:o.dataUpdateCount+1,...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return h(this,St,e.manual?a:void 0),a;case"error":let s=e.error;return{...o,error:s,errorUpdateCount:o.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:o.fetchFailureCount+1,fetchFailureReason:s,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...o,isInvalidated:!0};case"setState":return{...o,...e.state}}};this.state=r(this.state),C.batch(()=>{this.observers.forEach(o=>{o.onQueryUpdate()}),i(this,he).notify({query:this,type:"updated",action:e})})},na);function uo(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:po(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function ia(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}function sa(t){let e=typeof t.initialData=="function"?t.initialData():t.initialData,r=e!==void 0,o=r?typeof t.initialDataUpdatedAt=="function"?t.initialDataUpdatedAt():t.initialDataUpdatedAt:0;return{data:e,dataUpdateCount:0,dataUpdatedAt:r?o??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}var J,k,tr,V,nt,Ct,Oe,je,rr,Rt,At,lt,ct,$e,Ot,S,er,ho,mo,fo,go,vo,bo,yo,ha,ua,or=(ua=class extends ue{constructor(e,r){super();g(this,S);g(this,J);g(this,k);g(this,tr);g(this,V);g(this,nt);g(this,Ct);g(this,Oe);g(this,je);g(this,rr);g(this,Rt);g(this,At);g(this,lt);g(this,ct);g(this,$e);g(this,Ot,new Set);this.options=r,h(this,J,e),h(this,je,null),h(this,Oe,Jt()),this.bindMethods(),this.setOptions(r)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(i(this,k).addObserver(this),da(i(this,k),this.options)?y(this,S,er).call(this):this.updateResult(),y(this,S,go).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return wo(i(this,k),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return wo(i(this,k),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,y(this,S,vo).call(this),y(this,S,bo).call(this),i(this,k).removeObserver(this)}setOptions(e){let r=this.options,o=i(this,k);if(this.options=i(this,J).defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Z(this.options.enabled,i(this,k))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");y(this,S,yo).call(this),i(this,k).setOptions(this.options),r._defaulted&&!wt(this.options,r)&&i(this,J).getQueryCache().notify({type:"observerOptionsUpdated",query:i(this,k),observer:this});let a=this.hasListeners();a&&pa(i(this,k),o,this.options,r)&&y(this,S,er).call(this),this.updateResult(),a&&(i(this,k)!==o||Z(this.options.enabled,i(this,k))!==Z(r.enabled,i(this,k))||ve(this.options.staleTime,i(this,k))!==ve(r.staleTime,i(this,k)))&&y(this,S,ho).call(this);let s=y(this,S,mo).call(this);a&&(i(this,k)!==o||Z(this.options.enabled,i(this,k))!==Z(r.enabled,i(this,k))||s!==i(this,$e))&&y(this,S,fo).call(this,s)}getOptimisticResult(e){let r=i(this,J).getQueryCache().build(i(this,J),e),o=this.createResult(r,e);return ys(this,o)&&(h(this,V,o),h(this,Ct,this.options),h(this,nt,i(this,k).state)),o}getCurrentResult(){return i(this,V)}trackResult(e,r){return new Proxy(e,{get:(o,a)=>(this.trackProp(a),r?.(a),a==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&i(this,Oe).status==="pending"&&i(this,Oe).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(o,a))})}trackProp(e){i(this,Ot).add(e)}getCurrentQuery(){return i(this,k)}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let r=i(this,J).defaultQueryOptions(e),o=i(this,J).getQueryCache().build(i(this,J),r);return o.fetch().then(()=>this.createResult(o,r))}fetch(e){return y(this,S,er).call(this,{...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),i(this,V)))}createResult(e,r){let o=i(this,k),a=this.options,s=i(this,V),n=i(this,nt),l=i(this,Ct),d=e!==o?e.state:i(this,tr),{state:p}=e,u={...p},v=!1,f;if(r._optimisticResults){let pe=this.hasListeners(),qt=!pe&&da(e,r),br=pe&&pa(e,o,r,a);(qt||br)&&(u={...u,...uo(p.data,e.options)}),r._optimisticResults==="isRestoring"&&(u.fetchStatus="idle")}let{error:b,errorUpdatedAt:w,status:N}=u;f=u.data;let T=!1;if(r.placeholderData!==void 0&&f===void 0&&N==="pending"){let pe;s?.isPlaceholderData&&r.placeholderData===l?.placeholderData?(pe=s.data,T=!0):pe=typeof r.placeholderData=="function"?r.placeholderData(i(this,At)?.state.data,i(this,At)):r.placeholderData,pe!==void 0&&(N="success",f=Zt(s?.data,pe,r),v=!0)}if(r.select&&f!==void 0&&!T)if(s&&f===n?.data&&r.select===i(this,rr))f=i(this,Rt);else try{h(this,rr,r.select),f=r.select(f),f=Zt(s?.data,f,r),h(this,Rt,f),h(this,je,null)}catch(pe){h(this,je,pe)}i(this,je)&&(b=i(this,je),f=i(this,Rt),w=Date.now(),N="error");let R=u.fetchStatus==="fetching",I=N==="pending",ce=N==="error",de=I&&R,ze=f!==void 0,ge={status:N,fetchStatus:u.fetchStatus,isPending:I,isSuccess:N==="success",isError:ce,isInitialLoading:de,isLoading:de,data:f,dataUpdatedAt:u.dataUpdatedAt,error:b,errorUpdatedAt:w,failureCount:u.fetchFailureCount,failureReason:u.fetchFailureReason,errorUpdateCount:u.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:u.dataUpdateCount>d.dataUpdateCount||u.errorUpdateCount>d.errorUpdateCount,isFetching:R,isRefetching:R&&!I,isLoadingError:ce&&!ze,isPaused:u.fetchStatus==="paused",isPlaceholderData:v,isRefetchError:ce&&ze,isStale:xo(e,r),refetch:this.refetch,promise:i(this,Oe),isEnabled:Z(r.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){let pe=ge.data!==void 0,qt=ge.status==="error"&&!pe,br=wr=>{qt?wr.reject(ge.error):pe&&wr.resolve(ge.data)},Ho=()=>{let wr=h(this,Oe,ge.promise=Jt());br(wr)},yr=i(this,Oe);switch(yr.status){case"pending":e.queryHash===o.queryHash&&br(yr);break;case"fulfilled":(qt||ge.data!==yr.value)&&Ho();break;case"rejected":(!qt||ge.error!==yr.reason)&&Ho();break}}return ge}updateResult(){let e=i(this,V),r=this.createResult(i(this,k),this.options);if(h(this,nt,i(this,k).state),h(this,Ct,this.options),i(this,nt).data!==void 0&&h(this,At,i(this,k)),wt(r,e))return;h(this,V,r);let o=()=>{if(!e)return!0;let{notifyOnChangeProps:a}=this.options,s=typeof a=="function"?a():a;if(s==="all"||!s&&!i(this,Ot).size)return!0;let n=new Set(s??i(this,Ot));return this.options.throwOnError&&n.add("error"),Object.keys(i(this,V)).some(l=>{let c=l;return i(this,V)[c]!==e[c]&&n.has(c)})};y(this,S,ha).call(this,{listeners:o()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&y(this,S,go).call(this)}},J=new WeakMap,k=new WeakMap,tr=new WeakMap,V=new WeakMap,nt=new WeakMap,Ct=new WeakMap,Oe=new WeakMap,je=new WeakMap,rr=new WeakMap,Rt=new WeakMap,At=new WeakMap,lt=new WeakMap,ct=new WeakMap,$e=new WeakMap,Ot=new WeakMap,S=new WeakSet,er=function(e){y(this,S,yo).call(this);let r=i(this,k).fetch(this.options,e);return e?.throwOnError||(r=r.catch(D)),r},ho=function(){y(this,S,vo).call(this);let e=ve(this.options.staleTime,i(this,k));if(Pe.isServer()||i(this,V).isStale||!Vt(e))return;let o=xr(i(this,V).dataUpdatedAt,e)+1;h(this,lt,xe.setTimeout(()=>{i(this,V).isStale||this.updateResult()},o))},mo=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(i(this,k)):this.options.refetchInterval)??!1},fo=function(e){y(this,S,bo).call(this),h(this,$e,e),!(Pe.isServer()||Z(this.options.enabled,i(this,k))===!1||!Vt(i(this,$e))||i(this,$e)===0)&&h(this,ct,xe.setInterval(()=>{(this.options.refetchIntervalInBackground||yt.isFocused())&&y(this,S,er).call(this)},i(this,$e)))},go=function(){y(this,S,ho).call(this),y(this,S,fo).call(this,y(this,S,mo).call(this))},vo=function(){i(this,lt)&&(xe.clearTimeout(i(this,lt)),h(this,lt,void 0))},bo=function(){i(this,ct)&&(xe.clearInterval(i(this,ct)),h(this,ct,void 0))},yo=function(){let e=i(this,J).getQueryCache().build(i(this,J),this.options);if(e===i(this,k))return;let r=i(this,k);h(this,k,e),h(this,tr,e.state),this.hasListeners()&&(r?.removeObserver(this),e.addObserver(this))},ha=function(e){C.batch(()=>{e.listeners&&this.listeners.forEach(r=>{r(i(this,V))}),i(this,J).getQueryCache().notify({query:i(this,k),type:"observerResultsUpdated"})})},ua);function bs(t,e){return Z(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&e.retryOnMount===!1)}function da(t,e){return bs(t,e)||t.state.data!==void 0&&wo(t,e,e.refetchOnMount)}function wo(t,e,r){if(Z(e.enabled,t)!==!1&&ve(e.staleTime,t)!=="static"){let o=typeof r=="function"?r(t):r;return o==="always"||o!==!1&&xo(t,e)}return!1}function pa(t,e,r,o){return(t!==e||Z(o.enabled,t)===!1)&&(!r.suspense||t.state.status!=="error")&&xo(t,r)}function xo(t,e){return Z(e.enabled,t)!==!1&&t.isStaleByTime(ve(e.staleTime,t))}function ys(t,e){return!wt(t.getCurrentResult(),e)}function Ft(t){return{onFetch:(e,r)=>{let o=e.options,a=e.fetchOptions?.meta?.fetchMore?.direction,s=e.state.data?.pages||[],n=e.state.data?.pageParams||[],l={pages:[],pageParams:[]},c=0,d=async()=>{let p=!1,u=b=>{ta(b,()=>e.signal,()=>p=!0)},v=Nr(e.options,e.fetchOptions),f=async(b,w,N)=>{if(p)return Promise.reject();if(w==null&&b.pages.length)return Promise.resolve(b);let R=(()=>{let ze={client:e.client,queryKey:e.queryKey,pageParam:w,direction:N?"backward":"forward",meta:e.options.meta};return u(ze),ze})(),I=await v(R),{maxPages:ce}=e.options,de=N?ea:Xo;return{pages:de(b.pages,I,ce),pageParams:de(b.pageParams,w,ce)}};if(a&&s.length){let b=a==="backward",w=b?ma:ko,N={pages:s,pageParams:n},T=w(o,N);l=await f(N,T,b)}else{let b=t??s.length;do{let w=c===0?n[0]??o.initialPageParam:ko(o,l);if(c>0&&w==null)break;l=await f(l,w),c++}while(c<b)}return l};e.options.persister?e.fetchFn=()=>e.options.persister?.(d,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},r):e.fetchFn=d}}}function ko(t,{pages:e,pageParams:r}){let o=e.length-1;return e.length>0?t.getNextPageParam(e[o],e,r[o],r):void 0}function ma(t,{pages:e,pageParams:r}){return e.length>0?t.getPreviousPageParam?.(e[0],e,r[0],r):void 0}function fa(t,e){return e?ko(t,e)!=null:!1}function ga(t,e){return!e||!t.getPreviousPageParam?!1:ma(t,e)!=null}var Po=class extends or{constructor(t,e){super(t,e)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(t){super.setOptions({...t,behavior:Ft()})}getOptimisticResult(t){return t.behavior=Ft(),super.getOptimisticResult(t)}fetchNextPage(t){return this.fetch({...t,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(t){return this.fetch({...t,meta:{fetchMore:{direction:"backward"}}})}createResult(t,e){let{state:r}=t,o=super.createResult(t,e),{isFetching:a,isRefetching:s,isError:n,isRefetchError:l}=o,c=r.fetchMeta?.fetchMore?.direction,d=n&&c==="forward",p=a&&c==="forward",u=n&&c==="backward",v=a&&c==="backward";return{...o,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:fa(e,r.data),hasPreviousPage:ga(e,r.data),isFetchNextPageError:d,isFetchingNextPage:p,isFetchPreviousPageError:u,isFetchingPreviousPage:v,isRefetchError:l&&!d&&!u,isRefetching:s&&!p&&!v}}};var ar,Ne,q,dt,Te,qe,va,ba=(va=class extends Cr{constructor(e){super();g(this,Te);g(this,ar);g(this,Ne);g(this,q);g(this,dt);h(this,ar,e.client),this.mutationId=e.mutationId,h(this,q,e.mutationCache),h(this,Ne,[]),this.state=e.state||No(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){i(this,Ne).includes(e)||(i(this,Ne).push(e),this.clearGcTimeout(),i(this,q).notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){h(this,Ne,i(this,Ne).filter(r=>r!==e)),this.scheduleGc(),i(this,q).notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){i(this,Ne).length||(this.state.status==="pending"?this.scheduleGc():i(this,q).remove(this))}continue(){return i(this,dt)?.continue()??this.execute(this.state.variables)}async execute(e){let r=()=>{y(this,Te,qe).call(this,{type:"continue"})},o={client:i(this,ar),meta:this.options.meta,mutationKey:this.options.mutationKey};h(this,dt,Sr({fn:()=>this.options.mutationFn?this.options.mutationFn(e,o):Promise.reject(new Error("No mutationFn found")),onFail:(n,l)=>{y(this,Te,qe).call(this,{type:"failed",failureCount:n,error:l})},onPause:()=>{y(this,Te,qe).call(this,{type:"pause"})},onContinue:r,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>i(this,q).canRun(this)}));let a=this.state.status==="pending",s=!i(this,dt).canStart();try{if(a)r();else{y(this,Te,qe).call(this,{type:"pending",variables:e,isPaused:s}),i(this,q).config.onMutate&&await i(this,q).config.onMutate(e,this,o);let l=await this.options.onMutate?.(e,o);l!==this.state.context&&y(this,Te,qe).call(this,{type:"pending",context:l,variables:e,isPaused:s})}let n=await i(this,dt).start();return await i(this,q).config.onSuccess?.(n,e,this.state.context,this,o),await this.options.onSuccess?.(n,e,this.state.context,o),await i(this,q).config.onSettled?.(n,null,this.state.variables,this.state.context,this,o),await this.options.onSettled?.(n,null,e,this.state.context,o),y(this,Te,qe).call(this,{type:"success",data:n}),n}catch(n){try{await i(this,q).config.onError?.(n,e,this.state.context,this,o)}catch(l){Promise.reject(l)}try{await this.options.onError?.(n,e,this.state.context,o)}catch(l){Promise.reject(l)}try{await i(this,q).config.onSettled?.(void 0,n,this.state.variables,this.state.context,this,o)}catch(l){Promise.reject(l)}try{await this.options.onSettled?.(void 0,n,e,this.state.context,o)}catch(l){Promise.reject(l)}throw y(this,Te,qe).call(this,{type:"error",error:n}),n}finally{i(this,q).runNext(this)}}},ar=new WeakMap,Ne=new WeakMap,q=new WeakMap,dt=new WeakMap,Te=new WeakSet,qe=function(e){let r=o=>{switch(e.type){case"failed":return{...o,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...o,isPaused:!0};case"continue":return{...o,isPaused:!1};case"pending":return{...o,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{...o,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...o,data:void 0,error:e.error,failureCount:o.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}};this.state=r(this.state),C.batch(()=>{i(this,Ne).forEach(o=>{o.onMutationUpdate(e)}),i(this,q).notify({mutation:this,type:"updated",action:e})})},va);function No(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Fe,be,ir,ya,wa=(ya=class extends ue{constructor(e={}){super();g(this,Fe);g(this,be);g(this,ir);this.config=e,h(this,Fe,new Set),h(this,be,new Map),h(this,ir,0)}build(e,r,o){let a=new ba({client:e,mutationCache:this,mutationId:++Gt(this,ir)._,options:e.defaultMutationOptions(r),state:o});return this.add(a),a}add(e){i(this,Fe).add(e);let r=Rr(e);if(typeof r=="string"){let o=i(this,be).get(r);o?o.push(e):i(this,be).set(r,[e])}this.notify({type:"added",mutation:e})}remove(e){if(i(this,Fe).delete(e)){let r=Rr(e);if(typeof r=="string"){let o=i(this,be).get(r);if(o)if(o.length>1){let a=o.indexOf(e);a!==-1&&o.splice(a,1)}else o[0]===e&&i(this,be).delete(r)}}this.notify({type:"removed",mutation:e})}canRun(e){let r=Rr(e);if(typeof r=="string"){let a=i(this,be).get(r)?.find(s=>s.state.status==="pending");return!a||a===e}else return!0}runNext(e){let r=Rr(e);return typeof r=="string"?i(this,be).get(r)?.find(a=>a!==e&&a.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){C.batch(()=>{i(this,Fe).forEach(e=>{this.notify({type:"removed",mutation:e})}),i(this,Fe).clear(),i(this,be).clear()})}getAll(){return Array.from(i(this,Fe))}find(e){let r={exact:!0,...e};return this.getAll().find(o=>Pr(r,o))}findAll(e={}){return this.getAll().filter(r=>Pr(e,r))}notify(e){C.batch(()=>{this.listeners.forEach(r=>{r(e)})})}resumePausedMutations(){let e=this.getAll().filter(r=>r.state.isPaused);return C.batch(()=>Promise.all(e.map(r=>r.continue().catch(D))))}},Fe=new WeakMap,be=new WeakMap,ir=new WeakMap,ya);function Rr(t){return t.options.scope?.id}var Ee,Ke,X,Ie,Me,Ar,To,xa,So=(xa=class extends ue{constructor(e,r){super();g(this,Me);g(this,Ee);g(this,Ke);g(this,X);g(this,Ie);h(this,Ee,e),this.setOptions(r),this.bindMethods(),y(this,Me,Ar).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let r=this.options;this.options=i(this,Ee).defaultMutationOptions(e),wt(this.options,r)||i(this,Ee).getMutationCache().notify({type:"observerOptionsUpdated",mutation:i(this,X),observer:this}),r?.mutationKey&&this.options.mutationKey&&ke(r.mutationKey)!==ke(this.options.mutationKey)?this.reset():i(this,X)?.state.status==="pending"&&i(this,X).setOptions(this.options)}onUnsubscribe(){this.hasListeners()||i(this,X)?.removeObserver(this)}onMutationUpdate(e){y(this,Me,Ar).call(this),y(this,Me,To).call(this,e)}getCurrentResult(){return i(this,Ke)}reset(){i(this,X)?.removeObserver(this),h(this,X,void 0),y(this,Me,Ar).call(this),y(this,Me,To).call(this)}mutate(e,r){return h(this,Ie,r),i(this,X)?.removeObserver(this),h(this,X,i(this,Ee).getMutationCache().build(i(this,Ee),this.options)),i(this,X).addObserver(this),i(this,X).execute(e)}},Ee=new WeakMap,Ke=new WeakMap,X=new WeakMap,Ie=new WeakMap,Me=new WeakSet,Ar=function(){let e=i(this,X)?.state??No();h(this,Ke,{...e,isPending:e.status==="pending",isSuccess:e.status==="success",isError:e.status==="error",isIdle:e.status==="idle",mutate:this.mutate,reset:this.reset})},To=function(e){C.batch(()=>{if(i(this,Ie)&&this.hasListeners()){let r=i(this,Ke).variables,o=i(this,Ke).context,a={client:i(this,Ee),meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type==="success"){try{i(this,Ie).onSuccess?.(e.data,r,o,a)}catch(s){Promise.reject(s)}try{i(this,Ie).onSettled?.(e.data,null,r,o,a)}catch(s){Promise.reject(s)}}else if(e?.type==="error"){try{i(this,Ie).onError?.(e.error,r,o,a)}catch(s){Promise.reject(s)}try{i(this,Ie).onSettled?.(void 0,e.error,r,o,a)}catch(s){Promise.reject(s)}}}this.listeners.forEach(r=>{r(i(this,Ke))})})},xa);var Se,ka,Pa=(ka=class extends ue{constructor(e={}){super();g(this,Se);this.config=e,h(this,Se,new Map)}build(e,r,o){let a=r.queryKey,s=r.queryHash??Yt(a,r),n=this.get(s);return n||(n=new la({client:e,queryKey:a,queryHash:s,options:e.defaultQueryOptions(r),state:o,defaultOptions:e.getQueryDefaults(a)}),this.add(n)),n}add(e){i(this,Se).has(e.queryHash)||(i(this,Se).set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){let r=i(this,Se).get(e.queryHash);r&&(e.destroy(),r===e&&i(this,Se).delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){C.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return i(this,Se).get(e)}getAll(){return[...i(this,Se).values()]}find(e){let r={exact:!0,...e};return this.getAll().find(o=>kr(r,o))}findAll(e={}){let r=this.getAll();return Object.keys(e).length>0?r.filter(o=>kr(e,o)):r}notify(e){C.batch(()=>{this.listeners.forEach(r=>{r(e)})})}onFocus(){C.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){C.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},Se=new WeakMap,ka);var L,Ge,Ve,Et,It,Ye,Mt,Dt,Na,Co=(Na=class{constructor(t={}){g(this,L);g(this,Ge);g(this,Ve);g(this,Et);g(this,It);g(this,Ye);g(this,Mt);g(this,Dt);h(this,L,t.queryCache||new Pa),h(this,Ge,t.mutationCache||new wa),h(this,Ve,t.defaultOptions||{}),h(this,Et,new Map),h(this,It,new Map),h(this,Ye,0)}mount(){Gt(this,Ye)._++,i(this,Ye)===1&&(h(this,Mt,yt.subscribe(async t=>{t&&(await this.resumePausedMutations(),i(this,L).onFocus())})),h(this,Dt,Tt.subscribe(async t=>{t&&(await this.resumePausedMutations(),i(this,L).onOnline())})))}unmount(){var t,e;Gt(this,Ye)._--,i(this,Ye)===0&&((t=i(this,Mt))==null||t.call(this),h(this,Mt,void 0),(e=i(this,Dt))==null||e.call(this),h(this,Dt,void 0))}isFetching(t){return i(this,L).findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return i(this,Ge).findAll({...t,status:"pending"}).length}getQueryData(t){let e=this.defaultQueryOptions({queryKey:t});return i(this,L).get(e.queryHash)?.state.data}ensureQueryData(t){let e=this.defaultQueryOptions(t),r=i(this,L).build(this,e),o=r.state.data;return o===void 0?this.fetchQuery(t):(t.revalidateIfStale&&r.isStaleByTime(ve(e.staleTime,r))&&this.prefetchQuery(e),Promise.resolve(o))}getQueriesData(t){return i(this,L).findAll(t).map(({queryKey:e,state:r})=>{let o=r.data;return[e,o]})}setQueryData(t,e,r){let o=this.defaultQueryOptions({queryKey:t}),s=i(this,L).get(o.queryHash)?.state.data,n=Zo(e,s);if(n!==void 0)return i(this,L).build(this,o).setData(n,{...r,manual:!0})}setQueriesData(t,e,r){return C.batch(()=>i(this,L).findAll(t).map(({queryKey:o})=>[o,this.setQueryData(o,e,r)]))}getQueryState(t){let e=this.defaultQueryOptions({queryKey:t});return i(this,L).get(e.queryHash)?.state}removeQueries(t){let e=i(this,L);C.batch(()=>{e.findAll(t).forEach(r=>{e.remove(r)})})}resetQueries(t,e){let r=i(this,L);return C.batch(()=>(r.findAll(t).forEach(o=>{o.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){let r={revert:!0,...e},o=C.batch(()=>i(this,L).findAll(t).map(a=>a.cancel(r)));return Promise.all(o).then(D).catch(D)}invalidateQueries(t,e={}){return C.batch(()=>(i(this,L).findAll(t).forEach(r=>{r.invalidate()}),t?.refetchType==="none"?Promise.resolve():this.refetchQueries({...t,type:t?.refetchType??t?.type??"active"},e)))}refetchQueries(t,e={}){let r={...e,cancelRefetch:e.cancelRefetch??!0},o=C.batch(()=>i(this,L).findAll(t).filter(a=>!a.isDisabled()&&!a.isStatic()).map(a=>{let s=a.fetch(void 0,r);return r.throwOnError||(s=s.catch(D)),a.state.fetchStatus==="paused"?Promise.resolve():s}));return Promise.all(o).then(D)}fetchQuery(t){let e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);let r=i(this,L).build(this,e);return r.isStaleByTime(ve(e.staleTime,r))?r.fetch(e):Promise.resolve(r.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(D).catch(D)}fetchInfiniteQuery(t){return t.behavior=Ft(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(D).catch(D)}ensureInfiniteQueryData(t){return t.behavior=Ft(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return Tt.isOnline()?i(this,Ge).resumePausedMutations():Promise.resolve()}getQueryCache(){return i(this,L)}getMutationCache(){return i(this,Ge)}getDefaultOptions(){return i(this,Ve)}setDefaultOptions(t){h(this,Ve,t)}setQueryDefaults(t,e){i(this,Et).set(ke(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){let e=[...i(this,Et).values()],r={};return e.forEach(o=>{rt(t,o.queryKey)&&Object.assign(r,o.defaultOptions)}),r}setMutationDefaults(t,e){i(this,It).set(ke(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){let e=[...i(this,It).values()],r={};return e.forEach(o=>{rt(t,o.mutationKey)&&Object.assign(r,o.defaultOptions)}),r}defaultQueryOptions(t){if(t._defaulted)return t;let e={...i(this,Ve).queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return e.queryHash||(e.queryHash=Yt(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===xt&&(e.enabled=!1),e}defaultMutationOptions(t){return t?._defaulted?t:{...i(this,Ve).mutations,...t?.mutationKey&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){i(this,L).clear(),i(this,Ge).clear()}},L=new WeakMap,Ge=new WeakMap,Ve=new WeakMap,Et=new WeakMap,It=new WeakMap,Ye=new WeakMap,Mt=new WeakMap,Dt=new WeakMap,Na);var Lt=we(require("react"),1),Ta=require("react/jsx-runtime"),Ro=Lt.createContext(void 0),De=t=>{let e=Lt.useContext(Ro);if(t)return t;if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},Ao=({client:t,children:e})=>(Lt.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),(0,Ta.jsx)(Ro.Provider,{value:t,children:e}));var Or=we(require("react"),1),Sa=Or.createContext(!1),Ca=()=>Or.useContext(Sa),jl=Sa.Provider;var sr=we(require("react"),1),ws=require("react/jsx-runtime");function xs(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var ks=sr.createContext(xs()),Ra=()=>sr.useContext(ks);var Aa=we(require("react"),1);var Oa=(t,e,r)=>{let o=r?.state.error&&typeof t.throwOnError=="function"?kt(t.throwOnError,[r.state.error,r]):t.throwOnError;(t.suspense||t.experimental_prefetchInRender||o)&&(e.isReset()||(t.retryOnMount=!1))},Fa=t=>{Aa.useEffect(()=>{t.clearReset()},[t])},Ea=({result:t,errorResetBoundary:e,throwOnError:r,query:o,suspense:a})=>t.isError&&!e.isReset()&&!t.isFetching&&o&&(a&&t.data===void 0||kt(r,[t.error,o]));var Fr=(t,e)=>e.state.data===void 0,Ia=t=>{if(t.suspense){let r=a=>a==="static"?a:Math.max(a??1e3,1e3),o=t.staleTime;t.staleTime=typeof o=="function"?(...a)=>r(o(...a)):r(o),typeof t.gcTime=="number"&&(t.gcTime=Math.max(t.gcTime,1e3))}},Ma=(t,e)=>t.isLoading&&t.isFetching&&!e,Da=(t,e)=>t?.suspense&&e.isPending,Oo=(t,e,r)=>e.fetchOptimistic(t).catch(()=>{r.clearReset()});var Ze=we(require("react"),1);function Er(t,e,r){let o=Ca(),a=Ra(),s=De(r),n=s.defaultQueryOptions(t);s.getDefaultOptions().queries?._experimental_beforeQuery?.(n);let l=s.getQueryCache().get(n.queryHash);n._optimisticResults=o?"isRestoring":"optimistic",Ia(n),Oa(n,a,l),Fa(a);let c=!s.getQueryCache().get(n.queryHash),[d]=Ze.useState(()=>new e(s,n)),p=d.getOptimisticResult(n),u=!o&&t.subscribed!==!1;if(Ze.useSyncExternalStore(Ze.useCallback(v=>{let f=u?d.subscribe(C.batchCalls(v)):D;return d.updateResult(),f},[d,u]),()=>d.getCurrentResult(),()=>d.getCurrentResult()),Ze.useEffect(()=>{d.setOptions(n)},[n,d]),Da(n,p))throw Oo(n,d,a);if(Ea({result:p,errorResetBoundary:a,throwOnError:n.throwOnError,query:l,suspense:n.suspense}))throw p.error;return s.getDefaultOptions().queries?._experimental_afterQuery?.(n,p),n.experimental_prefetchInRender&&!Pe.isServer()&&Ma(p,o)&&(c?Oo(n,d,a):l?.promise)?.catch(D).finally(()=>{d.updateResult()}),n.notifyOnChangeProps?p:d.trackResult(p)}function pt(t,e){return Er({...t,enabled:!0,suspense:!0,throwOnError:Fr,placeholderData:void 0},or,e)}function nr(t,e){return Er({...t,enabled:!0,suspense:!0,throwOnError:Fr},Po,e)}var Le=we(require("react"),1);function Fo(t,e){let r=De(e),[o]=Le.useState(()=>new So(r,t));Le.useEffect(()=>{o.setOptions(t)},[o,t]);let a=Le.useSyncExternalStore(Le.useCallback(n=>o.subscribe(C.batchCalls(n)),[o]),()=>o.getCurrentResult(),()=>o.getCurrentResult()),s=Le.useCallback((n,l)=>{o.mutate(n,l).catch(D)},[o]);if(a.error&&kt(o.options.throwOnError,[a.error]))throw a.error;return{...a,mutate:s,mutateAsync:a.mutate}}var me={widgetTitle:"Savings Box",launcherLabel:"Insurance Savings",launcherIcon:"arrow",showLauncher:!0,mode:"light",allowUserThemeControl:!1,defaultTheme:"light",uiVersion:"current",primary:"#1E40AF",accent:"#2648C9",accentTextLight:"#FFFFFF",accentTextDark:"#FFFFFF",bg:"#0B1220",panel:"#0F1A2E",panel2:"#111F38",itemBg:"rgba(255,255,255,0.03)",text:"#E6EDF7",muted:"#A7B3C6",border:"rgba(255,255,255,0.08)",success:"#34D399",danger:"#EF4444",warning:"#FBBF24",lightBg:"#F8FAFC",lightPanel:"#FFFFFF",lightPanel2:"#F1F5F9",lightItemBg:"rgba(0,0,0,0.04)",lightText:"#0F172A",lightMuted:"#64748B",lightBorder:"rgba(0,0,0,0.1)"};function Ir(t){let e=t.mode==="light",r=e?t.textColorLight?.trim()||t.lightText:t.textColorDark?.trim()||t.text;return{...t,bg:e?t.lightBg:t.bg,panel:e?t.lightPanel:t.panel,panel2:e?t.lightPanel2:t.panel2,itemBg:e?t.lightItemBg:t.itemBg,text:r,muted:e?t.lightMuted:t.muted,border:e?t.lightBorder:t.border,subtleBg:e?"rgba(0,0,0,0.02)":"rgba(255,255,255,0.03)",tooltipBg:e?"#FFFFFF":"#0B1220",tooltipBorder:e?"rgba(0,0,0,0.12)":"rgba(255,255,255,0.12)",accentText:e?t.accentTextLight?.trim()||"#0F172A":t.accentTextDark?.trim()||"#FFFFFF",isLight:e,mode:t.mode}}var Mr=class{constructor(e,r){this.baseUrl=e;this.token=r}async getWallet(){try{let e=await fetch(`${this.baseUrl}/api/wallet`,{method:"GET",headers:{Accept:"application/json",Authorization:`Bearer ${this.token}`}});if(!e.ok)return console.warn(`[FrugaSDK] Failed to fetch wallet: ${e.status}. Returning zeroed wallet.`),this.getEmptyWallet();let r=await e.json();return{available:r.available??0,pending:r.pending??0,totalBalance:(r.available||0)+(r.pending||0),lifetimeEarned:r.lifetimeEarned??0,lifetimeRedeemed:r.lifetimeRedeemed??0,updatedAt:r.updatedAt??new Date().toISOString(),requiredActions:r.requiredActions??null}}catch(e){return console.warn("[FrugaSDK] Network error fetching wallet. Returning zeroed wallet.",e),this.getEmptyWallet()}}getEmptyWallet(){return{available:0,pending:0,totalBalance:0,lifetimeEarned:0,lifetimeRedeemed:0,updatedAt:new Date().toISOString(),requiredActions:null}}};var Bt=class{constructor(e,r){this.baseUrl=e;this.token=r}async fetchQuery(e,r={}){let o=new URL(`${this.baseUrl}${e}`);return Object.entries(r).forEach(([a,s])=>{s!=null&&(Array.isArray(s)?s.forEach(n=>o.searchParams.append(a,String(n))):o.searchParams.append(a,String(s)))}),fetch(o.toString(),{method:"GET",headers:{Accept:"application/json",Authorization:`Bearer ${this.token}`}})}};var Dr=class extends Bt{constructor(e,r){super(e,r)}async getActivity(e,r){try{let o=await this.fetchQuery("/api/activity",{pageNumber:e,pageSize:r});if(!o.ok)return console.warn(`[FrugaSDK] Failed to fetch activity: ${o.status}. Returning empty activity.`),this.getEmptyActivity();let a=await o.json();return{...a,transactions:a.transactions||[]}}catch(o){return console.warn("[FrugaSDK] Network error fetching activity. Returning empty activity.",o),this.getEmptyActivity()}}getEmptyActivity(){return{actorType:"",partnerId:0,transactions:[]}}};var Lr=class extends Bt{constructor(e,r){super(e,r)}async getCategories(){try{let e=await this.fetchQuery("/api/offers/categories");return e.ok?(await e.json()).categories||[]:(console.warn(`[FrugaSDK] Failed to fetch offer categories: ${e.status}. Returning empty list.`),[])}catch(e){return console.warn("[FrugaSDK] Network error fetching offer categories. Returning empty list.",e),[]}}async getOffers(e){try{let r=await this.fetchQuery("/api/offers",{pageNumber:e.pageNumber??0,pageSize:e.pageSize??10,type:e.type,query:e.query,featured:e.featured,categories:e.categories});if(!r.ok)return console.warn(`[FrugaSDK] Failed to fetch offers: ${r.status}. Returning empty response.`),this.getEmptyPaginatedResponse();let o=await r.json();return{...o,content:o.content||[]}}catch(r){return console.warn("[FrugaSDK] Network error fetching offers. Returning empty response.",r),this.getEmptyPaginatedResponse()}}getEmptyPaginatedResponse(){return{content:[],totalElements:0,totalPages:0,number:0,size:0,numberOfElements:0,numberOfPages:0}}};var Br=class{constructor(e,r){this.baseUrl=e;this.token=r}async listMethods(){try{let e=await fetch(`${this.baseUrl}/api/payout-methods`,{method:"GET",headers:{Accept:"application/json",Authorization:`Bearer ${this.token}`}});if(!e.ok)throw new Error(`Failed to list payout methods: ${e.status}`);return(await e.json()).items||[]}catch(e){return console.error("[FrugaSDK] Error listing payout methods:",e),[]}}async addBankMethod(e){let r=await fetch(`${this.baseUrl}/api/payout-methods/bank`,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json",Authorization:`Bearer ${this.token}`},body:JSON.stringify(e)});if(!r.ok)throw new Error(`Failed to add bank payout method: ${r.status}`);return r.json()}async deleteMethod(e){let r=await fetch(`${this.baseUrl}/api/payout-methods/${e}`,{method:"DELETE",headers:{Accept:"application/json",Authorization:`Bearer ${this.token}`}});if(!r.ok)throw new Error(`Failed to delete payout method: ${r.status}`)}};var Ps=require("react/jsx-runtime");var Be=require("react");var Je=require("lucide-react"),lr=require("react/jsx-runtime");function La({theme:t}){return t.launcherIcon==="none"?null:t.launcherIcon==="sparkles"?(0,lr.jsx)(Je.Sparkles,{size:20}):t.launcherIcon==="credit"?(0,lr.jsx)(Je.CreditCard,{size:20}):t.launcherIcon==="arrow"?(0,lr.jsx)(Je.MoveUpRight,{size:20}):(0,lr.jsx)(Je.Gift,{size:20})}var _r=require("react");var Ba=t=>{let e,r=new Set,o=(d,p)=>{let u=typeof d=="function"?d(e):d;if(!Object.is(u,e)){let v=e;e=p??(typeof u!="object"||u===null)?u:Object.assign({},e,u),r.forEach(f=>f(e,v))}},a=()=>e,l={setState:o,getState:a,getInitialState:()=>c,subscribe:d=>(r.add(d),()=>r.delete(d))},c=e=t(o,a,l);return l},_a=(t=>t?Ba(t):Ba);var cr=we(require("react"),1);var Ns=t=>t;function Ts(t,e=Ns){let r=cr.default.useSyncExternalStore(t.subscribe,cr.default.useCallback(()=>e(t.getState()),[t,e]),cr.default.useCallback(()=>e(t.getInitialState()),[t,e]));return cr.default.useDebugValue(r),r}var Ua=t=>{let e=_a(t),r=o=>Ts(e,o);return Object.assign(r,e),r},za=(t=>t?Ua(t):Ua);var O=za(t=>({isOpen:!1,isFocused:!0,isIdle:!1,available:0,pending:0,mode:"light",token:null,partnerPayout:null,isAddingPayoutFromAlert:!1,showPayoutSuccess:!1,toggle:()=>t(e=>({isOpen:!e.isOpen})),setOpen:e=>t({isOpen:e}),setFocused:e=>t({isFocused:e}),setIdle:e=>t({isIdle:e}),setBalances:(e,r)=>t({available:e,pending:r}),setMode:e=>t({mode:e}),setToken:e=>t({token:e}),setPartnerPayout:e=>t({partnerPayout:e}),setIsAddingPayoutFromAlert:e=>t({isAddingPayoutFromAlert:e}),setShowPayoutSuccess:e=>t({showPayoutSuccess:e})}));function Qa(){let{setFocused:t,setIdle:e}=O(),r=(0,_r.useRef)(null);(0,_r.useEffect)(()=>{let o=()=>t(!0),a=()=>t(!1),s=()=>{e(!1),r.current&&clearTimeout(r.current),r.current=setTimeout(()=>{e(!0)},6e4)},n=()=>{s()};s(),t(document.hasFocus()),window.addEventListener("focus",o),window.addEventListener("blur",a);let l=["mousemove","keydown","scroll","touchstart","mousedown"];return l.forEach(c=>{window.addEventListener(c,n,c==="scroll"?!0:void 0)}),()=>{window.removeEventListener("focus",o),window.removeEventListener("blur",a),l.forEach(c=>{window.removeEventListener(c,n,c==="scroll"?!0:void 0)}),r.current&&clearTimeout(r.current)}},[t,e])}var Ha=require("lucide-react"),ae=require("react/jsx-runtime"),Wa=({children:t,theme:e,hostHeight:r=800,isMobile:o=!1})=>{Qa();let{isOpen:a,toggle:s,mode:n}=O(),l=e||me,[c,d]=(0,Be.useState)(r),[p,u]=(0,Be.useState)(o),v=l.allowUserThemeControl?{...l,mode:n}:{...l,mode:l.mode||"light"},f=Ir(v),b=(0,Be.useRef)(null),w=(0,Be.useRef)(null);return(0,Be.useEffect)(()=>{let N=T=>{if(T.data?.type==="FRUGA_HOST_RESIZE"&&(d(T.data.hostHeight),u(T.data.isHostMobile)),T.data?.type==="FRUGA_TOKEN_UPDATE"){let{setToken:R}=O.getState();R(T.data.token)}if(T.data?.type==="FRUGA_GET_BALANCE"){let{available:R,pending:I}=O.getState();console.log("FRUGA_GET_BALANCE",R,I),window.parent.postMessage({type:"FRUGA_BALANCE_RESPONSE",requestId:T.data.requestId,available:R,pending:I},"*")}};return window.addEventListener("message",N),()=>window.removeEventListener("message",N)},[]),(0,Be.useEffect)(()=>{if(!b.current)return;let N=()=>{if(!b.current)return;let R=a?450:100;!a&&w.current&&(R=w.current.offsetWidth+40);let I=a?Math.max(200,c-100):100;p&&a&&(R=window.innerWidth,I=c),window.parent.postMessage({type:"FRUGA_RESIZE",height:I,width:R,isFullscreen:p&&a},"*")},T=new ResizeObserver(()=>N());return T.observe(b.current),N(),()=>T.disconnect()},[a,c,p]),(0,ae.jsxs)("div",{ref:b,className:f.mode==="dark"?"dark":"",style:{fontFamily:'ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"',color:f.text,display:"flex",flexDirection:"column",alignItems:"flex-end",justifyContent:"flex-end",padding:p&&a?"0":"20px",boxSizing:"border-box",height:"100%",margin:0,overscrollBehavior:"contain"},children:[a&&(0,ae.jsx)("div",{style:{width:p?"100vw":"410px",minWidth:p?"100vw":"410px",flexShrink:0,maxHeight:p?"100vh":`${Math.max(100,c-100)}px`,height:"100%",marginBottom:p?"0":"20px",backgroundColor:f.accent,borderRadius:p?"0":"16px",boxShadow:p?"none":"0 20px 40px -10px rgba(0, 0, 0, 0.15), 0 0 1px rgba(0,0,0,0.1)",display:"flex",flexDirection:"column",overflow:"hidden",zIndex:9998},children:(0,ae.jsx)("div",{className:"fruga-scrollbar",style:{flex:1,minHeight:0,backgroundColor:f.isLight?"#f9f9f9":"#111",display:"flex",flexDirection:"column",boxShadow:p?"none":"0 20px 40px -10px rgba(0, 0, 0, 0.15), 0 0 1px rgba(0,0,0,0.1)"},children:t})}),(0,ae.jsxs)("button",{ref:w,onClick:s,style:{backgroundColor:f.accent,color:f.accentText,border:"none",cursor:"pointer",boxShadow:"0 12px 30px -5px rgba(0, 0, 0, 0.1), 0 0 1px rgba(0,0,0, 0.1)",display:a?"none":"flex",alignItems:"center",justifyContent:"center",zIndex:9999,flexShrink:0,borderRadius:"20px",padding:"10px 16px",transition:"transform 0.3s ease-in-out"},className:"flex h-15 items-center gap-2 rounded-xl px-4 active:scale-[0.99]","aria-label":a?"Close widget":"Open widget",children:[l.launcherLabel&&!a?(0,ae.jsxs)(ae.Fragment,{children:[l.launcherLabel!=="none"&&(0,ae.jsx)("div",{className:"text-sm font-semibold",children:l.launcherLabel}),(0,ae.jsx)("div",{className:"flex h-6 w-5 shrink-0 items-center justify-center",children:(0,ae.jsx)(La,{theme:f})})]}):null,a?(0,ae.jsx)(Ha.X,{}):null]})]})};var ja=require("react/jsx-runtime");var Ur=require("react"),$a=(t,e)=>{let[r,o]=(0,Ur.useState)(t);return(0,Ur.useEffect)(()=>{let a=setTimeout(()=>{o(t)},e);return()=>{clearTimeout(a)}},[t,e]),r};var qa={BOOTSTRAP_DATA:"fruga_bootstrap",BOOTSTRAP_CONFIG:"fruga_active_config"},zr=class{static set(e,r){if(!(typeof window>"u"))try{window.localStorage.setItem(e,JSON.stringify(r))}catch(o){console.warn(`[FrugaStorage] Failed to save key "${e}":`,o)}}static get(e){if(typeof window>"u")return null;try{let r=window.localStorage.getItem(e);return r?JSON.parse(r):null}catch(r){return console.warn(`[FrugaStorage] Failed to load key "${e}":`,r),null}}static remove(e){typeof window>"u"||window.localStorage.removeItem(e)}static clear(){typeof window>"u"||window.localStorage.clear()}};var Cs=typeof process<"u"&&process.env.VITE_FRUGA_API_URL||"https://api-dev.fruga.co.uk",Ka=t=>t||Cs;var Eo=t=>{if(!t)return"";try{let e=t.includes("/")&&!t.includes("-")?t.split(" ")[0].split("/").reverse().join("-"):t,r=new Date(e);if(isNaN(r.getTime()))return t;let o=r.getDate().toString().padStart(2,"0"),a=(r.getMonth()+1).toString().padStart(2,"0"),s=r.getFullYear();return`${o}-${a}-${s}`}catch{return t}},Ga=t=>{try{let e=t.includes("/")&&!t.includes("-")?t.split(" ")[0].split("/").reverse().join("-"):t,r=new Date(e);return isNaN(r.getTime())?null:r}catch{return null}},Va=(t,e=30)=>{if(!t)return!1;let r=Ga(t);if(!r)return!1;let o=new Date,a=new Date(o.getFullYear(),o.getMonth(),o.getDate()),n=new Date(r.getFullYear(),r.getMonth(),r.getDate()).getTime()-a.getTime(),l=Math.ceil(n/(1e3*60*60*24));return l>=0&&l<=e},Ya=t=>{if(!t)return null;let e=Ga(t);if(!e)return null;let r=new Date,o=new Date(r.getFullYear(),r.getMonth(),r.getDate()),s=new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime()-o.getTime(),n=Math.ceil(s/(1e3*60*60*24));return n>=0?n:0};var Za=(t,e=40)=>t?t.length<=e?t:t.slice(0,e)+"...":"";var $=require("react");var _t=require("react");var Qr=class{constructor(e){this.offerRepository=e}async getOffers(e){return this.offerRepository.getOffers(e)}async getFeaturedOffers(){return(await this.offerRepository.getOffers({featured:!0,pageSize:20})).content}async getOfferDetails(e){return this.offerRepository.getOfferById(e)}async claimOffer(e){return console.log(`[Use Case] Claiming offer: ${e}`),!0}async getOfferCategories(){return this.offerRepository.getCategories()}};var Hr=class{constructor(e){this.accountRepository=e}async getWallet(){return this.accountRepository.getWallet()}async getActivity(e,r){return this.accountRepository.getActivity(e,r)}};var ie=t=>{let e=new Date;return e.setDate(e.getDate()+t),e.toISOString().split("T")[0]},ee={Travel:{id:2,name:"Travel",rank:2,offerCount:15},Sports:{id:4,name:"Sports",rank:4,offerCount:10},Fashion:{id:3,name:"Fashion",rank:3,offerCount:30},"Food&Bev":{id:1,name:"Food&Bev",rank:1,offerCount:20},Entertainment:{id:5,name:"Entertainment",rank:5,offerCount:5}},Io=[{id:1,name:"easyJet flight booking",brandName:"easyJet",description:"Save on your next flight",terms:"T&Cs apply.",link:"https://easyjet.com",type:"AFFILIATE_LINK",logo:"https://logo.clearbit.com/easyjet.com",cashback:.035,endDate:ie(10),featured:!0,categories:[ee.Travel]},{id:2,name:"Nike shoes",brandName:"Nike",description:"Just do it",terms:"Online only",link:"https://nike.com",type:"AFFILIATE_LINK",logo:"https://logo.clearbit.com/nike.com",cashback:.06,endDate:ie(30),featured:!0,categories:[ee.Sports]},{id:3,name:"Adidas gear",brandName:"Adidas",description:"Sportswear and shoes",terms:"T&Cs apply.",link:"https://adidas.com",type:"AFFILIATE_LINK",logo:"https://logo.clearbit.com/adidas.com",cashback:.05,endDate:ie(30),featured:!1,categories:[ee.Sports]},{id:4,name:"ASOS fashion",brandName:"ASOS",description:"Latest trends",terms:"T&Cs apply.",link:"https://asos.com",type:"AFFILIATE_LINK",logo:"https://logo.clearbit.com/asos.com",cashback:.08,endDate:ie(30),featured:!0,categories:[ee.Fashion]},{id:5,name:"Morrisons groceries",brandName:"Morrisons",description:"Fresh food",terms:"T&Cs apply.",link:"https://morrisons.com",type:"AFFILIATE_LINK",logo:"https://logo.clearbit.com/morrisons.com",cashback:.02,endDate:ie(6),featured:!1,categories:[ee["Food&Bev"]]},{id:6,name:"Just Eat delivery",brandName:"Just Eat",description:"Food delivery",terms:"T&Cs apply.",link:"https://just-eat.com",type:"AFFILIATE_LINK",logo:"https://logo.clearbit.com/just-eat.com",cashback:.04,endDate:ie(30),featured:!1,categories:[ee["Food&Bev"]]},{id:7,name:"TripAdvisor bookings",brandName:"TripAdvisor",description:"Hotels and more",terms:"T&Cs apply.",link:"https://tripadvisor.com",type:"AFFILIATE_LINK",logo:"https://logo.clearbit.com/tripadvisor.com",cashback:.19,endDate:ie(30),featured:!0,categories:[ee.Travel]},{id:8,name:"Debenhams store",brandName:"Debenhams",description:"Department store",terms:"T&Cs apply.",link:"https://debenhams.com",type:"AFFILIATE_LINK",logo:"https://logo.clearbit.com/debenhams.com",cashback:.03,endDate:ie(30),featured:!0,categories:[ee.Fashion]},{id:9,name:"Booking.com hotel",brandName:"Booking.com",description:"Hotels worldwide",terms:"T&Cs apply.",link:"https://booking.com",type:"AFFILIATE_LINK",logo:"https://logo.clearbit.com/booking.com",cashback:.04,endDate:ie(30),featured:!1,categories:[ee.Travel]},{id:10,name:"Deliveroo orders",brandName:"Deliveroo",description:"Food delivery",terms:"T&Cs apply.",link:"https://deliveroo.com",type:"AFFILIATE_LINK",logo:"https://logo.clearbit.com/deliveroo.com",cashback:.05,endDate:ie(30),featured:!0,categories:[ee["Food&Bev"]]},{id:11,name:"Puma shoes",brandName:"Puma",description:"Sportswear",terms:"T&Cs apply.",link:"https://puma.com",type:"AFFILIATE_LINK",logo:"https://logo.clearbit.com/puma.com",cashback:.07,endDate:ie(30),featured:!1,categories:[ee.Sports]},{id:12,name:"H&M clothing",brandName:"H&M",description:"Fashion",terms:"T&Cs apply.",link:"https://hm.com",type:"AFFILIATE_LINK",logo:"https://logo.clearbit.com/hm.com",cashback:.04,endDate:ie(30),featured:!1,categories:[ee.Fashion]},{id:13,name:"Uber rides",brandName:"Uber",description:"Ride sharing",terms:"T&Cs apply.",link:"https://uber.com",type:"AFFILIATE_LINK",logo:"https://logo.clearbit.com/uber.com",cashback:.02,endDate:ie(30),featured:!1,categories:[ee.Travel]}],Wr=class{async getOffers(e){let r=[...Io];if(e.featured&&(r=r.filter(d=>d.featured)),e.categories&&e.categories.length>0&&e.categories[0]!=="All"&&(r=r.filter(d=>d.categories?.some(p=>e.categories.includes(p.name)))),e.query){let d=e.query.toLowerCase();r=r.filter(p=>p.brandName.toLowerCase().includes(d)||p.name?.toLowerCase().includes(d))}let o=e.pageNumber??0,a=e.pageSize??10;await new Promise(d=>setTimeout(d,400));let s=r.length,n=Math.ceil(s/a),l=o*a,c=r.slice(l,l+a);return{content:c,totalElements:s,totalPages:n,number:o,size:a,numberOfElements:c.length,numberOfPages:n}}async getFeaturedOffers(){return Io.filter(e=>e.featured)}async getOfferById(e){let r=Number(e);return Io.find(o=>o.id===r)||null}async getCategories(){return Object.values(ee).sort((e,r)=>e.rank-r.rank)}};var jr=class{async getWallet(){return{available:241.5,pending:27.99,totalBalance:269.49,lifetimeEarned:396.94,lifetimeRedeemed:127.45,updatedAt:new Date().toISOString(),requiredActions:[{type:"ADD_PAYOUT_METHOD",transactionId:1234}]}}async getActivity(e,r){let o=this.getMockTransactions(),a=e??0,s=r??10;await new Promise(c=>setTimeout(c,400));let n=a*s;return{actorType:"user",partnerId:1,transactions:o.slice(n,n+s)}}getMockTransactions(){let e=[{name:"Adidas",logo:"https://logo.clearbit.com/adidas.com"},{name:"Fruga",logo:""},{name:"Samsung",logo:"https://logo.clearbit.com/samsung.com"},{name:"Booking.com",logo:"https://logo.clearbit.com/booking.com"},{name:"ASOS",logo:"https://logo.clearbit.com/asos.com"},{name:"Nike",logo:"https://logo.clearbit.com/nike.com"},{name:"Amazon",logo:"https://logo.clearbit.com/amazon.com"},{name:"Apple",logo:"https://logo.clearbit.com/apple.com"},{name:"Zara",logo:"https://logo.clearbit.com/zara.com"},{name:"Starbucks",logo:"https://logo.clearbit.com/starbucks.com"},{name:"Uber",logo:"https://logo.clearbit.com/uber.com"},{name:"Netflix",logo:"https://logo.clearbit.com/netflix.com"}],r=["APPROVED","FAILED","CANCELLED","PROCESSING","PENDING_RETAILER","PENDING_BANK","PAID"],o=["AFFILIATE_LINK","PAYOUT","BONUS"],a=[];a.push({id:1234,activityAmount:-120,occuredAt:"23/04/2026 14:30",brandName:"Fruga",status:"PROCESSING",purchaseAmount:0,brandLogo:"",offerName:"",type:"PAYOUT",flow:"PAYOUT",partnerEventId:"p1234",redemptionContext:"OTHER"}),a.push({id:5555,activityAmount:-45,occuredAt:"25/04/2026 11:15",brandName:"Fruga",status:"ACTION_REQUIRED",purchaseAmount:0,brandLogo:"",offerName:"",type:"PAYOUT",flow:"PAYOUT",partnerEventId:"p5555",redemptionContext:"NEW_POLICY"});for(let s=1;s<=50;s++){let n=e[s%e.length],l=r[s%r.length],c=o[s%o.length],d=s*25.5%300,p=d*.1,u="EARN";c==="PAYOUT"&&(d=0,p=-25,u="PAYOUT");let v=new Date(2026,3,15);v.setDate(v.getDate()-s);let f=String(v.getMonth()+1).padStart(2,"0"),b=String(v.getDate()).padStart(2,"0"),w=v.getFullYear();a.push({id:s,activityAmount:p,occuredAt:`${b}/${f}/${w} 10:00`,brandName:n.name,status:l,purchaseAmount:d,brandLogo:n.logo,offerName:c==="PAYOUT"?"":"Cashback Offer",type:c,flow:u,partnerEventId:`e${s}`,redemptionContext:c==="PAYOUT"?"OTHER":""})}return a}};var $r=class{constructor(e,r){this.walletService=e;this.activityService=r}async getWallet(){return this.walletService.getWallet()}async getActivity(e,r){return this.activityService.getActivity(e,r)}};var qr=class{constructor(e){this.offersService=e}async getOffers(e){return this.offersService.getOffers(e)}async getFeaturedOffers(){return[]}async getOfferById(e){return null}async getCategories(){return this.offersService.getCategories()}};var Kr=class{constructor(e){this.repository=e}async getMethod(){return console.log(">>>>>>>>>>>>>>> getMethod"),this.repository.getPaymentMethod()}async addMethod(e){return this.repository.savePaymentMethod(e)}async removeMethod(e){return this.repository.deletePaymentMethod(e)}};var Gr=class{constructor(e=!0){$o(this,"method",null);e&&(this.method={id:"9007199254740991",methodType:"BANK",isDefault:!0,status:"ACTIVE",bank:{accountHolderName:"John Doe",accountLast4:"5789",sortCodeMasked:"12-34-**"},createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()})}async getPaymentMethod(){return await new Promise(e=>setTimeout(e,500)),this.method}async savePaymentMethod(e){return await new Promise(r=>setTimeout(r,1e3)),this.method={id:Math.random().toString(36).substr(2,9),methodType:"BANK",isDefault:!0,status:"ACTIVE",bank:{accountHolderName:e.accountHolderName,accountLast4:e.accountNumber.slice(-4),sortCodeMasked:e.sortCode.replace(/\d/g,"*")},createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()},this.method}async deletePaymentMethod(e){await new Promise(r=>setTimeout(r,500)),this.method&&String(this.method.id)===String(e)&&(this.method=null)}};var Vr=class{constructor(e){this.service=e}async getPaymentMethod(){let e=await this.service.listMethods();return e.find(r=>r.status==="ACTIVE")||e[0]||null}async savePaymentMethod(e){return this.service.addBankMethod(e)}async deletePaymentMethod(e){return this.service.deleteMethod(e)}};var ei=require("react/jsx-runtime"),Ja=(0,_t.createContext)(null),Xa=({children:t,baseUrl:e})=>{let{token:r}=O(),o=(0,_t.useMemo)(()=>{let a=Ka(e),s,n,l;return r?(s=new qr(new Lr(a,r)),n=new $r(new Mr(a,r),new Dr(a,r)),l=new Vr(new Br(a,r))):(s=new Wr,n=new jr,l=new Gr(!1)),{offerUseCases:new Qr(s),accountUseCases:new Hr(n),paymentService:new Kr(l)}},[r,e]);return(0,ei.jsx)(Ja.Provider,{value:o,children:t})};function Ce(){let t=(0,_t.useContext)(Ja);if(!t)throw new Error("useDependencies must be used within a DependencyProvider");return t}var fr=require("react");var Re=require("lucide-react"),Q=require("react/jsx-runtime"),dr=[{title:"Welcome to SavingsBox",description:"Your new way to save while you shop. Earn cashback on every purchase from your favorite brands.",icon:Re.Sparkles,color:"#8B5CF6",gradient:"linear-gradient(135deg, #8B5CF6 0%, #7C3AED 100%)"},{title:"Shop and Earn",description:"Simply browse through our partner brands, shop as usual, and watch your cashback balance grow.",icon:Re.TrendingUp,color:"#3B82F6",gradient:"linear-gradient(135deg, #3B82F6 0%, #2563EB 100%)"},{title:"Secure Policy",description:"Use your earned cashback to pay for your insurance policies or withdraw it directly to your bank.",icon:Re.ShieldCheck,color:"#10B981",gradient:"linear-gradient(135deg, #10B981 0%, #059669 100%)"},{title:"Bonus Rewards",description:"Get exclusive bonuses and higher cashback rates as you use the platform more.",icon:Re.Gift,color:"#F59E0B",gradient:"linear-gradient(135deg, #F59E0B 0%, #D97706 100%)"}],ti=({theme:t,onboardingStep:e,setOnboardingStep:r,onFinish:o})=>{let a=dr[e],s=a.icon,n=()=>{e<dr.length-1?r(e+1):o()};return(0,Q.jsxs)("div",{className:"relative flex h-full flex-col items-center justify-center overflow-hidden px-8 text-center transition-all duration-700",children:[(0,Q.jsx)("div",{className:"absolute -top-24 -left-24 h-64 w-64 rounded-full blur-[80px] opacity-20 transition-all duration-1000",style:{backgroundColor:a.color}}),(0,Q.jsxs)("div",{className:"relative z-10 flex flex-col items-center w-full max-w-[320px]",children:[(0,Q.jsx)("div",{className:"group mb-10 flex h-24 w-24 items-center justify-center rounded-[2rem] shadow-2xl transition-all duration-500 hover:scale-110",style:{background:a.gradient,boxShadow:`0 20px 40px -10px ${a.color}66`},children:(0,Q.jsx)(s,{size:44,className:"text-white drop-shadow-md transition-transform duration-500 group-hover:rotate-12"})}),(0,Q.jsxs)("div",{className:"space-y-4 animate-in slide-in-from-bottom-4 duration-700 fill-mode-both",children:[(0,Q.jsx)("h2",{className:"text-3xl font-extrabold tracking-tight sm:text-4xl",style:{color:t.text},children:a.title}),(0,Q.jsx)("p",{className:"text-lg leading-relaxed opacity-90 font-medium",style:{color:t.muted},children:a.description})]}),(0,Q.jsx)("div",{className:"mt-12 mb-10 flex gap-2.5",children:dr.map((l,c)=>(0,Q.jsx)("div",{className:"h-2 rounded-full transition-all duration-500",style:{width:c===e?"32px":"8px",backgroundColor:c===e?a.color:t.isLight?"rgba(0,0,0,0.1)":"rgba(255,255,255,0.1)",opacity:c===e?1:.4}},c))}),(0,Q.jsxs)("button",{onClick:n,className:"group relative flex w-full cursor-pointer items-center justify-center gap-2 overflow-hidden rounded-[1.25rem] py-4.5 text-lg font-bold text-white shadow-[0_15px_30px_-5px_rgba(0,0,0,0.3)] transition-all hover:scale-[1.03] active:scale-[0.97]",style:{background:a.gradient},children:[(0,Q.jsx)("span",{children:e===dr.length-1?"Start Saving":"Continue"}),(0,Q.jsx)(Re.ChevronRight,{size:20,className:"transition-transform duration-300 group-hover:translate-x-1"})]}),e<dr.length-1?(0,Q.jsx)("button",{onClick:o,className:"mt-6 cursor-pointer text-sm font-semibold opacity-60 transition-all hover:opacity-100 hover:translate-y-[-1px]",style:{color:t.text},children:"Skip for now"}):(0,Q.jsx)("div",{className:"mt-6 h-5"})]})]})};function Xe(...t){return t.filter(Boolean).join(" ")}var zt=require("lucide-react"),Ut=require("react/jsx-runtime"),ri=({theme:t,activeTab:e,onTabChange:r,onHelpPageReset:o})=>(0,Ut.jsx)("div",{className:"mx-3 grid grid-cols-3 gap-2 rounded-3xl p-2 shadow-[0_10px_25px_-5px_rgba(0,0,0,0.1),0_8px_10px_-6px_rgba(0,0,0,0.1)]",style:{background:t.panel},children:[{id:"offers",label:"Offers",Icon:zt.Tag},{id:"account",label:"Account",Icon:zt.UserStar},{id:"help",label:"Help",Icon:zt.CircleHelp}].map(a=>{let s=e===a.id,n=a.Icon;return(0,Ut.jsxs)("button",{onClick:()=>{r(a.id),o()},className:"flex flex-col items-center justify-center gap-1 rounded-3xl px-3 py-2.5",style:{background:s?t.isLight?`color-mix(in srgb, ${t.accent} 18%, transparent)`:`color-mix(in srgb, ${t.accent} 25%, transparent)`:"transparent",color:s?t.accent:t.text,cursor:"pointer"},children:[(0,Ut.jsx)(n,{size:18,strokeWidth:2.2}),(0,Ut.jsx)("div",{className:"text-[11px] font-semibold leading-none",children:a.label})]},a.id)})});var li=we(require("react")),_e=require("lucide-react");var Yr=require("lucide-react"),ut=require("react/jsx-runtime");function oi({isLight:t,onToggle:e,accentColor:r,hoverClass:o="hover:bg-white/5"}){return(0,ut.jsxs)("button",{type:"button",onClick:e,"aria-label":t?"Switch to dark mode":"Switch to light mode",title:t?"Dark mode":"Light mode",className:`group relative flex h-9 w-9 shrink-0 items-center justify-center rounded-full transition-all duration-300 cursor-pointer active:scale-90 ${o}`,children:[(0,ut.jsxs)("div",{className:"relative h-5 w-5 flex items-center justify-center",children:[(0,ut.jsx)(Yr.Sun,{size:18,strokeWidth:2.5,className:`absolute transition-all duration-500 ${t?"rotate-0 scale-100 opacity-100":"rotate-90 scale-0 opacity-0"}`,style:{transitionTimingFunction:"cubic-bezier(0.34, 1.56, 0.64, 1)",color:r}}),(0,ut.jsx)(Yr.Moon,{size:18,strokeWidth:2.5,className:`absolute transition-all duration-500 ${t?"-rotate-90 scale-0 opacity-0":"rotate-0 scale-100 opacity-100"}`,style:{transitionTimingFunction:"cubic-bezier(0.34, 1.56, 0.64, 1)",color:r}})]}),(0,ut.jsx)("div",{className:`absolute inset-0 rounded-full transition-opacity duration-700 blur-md -z-10 ${t?"bg-amber-400/20 opacity-100":"bg-blue-400/10 opacity-0"}`})]})}var M=require("react/jsx-runtime");function F({theme:t,className:e,style:r}){let o=t.isLight?"rgba(0,0,0,0.06)":"rgba(255,255,255,0.06)",a=t.isLight?"rgba(0,0,0,0.12)":"rgba(255,255,255,0.12)";return(0,M.jsx)("div",{className:Xe("rounded-2xl",e),style:{background:`linear-gradient(90deg, ${o} 0%, ${a} 20%, ${o} 40%, ${o} 100%)`,backgroundSize:"200% 100%",animation:"shimmer 1.5s ease-in-out infinite",...r}})}function ai({theme:t}){return(0,M.jsx)("div",{className:"w-full rounded-2xl p-4",style:{background:t.isLight?"#FFFFFF":t.panel,border:t.isLight?"none":"1px solid rgba(255,255,255,0.08)",boxShadow:t.isLight?"0 1px 3px rgba(0,0,0,0.06)":"0 1px 3px rgba(0,0,0,0.2)"},children:(0,M.jsxs)("div",{className:"flex items-center gap-3",children:[(0,M.jsx)(F,{theme:t,className:"h-10 w-16 shrink-0 rounded-lg"}),(0,M.jsx)("div",{className:"flex-1 space-y-2",children:(0,M.jsx)(F,{theme:t,className:"h-4 w-24"})}),(0,M.jsx)("div",{className:"shrink-0 flex flex-col items-end gap-2",children:(0,M.jsx)(F,{theme:t,className:"h-5 w-20 rounded-xl"})})]})})}function ii({theme:t}){return(0,M.jsxs)("div",{className:"flex h-[140px] w-[140px] shrink-0 flex-col items-center justify-start rounded-2xl p-3 pt-4",style:{background:t.isLight?"#FFFFFF":t.panel,border:t.isLight?void 0:"1px solid rgba(255,255,255,0.08)",boxShadow:t.isLight?"0 1px 3px rgba(0,0,0,0.06)":"0 1px 3px rgba(0,0,0,0.2)"},children:[(0,M.jsx)(F,{theme:t,className:"h-10 w-12 shrink-0 rounded-lg"}),(0,M.jsx)(F,{theme:t,className:"mt-1.5 h-5 w-20"}),(0,M.jsx)(F,{theme:t,className:"mt-1 h-6 w-16 rounded-full"})]})}function si({theme:t}){return(0,M.jsx)("div",{className:"flex flex-col gap-1 px-4 py-3",children:[1,2,3].map(e=>(0,M.jsxs)("div",{className:"flex items-center gap-4 py-3",children:[(0,M.jsx)(F,{theme:t,className:"h-10 w-10 shrink-0 rounded-full"}),(0,M.jsxs)("div",{className:"flex-1 space-y-2",children:[(0,M.jsx)(F,{theme:t,className:"h-4 w-1/2"}),(0,M.jsx)(F,{theme:t,className:"h-3 w-1/4 opacity-60"})]}),(0,M.jsxs)("div",{className:"text-right space-y-2",children:[(0,M.jsx)(F,{theme:t,className:"h-4 w-16"}),(0,M.jsx)(F,{theme:t,className:"h-3 w-12 ml-auto opacity-60"})]})]},e))})}var m=require("react/jsx-runtime"),pr=[{id:"how-it-works",title:"How it works",body:t=>{let e=t.isLight?{border:"1px solid rgba(0,0,0,0.1)",background:"rgba(0,0,0,0.04)"}:{border:"1px solid rgba(255,255,255,0.1)",background:"rgba(255,255,255,0.05)"};return(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)("p",{className:"leading-relaxed",children:["You earn cashback when you shop with partner brands through links in this widget. Cashback appears as ",(0,m.jsx)("b",{children:"Pending"})," first, then becomes ",(0,m.jsx)("b",{children:"Available"})," after it's confirmed."]}),(0,m.jsxs)("ul",{className:"mt-3 list-disc space-y-1 pl-5 text-sm opacity-90",children:[(0,m.jsx)("li",{children:"Pick an offer"}),(0,m.jsx)("li",{children:"Shop as normal on the brand's site"}),(0,m.jsx)("li",{children:"We track your purchase and update your credit"})]}),(0,m.jsxs)("div",{className:"mt-4 space-y-3 text-sm opacity-90",children:[(0,m.jsxs)("div",{children:[(0,m.jsx)("div",{className:"text-xs font-semibold opacity-80",children:"What happens after I click an offer?"}),(0,m.jsxs)("p",{className:"mt-1 leading-relaxed",children:["We open the brand's website in a tracked session. If you complete a purchase, the brand reports it back to us and we add cashback to your account as ",(0,m.jsx)("b",{children:"Pending"}),"."]})]}),(0,m.jsxs)("div",{children:[(0,m.jsx)("div",{className:"text-xs font-semibold opacity-80",children:"Why does cashback start as Pending?"}),(0,m.jsx)("p",{className:"mt-1 leading-relaxed",children:"Brands typically confirm orders after return periods or fraud checks. Once confirmed, Pending cashback becomes Available."})]}),(0,m.jsxs)("div",{children:[(0,m.jsx)("div",{className:"text-xs font-semibold opacity-80",children:"Quick checklist (to avoid missing cashback)"}),(0,m.jsxs)("ul",{className:"mt-2 list-disc space-y-1 pl-5",children:[(0,m.jsx)("li",{children:"Allow cookies for the host website and the brand site"}),(0,m.jsx)("li",{children:"Don't use ad-blockers that strip tracking parameters"}),(0,m.jsx)("li",{children:"Complete purchase in the same browser session"}),(0,m.jsx)("li",{children:"Avoid applying promo codes not listed on the offer"}),(0,m.jsx)("li",{children:"If you switch devices, start the offer again from this widget"})]})]}),(0,m.jsxs)("div",{children:[(0,m.jsx)("div",{className:"text-xs font-semibold opacity-80",children:"Typical timelines"}),(0,m.jsxs)("ul",{className:"mt-2 list-disc space-y-1 pl-5",children:[(0,m.jsx)("li",{children:"Pending shows up: within minutes to 48 hours"}),(0,m.jsx)("li",{children:"Confirmation: 7\u201360 days (varies by brand/category)"}),(0,m.jsx)("li",{children:"Available \u2192 redeem: depends on the host website's redemption options"})]})]}),(0,m.jsxs)("div",{className:"rounded-2xl p-3",style:e,children:[(0,m.jsx)("div",{className:"text-xs font-semibold opacity-80",children:"Troubleshooting"}),(0,m.jsxs)("div",{className:"mt-2 space-y-2 text-sm opacity-90",children:[(0,m.jsx)("div",{children:"\u2022 If you don't see Pending cashback within 48 hours, check you completed the purchase in the same browser session."}),(0,m.jsx)("div",{children:"\u2022 If you used a promo code not listed on the offer, cashback might be reduced or declined by the retailer."}),(0,m.jsx)("div",{children:"\u2022 Some categories confirm after returns windows, so Pending can take longer to become Available."}),(0,m.jsx)("div",{children:"\u2022 If you cancelled or returned an order, cashback is typically reversed."}),(0,m.jsx)("div",{children:"\u2022 If you used private browsing, tracking may fail. Retry in a normal session."}),(0,m.jsx)("div",{children:"\u2022 If you switch between tabs/checkout providers, keep cookies enabled."}),(0,m.jsx)("div",{children:"\u2022 Some retailers exclude gift cards and subscriptions from cashback."}),(0,m.jsx)("div",{children:"\u2022 If multiple cashback tools are active, retailers may reject tracking."}),(0,m.jsx)("div",{children:'\u2022 If you used "click & collect", cashback rules vary by retailer.'})]})]}),(0,m.jsxs)("div",{className:"rounded-2xl p-3",style:e,children:[(0,m.jsx)("div",{className:"text-xs font-semibold opacity-80",children:"Need more help?"}),(0,m.jsxs)("div",{className:"mt-2 space-y-2 text-sm opacity-90",children:[(0,m.jsx)("div",{children:"\u2022 Check your order history for the exact date/time of purchase."}),(0,m.jsx)("div",{children:"\u2022 If the retailer confirms the order, cashback will move to Available automatically."}),(0,m.jsx)("div",{children:"\u2022 In the full product, you can submit a missing cashback claim (prototype not wired)."})]})]})]})]})}},{id:"earn-more",title:"How to earn more credit",body:()=>(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)("p",{className:"leading-relaxed",children:"Use the filters to find higher cashback offers, and keep an eye on expiring deals."}),(0,m.jsxs)("div",{className:"mt-3 space-y-2 text-sm opacity-90",children:[(0,m.jsxs)("div",{children:["\u2022 Try ",(0,m.jsx)("b",{children:"Fashion"})," and ",(0,m.jsx)("b",{children:"Sports"})," for higher % offers."]}),(0,m.jsx)("div",{children:"\u2022 Check back weekly \u2014 offers change often."}),(0,m.jsx)("div",{children:"\u2022 Ensure cookies are enabled so tracking works properly."})]})]})},{id:"redeem",title:"How to redeem my credit",body:t=>{let e=t.isLight?{border:"1px solid rgba(0,0,0,0.1)",background:"rgba(0,0,0,0.04)"}:{border:"1px solid rgba(255,255,255,0.1)",background:"rgba(255,255,255,0.05)"};return(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)("p",{className:"leading-relaxed",children:["When your credit is ",(0,m.jsx)("b",{children:"Available"}),", you can redeem it \u2014 depending on what the host website supports."]}),(0,m.jsxs)("div",{className:"mt-3 rounded-2xl p-3 text-sm",style:e,children:[(0,m.jsx)("div",{className:"font-medium",children:"Prototype note"}),(0,m.jsx)("div",{className:"mt-1 opacity-90",children:"In the real SDK, redemption options are configurable per host website."})]})]})}},{id:"credits-work",title:"How do credits work?",body:()=>(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)("p",{className:"leading-relaxed",children:["Credits are the cashback you earn from shopping with partner brands. They start as ",(0,m.jsx)("b",{children:"Pending"})," while the retailer confirms your purchase, then move to ",(0,m.jsx)("b",{children:"Available"})," once confirmed."]}),(0,m.jsx)("p",{className:"mt-3 leading-relaxed",children:"You can use Available credit to pay for insurance, add-ons, or other options offered by the host website."})]})},{id:"credits-expire",title:"When do credits expire?",body:()=>(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)("p",{className:"leading-relaxed",children:"Pending credits typically become Available within 7\u201360 days, depending on the retailer. Once Available, your credit balance is yours to use."}),(0,m.jsx)("p",{className:"mt-3 leading-relaxed",children:"Expiry rules vary by host website. In the full product, you can check your account for any expiry dates on your credit."})]})},{id:"contact",title:"Contact us",body:()=>(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)("p",{className:"leading-relaxed",children:"Need help with cashback, redemption, or your account? Get in touch through the host website's support channels."}),(0,m.jsx)("p",{className:"mt-3 leading-relaxed",children:"In the full product, you can submit a missing cashback claim or contact support directly from your account."})]})}];var ni=require("react");function ht(){let{accountUseCases:t}=Ce(),e=De(),{token:r,isOpen:o,isFocused:a,isIdle:s,available:n,pending:l,setBalances:c}=O(),d=o?a?s?3e4:1e4:3e4:!1,{data:p}=pt({queryKey:["wallet",r],queryFn:()=>t.getWallet(),refetchInterval:d});return(0,ni.useEffect)(()=>{p&&(p.available!==n||p.pending!==l)&&(c(p.available,p.pending),e.invalidateQueries({queryKey:["activity"]}))},[p,n,l,e,c]),{wallet:p}}var P=require("react/jsx-runtime"),Rs=()=>{let{wallet:t}=ht(),e=t?.available||0;return(0,P.jsxs)("div",{className:"mt-1 flex items-baseline gap-1",children:[(0,P.jsxs)("span",{className:"text-3xl font-bold tracking-tight",children:["\xA3",e.toFixed(2)]}),(0,P.jsx)(_e.Sparkles,{size:20,className:"opacity-80"})]})},Zr=({toggle:t,theme:e,allowUserThemeControl:r,onThemeModeChange:o,isAccentBackground:a=!1})=>{let s=a?e.accentText:e.text,n=a?"hover:bg-white/15":e.isLight?"hover:bg-black/5":"hover:bg-white/10";return(0,P.jsxs)("div",{className:"absolute right-2 top-3 z-[100] flex items-center gap-1",style:{color:s},children:[r&&(0,P.jsx)(oi,{isLight:e.isLight,onToggle:()=>o?.(e.isLight?"dark":"light"),accentColor:s,hoverClass:n}),(0,P.jsx)("button",{className:`cursor-pointer rounded-full p-2 transition-all duration-200 active:scale-90 ${n}`,onClick:t,"aria-label":"Close",title:"Close",children:(0,P.jsx)(_e.X,{size:18,strokeWidth:2.5})})]})},ci=({tab:t,theme:e,allowUserThemeControl:r,onThemeModeChange:o,helpPage:a,setHelpPage:s,accountView:n,setAccountView:l})=>{let{toggle:c,partnerPayout:d}=O(),p=d==="USER";if(t==="offers")return(0,P.jsxs)("div",{className:"relative px-4 pt-4 pb-6",style:{background:`linear-gradient(135deg, ${e.accent} 0%, color-mix(in srgb, ${e.accent} 75%, black) 100%)`,color:e.accentText},children:[(0,P.jsx)(Zr,{toggle:c,theme:e,allowUserThemeControl:r,onThemeModeChange:o,isAccentBackground:!0}),(0,P.jsxs)("div",{className:"mt-6 px-1",children:[(0,P.jsx)("div",{className:"text-sm font-medium opacity-90",children:"Available credit"}),(0,P.jsx)(li.default.Suspense,{fallback:(0,P.jsx)(F,{theme:e,className:"mt-1 h-9 w-28 rounded-lg",style:{background:"rgba(255,255,255,0.3)"}}),children:(0,P.jsx)(Rs,{})})]})]});if(t==="account"){if(n!=="transactions"){let u=n==="settings"?"Settings":"Payout Method";return(0,P.jsxs)("div",{className:"relative px-4 pt-6 pb-2",children:[(0,P.jsx)(Zr,{toggle:c,theme:e,allowUserThemeControl:r,onThemeModeChange:o}),(0,P.jsxs)("div",{className:"flex items-center gap-2",children:[(0,P.jsxs)("button",{className:"inline-flex items-center gap-1 rounded-full cursor-pointer border px-2 py-1 text-xs transition hover:bg-white/10",style:{borderColor:e.border,background:e.isLight?"rgba(0,0,0,0.04)":"rgba(255,255,255,0.03)"},onClick:()=>{l?.(n==="payout-method"?"settings":"transactions")},children:[(0,P.jsx)(_e.ChevronLeft,{size:14})," Back"]}),(0,P.jsx)("div",{className:"text-lg font-semibold",children:u})]})]})}return(0,P.jsxs)("div",{className:"relative w-full z-0 px-4 pt-4 pb-12 flex flex-row justify-between items-start",style:{background:`linear-gradient(135deg, ${e.accent} 0%, color-mix(in srgb, ${e.accent} 75%, black) 100%)`,color:e.accentText},children:[(0,P.jsxs)("div",{className:"flex gap-3 items-center",children:[(0,P.jsx)("div",{className:"mt-2 text-lg font-semibold flex-1",children:"Account"}),p&&(0,P.jsx)("button",{className:"mt-2 rounded-full p-1.5 cursor-pointer transition hover:bg-white/15",onClick:()=>l?.("settings"),"aria-label":"Settings",children:(0,P.jsx)(_e.Settings,{size:20})})]}),(0,P.jsx)(Zr,{toggle:c,theme:e,allowUserThemeControl:r,onThemeModeChange:o,isAccentBackground:!0})]})}return(0,P.jsxs)("div",{className:"relative px-4 pt-6 pb-2",children:[(0,P.jsx)(Zr,{toggle:c,theme:e,allowUserThemeControl:r,onThemeModeChange:o}),a?(0,P.jsxs)("div",{className:"flex items-center gap-2",children:[(0,P.jsxs)("button",{className:"inline-flex items-center gap-1 rounded-full cursor-pointer border px-2 py-1 text-xs",style:{borderColor:e.border,background:e.isLight?"rgba(0,0,0,0.04)":"rgba(255,255,255,0.03)"},onClick:()=>s(null),children:[(0,P.jsx)(_e.ChevronLeft,{size:14})," Back"]}),(0,P.jsx)("div",{className:"truncate text-lg font-semibold",children:pr.find(u=>u.id===a)?.title})]}):(0,P.jsx)("div",{className:"text-lg font-semibold",children:"Help"})]})};var se=require("react");var hr=require("lucide-react");var di=require("react/jsx-runtime");function Do({active:t,onClick:e,children:r,theme:o}){return(0,di.jsx)("button",{onClick:e,className:"shrink-0 rounded-lg px-3.5 py-1.5 text-xs font-medium transition cursor-pointer",style:{background:t?o.accent:o.isLight?"rgba(0,0,0,0.06)":"rgba(255,255,255,0.06)",color:t?o.accentText:o.text,border:`1px solid ${t?(o.isLight,"rgba(0,0,0,0.15)"):o.border}`},children:r})}function pi(){let{offerUseCases:t}=Ce(),{isOpen:e,isFocused:r,isIdle:o}=O(),a=e?r?o?3e4:1e4:3e4:!1,{data:s}=pt({queryKey:["offerCategories"],queryFn:()=>t.getOfferCategories(),refetchInterval:a});return{categories:s}}var Y=require("react/jsx-runtime"),ui=({theme:t,showSearch:e,setShowSearch:r,searchUI:o,setSearchUI:a,activeCatUI:s,setActiveCatUI:n,searchRef:l})=>{let{categories:c}=pi();return(0,Y.jsxs)("div",{className:"sticky top-0 z-10 mx-3 mt-3 space-y-3 pb-3",style:{background:t.bg},children:[(0,Y.jsxs)("div",{className:"flex items-center justify-between",children:[(0,Y.jsx)("div",{className:"text-base font-semibold",children:"Offers"}),(0,Y.jsx)("button",{className:"inline-flex h-9 w-9 items-center justify-center rounded-2xl border transition-opacity active:opacity-70 cursor-pointer",style:{borderColor:t.border,background:t.isLight?"rgba(0,0,0,0.04)":"rgba(255,255,255,0.04)"},onClick:()=>r(d=>!d),"aria-label":e?"Hide search":"Search offers",children:(0,Y.jsx)(hr.Search,{size:16,className:"opacity-80"})})]}),e&&(0,Y.jsxs)("div",{className:"flex items-center gap-2 rounded-2xl border px-3 py-2",style:{borderColor:t.border,background:t.isLight?"rgba(0,0,0,0.04)":"rgba(255,255,255,0.04)"},children:[(0,Y.jsx)(hr.Search,{size:16,className:"opacity-80"}),(0,Y.jsx)("input",{ref:l,value:o,onChange:d=>a(d.target.value),placeholder:"Search offers",className:"w-full bg-transparent text-sm outline-none"}),o&&(0,Y.jsx)("button",{className:"rounded-xl p-1 cursor-pointer",onClick:()=>a(""),"aria-label":"Clear search",children:(0,Y.jsx)(hr.X,{size:16,className:"opacity-70"})})]}),(0,Y.jsxs)("div",{className:"flex gap-2 overflow-x-auto overscroll-contain fruga-scrollbar pb-1",children:[(0,Y.jsx)(Do,{theme:t,active:s==="All",onClick:()=>n("All"),children:"All"}),c.map(d=>(0,Y.jsx)(Do,{theme:t,active:s===d.name,onClick:()=>n(d.name),children:d.name},d.id))]})]})};var _o=we(require("react"));var Lo=require("react/jsx-runtime");function Bo(t){return t?t.replace(/[^a-zA-Z0-9 ]/g,"").split(" ").filter(Boolean).slice(0,2).map(e=>e[0]?.toUpperCase()).join("").slice(0,2):""}function mr({brand:t,theme:e,className:r}){return(0,Lo.jsx)("div",{className:Xe("flex h-10 w-16 shrink-0 items-center justify-center overflow-hidden rounded-lg text-xs font-semibold",r),style:{color:e.text},"aria-label":`${t.brandName} logo`,title:t.brandName,children:t.logo?(0,Lo.jsx)("img",{src:t.logo,alt:"",className:"h-full w-full object-contain"}):Bo(t.brandName)})}var H=require("react/jsx-runtime"),Jr=t=>Number.isInteger(t)?t.toFixed(0):t.toFixed(1),hi=({offer:t,theme:e,onClick:r})=>(0,H.jsxs)("div",{role:"button",tabIndex:0,onClick:()=>r(t),onKeyDown:o=>o.key==="Enter"&&r(t),className:"flex h-[140px] w-[140px] shrink-0 cursor-pointer flex-col items-center justify-start rounded-2xl p-3 pt-4",style:{background:e.isLight?"#FFFFFF":e.panel,border:e.isLight?void 0:"1px solid rgba(255,255,255,0.08)",boxShadow:e.isLight?"0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.05)":"0 4px 12px rgba(0,0,0,0.25)",scrollSnapAlign:"start"},children:[(0,H.jsx)(mr,{brand:t,theme:e,className:"h-10 w-12 shrink-0"}),(0,H.jsx)("div",{className:"mt-1.5 w-full truncate text-center text-sm font-bold leading-tight",children:t.brandName}),(0,H.jsx)("div",{className:"mt-1 flex shrink-0 justify-center",children:(0,H.jsxs)("span",{className:"rounded-full px-2.5 py-1 text-center text-xs font-bold",style:{background:`color-mix(in srgb, ${e.accent} ${e.isLight?"15%":"20%"}, transparent)`,color:e.accent},children:[Jr(t.cashback),"% cashback"]})})]}),mi=({offer:t,theme:e,onClick:r})=>(0,H.jsx)("div",{role:"button",tabIndex:0,onClick:()=>r(t),onKeyDown:o=>o.key==="Enter"&&r(t),className:"w-full cursor-pointer rounded-2xl p-4 text-left transition-transform active:scale-[0.98]",style:{background:e.isLight?"#FFFFFF":e.panel,border:e.isLight?void 0:"1px solid rgba(255,255,255,0.08)",boxShadow:e.isLight?"0 10px 15px -3px rgba(0,0,0,0.05), 0 4px 6px -2px rgba(0,0,0,0.05)":"0 2px 8px rgba(0,0,0,0.25), 0 4px 12px rgba(0,0,0,0.2)"},children:(0,H.jsxs)("div",{className:"flex items-center gap-3",children:[(0,H.jsx)(mr,{brand:t,theme:e}),(0,H.jsx)("div",{className:"flex-1 min-w-0",children:(0,H.jsx)("div",{className:"text-base font-bold truncate",children:t.brandName})}),(0,H.jsxs)("div",{className:"shrink-0 flex flex-col items-end",children:[(0,H.jsxs)("div",{className:"flex items-center justify-end gap-1 text-lg font-bold",style:{color:e.accent},children:[t.cashback>5&&(0,H.jsx)("span",{className:"inline-block text-base leading-none animate-fire","aria-hidden":!0,children:"\u{1F525}"}),Jr(t.cashback),"%"]}),(0,H.jsx)("div",{className:"text-[11px] mt-0.5",style:{color:e.muted},children:"Cashback"}),t.endDate&&Va(t.endDate,30)&&(0,H.jsxs)("div",{className:"mt-2 rounded-full px-2.5 py-1.5 text-xs font-semibold",style:{background:e.isLight?"rgba(245,158,11,0.15)":"rgba(251,191,36,0.2)",color:e.isLight?"#B45309":e.warning,border:`1px solid ${e.isLight?"rgba(245,158,11,0.35)":"rgba(251,191,36,0.35)"}`},children:["Expiring soon \xB7 ",Ya(t.endDate)," days"]})]})]})});var A=require("react/jsx-runtime"),fi=({children:t,color:e})=>(0,A.jsx)("div",{className:"text-[11px] font-semibold uppercase tracking-wide",style:{color:e},children:t}),As=({theme:t})=>(0,A.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[(0,A.jsx)("div",{className:"mb-3 text-3xl","aria-hidden":!0,children:"\u{1F622}"}),(0,A.jsx)("div",{className:"text-sm font-semibold",children:"No offers found"}),(0,A.jsx)("div",{className:"mt-1 text-xs",style:{color:t.muted},children:"Try a different search or filter."})]}),Os=({theme:t})=>(0,A.jsx)("div",{className:"flex items-center justify-center py-10",style:{color:t.muted},children:(0,A.jsxs)("div",{className:"flex items-center gap-2 text-sm",children:[(0,A.jsx)("span",{className:"h-4 w-4 animate-spin rounded-full border-2",style:{borderColor:t.isLight?"rgba(0,0,0,0.2)":"rgba(255,255,255,0.2)",borderTopColor:t.isLight?"rgba(0,0,0,0.7)":"rgba(255,255,255,0.7)"}}),"Updating offers\u2026"]})}),gi=({theme:t,appliedSearch:e,appliedCat:r,featuredOffers:o=[],results:a,handleOfferClick:s,fetchNextPage:n,hasNextPage:l,isFetchingNextPage:c})=>{let d=o.length>0&&r==="All"&&e.trim()==="",p=_o.default.useRef(null);return _o.default.useEffect(()=>{let u=new IntersectionObserver(v=>{v[0].isIntersecting&&l&&!c&&n?.()},{threshold:.1});return p.current&&u.observe(p.current),()=>u.disconnect()},[l,c,n]),(0,A.jsx)("div",{className:"relative flex-1 overflow-auto overscroll-contain fruga-scrollbar px-3 pb-24 pt-3",children:(0,A.jsxs)("div",{className:"space-y-4",children:[d&&(0,A.jsxs)("div",{className:"-mx-3 px-3",children:[(0,A.jsxs)("div",{className:"mb-2 flex items-center gap-1.5",children:[(0,A.jsx)(fi,{color:t.muted,children:"BEST DEALS"}),(0,A.jsx)("span",{className:"text-sm",style:{animation:"fire-flicker 1.2s ease-in-out infinite"},"aria-hidden":!0,children:"\u{1F525}"})]}),(0,A.jsx)("div",{className:"flex gap-3 overflow-x-auto overscroll-contain fruga-scrollbar pb-1",style:{scrollSnapType:"x mandatory"},children:o.map(u=>(0,A.jsx)(hi,{offer:u,theme:t,onClick:s},`featured-${u.id}`))}),(0,A.jsx)("div",{className:"mt-3",children:(0,A.jsx)(fi,{color:t.muted,children:"All"})})]}),a.length===0?(0,A.jsx)(As,{theme:t}):(0,A.jsxs)(A.Fragment,{children:[a.map(u=>(0,A.jsx)(mi,{offer:u,theme:t,onClick:s},u.id)),(0,A.jsx)("div",{ref:p,className:"h-4 w-full"}),c&&(0,A.jsx)(Os,{theme:t})]})]})})};function vi({category:t,query:e,pageSize:r=10}={}){let{offerUseCases:o}=Ce(),a=["offers","list",t||"All",e||""],{data:s,fetchNextPage:n,hasNextPage:l,isFetchingNextPage:c}=nr({queryKey:a,queryFn:({pageParam:f=0})=>o.getOffers({pageNumber:f,pageSize:r,categories:t&&t!=="All"?[t]:[],query:e||void 0}),initialPageParam:0,getNextPageParam:f=>{if(f.number+1<f.totalPages)return f.number+1}}),{data:d}=pt({queryKey:["offers","featured"],queryFn:()=>o.getFeaturedOffers()}),p=Fo({mutationFn:f=>o.claimOffer(f)}),u=async f=>p.mutateAsync(f);return{offers:s?.pages.flatMap(f=>f.content)||[],featuredOffers:d,claimOffer:u,fetchNextPage:n,hasNextPage:l,isFetchingNextPage:c}}var yi=require("lucide-react");var bi=require("react/jsx-runtime"),Qt=({onClose:t,className:e=""})=>(0,bi.jsx)("div",{className:`absolute inset-0 cursor-pointer bg-black/55 transition-opacity animate-in fade-in duration-300 ${e}`,onClick:t,"aria-hidden":"true"});var W=require("react/jsx-runtime"),wi=({theme:t,offer:e,onClose:r})=>(0,W.jsxs)("div",{className:"absolute inset-0 z-50 flex items-center justify-center",children:[(0,W.jsx)(Qt,{onClose:r}),(0,W.jsxs)("div",{className:"relative mx-4 w-full max-w-sm rounded-[24px] border p-4 shadow-2xl",style:{borderColor:t.border,background:t.panel,color:t.text},children:[(0,W.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,W.jsxs)("div",{className:"flex items-center gap-3",children:[(0,W.jsx)(mr,{brand:e,theme:t}),(0,W.jsxs)("div",{children:[(0,W.jsx)("div",{className:"text-sm font-semibold",children:e.brandName}),(0,W.jsxs)("div",{className:"mt-1 inline-flex items-center gap-1 px-0 py-0 text-base font-bold",children:[e.cashback>5?(0,W.jsx)("span",{className:"inline-block text-sm leading-none animate-fire","aria-hidden":!0,children:"\u{1F525}"}):null,Jr(e.cashback),"% cashback"]})]})]}),(0,W.jsx)("button",{className:"p-2 cursor-pointer",onClick:r,"aria-label":"Close",title:"Close",children:(0,W.jsx)(yi.X,{size:18,strokeWidth:2.5})})]}),(0,W.jsx)("div",{className:"mt-4 text-sm",style:{color:t.muted},children:"You will now be redirected to the retailer website to complete your transaction."}),e.terms?(0,W.jsx)("div",{className:"mt-3 text-[11px] leading-snug",style:{color:t.muted},children:e.terms}):null,(0,W.jsx)("button",{className:"mt-4 inline-flex h-11 w-full cursor-pointer items-center justify-center rounded-2xl text-sm font-semibold",style:{background:t.accent,color:t.accentText},onClick:()=>{let o=e.link||`https://www.google.com/search?q=${encodeURIComponent(e.brandName+" cashback")}`;window.open(o,"_blank","noopener,noreferrer"),r()},children:"Shop now"})]})]});var _=require("react/jsx-runtime"),xi=({theme:t})=>(0,_.jsx)("div",{className:"space-y-0",children:[1,2,3,4,5].map(e=>(0,_.jsxs)("div",{className:"flex items-stretch gap-3 px-4 py-3",style:{borderBottom:e<5?`1px solid ${t.border}`:"none"},children:[(0,_.jsx)(F,{theme:t,className:"h-12 w-16 shrink-0 rounded-lg"}),(0,_.jsxs)("div",{className:"flex-1 space-y-2",children:[(0,_.jsx)(F,{theme:t,className:"h-4 w-24"}),(0,_.jsx)(F,{theme:t,className:"h-3 w-16"})]}),(0,_.jsx)(F,{theme:t,className:"h-5 w-14 shrink-0"})]},e))}),ki=({theme:t})=>(0,_.jsxs)("div",{className:"relative flex-1 overflow-hidden flex flex-col min-h-0 pt-0",children:[(0,_.jsxs)("div",{className:"px-3 pt-4 mb-4",children:[(0,_.jsx)(F,{theme:t,className:"h-10 w-full rounded-2xl"}),(0,_.jsx)("div",{className:"mt-4 flex gap-2 overflow-hidden",children:[1,2,3,4].map(e=>(0,_.jsx)(F,{theme:t,className:"h-8 w-20 rounded-full shrink-0"},e))})]}),(0,_.jsxs)("div",{className:"flex-1 px-3 space-y-4 overflow-hidden pt-3",children:[(0,_.jsxs)("div",{className:"-mx-3 px-3",children:[(0,_.jsx)("div",{className:"text-[11px] font-semibold uppercase tracking-wide mb-2",style:{color:t.muted},children:"BEST DEALS"}),(0,_.jsx)("div",{className:"flex gap-2 overflow-hidden",children:[1,2,3].map(e=>(0,_.jsx)(ii,{theme:t},e))})]}),(0,_.jsx)("div",{className:"text-[11px] font-semibold uppercase tracking-wide mb-2",style:{color:t.muted},children:"ALL"}),[1,2,3].map(e=>(0,_.jsx)(ai,{theme:t},e))]})]});var Pi=require("lucide-react"),Ue=require("react/jsx-runtime"),Ni=({theme:t,onAddPayout:e})=>{let r=t.isLight;return(0,Ue.jsxs)("button",{type:"button",onClick:e,className:"flex w-full items-start gap-3 rounded-2xl border-2 px-4 py-3.5 text-left shadow-lg transition hover:brightness-95 focus:outline-none focus-visible:ring-2 focus-visible:ring-white focus-visible:ring-offset-2 cursor-pointer",style:{borderColor:`${t.danger}${r?"40":"30"}`,background:t.danger,color:"#FFFFFF",boxShadow:`0 10px 20px -5px ${t.danger}40`},"aria-label":"Payout pending. Add a payout method to receive your money.",children:[(0,Ue.jsx)("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full",style:{background:"rgba(255, 255, 255, 0.2)"},children:(0,Ue.jsx)(Pi.AlertTriangle,{className:"h-5 w-5",strokeWidth:2.5,"aria-hidden":!0})}),(0,Ue.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,Ue.jsx)("span",{className:"block text-sm font-black leading-snug tracking-tight",children:"Payout pending"}),(0,Ue.jsx)("span",{className:"mt-0.5 block text-[13px] font-semibold leading-tight opacity-90",children:"Add a payout method now so we can send your money."}),(0,Ue.jsx)("span",{className:"mt-2.5 inline-block text-[12px] font-bold underline decoration-2 underline-offset-4 transition-all hover:opacity-80",children:"Add bank details"})]})]})};var Uo=require("react/jsx-runtime"),Xr=({theme:t,onAddPayout:e,className:r="relative z-10 mt-3 px-3"})=>{let{wallet:o}=ht();return o?.requiredActions?.some(s=>s.type==="ADD_PAYOUT_METHOD")?(0,Uo.jsx)("div",{className:r,children:(0,Uo.jsx)(Ni,{theme:t,onAddPayout:e})}):null};var te=require("react/jsx-runtime"),Fs=({theme:t,searchUI:e,activeCatUI:r,handleOfferClick:o,onNavigateToPayoutMethod:a})=>{let{offers:s,featuredOffers:n,fetchNextPage:l,hasNextPage:c,isFetchingNextPage:d}=vi({query:e,category:r,pageSize:10});return(0,te.jsxs)("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[(0,te.jsx)(Xr,{theme:t,onAddPayout:()=>a?.()}),(0,te.jsx)(gi,{theme:t,appliedSearch:e,appliedCat:r,featuredOffers:n,results:s,handleOfferClick:o,fetchNextPage:l,hasNextPage:c,isFetchingNextPage:d})]})},Ti=({theme:t,onNavigateToPayoutMethod:e})=>{let[r,o]=(0,se.useState)(!1),[a,s]=(0,se.useState)(""),[n,l]=(0,se.useState)("All"),[c,d]=(0,se.useState)(null),p=$a(a,300),u=(0,se.useRef)(null);(0,se.useEffect)(()=>{if(r){let f=window.setTimeout(()=>u.current?.focus(),0);return()=>window.clearTimeout(f)}},[r]);let v=(0,se.useCallback)(f=>{d(f)},[]);return(0,te.jsxs)(te.Fragment,{children:[c&&(0,te.jsx)(wi,{theme:t,offer:c,onClose:()=>d(null)}),(0,te.jsx)(ui,{theme:t,showSearch:r,setShowSearch:o,searchUI:a,setSearchUI:s,activeCatUI:n,setActiveCatUI:l,searchRef:u}),(0,te.jsx)(se.Suspense,{fallback:(0,te.jsx)("div",{className:"px-3",children:(0,te.jsx)(ki,{theme:t})}),children:(0,te.jsx)(Fs,{theme:t,searchUI:p,activeCatUI:n,handleOfferClick:v,onNavigateToPayoutMethod:e})})]})};var ro=require("react");function Si(t=10){let{accountUseCases:e}=Ce(),{token:r}=O();return nr({queryKey:["activity",r,t],queryFn:({pageParam:o=0})=>e.getActivity(o,t),initialPageParam:0,getNextPageParam:(o,a)=>{if(o.transactions&&o.transactions.length===t)return a.length},staleTime:1/0,refetchOnWindowFocus:!1,refetchOnReconnect:!1})}var Wt=require("react"),Ci=require("lucide-react");var Ht=require("react/jsx-runtime");function Ri({theme:t,label:e}){let[r,o]=(0,Wt.useState)(!1),a=(0,Wt.useRef)(null);return(0,Wt.useEffect)(()=>{if(!r)return;let s=n=>{a.current&&(a.current.contains(n.target)||o(!1))};return document.addEventListener("mousedown",s),()=>document.removeEventListener("mousedown",s)},[r]),(0,Ht.jsxs)("span",{ref:a,className:"relative inline-flex items-center",children:[(0,Ht.jsx)("button",{type:"button",className:"ml-1 inline-flex h-4 w-4 items-center justify-center rounded-full","aria-label":"More info",onClick:s=>{s.stopPropagation(),o(n=>!n)},onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),children:(0,Ht.jsx)(Ci.Info,{size:11,className:"opacity-80"})}),(0,Ht.jsx)("span",{className:Xe("pointer-events-none absolute bottom-full left-1/2 z-20 mb-2 w-64 -translate-x-1/2 rounded-xl border px-3 py-2 text-[11px] leading-snug shadow-xl transition",r?"opacity-100":"opacity-0"),style:{background:t.tooltipBg,borderColor:t.tooltipBorder,color:t.text},children:e})]})}var B=require("react/jsx-runtime"),Ai=({theme:t,accountDataLoading:e,available:r,pending:o,lifetimeSavings:a})=>(0,B.jsx)("div",{className:"relative z-20 px-3 -mt-10",children:(0,B.jsxs)("div",{className:"rounded-3xl border p-4",style:{borderColor:t.border,background:t.isLight?t.panel:t.panel2,boxShadow:t.isLight?"0 4px 12px rgba(0,0,0,0.08)":"0 4px 12px rgba(0,0,0,0.25)"},children:[(0,B.jsxs)("div",{className:"flex items-end justify-between gap-4",children:[(0,B.jsxs)("div",{children:[e?(0,B.jsx)(F,{theme:t,className:"h-9 w-24"}):(0,B.jsxs)("div",{className:"text-3xl font-bold",children:["\xA3",r.toFixed(2)]}),(0,B.jsx)("div",{className:"mt-1 text-xs",style:{color:t.muted},children:"Available Credit"})]}),(0,B.jsxs)("div",{className:"text-right",children:[e?(0,B.jsx)(F,{theme:t,className:"mx-auto h-5 w-14"}):(0,B.jsxs)("div",{className:"text-sm font-semibold",children:["\xA3",o.toFixed(2)]}),(0,B.jsxs)("div",{className:"mt-1 flex items-center justify-end gap-1 text-[11px]",style:{color:t.muted},children:["Pending",(0,B.jsx)(Ri,{theme:t,label:"Waiting for retailer confirmation and processing and will be available soon"})]})]}),(0,B.jsxs)("div",{className:"text-right",children:[e?(0,B.jsx)(F,{theme:t,className:"mx-auto h-5 w-14"}):(0,B.jsxs)("div",{className:"text-sm font-semibold",children:["\xA3",(r+o).toFixed(2)]}),(0,B.jsx)("div",{className:"mt-1 text-[11px]",style:{color:t.muted},children:"Total Balance"})]})]}),(0,B.jsxs)("div",{className:"mt-3 flex items-center justify-between border-t pt-3",style:{borderColor:t.border},children:[(0,B.jsx)("div",{className:"text-[11px] uppercase tracking-wider",style:{color:t.muted},children:"Lifetime Insurance Savings"}),e?(0,B.jsx)(F,{theme:t,className:"h-4 w-16"}):(0,B.jsxs)("div",{className:"text-sm font-semibold",style:{color:t.muted},children:["\xA3",a.toFixed(2)]})]})]})});var eo=require("react");var Oi=require("react"),K=require("react/jsx-runtime");function Fi({accent:t,className:e}){let r=(0,Oi.useId)().replace(/:/g,""),o=`color-mix(in srgb, ${t} 70%, black)`,a=`color-mix(in srgb, ${t} 45%, black)`;return(0,K.jsxs)("svg",{viewBox:"0 0 256 256",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,style:{background:"transparent"},children:[(0,K.jsxs)("defs",{children:[(0,K.jsxs)("linearGradient",{id:`shieldGrad-${r}`,x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[(0,K.jsx)("stop",{offset:"0%",stopColor:o}),(0,K.jsx)("stop",{offset:"100%",stopColor:a})]}),(0,K.jsxs)("linearGradient",{id:`glossGrad-${r}`,x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[(0,K.jsx)("stop",{offset:"0%",stopColor:"white",stopOpacity:"0.35"}),(0,K.jsx)("stop",{offset:"100%",stopColor:"white",stopOpacity:"0"})]}),(0,K.jsx)("filter",{id:`shieldDropShadow-${r}`,x:"-10%",y:"-10%",width:"120%",height:"130%",children:(0,K.jsx)("feDropShadow",{dx:"0",dy:"2",stdDeviation:"2",floodColor:t,floodOpacity:"0.4"})})]}),(0,K.jsx)("path",{d:"M 40 50 Q 128 30 216 50 C 216 150 160 210 128 236 C 96 210 40 150 40 50 Z",fill:a,filter:`url(#shieldDropShadow-${r})`}),(0,K.jsx)("path",{d:"M 52 58 Q 128 42 204 58 C 204 144 156 196 128 218 C 100 196 52 144 52 58 Z",fill:`url(#shieldGrad-${r})`,stroke:o,strokeWidth:"3"}),(0,K.jsx)("path",{d:"M 52 58 Q 128 42 128 42 L 128 218 C 100 196 52 144 52 58 Z",fill:`url(#glossGrad-${r})`}),(0,K.jsx)("path",{d:"M 60 66 Q 128 52 196 66 Q 128 80 60 66 Z",fill:"white",fillOpacity:"0.1"})]})}var Ei=require("react"),j=require("react/jsx-runtime");function Ii({accent:t,className:e}){let r=(0,Ei.useId)().replace(/:/g,""),o=`color-mix(in srgb, ${t} 70%, black)`,a=`color-mix(in srgb, ${t} 45%, black)`;return(0,j.jsxs)("svg",{viewBox:"0 0 256 256",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:e,style:{background:"transparent"},children:[(0,j.jsxs)("defs",{children:[(0,j.jsxs)("linearGradient",{id:`giftGrad-${r}`,x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[(0,j.jsx)("stop",{offset:"0%",stopColor:o}),(0,j.jsx)("stop",{offset:"100%",stopColor:a})]}),(0,j.jsx)("filter",{id:`giftDropShadow-${r}`,x:"-20%",y:"-20%",width:"140%",height:"140%",children:(0,j.jsx)("feDropShadow",{dx:"0",dy:"2",stdDeviation:"2",floodColor:t,floodOpacity:"0.4"})})]}),(0,j.jsxs)("g",{filter:`url(#giftDropShadow-${r})`,children:[(0,j.jsx)("rect",{x:"36",y:"80",width:"85",height:"36",fill:`url(#giftGrad-${r})`}),(0,j.jsx)("rect",{x:"135",y:"80",width:"85",height:"36",fill:`url(#giftGrad-${r})`}),(0,j.jsx)("rect",{x:"48",y:"130",width:"73",height:"90",fill:`url(#giftGrad-${r})`}),(0,j.jsx)("rect",{x:"135",y:"130",width:"73",height:"90",fill:`url(#giftGrad-${r})`}),(0,j.jsxs)("g",{stroke:o,strokeWidth:"14",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,j.jsx)("path",{d:"M 121 80 C 110 25 55 25 55 55 C 55 75 95 80 121 80 Z"}),(0,j.jsx)("path",{d:"M 135 80 C 146 25 201 25 201 55 C 201 75 161 80 135 80 Z"})]})]})]})}var Mi=require("lucide-react");var mt=require("react/jsx-runtime"),Di=({theme:t,onAddDetails:e})=>{let{setIsAddingPayoutFromAlert:r}=O(),o=t.isLight,a=()=>{r(!0),e()};return(0,mt.jsxs)("div",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-x-3 gap-y-1.5 rounded-2xl border px-3 py-2.5 text-[11px] leading-tight shadow-sm transition-all",style:{borderColor:`${t.danger}${o?"35":"25"}`,background:o?`${t.danger}08`:`${t.danger}12`,color:t.text},children:[(0,mt.jsx)("div",{className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-full",style:{background:`${t.danger}20`},children:(0,mt.jsx)(Mi.AlertTriangle,{className:"h-3.5 w-3.5",strokeWidth:2.5,style:{color:t.danger},"aria-hidden":!0})}),(0,mt.jsx)("span",{className:"min-w-0 flex-1 font-semibold opacity-90",children:"Bank details required to send this payout."}),(0,mt.jsx)("button",{type:"button",className:"ml-auto shrink-0 cursor-pointer text-[12px] font-extrabold underline decoration-2 underline-offset-2 transition-all hover:opacity-80 active:scale-95",style:{color:t.accent},onClick:a,children:"Add details"})]})};var x=require("react/jsx-runtime"),Es=({transaction:t,theme:e,isPolicy:r,isPayout:o,isBonus:a})=>(0,x.jsx)("div",{className:"flex w-16 shrink-0 self-stretch items-center justify-center overflow-hidden rounded-lg text-xs font-semibold",style:{color:e.text},children:r||o?(0,x.jsx)(Fi,{accent:e.accent,className:"h-[40px] w-[40px] object-contain"}):a?(0,x.jsx)(Ii,{accent:e.accent,className:"h-[40px] w-[40px] object-contain"}):t.brandName&&t.brandLogo?(0,x.jsx)("img",{src:t.brandLogo,alt:"",className:"h-full w-full object-contain"}):Bo(t.brandName||t.type)}),Li=({transaction:t,theme:e,isLast:r,requiredActions:o,onAddPayout:a})=>{let s=t.brandName==="Policy purchase",n=t.type==="BONUS",l=t.flow==="EARN"&&t.type==="AFFILIATE_LINK"&&t.status==="PAID",c=t.flow==="EARN"&&t.type==="AFFILIATE_LINK"&&["APPROVED","PENDING_PROVIDER","PENDING_BANK","PENDING_RETAILER"].includes(t.status),d=t.status==="PROCESSING",p=t.flow==="PAYOUT"&&t.status==="PAID",u=t.flow==="PAYOUT"&&t.status==="FAILED",v=t.flow==="PAYOUT"&&t.status==="CANCELLED",f=t.flow==="PAYOUT"&&t.status==="ACTION_REQUIRED",b=t.flow==="PAYOUT",w=b||d||u||s||t.activityAmount<0,N=l||c||d||u||v||!s&&!n&&!p&&t.purchaseAmount!=null&&t.purchaseAmount>0,T=t.activityAmount||0,R=t.purchaseAmount||0,I=N&&R&&!b?Math.round(T/R*100):null,ce={NEW_POLICY:"New policy purchase",POLICY_ADDON:"Policy add-on purchase",CLAIM_EXCESS:"Claim excess payment",OTHER:"Other"},de=n||t.flow==="EARN"&&!d?e.success:b||s||d?e.text:T>=0?e.success:e.danger,ze=Za(s?"Policy purchase":n?"Bonus":p||d||u||v||f?ce[t.redemptionContext]||"Other":l||c?t.brandName||"Payout":I!=null?`${I}% Cashback`:t.brandName||(t.type==="PAYOUT"?"Payout":"Activity"),40),ao=()=>(0,x.jsx)(x.Fragment,{children:c?(0,x.jsx)("span",{className:"text-[11px]",style:{color:e.warning},children:"Pending"}):d?(0,x.jsx)("span",{className:"text-[11px]",style:{color:e.warning},children:"Processing"}):u?(0,x.jsx)("span",{className:"text-[11px]",style:{color:e.muted},children:"Payout failed"}):v?(0,x.jsx)("span",{className:"text-[11px]",style:{color:e.muted},children:"Payout cancelled"}):f?(0,x.jsx)("span",{className:"text-[11px]",style:{color:e.warning},children:"On hold"}):null});return(0,x.jsxs)("div",{className:"flex items-stretch gap-3 px-4 py-3 flex-col",style:{borderBottom:r?"none":`1px solid ${e.border}`},children:[(0,x.jsxs)("div",{className:"flex items-stretch gap-3",children:[(0,x.jsx)(Es,{transaction:t,theme:e,isPolicy:s,isPayout:p||d||u||v||f,isBonus:n}),(0,x.jsx)("div",{className:"grid min-w-0 flex-1 grid-cols-[1fr_auto] items-baseline gap-x-4 gap-y-0.5",children:N?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)("div",{className:"min-w-0 text-sm font-semibold truncate",children:ze}),(0,x.jsxs)("div",{className:"flex items-center justify-end gap-1.5",children:[(0,x.jsx)(ao,{}),(0,x.jsxs)("span",{className:"text-sm font-bold",style:{color:de},children:[w?"-":"+","\xA3",Math.abs(T).toFixed(2)]})]}),(0,x.jsx)("div",{className:"min-w-0 text-[11px] font-bold",style:{color:e.muted},children:l||c||d?t.offerName:I!=null?`${I}% Cashback`:null}),(0,x.jsxs)("div",{className:"text-right text-xs",style:{color:e.muted},children:["\xA3",R.toFixed(2)]}),(0,x.jsx)("div",{className:"text-[11px]",style:{color:e.muted},children:Eo(t.occuredAt)}),(0,x.jsx)("div",{})]}):(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)("div",{className:"min-w-0 text-sm font-semibold",style:{color:e.text},children:ze}),(0,x.jsxs)("div",{className:"flex items-center justify-end gap-1.5",children:[(0,x.jsx)(ao,{}),(0,x.jsxs)("span",{className:"text-sm font-semibold",style:{color:de},children:[w?"-":"+","\xA3",Math.abs(T).toFixed(2)]})]}),(0,x.jsx)("div",{className:"text-[11px]",style:{color:e.muted},children:Eo(t.occuredAt)}),(0,x.jsx)("div",{})]})})]}),(f||o?.some(ge=>ge.type==="ADD_PAYOUT_METHOD"&&String(ge.transactionId)===String(t.id)))&&(0,x.jsx)("div",{className:"flex gap-3 pl-[4.75rem]",children:(0,x.jsx)(Di,{theme:e,onAddDetails:()=>a?.()})})]})};var ne=require("react/jsx-runtime"),Bi=({transactions:t,theme:e,fetchNextPage:r,hasNextPage:o,isFetchingNextPage:a,requiredActions:s,onAddPayout:n})=>{let l=(0,eo.useRef)(null);return(0,eo.useEffect)(()=>{if(!o||!r||a)return;let c=new IntersectionObserver(d=>{d[0].isIntersecting&&r()},{rootMargin:"100px"});return l.current&&c.observe(l.current),()=>c.disconnect()},[r,o,a]),(0,ne.jsx)("div",{className:"relative flex-1 flex flex-col overflow-auto overscroll-contain fruga-scrollbar px-3 pb-24 pt-0",children:t.length===0?(0,ne.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 px-4 text-center",children:[(0,ne.jsx)("div",{className:"mb-3 text-3xl","aria-hidden":!0,children:"\u{1F6D2}"}),(0,ne.jsx)("div",{className:"text-sm font-semibold",children:"No transactions yet"}),(0,ne.jsx)("div",{className:"mt-1 text-xs",style:{color:e.muted},children:"Start shopping through the offers to earn cashback"})]}):(0,ne.jsxs)(ne.Fragment,{children:[t.map((c,d)=>c?(0,ne.jsx)(Li,{transaction:c,theme:e,isLast:d===t.length-1,requiredActions:s,onAddPayout:n},c.id):null),(0,ne.jsx)("div",{ref:l,className:"h-10 flex items-center justify-center -mt-2",children:a&&(0,ne.jsx)("div",{className:"w-5 h-5 rounded-full animate-spin border-2",style:{borderColor:`${e.muted}40`,borderTopColor:e.text}})})]})})};var _i=require("lucide-react"),ft=require("react/jsx-runtime"),Ui=({theme:t,onNavigateToPayoutMethod:e})=>(0,ft.jsx)("div",{className:"pb-24",children:(0,ft.jsx)("div",{className:"divide-y",style:{borderColor:t.border},children:(0,ft.jsxs)("button",{type:"button",className:"flex w-full cursor-pointer items-center justify-between gap-4 py-4 text-left transition hover:opacity-80",onClick:e,children:[(0,ft.jsx)("span",{className:"text-sm font-semibold",children:"Payout method"}),(0,ft.jsx)(_i.ChevronRight,{size:18,className:"shrink-0",style:{color:t.text},"aria-hidden":!0})]})})});var zo=require("react");var gt=require("react");var zi=t=>{let e=De(),{token:r}=O(),[o,a]=(0,gt.useState)(null),[s,n]=(0,gt.useState)(!0),[l,c]=(0,gt.useState)("idle"),[d,p]=(0,gt.useState)(null),u=async()=>{n(!0),p(null);try{let b=await t.getMethod();a(b)}catch(b){p(b)}finally{n(!1)}};return(0,gt.useEffect)(()=>{u()},[]),{paymentMethod:o,loading:s,flow:l,setFlow:c,error:d,setError:p,addMethod:async b=>{n(!0),p(null);try{let w=await t.addMethod(b);a(w),c("success"),e.invalidateQueries({queryKey:["wallet",r]})}catch(w){p(w)}finally{n(!1)}},removeMethod:async()=>{if(o){n(!0),p(null);try{await t.removeMethod(o.id),a(null),c("idle"),e.invalidateQueries({queryKey:["wallet",r]})}catch(b){throw p(b),b}finally{n(!1)}}}}};var to=require("lucide-react"),et=require("react/jsx-runtime"),Qi=({theme:t,paymentMethod:e,onRemove:r})=>(0,et.jsxs)("div",{className:"flex items-center gap-3 py-2",children:[(0,et.jsx)("div",{className:"flex h-12 w-12 shrink-0 items-center justify-center rounded-full border",style:{borderColor:t.border,background:t.isLight?"rgba(0,0,0,0.03)":"rgba(255,255,255,0.04)"},"aria-hidden":!0,children:(0,et.jsx)(to.Landmark,{size:22,strokeWidth:2,style:{color:t.text}})}),(0,et.jsxs)("div",{className:"min-w-0 flex-1 text-sm font-semibold",children:["Bank account ending ",e.bank.accountLast4]}),(0,et.jsx)("button",{type:"button",className:"inline-flex h-10 w-10 cursor-pointer shrink-0 items-center justify-center rounded-xl transition hover:opacity-80",style:{color:t.muted},onClick:r,"aria-label":"Remove payout method",title:"Remove payout method",children:(0,et.jsx)(to.Trash2,{size:20,strokeWidth:2})})]});var jt=require("react"),le=require("react/jsx-runtime"),Hi=({theme:t,onSubmit:e,isSubmitting:r})=>{let[o,a]=(0,jt.useState)(""),[s,n]=(0,jt.useState)(""),[l,c]=(0,jt.useState)(""),d=(0,jt.useMemo)(()=>{let p=o.trim(),u=s.replace(/\s/g,""),v=l.replace(/[^0-9]/g,"");return p.length>0&&u.length>=6&&u.length<=10&&v.length===6},[o,s,l]);return(0,le.jsxs)("form",{className:"space-y-4 pt-1",onSubmit:p=>{p.preventDefault(),!(!d||r)&&e({accountHolderName:o,accountNumber:s,sortCode:l})},children:[(0,le.jsxs)("label",{className:"grid gap-1.5",children:[(0,le.jsx)("span",{className:"text-xs font-medium",style:{color:t.muted},children:"Account name"}),(0,le.jsx)("input",{value:o,onChange:p=>a(p.target.value.replace(/[^a-zA-Z\s\-']/g,"")),autoComplete:"name",className:"h-11 rounded-2xl border bg-transparent px-3 text-sm outline-none",style:{borderColor:t.border,color:t.text},placeholder:"Account holder name"})]}),(0,le.jsxs)("label",{className:"grid gap-1.5",children:[(0,le.jsx)("span",{className:"text-xs font-medium",style:{color:t.muted},children:"Account number"}),(0,le.jsx)("input",{value:s,onChange:p=>n(p.target.value.replace(/[^\d\s]/g,"")),inputMode:"numeric",autoComplete:"off",className:"h-11 rounded-2xl border bg-transparent px-3 text-sm outline-none",style:{borderColor:t.border,color:t.text},placeholder:"e.g. 12345678",maxLength:10})]}),(0,le.jsxs)("label",{className:"grid gap-1.5",children:[(0,le.jsx)("span",{className:"text-xs font-medium",style:{color:t.muted},children:"Sort code"}),(0,le.jsx)("input",{value:l,onChange:p=>{let u=p.target.value.replace(/\D/g,"").slice(0,6),v=u.length<=2?u:u.length<=4?`${u.slice(0,2)}-${u.slice(2)}`:`${u.slice(0,2)}-${u.slice(2,4)}-${u.slice(4)}`;c(v)},inputMode:"numeric",autoComplete:"off",className:"h-11 rounded-2xl border bg-transparent px-3 text-sm outline-none",style:{borderColor:t.border,color:t.text},placeholder:"12-34-56",maxLength:8})]}),(0,le.jsx)("button",{type:"submit",disabled:!d||r,className:"mt-2 inline-flex h-11 w-full cursor-pointer items-center justify-center rounded-2xl text-sm font-semibold disabled:cursor-not-allowed disabled:opacity-45",style:{background:t.accent,color:t.accentText},children:r?"Saving...":"Save bank details"})]})};var Wi=require("lucide-react"),vt=require("react/jsx-runtime"),ji=({theme:t,onDone:e})=>(0,vt.jsxs)("div",{className:"flex flex-col items-center px-2 py-6 text-center",children:[(0,vt.jsx)(Wi.CheckCircle2,{className:"h-14 w-14 shrink-0",style:{color:t.success},strokeWidth:2,"aria-hidden":!0}),(0,vt.jsx)("div",{className:"mt-4 text-base font-semibold",children:"Bank account added"}),(0,vt.jsx)("div",{className:"mt-2 max-w-xs text-sm leading-relaxed",style:{color:t.muted},children:"Your bank details have been saved. We will use this account for payouts."}),(0,vt.jsx)("button",{type:"button",className:"mt-8 inline-flex h-11 w-full max-w-xs cursor-pointer items-center justify-center rounded-2xl text-sm font-semibold",style:{background:t.accent,color:t.accentText},onClick:e,children:"Done"})]});var ye=require("react/jsx-runtime"),$i=({theme:t,isOpen:e,onClose:r,onConfirm:o,isRemoving:a=!1})=>e?(0,ye.jsxs)("div",{className:"absolute inset-0 z-50 flex items-center justify-center p-4",children:[(0,ye.jsx)(Qt,{onClose:r}),(0,ye.jsxs)("div",{className:"relative w-full max-w-[320px] overflow-hidden rounded-[32px] border p-6 shadow-2xl animate-in zoom-in-95 fade-in duration-300",style:{borderColor:t.border,background:t.panel,color:t.text},children:[(0,ye.jsxs)("div",{className:"text-center pt-2",children:[(0,ye.jsx)("h3",{className:"text-[19px] font-bold tracking-tight",children:"Remove payout method"}),(0,ye.jsx)("p",{className:"mt-3 px-2 text-[15px] leading-snug opacity-70",style:{color:t.muted},children:"Are you sure you want to remove this payout method?"})]}),(0,ye.jsxs)("div",{className:"mt-8 flex gap-3",children:[(0,ye.jsx)("button",{type:"button",className:"flex-1 rounded-[20px] border py-3 text-[15px] font-bold transition hover:bg-black/5 dark:hover:bg-white/5 cursor-pointer",style:{borderColor:t.border,color:t.text},onClick:r,children:"Cancel"}),(0,ye.jsx)("button",{type:"button",disabled:a,className:"flex-1 rounded-[20px] py-3 text-[15px] font-bold transition hover:opacity-90 disabled:opacity-50 cursor-pointer shadow-lg",style:{background:t.accent,color:t.accentText,boxShadow:`0 10px 15px -3px ${t.accent}33`},onClick:o,children:a?"Removing...":"Delete"})]})]})]}):null;var qi=require("lucide-react");var fe=require("react/jsx-runtime"),Ki=({theme:t,isOpen:e,onClose:r,title:o,message:a,confirmLabel:s="Got it"})=>e?(0,fe.jsxs)("div",{className:"absolute inset-0 z-[100] flex items-center justify-center p-4",children:[(0,fe.jsx)(Qt,{onClose:r}),(0,fe.jsxs)("div",{className:"relative w-full max-w-[320px] overflow-hidden rounded-[32px] border p-6 shadow-2xl animate-in zoom-in-95 fade-in duration-300",style:{borderColor:t.border,background:t.panel,color:t.text},children:[(0,fe.jsxs)("div",{className:"flex flex-col items-center text-center",children:[(0,fe.jsx)("div",{className:"flex h-12 w-12 items-center justify-center rounded-full mb-4",style:{background:`${t.isLight?"rgba(220, 38, 38, 0.1)":"rgba(220, 38, 38, 0.2)"}`},children:(0,fe.jsx)(qi.AlertCircle,{className:"h-6 w-6 text-red-600"})}),(0,fe.jsx)("h3",{className:"text-[19px] font-bold tracking-tight",children:o}),(0,fe.jsx)("p",{className:"mt-2 text-[14px] leading-relaxed opacity-70",style:{color:t.muted},children:a})]}),(0,fe.jsx)("div",{className:"mt-8",children:(0,fe.jsx)("button",{type:"button",className:"w-full rounded-[20px] py-3 text-[15px] font-bold text-white transition hover:opacity-90 cursor-pointer shadow-lg",style:{background:t.accent,color:t.accentText,boxShadow:`0 10px 15px -3px ${t.accent}33`},onClick:r,children:s})})]})]}):null;var G=require("react/jsx-runtime"),Gi=({theme:t,service:e,onDone:r})=>{let{paymentMethod:o,loading:a,flow:s,setFlow:n,addMethod:l,removeMethod:c,error:d,setError:p}=zi(e),[u,v]=(0,zo.useState)(!1),[f,b]=(0,zo.useState)(!1),w=async()=>{b(!0);try{await c(),v(!1)}catch{v(!1)}finally{b(!1)}};return a&&s==="idle"?(0,G.jsx)("div",{className:"py-8 text-center",children:(0,G.jsx)("div",{className:"text-sm animate-pulse",style:{color:t.muted},children:"Loading payment details..."})}):s==="success"?(0,G.jsx)(ji,{theme:t,onDone:()=>{n("idle"),r?.()}}):o&&s==="idle"?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Qi,{theme:t,paymentMethod:o,onRemove:()=>v(!0)}),(0,G.jsx)("button",{type:"button",className:"mt-8 inline-flex h-11 w-full max-w-xs cursor-pointer items-center justify-center rounded-2xl text-sm font-semibold mx-auto",style:{background:t.accent,color:t.accentText},onClick:r,children:"Done"}),(0,G.jsx)($i,{theme:t,isOpen:u,onClose:()=>v(!1),onConfirm:w,isRemoving:f}),(0,G.jsx)(Ki,{theme:t,isOpen:!!d,onClose:()=>p(null),title:typeof d=="string"?"Error":d?.error||"Notice",message:typeof d=="string"?d:d?.message||"An unexpected error occurred. Please try again."})]}):s==="form"?(0,G.jsx)(Hi,{theme:t,onSubmit:l,isSubmitting:a}):(0,G.jsxs)("div",{className:"py-8 text-center",children:[(0,G.jsx)("p",{className:"text-sm leading-relaxed",style:{color:t.muted},children:"Add a UK bank account so we can pay your savings when redeemed."}),(0,G.jsx)("button",{type:"button",className:"mt-4 inline-flex h-11 w-full max-w-xs cursor-pointer items-center justify-center rounded-2xl text-sm font-semibold",style:{background:t.accent,color:t.accentText},onClick:()=>n("form"),children:"Add payout method"})]})};var E=require("react/jsx-runtime"),Is=({theme:t})=>{let{wallet:e}=ht(),r=e?.available||0,o=e?.pending||0,a=e?.lifetimeEarned||0;return(0,E.jsx)(Ai,{theme:t,accountDataLoading:!1,available:r,pending:o,lifetimeSavings:a})},Ms=({theme:t,onAddPayout:e})=>{let{wallet:r}=ht(),{data:o,fetchNextPage:a,hasNextPage:s,isFetchingNextPage:n}=Si(10),l=o?.pages.flatMap(c=>c.transactions||[]).filter(Boolean)||[];return(0,E.jsx)(Bi,{transactions:l,theme:t,fetchNextPage:a,hasNextPage:s,isFetchingNextPage:n,requiredActions:r?.requiredActions,onAddPayout:e})},Vi=({theme:t,accountView:e="transactions",setAccountView:r})=>{let{paymentService:o}=Ce(),{partnerPayout:a,isAddingPayoutFromAlert:s,setShowPayoutSuccess:n,setIsAddingPayoutFromAlert:l}=O(),c=a==="PARTNER"?"transactions":e;if(c==="settings")return(0,E.jsx)("div",{className:"relative flex-1 flex flex-col min-h-0 px-3 mt-4",children:(0,E.jsx)(Ui,{theme:t,onNavigateToPayoutMethod:()=>r?.("payout-method")})});let d=()=>{s&&(n(!0),l(!1)),r?.("transactions")};return c==="payout-method"?(0,E.jsx)("div",{className:"relative flex-1 flex flex-col min-h-0 px-3 mt-4",children:(0,E.jsx)(Gi,{theme:t,service:o,onDone:d})}):(0,E.jsxs)("div",{className:"relative flex-1 flex flex-col min-h-0",children:[(0,E.jsx)(ro.Suspense,{fallback:(0,E.jsx)("div",{className:"px-3 -mt-10",children:(0,E.jsx)("div",{className:"h-32 w-full animate-pulse rounded-3xl bg-gray-100/10"})}),children:(0,E.jsx)(Is,{theme:t})}),(0,E.jsx)(ro.Suspense,{fallback:(0,E.jsx)(si,{theme:t}),children:(0,E.jsx)(Xr,{theme:t,onAddPayout:()=>r?.("payout-method")})}),(0,E.jsxs)("div",{className:"relative z-20 pt-0 flex-1 flex flex-col min-h-0 overflow-hidden",children:[(0,E.jsx)("div",{className:"mt-10 px-3 pb-2 flex-shrink-0",children:(0,E.jsx)("div",{className:"mb-3 text-base font-semibold",children:"Transactions"})}),(0,E.jsx)("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:(0,E.jsx)(ro.Suspense,{fallback:(0,E.jsx)("div",{className:"px-3",children:(0,E.jsx)(xi,{theme:t})}),children:(0,E.jsx)(Ms,{theme:t,onAddPayout:()=>r?.("payout-method")})})})]})]})};var $t=require("lucide-react");var U=require("react/jsx-runtime"),Yi=({theme:t,helpPage:e,setHelpPage:r,helpSearch:o,setHelpSearch:a})=>(0,U.jsx)("div",{className:"relative h-full",children:e?(0,U.jsx)("div",{className:"h-full",children:(0,U.jsx)("div",{className:"px-3 pb-24 pt-3 text-sm",children:pr.find(s=>s.id===e)?.body(t)})}):(0,U.jsxs)("div",{children:[(0,U.jsxs)("div",{className:"mb-4 flex items-center gap-2 rounded-2xl border px-3 py-2",style:{borderColor:t.border,background:t.isLight?"rgba(0,0,0,0.04)":"rgba(255,255,255,0.04)"},children:[(0,U.jsx)($t.Search,{size:16,className:"shrink-0 opacity-80"}),(0,U.jsx)("input",{value:o,onChange:s=>a(s.target.value),placeholder:"Search help",className:"w-full bg-transparent text-sm outline-none"}),o?(0,U.jsx)("button",{className:"shrink-0 rounded-xl p-1 cursor-pointer",onClick:()=>a(""),"aria-label":"Clear search",title:"Clear search",children:(0,U.jsx)($t.X,{size:16,className:"opacity-70"})}):null]}),(0,U.jsx)("div",{className:"pb-4",children:(0,U.jsx)("div",{className:"text-sm",style:{color:t.muted},children:"Learn more about cashback and how to use your credit"})}),(0,U.jsx)("div",{className:"divide-y divide-[#e5e7eb]",children:(()=>{let s=pr.filter(n=>!o.trim()||n.title.toLowerCase().includes(o.trim().toLowerCase()));return s.length===0?(0,U.jsx)("div",{className:"py-8 text-center text-sm",style:{color:t.muted},children:"No help topics match your search"}):s.map(n=>{let l=n.id==="how-it-works"||n.id==="redeem";return(0,U.jsxs)("button",{className:"flex w-full items-center justify-between gap-4 py-4 text-left cursor-pointer",onClick:()=>r(n.id),children:[(0,U.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,U.jsx)("div",{className:"text-sm font-semibold",children:n.title}),l?(0,U.jsx)("div",{className:"mt-0.5 text-xs leading-relaxed",style:{color:t.muted},children:"Quick explainer \u2192"}):null]}),(0,U.jsx)($t.ChevronRight,{size:18,className:"shrink-0",style:{color:t.text},"aria-hidden":!0})]},n.id)})})()})]})});var re=require("react/jsx-runtime");function Zi({theme:t,onboardingOpen:e,onboardingStep:r,setOnboardingStep:o,finishOnboarding:a,allowUserThemeControl:s,onThemeModeChange:n}){let[l,c]=(0,fr.useState)("offers"),[d,p]=(0,fr.useState)("transactions"),[u,v]=(0,fr.useState)(null),[f,b]=(0,fr.useState)("");return e?(0,re.jsx)("div",{className:"relative flex h-full w-full min-w-0 flex-col overflow-hidden",style:{background:t.bg,color:t.text},children:(0,re.jsx)(ti,{theme:t,onboardingStep:r,setOnboardingStep:o,onFinish:a})}):(0,re.jsxs)("div",{className:"relative flex h-full w-full min-w-0 flex-col overflow-hidden",style:{background:t.bg,color:t.text},children:[(0,re.jsx)(ci,{tab:l,theme:t,allowUserThemeControl:s,onThemeModeChange:n,helpPage:u,setHelpPage:v,accountView:d,setAccountView:p}),(0,re.jsxs)("div",{className:Xe("relative flex-1 flex flex-col min-h-0","pt-0"),children:[l==="offers"&&(0,re.jsx)(Ti,{theme:t,onNavigateToPayoutMethod:()=>{c("account"),p("payout-method")}}),l==="account"&&(0,re.jsx)(Vi,{theme:t,accountView:d,setAccountView:p}),l==="help"&&(0,re.jsx)("div",{className:"relative flex-1 min-h-0 overflow-auto overscroll-contain fruga-scrollbar px-3",children:(0,re.jsx)(Yi,{theme:t,helpPage:u,setHelpPage:v,helpSearch:f,setHelpSearch:b})})]}),(0,re.jsx)("div",{className:"absolute inset-x-0 bottom-0 pt-10 pb-3 z-30 pointer-events-none",style:{background:`linear-gradient(to top, ${t.bg} 40%, transparent)`},children:(0,re.jsx)("div",{className:"pointer-events-auto",children:(0,re.jsx)(ri,{theme:t,activeTab:l,onTabChange:c,onHelpPageReset:()=>v(null)})})})]})}var gr=require("react/jsx-runtime"),Ds=800;function Ls(){let[t,e]=(0,$.useState)(()=>{if(typeof window>"u")return{isMobile:!1,hostHeight:0,hostWidth:0};let r=new URLSearchParams(window.location.search);return{isMobile:r.get("isHostMobile")==="true"||window.innerWidth<Ds,hostHeight:Number(r.get("hostHeight"))||window.innerHeight,hostWidth:Number(r.get("hostWidth"))||window.innerWidth}});return(0,$.useEffect)(()=>{let r=o=>{o.data?.type==="FRUGA_HOST_RESIZE"&&e({isMobile:o.data.isHostMobile,hostHeight:o.data.hostHeight,hostWidth:o.data.hostWidth})};return window.addEventListener("message",r),()=>window.removeEventListener("message",r)},[]),t}var Bs=(0,$.forwardRef)(function({theme:e,onThemeModeChange:r},o){let[a,s]=(0,$.useState)(!1),[n,l]=(0,$.useState)(!1),[c,d]=(0,$.useState)(!1),[p,u]=(0,$.useState)(0),[v,f]=(0,$.useState)(!1),{isMobile:b,hostHeight:w}=Ls(),N=e.allowUserThemeControl?e:{...e,mode:e.defaultTheme},T=Ir(N),R=(0,$.useRef)(null);R.current=()=>{s(!0),f(!1),n||(l(!0),u(0),d(!0))},(0,$.useImperativeHandle)(o,()=>({open:()=>R.current?.()}),[]);let I=a&&!v;return(0,$.useEffect)(()=>{if(!b||!I)return;let ce=document.documentElement.style.overflowX,de=document.body.style.overflowX;return document.documentElement.style.overflowX="hidden",document.body.style.overflowX="hidden",()=>{document.documentElement.style.overflowX=ce,document.body.style.overflowX=de}},[b,I]),(0,gr.jsx)("div",{className:"h-full w-full overflow-hidden min-w-0",style:{background:T.bg},children:(0,gr.jsx)(Zi,{theme:T,onboardingOpen:c,onboardingStep:p,setOnboardingStep:u,finishOnboarding:()=>d(!1),allowUserThemeControl:e.allowUserThemeControl,onThemeModeChange:r,hostHeight:w,isHostMobile:b})})}),_s=(0,$.forwardRef)((t,e)=>(0,gr.jsx)(Xa,{baseUrl:t.baseUrl,children:(0,gr.jsx)(Bs,{...t,ref:e})})),Ji=_s;var oo=require("react/jsx-runtime"),Xi=new Co,Us="1E40AF",es=t=>{let{bootstrapConfig:e,isHostMobile:r,hostHeight:o}=t,{mode:a,setMode:s,token:n,setToken:l,setPartnerPayout:c}=O(),d=e?.config.ui.defaultTheme||"dark";(0,vr.useEffect)(()=>{e?.partnerPayout&&c(e.partnerPayout)},[e?.partnerPayout,c]),(0,vr.useEffect)(()=>{d&&s(d)},[d,s]),(0,vr.useEffect)(()=>{t.token&&l(t.token)},[t.token,l]),(0,vr.useEffect)(()=>{let f=e?.auth?.tokenTtlSeconds;if(!f||f<=0)return;let w=(f-60)*1e3,N=Math.max(1e3,w),T=setTimeout(()=>{window.parent.postMessage({type:"NEED_TOKEN"},"*")},N);return()=>clearTimeout(T)},[e?.auth?.tokenTtlSeconds,n]),e&&Xi.setQueryData(["bootstrapConfig"],e);let p=e?.config.ui.accent??Us,u={...me,defaultTheme:d,mode:a,primary:p,accent:e?.config.ui.accent??me.accent,accentTextLight:e?.config.ui.accentTextLight??me.accentTextLight,accentTextDark:e?.config.ui.accentTextDark??me.accentTextDark,allowUserThemeControl:e?.config.ui.allowUserThemeControl??me.allowUserThemeControl,launcherIcon:e?.config.ui.launcherIcon??me.launcherIcon,showLauncher:e?.config.ui.showLauncher??me.showLauncher,launcherLabel:e?.config.ui.launcherLabel??me.launcherLabel},v=f=>{s(f)};return(0,oo.jsx)(Ao,{client:Xi,children:(0,oo.jsx)(Wa,{theme:u,isMobile:r,hostHeight:o,children:(0,oo.jsx)(Ji,{theme:u,baseUrl:t.baseUrl,onThemeModeChange:v})})})};var rs=require("react/jsx-runtime"),Qo=t=>{let e=zr.get(qa.BOOTSTRAP_CONFIG),r=e?{config:e}:void 0,o={...t,bootstrapConfig:t.bootstrapConfig||r||void 0},a=document.getElementById(o.containerId);if(a||(console.warn(`FrugaRelay: Container #${o.containerId} not found. Creating a default container.`),a=document.createElement("div"),a.id=o.containerId,document.body.appendChild(a)),a.getAttribute("data-fruga-relay-mounted")==="true"){console.info(`FrugaRelay: SDK already mounted in container #${o.containerId}.`);return}ts.default.createRoot(a).render((0,rs.jsx)(es,{...o})),a.setAttribute("data-fruga-relay-mounted","true")},zs={init:Qo};if(typeof window<"u"){let t=new URLSearchParams(window.location.search),e=t.get("partnerKey");if(e){let r=t.get("theme"),o=r==="dark"||r==="light"?r:void 0,a=t.get("primaryColor")||void 0,s=t.get("userId")||void 0,n=t.get("token")||void 0,l=t.get("baseUrl")||void 0,c=t.get("isHostMobile")==="true",d=Number(t.get("hostHeight"))||void 0,p,u=t.get("bootstrapConfig");if(u)try{p=JSON.parse(atob(u))}catch(v){console.warn("FrugaRelay: Failed to parse bootstrapConfig from URL",v)}Qo({partnerKey:e,containerId:"root",token:n,baseUrl:l,theme:o,primaryColor:a,userId:s,isHostMobile:c,hostHeight:d,bootstrapConfig:p})}}var Qs=zs;0&&(module.exports={init});
2
+ //# sourceMappingURL=relay.js.map