PageSourceSearch

https://www.repaircoin.ai/_next/static/chunks/1977-42bacb672118ab74.js?dpl=dpl_63VTYiyLda5miGsC6hVybkHiXUcG

js repaircoin.ai collected 2026-10-05 14:11:04 UTC 16,145 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1977],{16337:(e,t,r)=>{r.d(t,{authApi:()=>i,ri:()=>n});var a=r(60648);let n=async()=>{try{await a.Ay.post("/auth/logout")}catch(e){console.error("Logout error:",e)}},i={checkUser:async(e,t)=>{try{return await a.Ay.post("/auth/check-user",{address:e,email:t})}catch(e){var r;return(null==e||null==(r=e.response)?void 0:r.status)===404||console.error("Error checking user:",e),{exists:!1}}},getProfile:async e=>{try{return await a.Ay.post("/auth/profile",e)||null}catch(e){return console.error("Error getting profile:",e),null}},getSession:async()=>{try{return await a.Ay.get("/auth/session")||{isValid:!1}}catch(r){var e;let t=null==r||null==(e=r.response)?void 0:e.status;if(401===t)return{isValid:!1};return console.error("[Auth] Unexpected error getting session:",{status:t,message:null==r?void 0:r.message,error:r}),{isValid:!1,unreachable:!t||t>=500}}},authenticateAdmin:async e=>{try{return await a.Ay.post("/auth/admin",{address:e})||null}catch(e){throw console.error("Error authenticating admin:",e),e}},authenticateCustomer:async e=>{try{return await a.Ay.post("/auth/customer",{address:e})||null}catch(e){throw console.error("Error authenticating customer:",e),e}},authenticateShop:async(e,t)=>{try{return await a.Ay.post("/auth/shop",{address:e,email:t})||null}catch(e){throw console.error("Error authenticating shop:",e),e}},isAuthenticated:async()=>{try{let e=await a.Ay.get("/auth/session");return(null==e?void 0:e.authenticated)||!1}catch(e){return!1}},logout:n,refreshToken:async()=>{try{let e=await a.Ay.post("/auth/refresh");return(null==e?void 0:e.success)||!1}catch(e){return console.error("Token refresh error:",e),!1}},getDeviceSessions:async()=>{try{var e,t;let r=await a.Ay.get("/auth/sessions");return null!=(t=null==r||null==(e=r.data)?void 0:e.sessions)?t:[]}catch(e){return console.error("Failed to list device sessions:",e),[]}},switchAccount:async e=>{try{var t;let r=await a.Ay.post("/auth/switch",{address:e});if(!(null==r?void 0:r.success)||!(null==(t=r.data)?void 0:t.user)){let e=Error((null==r?void 0:r.error)||"Switch failed");throw e.code=null==r?void 0:r.code,e}return r.data.user}catch(e){throw e.code||(e.code="SWITCH_FAILED"),e}}}},31023:(e,t,r)=>{r.d(t,{A:()=>v,Q:()=>S});var a=r(12115),n=r(15156),i=r(74180),s=r(88167),o=r(35159),l=r(16337),u=r(93626),c=r(2262),d=r(83618);let h="rc_auth_lock",m="rc_session_cache",w="rc_switch_intent";function p(){try{let e=sessionStorage.getItem(w);if(!e)return null;let t=JSON.parse(e);if(Date.now()-t.timestamp>6e4)return sessionStorage.removeItem(w),null;return t}catch(e){return null}}async function g(e){try{try{let t=await l.authApi.getSession();if(t.isValid&&t.user&&(t.user.address||t.user.walletAddress||"").toLowerCase()===e.newAddress.toLowerCase())return sessionStorage.removeItem(w),v(),window.location.replace(e.targetPath),!0}catch(e){}if(e.targetType){switch(e.targetType){case"admin":await l.authApi.authenticateAdmin(e.newAddress);break;case"shop":await l.authApi.authenticateShop(e.newAddress,e.email||void 0);break;case"customer":await l.authApi.authenticateCustomer(e.newAddress)}return sessionStorage.removeItem(w),v(),window.location.replace(e.targetPath),!0}else{let e=(0,d.s)();return sessionStorage.removeItem(w),v(),window.location.replace(e),!0}}catch(e){return console.error("[AuthInitializer] \uD83D\uDD04 Resume switch failed:",e),sessionStorage.removeItem(w),!1}}function f(e,t){return{id:e.id,address:e.address||e.walletAddress||t,type:e.type||e.role,name:e.name||e.shopName,memberName:e.memberName,email:e.email,avatarUrl:e.logoUrl||e.profile_image_url||void 0,isActive:!1!==e.active,tier:e.tier,shopId:e.shopId,homeShopId:e.homeShopId,registrationDate:e.createdAt||e.created_at,suspended:e.suspended||!1,suspendedAt:e.suspendedAt,suspensionReason:e.suspensionReason,permissions:e.permissions,isTeamMember:e.isTeamMember}}function y(){try{let e=localStorage.getItem(m);if(!e)return null;let t=JSON.parse(e);if(Date.now()-t.timestamp>3e4)return localStorage.removeItem(m),null;return t.profile}catch(e){return null}}function A(e){try{let t={timestamp:Date.now(),profile:e};localStorage.setItem(m,JSON.stringify(t))}catch(e){}}function v(){try{localStorage.removeItem(m),localStorage.removeItem(h),sessionStorage.removeItem("rc_shop_data_cache"),sessionStorage.removeItem("rc_shop_id")}catch(e){}}function I(){try{localStorage.removeItem(h)}catch(e){}}function S(){let e=(0,n.L)();(0,i.z)();let{login:t,logout:r,switchAccount:d,setAccount:w,setUserProfile:S,setAuthInitialized:P,walletMismatchPending:k,setWalletMismatchPending:E,switchingAccount:L}=(0,o.useAuthStore)(),b=(0,a.useRef)(null),_=(0,a.useRef)(!1),C=(0,a.useRef)(!1),T=(0,a.useRef)(!1),N=(0,a.useRef)(null),R=(0,a.useRef)(!1),U=(0,a.useRef)(null),D=(0,a.useRef)(!1);return(0,a.useEffect)(()=>{let e=async()=>
1{if("visible"!==document.visibilityState)return;let e=p();if(!e)return;let{switchingAccount:t}=o.useAuthStore.getState();t||await g(e)};return document.addEventListener("visibilitychange",e),()=>{document.removeEventListener("visibilitychange",e)}},[]),(0,a.useEffect)(()=>{if(D.current)return;let e=window.ethereum;if(!e)return;let t=async e=>{var t,r;let a=null==(t=e[0])?void 0:t.toLowerCase(),{userProfile:n,switchingAccount:i}=o.useAuthStore.getState(),s=null==n||null==(r=n.address)?void 0:r.toLowerCase();if(a&&!i&&s&&a!==s)try{await d(a)}catch(e){console.error("[AuthInitializer] ❌ Auto-switch failed:",e)}};return e.on("accountsChanged",t),D.current=!0,()=>{e.removeListener("accountsChanged",t),D.current=!1}},[d]),(0,a.useEffect)(()=>{let e=async()=>{if(T.current||(T.current=!0,!(window.location.pathname.startsWith("/shop")||window.location.pathname.startsWith("/customer")||window.location.pathname.startsWith("/admin"))))return;let e=y();if(e){S(e),P(!0),(0,c.T7)();return}let t=e=>{if(!e)return!1;let t=f(e);return S(t),A(t),P(!0),(0,c.T7)(),!0};try{let e=await l.authApi.getSession();if(e.isValid&&e.user&&t(e.user))return;if(e.unreachable){console.warn("[AuthInitializer] IMMEDIATE: Session check unreachable - not redirecting"),R.current=!0,(0,c.YH)("Immediate session check unreachable");return}if(await l.authApi.refreshToken()){let e=await l.authApi.getSession();if(e.isValid&&e.user&&t(e.user))return}}catch(e){(0,c.YH)("Immediate session check failed: "+((null==e?void 0:e.message)||"Unknown"))}let r=p();r&&await g(r)||(v(),window.location.href="/")};N.current||(N.current=e())},[]),(0,a.useEffect)(()=>{let a=null==e?void 0:e.address,n=b.current;return(async()=>{N.current&&await N.current;let{switchingAccount:i}=o.useAuthStore.getState();if(i)return;let{userProfile:p,authInitialized:g}=o.useAuthStore.getState();if((!g||!p||a)&&!_.current){if(!function(){try{let e=Date.now(),t=localStorage.getItem(h);if(t){let r=parseInt(t,10);if(e-r<5e3)return!1}return localStorage.setItem(h,e.toString()),!0}catch(e){return!0}}()){let e=y();e&&S(e),P(!0);return}_.current=!0,C.current=!0;try{var v,L;let i;if(!a){R.current||P(!0);return}if(n&&!a){if(k)E(!1);else{try{localStorage.removeItem(m),localStorage.removeItem(h)}catch(e){}r(),P(!1)}return}if(a===n)return void P(!0);w(e);let o=y();if(o&&(null==(v=o.address)?void 0:v.toLowerCase())===a.toLowerCase()){S(o),P(!0),(0,c.T7)();return}try{let t=await l.authApi.getSession();if(t.isValid&&t.user){let r=t.user,n=(r.address||r.walletAddress||"").toLowerCase(),i=null==a?void 0:a.toLowerCase();if(n&&i&&n!==i&&!r.homeShopId){let t;try{t=await (0,s.getUserEmail)({client:u.Sn})}catch(e){}let a=null==(L=r.email)?void 0:L.toLowerCase();if(t&&a&&t.toLowerCase()===a);else{U.current&&clearTimeout(U.current),U.current=setTimeout(async()=>{var r;let a=null==e||null==(r=e.address)?void 0:r.toLowerCase();if(a&&n!==a)try{await d(a,t)}catch(e){console.error("[AuthInitializer] ❌ Auto-switch failed:",e),window.dispatchEvent(new CustomEvent("auth:wallet-mismatch",{detail:{sessionWallet:n,connectedWallet:a}}))}},500);return}}let o=f(r,a);S(o),A(o),P(!0),(0,c.T7)();return}}catch(e){(0,c.YH)("Session check failed: "+((null==e?void 0:e.message)||"Unknown"))}try{i=await (0,s.getUserEmail)({client:u.Sn})}catch(e){}await t(a,i),P(!0),(0,c.T7)()}finally{_.current=!1,C.current&&(I(),C.current=!1)}}})(),b.current=a||null,()=>{C.current&&(I(),C.current=!1),U.current&&(clearTimeout(U.current),U.current=null)}},[null==e?void 0:e.address,d]),null}},35159:(e,t,r)=>{r.d(t,{useAuthStore:()=>c});var a=r(65453),n=r(46786),i=r(16337),s=r(66177),o=r(31023),l=r(60648),u=r(83618);let c=(0,a.v)()((0,n.lt)((e,t)=>({account:null,userProfile:null,isAuthenticated:!1,isLoading:!1,error:null,loginInProgress:!1,authLockId:null,authError:null,authInitialized:!1,walletMismatchPending:!1,switchingAccount:!1,userType:null,isAdmin:!1,isShop:!1,isCustomer:!1,setAccount:t=>{e({account:t},!1,"setAccount")},setUserProfile:t=>{let r=(null==t?void 0:t.type)||null;e({userProfile:t,isAuthenticated:!!t,userType:r,isAdmin:"admin"===r,isShop:"shop"===r,isCustomer:"customer"===r},!1,"setUserProfile")}
1,setLoading:t=>{e({isLoading:t},!1,"setLoading")},setError:t=>{e({error:t},!1,"setError")},setAuthError:t=>{e({authError:t},!1,"setAuthError")},setLoginInProgress:t=>{e({loginInProgress:t},!1,"setLoginInProgress")},setAuthInitialized:t=>{e({authInitialized:t},!1,"setAuthInitialized")},setWalletMismatchPending:t=>{e({walletMismatchPending:t},!1,"setWalletMismatchPending")},hasPermission:e=>{var r;let a=t().userProfile;if(!a)return!1;if("admin"===a.type)return!0;let n=null!=(r=a.permissions)?r:["*"];return n.includes("*")||n.includes(e)},resetAuth:()=>{e({account:null,userProfile:null,isAuthenticated:!1,userType:null,isAdmin:!1,isShop:!1,isCustomer:!1,error:null,authError:null,authInitialized:!1,loginInProgress:!1,authLockId:null},!1,"resetAuth"),(0,o.A)()},login:async(r,a)=>{var n,s,o,l,u,c,d,h,m;let w=t(),p="login_".concat(Date.now(),"_").concat(Math.random().toString(36).substr(2,9));if(w.loginInProgress)return;e({loginInProgress:!0,authLockId:p,isLoading:!0,error:null},!1,"login:start");let g=setTimeout(()=>{let r=t();r.authLockId===p&&r.loginInProgress&&(console.warn("[authStore] Login timeout reached, releasing lock:",p),e({loginInProgress:!1,authLockId:null,isLoading:!1},!1,"login:timeout"))},15e3);try{let l=await i.authApi.checkUser(r,a);if(!l.exists||!l.type)return void e({userProfile:null,isAuthenticated:!1},!1,"login:not-found");let u=null,c=!1;try{switch(l.type){case"admin":u=await i.authApi.authenticateAdmin(r);break;case"shop":u=await i.authApi.authenticateShop(r,a);break;case"customer":u=await i.authApi.authenticateCustomer(r)}}catch(r){let e=(null==r||null==(s=r.response)||null==(n=s.data)?void 0:n.error)||"",t=null==r||null==(o=r.response)?void 0:o.status;if("shop"===l.type&&403===t&&(e.includes("verified")||e.includes("active")))c=!0;else throw r}if(!u&&!c){console.error("[authStore] Authentication failed");let r="Authentication failed. Please try again or contact support.";if(e({error:r,userProfile:null,isAuthenticated:!1},!1,"login:failed"),!t().switchingAccount){let e={message:r,type:"general",timestamp:Date.now()};window.dispatchEvent(new CustomEvent("auth:login-failed",{detail:e}))}return}let d=(null==u?void 0:u.user)?{...l.user,...u.user}:l.user,h={id:d.id,address:d.walletAddress||d.address||r,type:l.type,name:d.name||d.shopName,memberName:d.memberName,firstName:d.firstName,lastName:d.lastName,email:d.email,avatarUrl:d.logoUrl||d.profile_image_url||void 0,isActive:!1!==d.active,tier:d.tier,shopId:d.shopId,registrationDate:d.createdAt||d.created_at,suspended:d.suspended||!1,suspendedAt:d.suspendedAt,suspensionReason:d.suspensionReason,permissions:d.permissions,isTeamMember:d.isTeamMember||!1};e({userProfile:h,isAuthenticated:!c,userType:h.type,isAdmin:"admin"===h.type,isShop:"shop"===h.type,isCustomer:"customer"===h.type},!1,c?"login:unverified-shop":"login:success")}catch(o){let r,a;console.error("[authStore] Login error:",o);let n=(null==o||null==(u=o.response)||null==(l=u.data)?void 0:l.code)==="RECENT_REVOCATION",i=(null==o||null==(d=o.response)||null==(c=d.data)?void 0:c.error)||"";n?(r="Your account access has been revoked. Please try again later or contact support.",a="revoked"):i.includes("inactive")||i.includes("not active")?(r=i,a="inactive"):i.includes("verified")?(r=i,a="unverified"):(null==o||null==(h=o.response)?void 0:h.status)===403?(r=i||"Access denied. Your account may be suspended or inactive.",a="unauthorized"):(null==o||null==(m=o.response)?void 0:m.status)===401?(r="Authentication failed. Please try reconnecting your wallet.",a="unauthorized"):(r=(null==o?void 0:o.message)?"Authentication error: ".concat(o.message):"Failed to authenticate. Please check your connection and try again.",a="general");let s={message:r,type:a,timestamp:Date.now()};e({error:r,authError:s,userProfile:null},!1,"login:error"),t().switchingAccount||window.dispatchEvent(new CustomEvent("auth:login-failed",{detail:s}))}finally{clearTimeout(g),t().authLockId===p&&e({isLoading:!1,loginInProgress:!1,authLockId:null},!1,"login:complete")}},logout:async()=>{t().loginInProgress&&await new Promise(e=>setTimeout(e,2e3)),e({loginInProgress:!0,authLockId:"logout"},!1,"logout:start");try{await i.authApi.logout()}catch(e){console.error("[authStore] Logout error:",e)}try{var r,a;await (0,s.O4)();let e=await (null==(r=navigator.serviceWorker)?void 0:r.getRegistration()),t=await (null==e||null==(a=e.pushManager)?void 0:a.getSubscription());await (null==t?void 0:t.unsubscribe()),localStorage.removeItem("rc_push_endpoint")}catch(e){}t().resetAuth(),sessionStorage.removeItem("rc_switch_intent"),window.location.href="/"},switchAccount:async(r,a)=>{if(!t().switchingAccount){e({switchingAccount:!0},!1,"switchAccount:start"),(0,l.PY)(!0);try{let t=await i.authApi.checkUser(r,a),n=t.exists&&t.type?({admin:"/admin",shop:"/shop",customer:"/customer"})[t.type]||"/":(0,u.s)();{let e={newAddress:r,email:a||null,targetType:t.type||null,targetPath:n,timestamp:Date.now()};sessionStorage.setItem("rc_switch_intent",JSON.stringify(e))}try{await i.authApi.logout()}catch(e){console.warn("[authStore] Logout failed (continuing with switch):",e)}if(t.exists&&t.type)try{switch(t.type){case"admin":await i.authApi.authenticateAdmin(r);break;case"shop":await i.authApi.authenticateShop(r,a);break;case"customer":await i.authApi.authenticateCustomer(r)}}catch(t){console.error("[authStore] \uD83D\uDD04 Authentication failed during switch:",t),(0,l.PY)(!1),e({switchingAccount:!1},!1,"switchAccount:authFailed");return}sessionStorage.removeItem("rc_switch_intent"),(0,o.A)(),t.exists||window.dispatchEvent(new CustomEvent("auth:new-wallet-detected",{detail:{address:r}})),window.location.replace(n)}catch(t){console.error("[authStore] ❌ Account switch error:",t),(0,l.PY)(!1),e({switchingAccount:!1},!1,"switchAccount:error"),window.dispatchEvent(new CustomEvent("auth:switch-failed",{detail:{message:(null==t?void 0:t.message)||"Failed to switch accounts"}}))}}}}),{name:"auth-store"}))},66177:(e,t,r)=>{r.d(t,{HR:()=>n,O4:()=>s,pU:()=>i,vx:()=>o});var a=r(60648);let n=async()=>(await a.Ay.get("/notifications/vapid-public-key")).vapidPublicKey,i=async e=>{await a.Ay.post("/notifications/push-tokens",e)},s=async()=>{await a.Ay.delete("/notifications/push-tokens")}
1,o={getGeneralNotificationPreferences:async()=>{let e=await a.Ay.get("/notifications/preferences/general");if(!e||!e.data)throw console.error("Invalid API response structure:",e),Error("Invalid response from notification preferences API");return e.data},updateGeneralNotificationPreferences:async e=>(await a.Ay.put("/notifications/preferences/general",e)).data,resetGeneralNotificationPreferences:async()=>(await a.Ay.post("/notifications/preferences/general/reset")).data,getVapidPublicKey:n,registerPushToken:i,deactivateAllPushTokens:s}},83618:(e,t,r)=>{r.d(t,{m:()=>a,s:()=>n});let a=()=>"/team/accept"===window.location.pathname,n=()=>a()?"".concat(window.location.pathname).concat(window.location.search):"/choose"},93626:(e,t,r)=>{r.d(t,{BD:()=>n,I9:()=>i,Sn:()=>s});var a=r(97258);let n=(0,a.N)({clientId:"1969ac335e07ba13ad0f8d1a1de4f6ab"}),i=(0,a.N)({clientId:"99f01d5781fadab9f6a42660090e824b"}),s=n}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.