tokentracker-cli 1.3.9 → 1.3.10
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/README.de.md +7 -6
- package/README.ja.md +6 -5
- package/README.ko.md +6 -5
- package/README.md +7 -6
- package/README.zh-CN.md +6 -5
- package/dashboard/dist/assets/{AchievementBadge-C6ZoXGzv.js → AchievementBadge-vU4Dwu_p.js} +1 -1
- package/dashboard/dist/assets/{AchievementsPage-BkHoOrUq.js → AchievementsPage-C8LspyPK.js} +2 -2
- package/dashboard/dist/assets/{AchievementsSection-BmK0_LQF.js → AchievementsSection-CP8J07fV.js} +1 -1
- package/dashboard/dist/assets/{BadgeDetailModal-DwoD1Nsr.js → BadgeDetailModal-Ci1egHvR.js} +1 -1
- package/dashboard/dist/assets/{BotAnimated-m4GXCXTJ.js → BotAnimated-CMXILM_h.js} +1 -1
- package/dashboard/dist/assets/{Card-D_SqQIBC.js → Card-BHHCCnqR.js} +1 -1
- package/dashboard/dist/assets/{CloudCheckoutPage-BSYvxA_x.js → CloudCheckoutPage-BY9Hsbix.js} +1 -1
- package/dashboard/dist/assets/{CloudPage-Bwnj7Ocg.js → CloudPage-Y6JgOXcJ.js} +2 -2
- package/dashboard/dist/assets/{CommandPalette-CBMCbek2.js → CommandPalette-BRWQFJwy.js} +1 -1
- package/dashboard/dist/assets/CommunityStatsModal-krT4ZZX9.js +1 -0
- package/dashboard/dist/assets/{ConfirmModal-DAt5opxx.js → ConfirmModal-ZvPOJ0he.js} +1 -1
- package/dashboard/dist/assets/{Controls-DsJLsMpr.js → Controls-CQlxw03i.js} +1 -1
- package/dashboard/dist/assets/{DashboardPage-B4hR6Jr1.js → DashboardPage-Dbi0d2JY.js} +1 -1
- package/dashboard/dist/assets/{DateRangePopover-CyAT0F7i.js → DateRangePopover-DJ8RpQfV.js} +1 -1
- package/dashboard/dist/assets/DevicePage-C4_cbw3M.js +1 -0
- package/dashboard/dist/assets/{DialogClose-Dg8Rrcbc.js → DialogClose-Dx5AqmUG.js} +1 -1
- package/dashboard/dist/assets/DialogDescription-LvhfT1Ox.js +1 -0
- package/dashboard/dist/assets/{DialogTitle-CgQTzYDB.js → DialogTitle-Cro2S8s8.js} +1 -1
- package/dashboard/dist/assets/{ElectricLogo-PbWNE6Jw.js → ElectricLogo-gqnBCtSG.js} +1 -1
- package/dashboard/dist/assets/{FadeIn-CgGVCeA7.js → FadeIn-B9oATcDZ.js} +1 -1
- package/dashboard/dist/assets/{HeaderGithubStar-D8I6O4H1.js → HeaderGithubStar-CYa94wna.js} +1 -1
- package/dashboard/dist/assets/{HoverTooltip-BQ0w0NcA.js → HoverTooltip-BJ4qLyuS.js} +1 -1
- package/dashboard/dist/assets/{IpCheckPage-D9vVoMNk.js → IpCheckPage-Clpq3jdY.js} +1 -1
- package/dashboard/dist/assets/{LandingPage-DNV9PcRZ.js → LandingPage-CuazuOAo.js} +2 -2
- package/dashboard/dist/assets/{LeaderboardPage-BVfC39jk.js → LeaderboardPage-BSF1Lbtq.js} +2 -2
- package/dashboard/dist/assets/{LeaderboardProBadge-g6XLqOpA.js → LeaderboardProBadge-K32gY52s.js} +1 -1
- package/dashboard/dist/assets/{LeaderboardProfileModal-Dxwperqt.js → LeaderboardProfileModal-D5gpn7pP.js} +3 -3
- package/dashboard/dist/assets/{LeaderboardProfilePage-C9552VgQ.js → LeaderboardProfilePage-BmO9nIi-.js} +1 -1
- package/dashboard/dist/assets/{LimitsPage-CWaM8Ubc.js → LimitsPage-D9ZJ1TeK.js} +1 -1
- package/dashboard/dist/assets/{LocalOnlyNotice-DJ8t4CkI.js → LocalOnlyNotice-BkzysTS7.js} +1 -1
- package/dashboard/dist/assets/{LoginCard-5cDUjlaP.js → LoginCard-Do3SNJFU.js} +1 -1
- package/dashboard/dist/assets/{LoginModal-CaEskXOR.js → LoginModal-hph1i_YK.js} +1 -1
- package/dashboard/dist/assets/{LoginPage--buWhwDc.js → LoginPage-DXYAaFjJ.js} +1 -1
- package/dashboard/dist/assets/{PetPage-DZlGXdiW.js → PetPage-D1Pk4OKI.js} +2 -2
- package/dashboard/dist/assets/{PopoverPopup-IQrgeWzz.js → PopoverPopup-CAIuP_a5.js} +1 -1
- package/dashboard/dist/assets/{ProviderIcon-CSKhjDnT.js → ProviderIcon-R6Bsj81X.js} +1 -1
- package/dashboard/dist/assets/{ResetPasswordPage-ClzIMLjQ.js → ResetPasswordPage-BR3GTF-3.js} +1 -1
- package/dashboard/dist/assets/{Select-KHVnbrwD.js → Select-38Dh-OWv.js} +1 -1
- package/dashboard/dist/assets/{SelectItemText-BqAFvX8b.js → SelectItemText-90n7jKbI.js} +1 -1
- package/dashboard/dist/assets/{SelfHostPage-DHA9hDnA.js → SelfHostPage-BKVYkHI6.js} +1 -1
- package/dashboard/dist/assets/{ServiceStatusPage-A4WcSrnG.js → ServiceStatusPage-PBmBn29J.js} +1 -1
- package/dashboard/dist/assets/{SessionsPage-CWu0gXwO.js → SessionsPage-58MfDHhe.js} +3 -3
- package/dashboard/dist/assets/{SettingsPage-DzurIV6u.js → SettingsPage-BNLHbZUQ.js} +3 -3
- package/dashboard/dist/assets/{SkillsPage-CfM8w0xf.js → SkillsPage-DMMTk4jD.js} +1 -1
- package/dashboard/dist/assets/{TokenGalaxy-BiCXCnEH.js → TokenGalaxy-BdPETjru.js} +1 -1
- package/dashboard/dist/assets/{TooltipPopup-BcnMVc6a.js → TooltipPopup-BXl-vM4L.js} +1 -1
- package/dashboard/dist/assets/{TrendMonitor-PFSJn43N.js → TrendMonitor-wPfTlX-7.js} +1 -1
- package/dashboard/dist/assets/{WidgetsPage-CnH4zkP8.js → WidgetsPage-CuwRMWka.js} +1 -1
- package/dashboard/dist/assets/{WrappedPage-BpsnuM4e.js → WrappedPage-DOpA9kkg.js} +1 -1
- package/dashboard/dist/assets/{__vite-browser-external-CbhiyufG.js → __vite-browser-external-Go6WKt6Z.js} +3 -3
- package/dashboard/dist/assets/{__vite-browser-external-CbUj3l39.css → __vite-browser-external-kAUz3kFs.css} +1 -1
- package/dashboard/dist/assets/{agent-logos-DFupeEJz.js → agent-logos-D7eMvAlk.js} +1 -1
- package/dashboard/dist/assets/{arrow-left-Cu0jOgzo.js → arrow-left--eOVP_Dk.js} +1 -1
- package/dashboard/dist/assets/{arrow-right-DgFuyz9F.js → arrow-right-DJYhwBMz.js} +1 -1
- package/dashboard/dist/assets/{arrow-up-right-COoZfksW.js → arrow-up-right-DhDvpd-S.js} +1 -1
- package/dashboard/dist/assets/{calendar-days-B_QPPq3a.js → calendar-days-BuOFlNcJ.js} +1 -1
- package/dashboard/dist/assets/{check-D_enaDhp.js → check-UztXSVYi.js} +1 -1
- package/dashboard/dist/assets/{chevron-down-Di_xdF9P.js → chevron-down-CbJ2QGDU.js} +1 -1
- package/dashboard/dist/assets/{cloud-checkout-DNFMqoiZ.js → cloud-checkout-CoRQjKEu.js} +1 -1
- package/dashboard/dist/assets/{composite-CUbvhoGL.js → composite-PlKvZfdM.js} +1 -1
- package/dashboard/dist/assets/{download-CrDgjohg.js → download-McE9gFto.js} +1 -1
- package/dashboard/dist/assets/{external-link-DgnNV6zS.js → external-link-DZWnR9gS.js} +1 -1
- package/dashboard/dist/assets/{flame-Lsd5DkgX.js → flame-0xjueXt4.js} +1 -1
- package/dashboard/dist/assets/{format-tokens-DSxX2imE.js → format-tokens-CZoG68uJ.js} +1 -1
- package/dashboard/dist/assets/{gift-BA3WiW1-.js → gift-pKc80Nqb.js} +1 -1
- package/dashboard/dist/assets/{host-mode-BiJLkMdX.js → host-mode-99_v1j5J.js} +1 -1
- package/dashboard/dist/assets/{icons-BxxxA-aw.js → icons-BtfYKSGC.js} +1 -1
- package/dashboard/dist/assets/{index-V-WILWJ0.js → index-Cgthm7BO.js} +1 -1
- package/dashboard/dist/assets/{index-BTC0A20d.js → index-CyZxN1O0.js} +1 -1
- package/dashboard/dist/assets/{index-BlvkImKO.js → index-DuaQmNZo.js} +1 -1
- package/dashboard/dist/assets/{info-CluBWyTe.js → info-C8vkxwsO.js} +1 -1
- package/dashboard/dist/assets/{link-2-M880npIj.js → link-2-CQzIW5b6.js} +1 -1
- package/dashboard/dist/assets/{loader-circle-BEowiVYF.js → loader-circle-B9GqzQyC.js} +1 -1
- package/dashboard/dist/assets/{modifiers.esm-pR4sKZep.js → modifiers.esm-ChkCUrZp.js} +1 -1
- package/dashboard/dist/assets/{monitor-smartphone-GOnwL7NC.js → monitor-smartphone-DQjBY1W3.js} +1 -1
- package/dashboard/dist/assets/{play-C2Yih72t.js → play-qC6xc6fe.js} +1 -1
- package/dashboard/dist/assets/{plus-KF6U4UP_.js → plus-CoNHx5Og.js} +1 -1
- package/dashboard/dist/assets/{provider-display-Bio3tJX4.js → provider-display-x2EG6zAY.js} +1 -1
- package/dashboard/dist/assets/{react-Dt52_FiQ.js → react-EctmAw3f.js} +1 -1
- package/dashboard/dist/assets/{safePolygon-D7wQNKcm.js → safePolygon-DlSbLtZC.js} +1 -1
- package/dashboard/dist/assets/{search-CW0YCdKx.js → search-CBcpAj9I.js} +1 -1
- package/dashboard/dist/assets/{server-DKLG1DuM.js → server-DtMUoEq0.js} +1 -1
- package/dashboard/dist/assets/{shield-check-DkJ3sCHH.js → shield-check-ByUPtUmu.js} +1 -1
- package/dashboard/dist/assets/{skills-api-yS1uW-mw.js → skills-api-BD9VNRej.js} +1 -1
- package/dashboard/dist/assets/{sortable.esm-DZo9A4kG.js → sortable.esm-B6qEViGJ.js} +1 -1
- package/dashboard/dist/assets/{store-BbYtf4Vy.js → store-BgW2uBRe.js} +1 -1
- package/dashboard/dist/assets/{terminal-FK6txO2c.js → terminal-DWPNkr2L.js} +1 -1
- package/dashboard/dist/assets/{trash-QX4FHz_p.js → trash-DdbRpgD1.js} +1 -1
- package/dashboard/dist/assets/{use-community-stats-DaURJ5sU.js → use-community-stats-43ySv9uM.js} +1 -1
- package/dashboard/dist/assets/{use-latest-request-guard-BZnnoQct.js → use-latest-request-guard-BuezAv4k.js} +1 -1
- package/dashboard/dist/assets/{use-limits-display-prefs-C77UTTya.js → use-limits-display-prefs-Yi0Hznar.js} +1 -1
- package/dashboard/dist/assets/{use-native-settings-DHS101SR.js → use-native-settings-BaSrhrM8.js} +1 -1
- package/dashboard/dist/assets/{use-ordered-list-h5iXqXbU.js → use-ordered-list-CBD-EIBf.js} +1 -1
- package/dashboard/dist/assets/use-reduced-motion-ObUuoXUE.js +1 -0
- package/dashboard/dist/assets/{use-session-efficiency-pref-DZVvvmoq.js → use-session-efficiency-pref-CwaFIkE5.js} +1 -1
- package/dashboard/dist/assets/{use-transform-dcPyhMQK.js → use-transform-Dea4uz8K.js} +1 -1
- package/dashboard/dist/assets/{use-usage-limits-BBAi4Wvb.js → use-usage-limits-DxkYcUIR.js} +1 -1
- package/dashboard/dist/assets/{useCurrency-CW5GHWIB.js → useCurrency-CcZktkbA.js} +1 -1
- package/dashboard/dist/assets/{usePositioner-BQgBHX5s.js → usePositioner-BLGIGihf.js} +1 -1
- package/dashboard/dist/assets/{useTokenFormat-DntK8yNR.js → useTokenFormat--dhm3nNf.js} +1 -1
- package/dashboard/dist/assets/{zap-Brp6hC7u.js → zap-CWTmP6Zw.js} +1 -1
- package/dashboard/dist/index.html +14 -12
- package/dashboard/dist/ip-check.html +2 -2
- package/dashboard/dist/leaderboard.html +2 -2
- package/dashboard/dist/llms.txt +3 -2
- package/dashboard/dist/share.html +2 -2
- package/package.json +2 -2
- package/src/commands/init.js +9 -0
- package/src/commands/status.js +11 -0
- package/src/commands/sync.js +197 -122
- package/src/lib/dumate.js +95 -0
- package/src/lib/pricing/seed-snapshot.json +1 -1
- package/src/lib/qoder-cn-cli-limits.js +117 -0
- package/src/lib/qoder-limits.js +24 -11
- package/src/lib/rollout.js +12 -9
- package/src/lib/session-analytics.js +210 -19
- package/src/lib/upload-queue.js +134 -0
- package/dashboard/dist/assets/CommunityStatsModal-DkMCREYc.js +0 -1
- package/dashboard/dist/assets/DevicePage-CaZzXt8j.js +0 -1
- package/dashboard/dist/assets/DialogDescription-gdxwXQBG.js +0 -1
- package/dashboard/dist/assets/use-reduced-motion-Bpc6LGag.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as _,j as I}from"./__vite-browser-external-CbhiyufG.js";import{T as j,r as $,c as u,a as et,l as H,b as y,d as U,s as rt,e as T,p as Yt,h as pt,f as Wt,S as Zt,t as at,g as jt,i as Jt,j as te,k as ee,C as se,m as ne,n as mt,B as ie,o as xt,q as oe,u as re}from"./PetPage-DZlGXdiW.js";import"./Controls-DsJLsMpr.js";import"./Card-D_SqQIBC.js";import"./ProviderIcon-CSKhjDnT.js";import"./use-native-settings-DHS101SR.js";import"./FadeIn-CgGVCeA7.js";import"./react-Dt52_FiQ.js";import"./use-reduced-motion-Bpc6LGag.js";import"./link-2-M880npIj.js";import"./loader-circle-BEowiVYF.js";import"./zap-Brp6hC7u.js";import"./trash-QX4FHz_p.js";import"./DialogTitle-CgQTzYDB.js";import"./composite-CUbvhoGL.js";import"./store-BbYtf4Vy.js";import"./DialogDescription-gdxwXQBG.js";import"./DialogClose-Dg8Rrcbc.js";function nt(t,e=.55,s=.62){const n=(t%360+360)%360,i=(1-Math.abs(2*s-1))*e,r=i*(1-Math.abs(n/60%2-1)),o=s-i/2,[l,c,p]=n<60?[i,r,0]:n<120?[r,i,0]:n<180?[0,i,r]:n<240?[0,r,i]:n<300?[r,0,i]:[i,0,r],h=f=>Math.round((f+o)*255).toString(16).padStart(2,"0");return`#${h(l)}${h(c)}${h(p)}`}function ae(t,e,s,n,i=1){const r=t.phase+e*t.speed*j,o=Math.cos(t.tilt),l=Math.sin(t.tilt),c=Math.sqrt(Math.max(0,1-t.k*t.k)),p=64,h=t.sweep*j;let f="",M="",k=null;for(let P=0;P<=p;P++){const x=r+P/p*h,m=Math.cos(x),g=Math.sin(x),d=t.a*(m*o+g*-l*t.k)+t.cx,C=t.a*(m*l+g*o*t.k)+t.cy,R=t.a*g*c<0,a=$(d*s),O=$(C*s),E=R!==k?"M":"L";R?M+=`${E}${a} ${O}`:f+=`${E}${a} ${O}`,k=R}const A=Math.cos(t.tilt)*t.a*s,w=Math.sin(t.tilt)*t.a*s;return{id:n,front:f,back:M,width:t.width*s,opacity:i,grad:{x1:$(t.cx*s-A),y1:$(t.cy*s-w),x2:$(t.cx*s+A),y2:$(t.cy*s+w),stops:[nt(t.hue),nt(t.hue+t.hueSpan*.5),nt(t.hue+t.hueSpan)]}}}const D=et(659918),gt=Array.from({length:6},(t,e)=>({a:1.3+D()*.1,k:.05+D()*.4,tilt:e/6*Math.PI+D()*.5,speed:3+D()*.7,phase:D()*j,sweep:.6+D()*.25,hue:e*360/6+D()*30,hueSpan:60+D()*60,width:.05+D()*.012,cx:0,cy:.1})),ce=Array.from({length:4},(t,e)=>({a:.78+e*.2,k:.05+e*.02,tilt:-.62+e*.05,speed:.3,phase:.06*e,sweep:.4,hue:95+e*62,hueSpan:100,width:.05,cx:0,cy:-.12})),Mt=[-.557,-.013,.532],bt=.165,At=1.25,wt=et(48879),le=Array.from({length:5},(t,e)=>({birth:e*.2,angle:wt()*j,rho:.58+wt()*.18}));function he(t,e){const s=[];for(const n of le){const i=t-n.birth;if(i<0||i>.62)continue;const r=n.rho*Math.pow(.75,i*10),o=n.angle+i*100*Math.PI/180;s.push({x:Math.cos(o)*r*e,y:Math.sin(o)*r*e,r:(.04+.028*u(i/.55))*e,depth:u(1-r/.8),opacity:u(i/.06)*u((.62-i)/.08)})}return s}const kt=et(49383),pe=Array.from({length:4},(t,e)=>{const s=e-1.5;return{a:.85*(1+s*.03),k:.15/.85*(1+s*.16),tilt:34*Math.PI/180+s*.035,speed:210/360,phase:-e*.045+kt()*.012,sweep:.34,hue:e*85+kt()*20,hueSpan:80,width:.095,cx:0,cy:0}}),ue=.129,de="#2496e8",fe=-42,It=1.003,ye=.15,me=1.14,xe=.054,ut=15.46,ct=.186,lt=.412,st={yaw:28.49,pitch:28.62,roll:-13},J=t=>t*Math.PI/180;function tt(t,e,s){const n=Math.cos(s),i=Math.sin(s);return[[t[0]*n+e[0]*i,t[1]*n+e[1]*i,t[2]*n+e[2]*i],[e[0]*n-t[0]*i,e[1]*n-t[1]*i,e[2]*n-t[2]*i]]}function Ht(t,e,s=ut){let n=[0,0,1],i=[1,0,0],r=[0,1,0];[n,i]=tt(n,i,J(t.yaw)),[r,n]=tt(r,n,J(t.pitch)),[i,r]=tt(i,r,J(t.roll));const o=l=>{const[c,p]=tt(n,i,J(s*l));return{x:c[0]*e,y:c[1]*e,a:p[0],b:p[1],c:r[0],d:r[1],depth:c[2]}};return[o(-1),o(1)]}const Pt=et(24301),Et=(()=>{const t=[];let e=1.4;for(;e<900;)t.push(e),e+=1.9+Pt()*2.7,Pt()<.18&&(t.push(e),e+=.24);return t})(),ge=.18;function Me(t){for(let e=0;e<Et.length;e++){const s=Et[e];if(t<s)break;const n=(t-s)/ge;if(n>=0&&n<=1)return n<.45?1-n/.45:(n-.45)/.55}return 1}function be(t,e={}){const{wander:s=1,blink:n=!0,float:i=!0}=e;return{dYaw:(H(t,11.3,.4)*5.5+H(t,3.7,2.1)*1.6)*s,dPitch:(H(t,9.1,1.3)*4.2+H(t,4.3,.7)*1.3)*s,dRoll:H(t,13.7,3.2)*2.2*s,lid:n?Me(t):1,driftX:i?H(t,7.9,1.9)*.006:0,driftY:i?H(t,5.3,.3)*.007:0,breath:i?1+Math.sin(t/3.4*Math.PI*2)*.005:1}}function Ae(t){return .06+.94*u(t)}const L=(t,e,s=0,n=1)=>({w:t,h:e,tilt:s,open:n}),F=(t,e,s=0,n=1)=>[L(t,e,s,n),L(t,e,-s,n)],Xt=[{id:"neutre",gaze:{...st},split:ut,eyes:[L(ct,lt),L(ct,lt)]},{id:"attentif",gaze:{yaw:4,pitch:5,roll:-4},split:16,eyes:F(.21,.44)},{id:"surpris",gaze:{yaw:3,pitch:-3,roll:0},split:19,eyes:F(.45,.47)},{id:"excite",gaze:{yaw:6,pitch:-14,roll:0},split:19.5,eyes:F(.4,.56,-10)},{id:"heureux",gaze:{yaw:5,pitch:9,roll:0},split:17,eyes:F(.27,.17,14)},{id:"hilare",gaze:{yaw:4,pitch:14,roll:0},split:18,eyes:F(.34,.13,20)},{id:"colere",gaze:{yaw:3,pitch:7,roll:0},split:17,eyes:F(.34,.15,30)},{id:"triste",gaze:{yaw:3,pitch:-13,roll:0},split:16,eyes:F(.22,.4,-28)},{id:"effraye",gaze:{yaw:2,pitch:-20,roll:0},split:20.5,eyes:F(.4,.6)},{id:"mefiant",gaze:{yaw:12,pitch:6,roll:-6},split:16,eyes:[L(.21,.4),L(.22,.15)]},{id:"confus",gaze:{yaw:-14,pitch:3,roll:8},split:16.5,eyes:[L(.2,.44,-18),L(.28,.17,14)]},{id:"curieux",gaze:{yaw:16,pitch:-9,roll:-15},split:16.5,eyes:[L(.24,.46,-8),L(.2,.38,-8)]},{id:"fier",gaze:{yaw:5,pitch:17,roll:0},split:17,eyes:F(.3,.15,18)},{id:"timide",gaze:{yaw:-19,pitch:-14,roll:-7},split:14,eyes:F(.17,.3)},{id:"blase",gaze:{yaw:-22,pitch:2,roll:0},split:16,eyes:F(.3,.12)},{id:"somnolent",gaze:{yaw:6,pitch:-9,roll:-3},split:16,eyes:F(.2,.42,0,.42)}],Ot=new Map(Xt.map(t=>[t.id,t])),zt=(t,e,s)=>({w:y(t.w,e.w,s),h:y(t.h,e.h,s),tilt:y(t.tilt??0,e.tilt??0,s),open:y(t.open,e.open,s)});function we(t,e,s){return{id:e.id,gaze:{yaw:y(t.gaze.yaw,e.gaze.yaw,s),pitch:y(t.gaze.pitch,e.gaze.pitch,s),roll:y(t.gaze.roll,e.gaze.roll,s)},split:y(t.split,e.split,s),eyes:[zt(t.eyes[0],e.eyes[0],s),zt(t.eyes[1],e.eyes[1],s)]}}const X=(t,e)=>[{w:t,h:e,open:1},{w:t,h:e,open:1}];function S(t={}){return{sil:U(1),offX:0,offY:0,gaze:{...st},split:ut,eyes:X(ct,lt),eyeAlpha:1,bodyAlpha:1,dots:[],arcs:[],notif:null,dotsBehind:!1,...t}}const Gt=-.1875,ke=Yt(pt(0,-.505,.132,0,.13,.075),0,Gt),Ie=Yt(pt(0,-.2535,.1345,0,.2535,.1345),0,0),Pe=(t={})=>({radii:[...ke],rot:0,cx:0,cy:Gt,sx:1,sy:1,...t}),Ee=(t={})=>({radii:[...Ie],rot:0,cx:0,cy:0,sx:1,sy:1,...t}),Oe=Wt(pt(0,0,.118,0,.172,.012)),Rt=.213;function _t(t){return rt("triangle",{rot:t,cx:-Rt*Math.sin(t),cy:Rt*Math.cos(t)})}function St(t,e){const s=((t-e*.5)/1.5%1+1)%1,n=s<.5?.5-.5*Math.cos(s*j):0;return u(n*2)}const Ut=[{id:"idle",duration:2.4,morph:.45,blinkIn:!1,baseFace:!0,baseBody:!0,pose:()=>S()},{id:"thinking",duration:2.6,morph:.4,baseFace:!1,baseBody:!1,blinkIn:!0,pose:t=>{const e=St(t,1),s=.3+.7*T.easeOutCubic(u(t/.3));return S({sil:U(bt*(1+(At-1)*e),{cx:Mt[1]}),eyeAlpha:0,dots:[0,2].map(n=>{const i=St(t,n);return{x:Mt[n]*s,y:0,r:bt*(1+(At-1)*i),opacity:.55+.45*i}})})}},{id:"wink",duration:1.6,morph:.3,blinkIn:!0,baseFace:!1,baseBody:!0,pose:()=>S({gaze:{yaw:-5.37,pitch:4.55,roll:6.7},split:16.25,eyes:[{w:.236,h:.464,open:1},{w:.447,h:.089,open:1}]})},{id:"wide",duration:1.8,morph:.55,blinkIn:!0,baseFace:!1,baseBody:!0,pose:()=>S({gaze:{yaw:6.92,pitch:-21.96,roll:11.6},split:18.43,eyes:X(.356,.875)})},{id:"alert",duration:2.4,minDuration:2,morph:.45,baseFace:!1,baseBody:!1,blinkIn:!1,pose:t=>{const e=u(t/1.5),s=T.easeInOutCubic(e)*.82-.087,n=t>1.6?u((t-1.6)/.4):0,i=s*(1-n)+.1*n,r=Math.sin(t*2.5*j)*.005,o=17.7*Math.PI/180;return S({sil:Ee({rot:o,cx:i,cy:-.325-r}),eyeAlpha:0,dots:[{x:i-Math.sin(o)*.58,y:-.325+Math.cos(o)*.58+r*2.8,r:.118,d:Oe,rot:o*180/Math.PI,opacity:1}]})}},{id:"notify",duration:2.2,morph:.5,blinkIn:!0,baseFace:!1,baseBody:!0,pose:t=>{const e=u(t/.45),s=1+(me-1)*Math.sin(e*Math.PI)*(1-e*.35),n=ye*(e<1?s:1),i=fe*Math.PI/180;return S({gaze:{yaw:-21.94,pitch:-5.82,roll:-12.2},split:18.89,eyes:X(.505,.498),notif:{x:Math.cos(i)*It,y:Math.sin(i)*It,r:n,notch:n+xe}})}},{id:"exclaim",duration:2,morph:.45,baseFace:!1,baseBody:!1,blinkIn:!1,pose:()=>S({sil:Pe(),eyeAlpha:0,dots:[{x:-.012,y:.526,r:.113,opacity:1}]})},{id:"sleep",duration:2.4,morph:.5,baseFace:!1,baseBody:!1,blinkIn:!1,pose:t=>S({sil:U(.1585,{cy:.11+Math.sin(t*(j/.6))*.19}),eyeAlpha:0})},{id:"egg",duration:1.8,morph:.4,baseFace:!1,baseBody:!1,blinkIn:!0,pose:()=>S({sil:rt("egg"),gaze:{yaw:19.97,pitch:26.01,roll:-17.1},split:11.07,eyes:X(.164,.385)})},{id:"hexagon",duration:1.6,morph:.4,baseFace:!1,baseBody:!1,blinkIn:!0,pose:()=>S({sil:rt("hexagon"),gaze:{yaw:23.11,pitch:24.42,roll:-13.3},split:13.37,eyes:X(.177,.411)})},{id:"play",duration:2,morph:.5,baseFace:!1,baseBody:!1,blinkIn:!0,pose:t=>{const e=u(t/.35)*u((2.2-t)/.5);return S({sil:_t(0),gaze:{yaw:12,pitch:-8,roll:-6},split:15,eyes:X(.18,.34),arcs:ce.map((s,n)=>({id:`sw${n}`,seed:{...s,cx:.45-t*.42},t,opacity:e}))})}},{id:"orbit",duration:3.4,minDuration:2.5,morph:.6,baseFace:!1,baseBody:!1,blinkIn:!1,pose:t=>{const e=T.easeInOutCubic(u(t/.35)),s=-j*1.25*t*e,n=T.easeInOutCubic(u((t-1.6)/.9)),i=_t(s),r=U(1,{rot:s}),o={radii:i.radii.map((c,p)=>c+(r.radii[p]-c)*n),rot:s,cx:i.cx*(1-n),cy:i.cy*(1-n),sx:1,sy:1},l=u(t/.8)*u((3.6-t)/.9);return S({sil:o,gaze:{yaw:st.yaw+Math.sin(t*6.5)*65*(1-n),pitch:-4+n*32,roll:-13},eyes:X(.18,.34+n*.07),arcs:gt.map((c,p)=>({id:`rg${p}`,seed:c,t,opacity:l*u((t-p*.13)/.3)}))})}},{id:"swirl",duration:1.3,minDuration:1.3,morph:.3,baseFace:!0,baseBody:!0,blinkIn:!0,pose:t=>S({arcs:gt.slice(0,3).map((e,s)=>({id:`sw${s}`,seed:e,t,opacity:u((t-s*.06)/.14)*u((1.22-t)/.34)}))})},{id:"burst",duration:2.6,minDuration:2.4,morph:.4,baseFace:!1,baseBody:!1,blinkIn:!1,pose:t=>{const e=1-.834*T.easeOutQuint(u(t/.7)),s=T.easeOutQuint(u((t-1.7)/.7));return S({sil:U(e+(1-e)*s),eyeAlpha:u((t-1.85)/.4),dots:he(t,1),dotsBehind:!0})}},{id:"comet",duration:2.4,minDuration:2.4,morph:.45,baseFace:!1,baseBody:!1,blinkIn:!1,pose:t=>{const e=1-(1-ue)*T.easeOutQuint(u(t/.55)),s=T.easeOutQuint(u((t-1.85)/.6)),n=u((t-.15)/.25)*u((1.95-t)/.3);return S({sil:U(e+(1-e)*s,{cy:Math.sin(u(t/1.7)*Math.PI)*.035}),eyeAlpha:u((t-2)/.35),arcs:pe.map((i,r)=>({id:`cm${r}`,seed:i,t,opacity:n}))})}}],Q=new Map(Ut.map(t=>[t.id,t])),Y=100,Tt=5.5+1.6,vt=4.2+1.3,ze=.006,Re=.007;function Ft(t,e,s){const n=[],i=Ht(t.gaze,Y,t.split);for(let r=0;r<2;r++){const o=i[r];if(o.depth<=.02)continue;const l=t.eyes[r],c=(l.tilt??0)*Math.PI/180,p=Math.cos(c),h=Math.sin(c),f=o.a*p+o.c*h,M=o.b*p+o.d*h,k=-o.a*h+o.c*p,A=-o.b*h+o.d*p,w=Math.max(l.w*Y,.01)/2,P=Math.max(l.h*Y,.01)/2,x=Math.min(w,P),m=P>w,g=m?P-x:w-x,d=jt(s,Math.atan2(o.y,o.x)-e.rot);n.push({x:o.x*d,y:o.y*d,ax:(m?k:f)*g,ay:(m?A:M)*g,r:x,m:[f,M,k,A]})}return n}function _e(t,e,s,n,i){const r=n-e,o=i-s,l=r*r+o*o;let c=1/0,p=0,h=0;for(let M=0;M<t.length;M++){const k=t[M];let A=l>0?((k.x-e)*r+(k.y-s)*o)/l:0;A=A<0?0:A>1?1:A;const w=e+A*r-k.x,P=s+A*o-k.y,x=w*w+P*P;x<c&&(c=x,p=w,h=P)}const f=Math.sqrt(c);return{d:f,ux:f>1e-9?p/f:0,uy:f>1e-9?h/f:0}}const Se=Math.hypot(ze,Re)*Y;function Bt(t,e,s,n){let i=1/0,r=0,o=0;for(const l of e){const c=l.x+s,p=l.y+n,h=_e(t,c-l.ax,p-l.ay,c+l.ax,p+l.ay),[f,M,k,A]=l.m,w=l.r*Math.hypot(f*h.ux+M*h.uy,k*h.ux+A*h.uy)+Se;h.d-w<i&&(i=h.d-w,r=h.ux,o=h.uy)}return{marge:i,ux:r,uy:o}}const $t=12,Te=8;function ve(t){if(!t.length)return{x:0,y:0};const e=(x,m)=>{let g=1/0;for(const d of t)g=Math.min(g,Bt(d.contour,d.empreintes,x,m).marge);return g};let s=1/0;for(const x of t)s=Math.min(s,Bt(x.calContour,x.reference,0,0).marge);let n=0,i=0;const r=t[0].empreintes;for(const x of r)n-=x.x/r.length,i-=x.y/r.length;const o=Math.max(.35*Y,Math.hypot(n,i)*1.25);s=Math.min(s,e(n,i));const l=e(0,0);if(l>=s&&l>=0)return{x:0,y:0};const c=Math.max(s,0);let p=0,h=0,f=1/0,M=0,k=0,A=l;for(let x=0;x<$t;x++){const m=x/$t*Math.PI*2,g=Math.cos(m),d=Math.sin(m);if(e(g*o,d*o)<c){for(const R of[.3,.6,1]){const a=e(g*o*R,d*o*R);a>A&&(A=a,M=g*o*R,k=d*o*R)}continue}let C=0,v=o;for(let R=0;R<Te;R++){const a=(C+v)/2;e(g*a,d*a)>=c?v=a:C=a}v<f&&(f=v,p=g*v,h=d*v)}const w=f===1/0?M:p,P=f===1/0?k:h;return{x:+(w/Y).toFixed(6),y:+(P/Y).toFixed(6)}}function Fe(t,e,s){return t.baseFace&&s?{gaze:s.gaze,split:s.split,eyes:s.eyes}:{gaze:e.gaze,split:e.split,eyes:e.eyes}}function Be(t){const e=n=>JSON.stringify([n.gaze,n.split,n.eyes,n.sil.rot,n.sil.cx,n.sil.cy,n.sil.sx,n.sil.sy]);if(e(t.pose(0))===e(t.pose(t.duration)))return[0];const s=3;return Array.from({length:s},(n,i)=>i/(s-1)*t.duration)}function $e(t,e,s){const n=[];for(const i of Be(t)){const r=t.pose(i),o=at({...r.sil,radii:e},Y),l=at(r.sil,Y),c=Fe(t,r,s),p=[];for(const h of[-Tt,Tt])for(const f of[-vt,vt])p.push({...c,gaze:{yaw:c.gaze.yaw+h,pitch:c.gaze.pitch+f,roll:c.gaze.roll}});for(const h of p)n.push({empreintes:Ft(h,r.sil,e),reference:Ft(h,r.sil,r.sil.radii),contour:o,calContour:l})}return ve(n)}const it={x:0,y:0},ht=(t,e)=>`${t}|${e??""}`;function Ce(){return new Map(Zt.map(t=>{const e=new Map;for(const s of Ut){if(!s.baseBody)continue;const n=s.baseFace?[null,...Xt]:[null];for(const i of n)e.set(ht(s.id,i?.id??null),$e(s,t.radii,i))}return[t.radii,e]}))}const Le=Ce();function Ct(t,e,s){if(!t)return it;const n=Le.get(t);return n?n.get(ht(e,s))??n.get(ht(e,null))??it:it}const ot={yaw:0,pitch:0,mix:0,spin:0,wander:1},Ne=(t,e,s)=>({yaw:y(t.yaw,e.yaw,s),pitch:y(t.pitch,e.pitch,s),mix:y(t.mix,e.mix,s),spin:y(t.spin,e.spin,s),wander:y(t.wander,e.wander,s)}),Lt=(t,e,s)=>({w:y(t.w,e.w,s),h:y(t.h,e.h,s),open:y(t.open,e.open,s),tilt:y(t.tilt??0,e.tilt??0,s)});function Nt(t,e,s){const n=1-s;return{sil:ee(t.sil,e.sil,s),offX:y(t.offX,e.offX,s),offY:y(t.offY,e.offY,s),gaze:{yaw:y(t.gaze.yaw,e.gaze.yaw,s),pitch:y(t.gaze.pitch,e.gaze.pitch,s),roll:y(t.gaze.roll,e.gaze.roll,s)},split:y(t.split,e.split,s),eyes:[Lt(t.eyes[0],e.eyes[0],s),Lt(t.eyes[1],e.eyes[1],s)],eyeAlpha:y(t.eyeAlpha,e.eyeAlpha,s),bodyAlpha:y(t.bodyAlpha,e.bodyAlpha,s),dots:[...t.dots.map(i=>({...i,opacity:i.opacity*n})),...e.dots.map(i=>({...i,opacity:i.opacity*s}))],arcs:[...t.arcs.map(i=>({...i,id:`a${i.id}`,opacity:i.opacity*n})),...e.arcs.map(i=>({...i,id:`b${i.id}`,opacity:i.opacity*s}))],notif:s<.5?t.notif:e.notif,dotsBehind:s<.5?t.dotsBehind:e.dotsBehind}}class G{scale;cur;prev=null;departFige=null;tCur=0;tPrev=0;blinkAt=-10;pts=[];shape=null;shapePrev=null;shapeAt=-10;expr=null;exprPrev=null;exprAt=-10;look=ot;lookPrev=ot;lookAt=-10;lookMorph=.24;static SHAPE_MORPH=.45;static LOOK_MORPH=.24;constructor(e=100,s="idle",n=null,i=null){this.scale=e,this.cur=s,this.shape=n,this.expr=i}setExpression(e,s=0){e!==this.expr&&(this.exprPrev=this.expr,this.expr=e,this.exprAt=s)}exprAtTime(e){const s=this.expr,n=this.exprPrev;if(!s||!n)return s;const i=(e-this.exprAt)/G.SHAPE_MORPH;return i>=1?s:we(n,s,T.easeOutQuint(u(i)))}setShape(e,s=0){e!==this.shape&&(this.shapePrev=this.shape,this.shape=e,this.shapeAt=s)}shapeAtTime(e){const s=this.shape,n=this.shapePrev;if(!s||!n)return s;const i=(e-this.shapeAt)/G.SHAPE_MORPH;if(i>=1)return s;const r=T.easeOutQuint(u(i));return s.map((o,l)=>y(n[l]??o,o,r))}setLook(e,s,n=G.LOOK_MORPH){e&&!Number.isFinite(e.yaw+e.pitch+e.mix+e.spin+e.wander)||(this.lookPrev=this.lookAtTime(s),this.look=e??ot,this.lookAt=s,this.lookMorph=n)}lookAtTime(e){const s=(e-this.lookAt)/this.lookMorph;return s>=1?this.look:Ne(this.lookPrev,this.look,T.easeOutQuint(u(s)))}posed(e,s,n,i){let r=e.pose(s);return e.baseBody&&n&&(r={...r,sil:{...r.sil,radii:n}}),e.baseFace&&i&&(r={...r,gaze:i.gaze,split:i.split,eyes:i.eyes}),r}decalageAtTime(e,s){const n=(r,o,l,c)=>{if(l===c)return c;const p=(e-r)/o;if(p>=1)return c;const h=T.easeOutQuint(u(p));return{x:y(l.x,c.x,h),y:y(l.y,c.y,h)}},i=r=>n(this.exprAt,G.SHAPE_MORPH,Ct(r,s,this.exprPrev?.id??null),Ct(r,s,this.expr?.id??null));return n(this.shapeAt,G.SHAPE_MORPH,i(this.shapePrev),i(this.shape))}get state(){return this.cur}reset(e,s){this.cur=e,this.prev=null,this.departFige=null,this.tCur=s,this.tPrev=s,this.blinkAt=-10}origine(e,s,n){if(this.departFige)return this.departFige;if(!this.prev)return null;const i=Q.get(this.prev);return this.posed(i,Math.max(0,e-this.tPrev),s,n)}poseComposee(e){const s=Q.get(this.cur),n=this.shapeAtTime(e),i=this.exprAtTime(e),r=this.posed(s,Math.max(0,e-this.tCur),n,i),o=e-this.tCur;if(o>=s.morph)return r;const l=this.origine(e,n,i);return l?Nt(l,r,T.easeOutQuint(u(o/s.morph))):r}setState(e,s){if(e===this.cur)return;const n=Q.get(this.cur).morph,i=this.prev!==null&&s-this.tCur<n;this.departFige=i?this.poseComposee(s):null,this.prev=this.cur,this.tPrev=this.tCur,this.cur=e,this.tCur=s,Q.get(e)?.blinkIn&&(this.blinkAt=s)}sample(e){const s=this.scale,n=Q.get(this.cur),i=this.shapeAtTime(e),r=this.exprAtTime(e);let o=this.posed(n,Math.max(0,e-this.tCur),i,r),l=this.decalageAtTime(e,this.cur);const c=e-this.tCur,p=c<n.morph?this.origine(e,i,r):null;if(p){const b=T.easeOutQuint(u(c/n.morph));o=Nt(p,o,b);const N=this.prev;if(N){const z=this.decalageAtTime(e,N);l={x:y(z.x,l.x,b),y:y(z.y,l.y,b)}}}const h=o.eyeAlpha>.01,f=this.lookAtTime(e),M=be(e,{wander:h?f.wander:0,blink:h}),k={yaw:y(o.gaze.yaw,f.yaw,f.mix)+M.dYaw-f.spin,pitch:y(o.gaze.pitch,f.pitch,f.mix)+M.dPitch,roll:o.gaze.roll+M.dRoll},A=u((e-this.blinkAt)/.2),w=A<1?Math.abs(A*2-1):1,P=Math.min(M.lid,w),x=o.offX+M.driftX,m=o.offY+M.driftY,g={...o.sil,cx:o.sil.cx+x,cy:o.sil.cy+m,sy:o.sil.sy*M.breath},d=Jt(at(g,s,this.pts)),C=(b,N)=>jt(o.sil.radii,Math.atan2(N,b)-o.sil.rot),v=[];if(o.eyeAlpha>.01){const b=Ht(k,s,o.split);for(let N=0;N<2;N++){const z=b[N];if(z.depth<=.02)continue;const K=o.eyes[N],dt=C(z.x,z.y),ft=(K.tilt??0)*Math.PI/180,W=Math.cos(ft),Z=Math.sin(ft),Qt=z.a*W+z.c*Z,Vt=z.b*W+z.d*Z,qt=-z.a*Z+z.c*W,Kt=-z.b*Z+z.d*W,yt=Ae(Math.min(P,K.open));v.push({d:te(K.w*s,K.h*s),matrix:`matrix(${$(Qt)},${$(Vt*yt)},${$(qt)},${$(Kt*yt)},${$(z.x*dt+(x+l.x)*s)},${$(z.y*dt+(m+l.y)*s)})`,alpha:o.eyeAlpha*u(z.depth/.12)})}}const R=o.dots.filter(b=>b.opacity>.01&&b.r>5e-4).map(b=>({...b,x:(b.x+x)*s,y:(b.y+m)*s,r:b.r*s})),a=o.notif?C(o.notif.x,o.notif.y):1,O=o.notif?(o.notif.x*a+x)*s:0,E=o.notif?(o.notif.y*a+m)*s:0,V=o.notif?{x:O,y:E,r:o.notif.r*s}:null,q=o.notif?{x:O,y:E,r:o.notif.notch*s}:null;return{bodyPath:d,bodyAlpha:o.bodyAlpha,eyes:v,dots:R,dotsBehind:o.dotsBehind,arcs:o.arcs.filter(b=>b.opacity>.01).map(b=>ae(b.seed,b.t,s,b.id,b.opacity)),notif:V,notch:q}}}const Dt=100,De=158,B=De,Ye=1e3/30,je=34;function He(){const[t,e]=_.useState(()=>typeof document>"u"?!1:document.documentElement.classList.contains("dark"));return _.useEffect(()=>{if(typeof MutationObserver!="function")return;const s=document.documentElement,n=new MutationObserver(()=>e(s.classList.contains("dark")));return n.observe(s,{attributes:!0,attributeFilter:["class"]}),()=>n.disconnect()},[]),t}function Xe(){const[t,e]=_.useState(()=>typeof document>"u"?!0:document.visibilityState!=="hidden");return _.useEffect(()=>{if(typeof document>"u")return;const s=()=>e(document.visibilityState!=="hidden");return document.addEventListener("visibilitychange",s),()=>document.removeEventListener("visibilitychange",s)},[]),t}function Ge(){const[t,e]=_.useState(()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches);return _.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const s=window.matchMedia("(prefers-reduced-motion: reduce)"),n=i=>e(i.matches);return s.addEventListener("change",n),()=>s.removeEventListener("change",n)},[]),t}function hs({state:t="idle-living",dragState:e=null,size:s=48,className:n="",leanX:i=0,shape:r=ie,color:o="auto",paper:l=null}){const c=oe(e==="running-left"||e==="running-right"?e:t),p=Ge(),h=Xe(),f=He(),M=l||(f?xt.dark:xt.light),k=se.get(ne(o,f)).hex,A=_.useId(),w=_.useMemo(()=>A.replace(/[^a-zA-Z0-9_-]/g,""),[A]),P=`bot-mask-${w}`,x=_.useRef(null);x.current===null&&(x.current=new G(Dt,c.state,mt.get(r)?.radii??null,Ot.get(c.expression)??null));const m=x.current,g=_.useRef(0),[d,C]=_.useState(()=>m.sample(0));_.useEffect(()=>{m.setShape(mt.get(r)?.radii??null,g.current)},[m,r]),_.useEffect(()=>{m.setExpression(Ot.get(c.expression)??null,g.current)},[m,c.expression]),_.useEffect(()=>{m.state!==c.state&&(m.setState(c.state,g.current),C(m.sample(g.current)))},[m,c.state]),_.useEffect(()=>{const a=Math.min(1,Math.abs(i));if(a<=0||!Q.get(c.state)?.baseFace){m.setLook(null,g.current);return}m.setLook({yaw:i*je,pitch:st.pitch,mix:a,spin:0,wander:1-a},g.current)},[m,i,c.state]),_.useEffect(()=>{if(p||!h)return;let a=0,O=0,E=0;const V=q=>{a=requestAnimationFrame(V);const b=O?Math.min((q-O)/1e3,.064):0;O=q,g.current+=b,E+=b*1e3,!(E<Ye)&&(E=0,C(m.sample(g.current)))};return a=requestAnimationFrame(V),()=>cancelAnimationFrame(a)},[m,p,h]);const v=a=>{const E={fill:a.color??(a.depth===void 0?k:re(M,k,a.depth)),opacity:a.opacity};return a.d?{...E,d:a.d,transform:`translate(${a.x} ${a.y}) rotate(${a.rot??0}) scale(${Dt})`}:{...E,cx:a.x,cy:a.y,r:a.r}},R=d.dots.map((a,O)=>{const E=v(a);return a.d?I.jsx("path",{...E},O):I.jsx("circle",{...E},O)});return I.jsxs("svg",{"aria-hidden":"true",className:`bot-animated ${n}`,width:s,height:s,viewBox:`${-B} ${-B} ${B*2} ${B*2}`,children:[I.jsxs("defs",{children:[I.jsxs("mask",{id:P,maskUnits:"userSpaceOnUse",x:-B,y:-B,width:B*2,height:B*2,children:[I.jsx("path",{d:d.bodyPath,fill:"#fff"}),d.eyes.map((a,O)=>I.jsx("path",{d:a.d,transform:a.matrix,opacity:a.alpha,fill:"#000"},O)),d.notch?I.jsx("circle",{cx:d.notch.x,cy:d.notch.y,r:d.notch.r,fill:"#000"}):null]}),d.arcs.map(a=>I.jsx("linearGradient",{id:`${w}-${a.id}`,gradientUnits:"userSpaceOnUse",x1:a.grad.x1,y1:a.grad.y1,x2:a.grad.x2,y2:a.grad.y2,children:a.grad.stops.map((O,E)=>I.jsx("stop",{offset:E/(a.grad.stops.length-1),stopColor:O},E))},a.id))]}),I.jsx("g",{fill:"none",strokeLinecap:"round",children:d.arcs.map(a=>I.jsx("path",{d:a.back,stroke:`url(#${w}-${a.id})`,strokeWidth:a.width,opacity:a.opacity},a.id))}),d.dotsBehind?I.jsx("g",{children:R}):null,I.jsxs("g",{opacity:d.bodyAlpha,children:[I.jsx("path",{d:d.bodyPath,fill:M}),I.jsx("g",{mask:`url(#${P})`,children:I.jsx("rect",{x:-B,y:-B,width:B*2,height:B*2,fill:k})})]}),d.dotsBehind?null:I.jsx("g",{children:R}),d.notif?I.jsx("circle",{cx:d.notif.x,cy:d.notif.y,r:d.notif.r,fill:de}):null,I.jsx("g",{fill:"none",strokeLinecap:"round",children:d.arcs.map(a=>I.jsx("path",{d:a.front,stroke:`url(#${w}-${a.id})`,strokeWidth:a.width,opacity:a.opacity},`f${a.id}`))})]})}export{hs as BotAnimated};
|
|
1
|
+
import{r as _,j as I}from"./__vite-browser-external-Go6WKt6Z.js";import{T as j,r as $,c as u,a as et,l as H,b as y,d as U,s as rt,e as T,p as Yt,h as pt,f as Wt,S as Zt,t as at,g as jt,i as Jt,j as te,k as ee,C as se,m as ne,n as mt,B as ie,o as xt,q as oe,u as re}from"./PetPage-D1Pk4OKI.js";import"./Controls-CQlxw03i.js";import"./Card-BHHCCnqR.js";import"./ProviderIcon-R6Bsj81X.js";import"./use-native-settings-BaSrhrM8.js";import"./FadeIn-B9oATcDZ.js";import"./react-EctmAw3f.js";import"./use-reduced-motion-ObUuoXUE.js";import"./link-2-CQzIW5b6.js";import"./loader-circle-B9GqzQyC.js";import"./zap-CWTmP6Zw.js";import"./trash-DdbRpgD1.js";import"./DialogTitle-Cro2S8s8.js";import"./composite-PlKvZfdM.js";import"./store-BgW2uBRe.js";import"./DialogDescription-LvhfT1Ox.js";import"./DialogClose-Dx5AqmUG.js";function nt(t,e=.55,s=.62){const n=(t%360+360)%360,i=(1-Math.abs(2*s-1))*e,r=i*(1-Math.abs(n/60%2-1)),o=s-i/2,[l,c,p]=n<60?[i,r,0]:n<120?[r,i,0]:n<180?[0,i,r]:n<240?[0,r,i]:n<300?[r,0,i]:[i,0,r],h=f=>Math.round((f+o)*255).toString(16).padStart(2,"0");return`#${h(l)}${h(c)}${h(p)}`}function ae(t,e,s,n,i=1){const r=t.phase+e*t.speed*j,o=Math.cos(t.tilt),l=Math.sin(t.tilt),c=Math.sqrt(Math.max(0,1-t.k*t.k)),p=64,h=t.sweep*j;let f="",M="",k=null;for(let P=0;P<=p;P++){const x=r+P/p*h,m=Math.cos(x),g=Math.sin(x),d=t.a*(m*o+g*-l*t.k)+t.cx,C=t.a*(m*l+g*o*t.k)+t.cy,R=t.a*g*c<0,a=$(d*s),O=$(C*s),E=R!==k?"M":"L";R?M+=`${E}${a} ${O}`:f+=`${E}${a} ${O}`,k=R}const A=Math.cos(t.tilt)*t.a*s,w=Math.sin(t.tilt)*t.a*s;return{id:n,front:f,back:M,width:t.width*s,opacity:i,grad:{x1:$(t.cx*s-A),y1:$(t.cy*s-w),x2:$(t.cx*s+A),y2:$(t.cy*s+w),stops:[nt(t.hue),nt(t.hue+t.hueSpan*.5),nt(t.hue+t.hueSpan)]}}}const D=et(659918),gt=Array.from({length:6},(t,e)=>({a:1.3+D()*.1,k:.05+D()*.4,tilt:e/6*Math.PI+D()*.5,speed:3+D()*.7,phase:D()*j,sweep:.6+D()*.25,hue:e*360/6+D()*30,hueSpan:60+D()*60,width:.05+D()*.012,cx:0,cy:.1})),ce=Array.from({length:4},(t,e)=>({a:.78+e*.2,k:.05+e*.02,tilt:-.62+e*.05,speed:.3,phase:.06*e,sweep:.4,hue:95+e*62,hueSpan:100,width:.05,cx:0,cy:-.12})),Mt=[-.557,-.013,.532],bt=.165,At=1.25,wt=et(48879),le=Array.from({length:5},(t,e)=>({birth:e*.2,angle:wt()*j,rho:.58+wt()*.18}));function he(t,e){const s=[];for(const n of le){const i=t-n.birth;if(i<0||i>.62)continue;const r=n.rho*Math.pow(.75,i*10),o=n.angle+i*100*Math.PI/180;s.push({x:Math.cos(o)*r*e,y:Math.sin(o)*r*e,r:(.04+.028*u(i/.55))*e,depth:u(1-r/.8),opacity:u(i/.06)*u((.62-i)/.08)})}return s}const kt=et(49383),pe=Array.from({length:4},(t,e)=>{const s=e-1.5;return{a:.85*(1+s*.03),k:.15/.85*(1+s*.16),tilt:34*Math.PI/180+s*.035,speed:210/360,phase:-e*.045+kt()*.012,sweep:.34,hue:e*85+kt()*20,hueSpan:80,width:.095,cx:0,cy:0}}),ue=.129,de="#2496e8",fe=-42,It=1.003,ye=.15,me=1.14,xe=.054,ut=15.46,ct=.186,lt=.412,st={yaw:28.49,pitch:28.62,roll:-13},J=t=>t*Math.PI/180;function tt(t,e,s){const n=Math.cos(s),i=Math.sin(s);return[[t[0]*n+e[0]*i,t[1]*n+e[1]*i,t[2]*n+e[2]*i],[e[0]*n-t[0]*i,e[1]*n-t[1]*i,e[2]*n-t[2]*i]]}function Ht(t,e,s=ut){let n=[0,0,1],i=[1,0,0],r=[0,1,0];[n,i]=tt(n,i,J(t.yaw)),[r,n]=tt(r,n,J(t.pitch)),[i,r]=tt(i,r,J(t.roll));const o=l=>{const[c,p]=tt(n,i,J(s*l));return{x:c[0]*e,y:c[1]*e,a:p[0],b:p[1],c:r[0],d:r[1],depth:c[2]}};return[o(-1),o(1)]}const Pt=et(24301),Et=(()=>{const t=[];let e=1.4;for(;e<900;)t.push(e),e+=1.9+Pt()*2.7,Pt()<.18&&(t.push(e),e+=.24);return t})(),ge=.18;function Me(t){for(let e=0;e<Et.length;e++){const s=Et[e];if(t<s)break;const n=(t-s)/ge;if(n>=0&&n<=1)return n<.45?1-n/.45:(n-.45)/.55}return 1}function be(t,e={}){const{wander:s=1,blink:n=!0,float:i=!0}=e;return{dYaw:(H(t,11.3,.4)*5.5+H(t,3.7,2.1)*1.6)*s,dPitch:(H(t,9.1,1.3)*4.2+H(t,4.3,.7)*1.3)*s,dRoll:H(t,13.7,3.2)*2.2*s,lid:n?Me(t):1,driftX:i?H(t,7.9,1.9)*.006:0,driftY:i?H(t,5.3,.3)*.007:0,breath:i?1+Math.sin(t/3.4*Math.PI*2)*.005:1}}function Ae(t){return .06+.94*u(t)}const L=(t,e,s=0,n=1)=>({w:t,h:e,tilt:s,open:n}),F=(t,e,s=0,n=1)=>[L(t,e,s,n),L(t,e,-s,n)],Xt=[{id:"neutre",gaze:{...st},split:ut,eyes:[L(ct,lt),L(ct,lt)]},{id:"attentif",gaze:{yaw:4,pitch:5,roll:-4},split:16,eyes:F(.21,.44)},{id:"surpris",gaze:{yaw:3,pitch:-3,roll:0},split:19,eyes:F(.45,.47)},{id:"excite",gaze:{yaw:6,pitch:-14,roll:0},split:19.5,eyes:F(.4,.56,-10)},{id:"heureux",gaze:{yaw:5,pitch:9,roll:0},split:17,eyes:F(.27,.17,14)},{id:"hilare",gaze:{yaw:4,pitch:14,roll:0},split:18,eyes:F(.34,.13,20)},{id:"colere",gaze:{yaw:3,pitch:7,roll:0},split:17,eyes:F(.34,.15,30)},{id:"triste",gaze:{yaw:3,pitch:-13,roll:0},split:16,eyes:F(.22,.4,-28)},{id:"effraye",gaze:{yaw:2,pitch:-20,roll:0},split:20.5,eyes:F(.4,.6)},{id:"mefiant",gaze:{yaw:12,pitch:6,roll:-6},split:16,eyes:[L(.21,.4),L(.22,.15)]},{id:"confus",gaze:{yaw:-14,pitch:3,roll:8},split:16.5,eyes:[L(.2,.44,-18),L(.28,.17,14)]},{id:"curieux",gaze:{yaw:16,pitch:-9,roll:-15},split:16.5,eyes:[L(.24,.46,-8),L(.2,.38,-8)]},{id:"fier",gaze:{yaw:5,pitch:17,roll:0},split:17,eyes:F(.3,.15,18)},{id:"timide",gaze:{yaw:-19,pitch:-14,roll:-7},split:14,eyes:F(.17,.3)},{id:"blase",gaze:{yaw:-22,pitch:2,roll:0},split:16,eyes:F(.3,.12)},{id:"somnolent",gaze:{yaw:6,pitch:-9,roll:-3},split:16,eyes:F(.2,.42,0,.42)}],Ot=new Map(Xt.map(t=>[t.id,t])),zt=(t,e,s)=>({w:y(t.w,e.w,s),h:y(t.h,e.h,s),tilt:y(t.tilt??0,e.tilt??0,s),open:y(t.open,e.open,s)});function we(t,e,s){return{id:e.id,gaze:{yaw:y(t.gaze.yaw,e.gaze.yaw,s),pitch:y(t.gaze.pitch,e.gaze.pitch,s),roll:y(t.gaze.roll,e.gaze.roll,s)},split:y(t.split,e.split,s),eyes:[zt(t.eyes[0],e.eyes[0],s),zt(t.eyes[1],e.eyes[1],s)]}}const X=(t,e)=>[{w:t,h:e,open:1},{w:t,h:e,open:1}];function S(t={}){return{sil:U(1),offX:0,offY:0,gaze:{...st},split:ut,eyes:X(ct,lt),eyeAlpha:1,bodyAlpha:1,dots:[],arcs:[],notif:null,dotsBehind:!1,...t}}const Gt=-.1875,ke=Yt(pt(0,-.505,.132,0,.13,.075),0,Gt),Ie=Yt(pt(0,-.2535,.1345,0,.2535,.1345),0,0),Pe=(t={})=>({radii:[...ke],rot:0,cx:0,cy:Gt,sx:1,sy:1,...t}),Ee=(t={})=>({radii:[...Ie],rot:0,cx:0,cy:0,sx:1,sy:1,...t}),Oe=Wt(pt(0,0,.118,0,.172,.012)),Rt=.213;function _t(t){return rt("triangle",{rot:t,cx:-Rt*Math.sin(t),cy:Rt*Math.cos(t)})}function St(t,e){const s=((t-e*.5)/1.5%1+1)%1,n=s<.5?.5-.5*Math.cos(s*j):0;return u(n*2)}const Ut=[{id:"idle",duration:2.4,morph:.45,blinkIn:!1,baseFace:!0,baseBody:!0,pose:()=>S()},{id:"thinking",duration:2.6,morph:.4,baseFace:!1,baseBody:!1,blinkIn:!0,pose:t=>{const e=St(t,1),s=.3+.7*T.easeOutCubic(u(t/.3));return S({sil:U(bt*(1+(At-1)*e),{cx:Mt[1]}),eyeAlpha:0,dots:[0,2].map(n=>{const i=St(t,n);return{x:Mt[n]*s,y:0,r:bt*(1+(At-1)*i),opacity:.55+.45*i}})})}},{id:"wink",duration:1.6,morph:.3,blinkIn:!0,baseFace:!1,baseBody:!0,pose:()=>S({gaze:{yaw:-5.37,pitch:4.55,roll:6.7},split:16.25,eyes:[{w:.236,h:.464,open:1},{w:.447,h:.089,open:1}]})},{id:"wide",duration:1.8,morph:.55,blinkIn:!0,baseFace:!1,baseBody:!0,pose:()=>S({gaze:{yaw:6.92,pitch:-21.96,roll:11.6},split:18.43,eyes:X(.356,.875)})},{id:"alert",duration:2.4,minDuration:2,morph:.45,baseFace:!1,baseBody:!1,blinkIn:!1,pose:t=>{const e=u(t/1.5),s=T.easeInOutCubic(e)*.82-.087,n=t>1.6?u((t-1.6)/.4):0,i=s*(1-n)+.1*n,r=Math.sin(t*2.5*j)*.005,o=17.7*Math.PI/180;return S({sil:Ee({rot:o,cx:i,cy:-.325-r}),eyeAlpha:0,dots:[{x:i-Math.sin(o)*.58,y:-.325+Math.cos(o)*.58+r*2.8,r:.118,d:Oe,rot:o*180/Math.PI,opacity:1}]})}},{id:"notify",duration:2.2,morph:.5,blinkIn:!0,baseFace:!1,baseBody:!0,pose:t=>{const e=u(t/.45),s=1+(me-1)*Math.sin(e*Math.PI)*(1-e*.35),n=ye*(e<1?s:1),i=fe*Math.PI/180;return S({gaze:{yaw:-21.94,pitch:-5.82,roll:-12.2},split:18.89,eyes:X(.505,.498),notif:{x:Math.cos(i)*It,y:Math.sin(i)*It,r:n,notch:n+xe}})}},{id:"exclaim",duration:2,morph:.45,baseFace:!1,baseBody:!1,blinkIn:!1,pose:()=>S({sil:Pe(),eyeAlpha:0,dots:[{x:-.012,y:.526,r:.113,opacity:1}]})},{id:"sleep",duration:2.4,morph:.5,baseFace:!1,baseBody:!1,blinkIn:!1,pose:t=>S({sil:U(.1585,{cy:.11+Math.sin(t*(j/.6))*.19}),eyeAlpha:0})},{id:"egg",duration:1.8,morph:.4,baseFace:!1,baseBody:!1,blinkIn:!0,pose:()=>S({sil:rt("egg"),gaze:{yaw:19.97,pitch:26.01,roll:-17.1},split:11.07,eyes:X(.164,.385)})},{id:"hexagon",duration:1.6,morph:.4,baseFace:!1,baseBody:!1,blinkIn:!0,pose:()=>S({sil:rt("hexagon"),gaze:{yaw:23.11,pitch:24.42,roll:-13.3},split:13.37,eyes:X(.177,.411)})},{id:"play",duration:2,morph:.5,baseFace:!1,baseBody:!1,blinkIn:!0,pose:t=>{const e=u(t/.35)*u((2.2-t)/.5);return S({sil:_t(0),gaze:{yaw:12,pitch:-8,roll:-6},split:15,eyes:X(.18,.34),arcs:ce.map((s,n)=>({id:`sw${n}`,seed:{...s,cx:.45-t*.42},t,opacity:e}))})}},{id:"orbit",duration:3.4,minDuration:2.5,morph:.6,baseFace:!1,baseBody:!1,blinkIn:!1,pose:t=>{const e=T.easeInOutCubic(u(t/.35)),s=-j*1.25*t*e,n=T.easeInOutCubic(u((t-1.6)/.9)),i=_t(s),r=U(1,{rot:s}),o={radii:i.radii.map((c,p)=>c+(r.radii[p]-c)*n),rot:s,cx:i.cx*(1-n),cy:i.cy*(1-n),sx:1,sy:1},l=u(t/.8)*u((3.6-t)/.9);return S({sil:o,gaze:{yaw:st.yaw+Math.sin(t*6.5)*65*(1-n),pitch:-4+n*32,roll:-13},eyes:X(.18,.34+n*.07),arcs:gt.map((c,p)=>({id:`rg${p}`,seed:c,t,opacity:l*u((t-p*.13)/.3)}))})}},{id:"swirl",duration:1.3,minDuration:1.3,morph:.3,baseFace:!0,baseBody:!0,blinkIn:!0,pose:t=>S({arcs:gt.slice(0,3).map((e,s)=>({id:`sw${s}`,seed:e,t,opacity:u((t-s*.06)/.14)*u((1.22-t)/.34)}))})},{id:"burst",duration:2.6,minDuration:2.4,morph:.4,baseFace:!1,baseBody:!1,blinkIn:!1,pose:t=>{const e=1-.834*T.easeOutQuint(u(t/.7)),s=T.easeOutQuint(u((t-1.7)/.7));return S({sil:U(e+(1-e)*s),eyeAlpha:u((t-1.85)/.4),dots:he(t,1),dotsBehind:!0})}},{id:"comet",duration:2.4,minDuration:2.4,morph:.45,baseFace:!1,baseBody:!1,blinkIn:!1,pose:t=>{const e=1-(1-ue)*T.easeOutQuint(u(t/.55)),s=T.easeOutQuint(u((t-1.85)/.6)),n=u((t-.15)/.25)*u((1.95-t)/.3);return S({sil:U(e+(1-e)*s,{cy:Math.sin(u(t/1.7)*Math.PI)*.035}),eyeAlpha:u((t-2)/.35),arcs:pe.map((i,r)=>({id:`cm${r}`,seed:i,t,opacity:n}))})}}],Q=new Map(Ut.map(t=>[t.id,t])),Y=100,Tt=5.5+1.6,vt=4.2+1.3,ze=.006,Re=.007;function Ft(t,e,s){const n=[],i=Ht(t.gaze,Y,t.split);for(let r=0;r<2;r++){const o=i[r];if(o.depth<=.02)continue;const l=t.eyes[r],c=(l.tilt??0)*Math.PI/180,p=Math.cos(c),h=Math.sin(c),f=o.a*p+o.c*h,M=o.b*p+o.d*h,k=-o.a*h+o.c*p,A=-o.b*h+o.d*p,w=Math.max(l.w*Y,.01)/2,P=Math.max(l.h*Y,.01)/2,x=Math.min(w,P),m=P>w,g=m?P-x:w-x,d=jt(s,Math.atan2(o.y,o.x)-e.rot);n.push({x:o.x*d,y:o.y*d,ax:(m?k:f)*g,ay:(m?A:M)*g,r:x,m:[f,M,k,A]})}return n}function _e(t,e,s,n,i){const r=n-e,o=i-s,l=r*r+o*o;let c=1/0,p=0,h=0;for(let M=0;M<t.length;M++){const k=t[M];let A=l>0?((k.x-e)*r+(k.y-s)*o)/l:0;A=A<0?0:A>1?1:A;const w=e+A*r-k.x,P=s+A*o-k.y,x=w*w+P*P;x<c&&(c=x,p=w,h=P)}const f=Math.sqrt(c);return{d:f,ux:f>1e-9?p/f:0,uy:f>1e-9?h/f:0}}const Se=Math.hypot(ze,Re)*Y;function Bt(t,e,s,n){let i=1/0,r=0,o=0;for(const l of e){const c=l.x+s,p=l.y+n,h=_e(t,c-l.ax,p-l.ay,c+l.ax,p+l.ay),[f,M,k,A]=l.m,w=l.r*Math.hypot(f*h.ux+M*h.uy,k*h.ux+A*h.uy)+Se;h.d-w<i&&(i=h.d-w,r=h.ux,o=h.uy)}return{marge:i,ux:r,uy:o}}const $t=12,Te=8;function ve(t){if(!t.length)return{x:0,y:0};const e=(x,m)=>{let g=1/0;for(const d of t)g=Math.min(g,Bt(d.contour,d.empreintes,x,m).marge);return g};let s=1/0;for(const x of t)s=Math.min(s,Bt(x.calContour,x.reference,0,0).marge);let n=0,i=0;const r=t[0].empreintes;for(const x of r)n-=x.x/r.length,i-=x.y/r.length;const o=Math.max(.35*Y,Math.hypot(n,i)*1.25);s=Math.min(s,e(n,i));const l=e(0,0);if(l>=s&&l>=0)return{x:0,y:0};const c=Math.max(s,0);let p=0,h=0,f=1/0,M=0,k=0,A=l;for(let x=0;x<$t;x++){const m=x/$t*Math.PI*2,g=Math.cos(m),d=Math.sin(m);if(e(g*o,d*o)<c){for(const R of[.3,.6,1]){const a=e(g*o*R,d*o*R);a>A&&(A=a,M=g*o*R,k=d*o*R)}continue}let C=0,v=o;for(let R=0;R<Te;R++){const a=(C+v)/2;e(g*a,d*a)>=c?v=a:C=a}v<f&&(f=v,p=g*v,h=d*v)}const w=f===1/0?M:p,P=f===1/0?k:h;return{x:+(w/Y).toFixed(6),y:+(P/Y).toFixed(6)}}function Fe(t,e,s){return t.baseFace&&s?{gaze:s.gaze,split:s.split,eyes:s.eyes}:{gaze:e.gaze,split:e.split,eyes:e.eyes}}function Be(t){const e=n=>JSON.stringify([n.gaze,n.split,n.eyes,n.sil.rot,n.sil.cx,n.sil.cy,n.sil.sx,n.sil.sy]);if(e(t.pose(0))===e(t.pose(t.duration)))return[0];const s=3;return Array.from({length:s},(n,i)=>i/(s-1)*t.duration)}function $e(t,e,s){const n=[];for(const i of Be(t)){const r=t.pose(i),o=at({...r.sil,radii:e},Y),l=at(r.sil,Y),c=Fe(t,r,s),p=[];for(const h of[-Tt,Tt])for(const f of[-vt,vt])p.push({...c,gaze:{yaw:c.gaze.yaw+h,pitch:c.gaze.pitch+f,roll:c.gaze.roll}});for(const h of p)n.push({empreintes:Ft(h,r.sil,e),reference:Ft(h,r.sil,r.sil.radii),contour:o,calContour:l})}return ve(n)}const it={x:0,y:0},ht=(t,e)=>`${t}|${e??""}`;function Ce(){return new Map(Zt.map(t=>{const e=new Map;for(const s of Ut){if(!s.baseBody)continue;const n=s.baseFace?[null,...Xt]:[null];for(const i of n)e.set(ht(s.id,i?.id??null),$e(s,t.radii,i))}return[t.radii,e]}))}const Le=Ce();function Ct(t,e,s){if(!t)return it;const n=Le.get(t);return n?n.get(ht(e,s))??n.get(ht(e,null))??it:it}const ot={yaw:0,pitch:0,mix:0,spin:0,wander:1},Ne=(t,e,s)=>({yaw:y(t.yaw,e.yaw,s),pitch:y(t.pitch,e.pitch,s),mix:y(t.mix,e.mix,s),spin:y(t.spin,e.spin,s),wander:y(t.wander,e.wander,s)}),Lt=(t,e,s)=>({w:y(t.w,e.w,s),h:y(t.h,e.h,s),open:y(t.open,e.open,s),tilt:y(t.tilt??0,e.tilt??0,s)});function Nt(t,e,s){const n=1-s;return{sil:ee(t.sil,e.sil,s),offX:y(t.offX,e.offX,s),offY:y(t.offY,e.offY,s),gaze:{yaw:y(t.gaze.yaw,e.gaze.yaw,s),pitch:y(t.gaze.pitch,e.gaze.pitch,s),roll:y(t.gaze.roll,e.gaze.roll,s)},split:y(t.split,e.split,s),eyes:[Lt(t.eyes[0],e.eyes[0],s),Lt(t.eyes[1],e.eyes[1],s)],eyeAlpha:y(t.eyeAlpha,e.eyeAlpha,s),bodyAlpha:y(t.bodyAlpha,e.bodyAlpha,s),dots:[...t.dots.map(i=>({...i,opacity:i.opacity*n})),...e.dots.map(i=>({...i,opacity:i.opacity*s}))],arcs:[...t.arcs.map(i=>({...i,id:`a${i.id}`,opacity:i.opacity*n})),...e.arcs.map(i=>({...i,id:`b${i.id}`,opacity:i.opacity*s}))],notif:s<.5?t.notif:e.notif,dotsBehind:s<.5?t.dotsBehind:e.dotsBehind}}class G{scale;cur;prev=null;departFige=null;tCur=0;tPrev=0;blinkAt=-10;pts=[];shape=null;shapePrev=null;shapeAt=-10;expr=null;exprPrev=null;exprAt=-10;look=ot;lookPrev=ot;lookAt=-10;lookMorph=.24;static SHAPE_MORPH=.45;static LOOK_MORPH=.24;constructor(e=100,s="idle",n=null,i=null){this.scale=e,this.cur=s,this.shape=n,this.expr=i}setExpression(e,s=0){e!==this.expr&&(this.exprPrev=this.expr,this.expr=e,this.exprAt=s)}exprAtTime(e){const s=this.expr,n=this.exprPrev;if(!s||!n)return s;const i=(e-this.exprAt)/G.SHAPE_MORPH;return i>=1?s:we(n,s,T.easeOutQuint(u(i)))}setShape(e,s=0){e!==this.shape&&(this.shapePrev=this.shape,this.shape=e,this.shapeAt=s)}shapeAtTime(e){const s=this.shape,n=this.shapePrev;if(!s||!n)return s;const i=(e-this.shapeAt)/G.SHAPE_MORPH;if(i>=1)return s;const r=T.easeOutQuint(u(i));return s.map((o,l)=>y(n[l]??o,o,r))}setLook(e,s,n=G.LOOK_MORPH){e&&!Number.isFinite(e.yaw+e.pitch+e.mix+e.spin+e.wander)||(this.lookPrev=this.lookAtTime(s),this.look=e??ot,this.lookAt=s,this.lookMorph=n)}lookAtTime(e){const s=(e-this.lookAt)/this.lookMorph;return s>=1?this.look:Ne(this.lookPrev,this.look,T.easeOutQuint(u(s)))}posed(e,s,n,i){let r=e.pose(s);return e.baseBody&&n&&(r={...r,sil:{...r.sil,radii:n}}),e.baseFace&&i&&(r={...r,gaze:i.gaze,split:i.split,eyes:i.eyes}),r}decalageAtTime(e,s){const n=(r,o,l,c)=>{if(l===c)return c;const p=(e-r)/o;if(p>=1)return c;const h=T.easeOutQuint(u(p));return{x:y(l.x,c.x,h),y:y(l.y,c.y,h)}},i=r=>n(this.exprAt,G.SHAPE_MORPH,Ct(r,s,this.exprPrev?.id??null),Ct(r,s,this.expr?.id??null));return n(this.shapeAt,G.SHAPE_MORPH,i(this.shapePrev),i(this.shape))}get state(){return this.cur}reset(e,s){this.cur=e,this.prev=null,this.departFige=null,this.tCur=s,this.tPrev=s,this.blinkAt=-10}origine(e,s,n){if(this.departFige)return this.departFige;if(!this.prev)return null;const i=Q.get(this.prev);return this.posed(i,Math.max(0,e-this.tPrev),s,n)}poseComposee(e){const s=Q.get(this.cur),n=this.shapeAtTime(e),i=this.exprAtTime(e),r=this.posed(s,Math.max(0,e-this.tCur),n,i),o=e-this.tCur;if(o>=s.morph)return r;const l=this.origine(e,n,i);return l?Nt(l,r,T.easeOutQuint(u(o/s.morph))):r}setState(e,s){if(e===this.cur)return;const n=Q.get(this.cur).morph,i=this.prev!==null&&s-this.tCur<n;this.departFige=i?this.poseComposee(s):null,this.prev=this.cur,this.tPrev=this.tCur,this.cur=e,this.tCur=s,Q.get(e)?.blinkIn&&(this.blinkAt=s)}sample(e){const s=this.scale,n=Q.get(this.cur),i=this.shapeAtTime(e),r=this.exprAtTime(e);let o=this.posed(n,Math.max(0,e-this.tCur),i,r),l=this.decalageAtTime(e,this.cur);const c=e-this.tCur,p=c<n.morph?this.origine(e,i,r):null;if(p){const b=T.easeOutQuint(u(c/n.morph));o=Nt(p,o,b);const N=this.prev;if(N){const z=this.decalageAtTime(e,N);l={x:y(z.x,l.x,b),y:y(z.y,l.y,b)}}}const h=o.eyeAlpha>.01,f=this.lookAtTime(e),M=be(e,{wander:h?f.wander:0,blink:h}),k={yaw:y(o.gaze.yaw,f.yaw,f.mix)+M.dYaw-f.spin,pitch:y(o.gaze.pitch,f.pitch,f.mix)+M.dPitch,roll:o.gaze.roll+M.dRoll},A=u((e-this.blinkAt)/.2),w=A<1?Math.abs(A*2-1):1,P=Math.min(M.lid,w),x=o.offX+M.driftX,m=o.offY+M.driftY,g={...o.sil,cx:o.sil.cx+x,cy:o.sil.cy+m,sy:o.sil.sy*M.breath},d=Jt(at(g,s,this.pts)),C=(b,N)=>jt(o.sil.radii,Math.atan2(N,b)-o.sil.rot),v=[];if(o.eyeAlpha>.01){const b=Ht(k,s,o.split);for(let N=0;N<2;N++){const z=b[N];if(z.depth<=.02)continue;const K=o.eyes[N],dt=C(z.x,z.y),ft=(K.tilt??0)*Math.PI/180,W=Math.cos(ft),Z=Math.sin(ft),Qt=z.a*W+z.c*Z,Vt=z.b*W+z.d*Z,qt=-z.a*Z+z.c*W,Kt=-z.b*Z+z.d*W,yt=Ae(Math.min(P,K.open));v.push({d:te(K.w*s,K.h*s),matrix:`matrix(${$(Qt)},${$(Vt*yt)},${$(qt)},${$(Kt*yt)},${$(z.x*dt+(x+l.x)*s)},${$(z.y*dt+(m+l.y)*s)})`,alpha:o.eyeAlpha*u(z.depth/.12)})}}const R=o.dots.filter(b=>b.opacity>.01&&b.r>5e-4).map(b=>({...b,x:(b.x+x)*s,y:(b.y+m)*s,r:b.r*s})),a=o.notif?C(o.notif.x,o.notif.y):1,O=o.notif?(o.notif.x*a+x)*s:0,E=o.notif?(o.notif.y*a+m)*s:0,V=o.notif?{x:O,y:E,r:o.notif.r*s}:null,q=o.notif?{x:O,y:E,r:o.notif.notch*s}:null;return{bodyPath:d,bodyAlpha:o.bodyAlpha,eyes:v,dots:R,dotsBehind:o.dotsBehind,arcs:o.arcs.filter(b=>b.opacity>.01).map(b=>ae(b.seed,b.t,s,b.id,b.opacity)),notif:V,notch:q}}}const Dt=100,De=158,B=De,Ye=1e3/30,je=34;function He(){const[t,e]=_.useState(()=>typeof document>"u"?!1:document.documentElement.classList.contains("dark"));return _.useEffect(()=>{if(typeof MutationObserver!="function")return;const s=document.documentElement,n=new MutationObserver(()=>e(s.classList.contains("dark")));return n.observe(s,{attributes:!0,attributeFilter:["class"]}),()=>n.disconnect()},[]),t}function Xe(){const[t,e]=_.useState(()=>typeof document>"u"?!0:document.visibilityState!=="hidden");return _.useEffect(()=>{if(typeof document>"u")return;const s=()=>e(document.visibilityState!=="hidden");return document.addEventListener("visibilitychange",s),()=>document.removeEventListener("visibilitychange",s)},[]),t}function Ge(){const[t,e]=_.useState(()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches);return _.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const s=window.matchMedia("(prefers-reduced-motion: reduce)"),n=i=>e(i.matches);return s.addEventListener("change",n),()=>s.removeEventListener("change",n)},[]),t}function hs({state:t="idle-living",dragState:e=null,size:s=48,className:n="",leanX:i=0,shape:r=ie,color:o="auto",paper:l=null}){const c=oe(e==="running-left"||e==="running-right"?e:t),p=Ge(),h=Xe(),f=He(),M=l||(f?xt.dark:xt.light),k=se.get(ne(o,f)).hex,A=_.useId(),w=_.useMemo(()=>A.replace(/[^a-zA-Z0-9_-]/g,""),[A]),P=`bot-mask-${w}`,x=_.useRef(null);x.current===null&&(x.current=new G(Dt,c.state,mt.get(r)?.radii??null,Ot.get(c.expression)??null));const m=x.current,g=_.useRef(0),[d,C]=_.useState(()=>m.sample(0));_.useEffect(()=>{m.setShape(mt.get(r)?.radii??null,g.current)},[m,r]),_.useEffect(()=>{m.setExpression(Ot.get(c.expression)??null,g.current)},[m,c.expression]),_.useEffect(()=>{m.state!==c.state&&(m.setState(c.state,g.current),C(m.sample(g.current)))},[m,c.state]),_.useEffect(()=>{const a=Math.min(1,Math.abs(i));if(a<=0||!Q.get(c.state)?.baseFace){m.setLook(null,g.current);return}m.setLook({yaw:i*je,pitch:st.pitch,mix:a,spin:0,wander:1-a},g.current)},[m,i,c.state]),_.useEffect(()=>{if(p||!h)return;let a=0,O=0,E=0;const V=q=>{a=requestAnimationFrame(V);const b=O?Math.min((q-O)/1e3,.064):0;O=q,g.current+=b,E+=b*1e3,!(E<Ye)&&(E=0,C(m.sample(g.current)))};return a=requestAnimationFrame(V),()=>cancelAnimationFrame(a)},[m,p,h]);const v=a=>{const E={fill:a.color??(a.depth===void 0?k:re(M,k,a.depth)),opacity:a.opacity};return a.d?{...E,d:a.d,transform:`translate(${a.x} ${a.y}) rotate(${a.rot??0}) scale(${Dt})`}:{...E,cx:a.x,cy:a.y,r:a.r}},R=d.dots.map((a,O)=>{const E=v(a);return a.d?I.jsx("path",{...E},O):I.jsx("circle",{...E},O)});return I.jsxs("svg",{"aria-hidden":"true",className:`bot-animated ${n}`,width:s,height:s,viewBox:`${-B} ${-B} ${B*2} ${B*2}`,children:[I.jsxs("defs",{children:[I.jsxs("mask",{id:P,maskUnits:"userSpaceOnUse",x:-B,y:-B,width:B*2,height:B*2,children:[I.jsx("path",{d:d.bodyPath,fill:"#fff"}),d.eyes.map((a,O)=>I.jsx("path",{d:a.d,transform:a.matrix,opacity:a.alpha,fill:"#000"},O)),d.notch?I.jsx("circle",{cx:d.notch.x,cy:d.notch.y,r:d.notch.r,fill:"#000"}):null]}),d.arcs.map(a=>I.jsx("linearGradient",{id:`${w}-${a.id}`,gradientUnits:"userSpaceOnUse",x1:a.grad.x1,y1:a.grad.y1,x2:a.grad.x2,y2:a.grad.y2,children:a.grad.stops.map((O,E)=>I.jsx("stop",{offset:E/(a.grad.stops.length-1),stopColor:O},E))},a.id))]}),I.jsx("g",{fill:"none",strokeLinecap:"round",children:d.arcs.map(a=>I.jsx("path",{d:a.back,stroke:`url(#${w}-${a.id})`,strokeWidth:a.width,opacity:a.opacity},a.id))}),d.dotsBehind?I.jsx("g",{children:R}):null,I.jsxs("g",{opacity:d.bodyAlpha,children:[I.jsx("path",{d:d.bodyPath,fill:M}),I.jsx("g",{mask:`url(#${P})`,children:I.jsx("rect",{x:-B,y:-B,width:B*2,height:B*2,fill:k})})]}),d.dotsBehind?null:I.jsx("g",{children:R}),d.notif?I.jsx("circle",{cx:d.notif.x,cy:d.notif.y,r:d.notif.r,fill:de}):null,I.jsx("g",{fill:"none",strokeLinecap:"round",children:d.arcs.map(a=>I.jsx("path",{d:a.front,stroke:`url(#${w}-${a.id})`,strokeWidth:a.width,opacity:a.opacity},`f${a.id}`))})]})}export{hs as BotAnimated};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as r,y as t}from"./__vite-browser-external-
|
|
1
|
+
import{j as r,y as t}from"./__vite-browser-external-Go6WKt6Z.js";function c({children:i,title:a,subtitle:o,className:s="",bodyClassName:d="",...e}){return r.jsxs("div",{...e,className:t("rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 transition-colors duration-200",s),children:[(a||o)&&r.jsxs("div",{className:"px-5 py-4 border-b border-oai-gray-200 dark:border-oai-gray-800 transition-colors duration-200",children:[a&&r.jsx("h3",{className:"text-sm font-medium text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wide transition-colors duration-200",children:a}),o&&r.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-300 mt-1 transition-colors duration-200",children:o})]}),r.jsx("div",{className:`p-5 ${d}`,children:i})]})}export{c as C};
|
package/dashboard/dist/assets/{CloudCheckoutPage-BSYvxA_x.js → CloudCheckoutPage-BY9Hsbix.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as nt,d as ct,u as it,r as o,e as ot,a0 as lt,a1 as dt,a2 as ut,a3 as mt,a4 as Te,c as t,t as ht,v as xt,p as ft,a5 as ee,a6 as Me,a7 as pt,j as e,B as x,a8 as je,L as w,a9 as E,aa as gt,ab as _t,ac as kt,ad as yt,ae as bt,af as vt,ag as wt}from"./__vite-browser-external-CbhiyufG.js";import{c as fe,r as pe,C as Ne,a as jt,g as Nt,s as ze,o as $e,b as Ct}from"./cloud-checkout-DNFMqoiZ.js";import{d as It}from"./os-DMmhX9tk.js";import{C as St}from"./Card-D_SqQIBC.js";import{T as Lt}from"./Controls-DsJLsMpr.js";import{CloudPlanView as Rt}from"./CloudPage-Bwnj7Ocg.js";import{L as Ue}from"./loader-circle-BEowiVYF.js";import{S as Et}from"./shield-check-DkJ3sCHH.js";import{E as Pt}from"./external-link-DgnNV6zS.js";import{A as Fe}from"./arrow-left-Cu0jOgzo.js";import"./arrow-right-DgFuyz9F.js";import"./chevron-down-Di_xdF9P.js";import"./server-DKLG1DuM.js";import"./check-D_enaDhp.js";const He={name:"circle-check",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 9-5.5 5.5L8 12",key:"xofnsj"}]],aliases:["check-circle-2"]};He.node;const At=nt(He);function Kt(){const H=ct(),{openLoginModal:te}=it(),re=o.useRef(null),[P,A]=ot();o.useEffect(()=>{if(!P.has("_ptxn"))return;const a=new URLSearchParams(P);a.delete("_ptxn"),A(a,{replace:!0})},[P,A]);const{catalog:S,loading:_,error:j,refresh:Ce}=lt(),{account:f,auth:k,loading:G,error:U,refresh:q}=dt(),s=P.get("order")||"",L=P.get("intent")==="trial",Ge=P.get("sku"),u=`/billing/checkout?${P}`,[V,ae]=o.useState(null),[h,Ie]=o.useState(!1),[ge,_e]=o.useState(!!s),[Se,Q]=o.useState(null),[ke,Ve]=o.useState(null),[se,ye]=o.useState(null),[We,Le]=o.useState(!1),[X,Re]=o.useState(null),ne=o.useRef(null),ce=o.useRef(!1),Y=o.useRef(0),be=o.useRef(null),y=o.useRef(!0),r=k?.signedIn?k.user?.id:null,i=ut(),T=o.useRef(i);T.current=i;const Ee=o.useRef(s);Ee.current=s;const N=o.useRef(r);N.current=r;const ie=V?.ownerId===r&&V?.backend===i&&(s?V.order?.id?.toLowerCase()===s.toLowerCase():!V.verified&&V.createdFrom===u)?V:null,Pe=ke?.ownerId===r&&ke?.backend===i?ke:null,Je=se?.ownerId===r&&se?.backend===i&&se?.orderId===s?se.error:null,R=Se||Je,n=ie?.order,p=Pe||ie?.membership||f?.membership,B=S?.policy?.hosting_mode==="self_hosted"||p?.status==="self_hosted",M=n?.sku||Ge,m=S?.prices?.find(a=>a.sku===M),Ke=n?.currency||m?.currency,Qe=n?.amount_cents??m?.amount_cents,C=n?.billing_mode||m?.billing_mode,Xe=n?.term_months||m?.term_months,F=n?.provider||"waffo",l=Pe?"trial_success":h&&!n?"creating":fe(n,p),g=mt(S),I=!!S?.providers?.[F],b=!!(n?.retry_payment_conflict_at||[...f?.conflict_orders||[],...f?.pending_orders||[]].some(a=>a.retry_payment_conflict_at)),W=p?.has_gift===!0||p?.access_source==="gift"||f?.membership?.has_gift===!0||f?.gifts?.some(a=>["active","pending"].includes(a.state)),Ye=n?.provider==="waffo"&&n.payment_state==="unpaid"&&n.status!=="paid"&&["awaiting","expired","canceled"].includes(l)&&g&&I&&!b&&!W,z=k?.getAccessToken,v=pe(r),oe=f?.subscriptions?.some(a=>["active","trialing","past_due","paused"].includes(a.status)&&!a.cancel_at_period_end),le=p?.status==="active"||f?.payments?.some(a=>a.refunded_cents<a.amount_cents&&Date.parse(a.ends_at)>Date.now()),Ae=["fixed","recurring"].includes(m?.billing_mode)?S?.prices?.find(a=>a.currency===m.currency&&a.term_months===m.term_months&&a.billing_mode===(m.billing_mode==="recurring"?"fixed":"recurring")):null,qe=!!(r&&p&&!k?.loading&&!G&&!U&&l==="review"&&!L&&!s&&!n&&!h&&g&&I&&!_&&!j&&Ae&&!le&&!W&&!oe&&!b&&!v?.request_id&&!v?.order_id&&!f?.pending_orders?.length),Ze=()=>{if(!qe||ce.current)return;const a=pe(r);if(a?.request_id||a?.order_id)return;const c=new URLSearchParams(P);c.set("sku",Ae.sku),A(c,{replace:!0})},et=Te(u,r)||(X?.nextPath===u&&X?.ownerId===r&&X?.backend===i?X:null),de=t(L?"cloud.login.trial_context":"cloud.login.purchase_context");o.useEffect(()=>{if(r){re.current=null;return}k?.loading||_||B||re.current===u||(re.current=u,te({nextPath:u,subtitle:de,closePath:"/cloud"}))},[r,k?.loading,_,B,u,de,te]);const Be=S?.environment==="live"&&!L&&P.getAll("order").length===1&&Ne.test(s)&&["mac","windows"].includes(It())&&!(navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1)&&!ht()&&!xt()&&!ft()?`tokentracker://billing/return?order=${s.toLowerCase()}`:null;o.useEffect(()=>(y.current=!0,()=>{y.current=!1}),[]);const J=o.useCallback(async()=>{if(B||!s||!r||N.current!==r)return null;if(!Ne.test(s))return Q({code:"order_not_found"}),_e(!1),null;const a=++Y.current;try{const c=await ee("order",{auth:z,params:{id:s}});if(a!==Y.current||N.current!==r||T.current!==i)return null;ae({...c,ownerId:r,backend:i,verified:!0}),Q(null);const d=fe(c.order,c.membership);if(d==="success"&&ye(null),["success","refunded"].includes(d)){const $=`${r}:${s}:${d}`;be.current!==$&&(be.current=$,q())}if(["success","expired","canceled","refunded"].includes(fe(c.order,c.membership))){const $=pe(r),K=c.order.payment_state==="unpaid"&&c.order.status!=="paid"&&["expired","canceled"].includes(fe(c.order,c.membership))&&$?.retry_order_id===s&&$?.retry_request_id;$?.order_id===s&&!K&&jt(r)}return c}catch(c){return a===Y.current&&Q(c),null}finally{a===Y.current&&_e(!1)}},[s,r,z,B,q,i]);o.useEffect(()=>(ae(null),Q(null),be.current=null,_e(!!(s&&r)),J(),()=>{Y.current+=1}),[J,s,r]),o.useEffect(()=>{if(B||!s||!r||["success","canceled","expired","refunded"].includes(l))return;const a=()=>{document.visibilityState==="visible"&&J()},c=window.setInterval(a,5e3);return window.addEventListener("focus",a),document.addEventListener("visibilitychange",a),()=>{window.clearInterval(c),window.removeEventListener("focus",a),document.removeEventListener("visibilitychange",a)}},[s,r,l,J,B]);const D=o.useCallback(async a=>{if(!ce.current){ce.current=!0,Ie(!0),Q(null),ye(null);try{await a()}catch(c){y.current&&N.current===r&&T.current===i&&ye({ownerId:r,backend:i,orderId:s,error:c})}finally{ce.current=!1,y.current&&Ie(!1)}}},[r,s,i]),ue=o.useCallback((a=!1)=>D(async()=>{const c=Nt(r,M,F),d=await ee("checkout",{auth:z,body:{sku:M,provider:F,request_id:c.request_id,mobile:window.matchMedia("(max-width: 640px)").matches}});T.current===i&&(ze(r,{...c,order_id:d.order.id}),!(!y.current||N.current!==r)&&(a===!0&&(ne.current={ownerId:r,backend:i,orderId:d.order.id,opened:!1}),ae({...d,ownerId:r,backend:i,createdFrom:u,order:{...m,provider:F,...d.order}}),A({order:d.order.id},{replace:!0})))}),[D,r,M,F,z,m,A,i,u]),me=o.useCallback((a=!1)=>D(async()=>{let c;try{c=await ee("trial",{auth:z,body:{}})}catch(d){if(a===!0&&(d.code||d.message)==="trial_unavailable"){y.current&&N.current===r&&T.current===i&&(await q(),y.current&&N.current===r&&T.current===i&&H("/cloud",{replace:!0}));return}throw d}!y.current||N.current!==r||T.current!==i||(Ve({...c.membership,ownerId:r,backend:i}),a===!0?(await q(),y.current&&N.current===r&&T.current===i&&H("/dashboard",{replace:!0})):q())}),[D,z,r,q,H,i]);o.useEffect(()=>{const a=Te(u,r);if(!a||!r||h||k?.loading||G||U||_||j||!p||B||!g)return;if(a.orderId){if(a.orderId!==s)return;const xe=Me(u,r);if(!xe)return;Re({...xe,ownerId:r}),b||(ne.current={ownerId:r,backend:i,orderId:s,opened:!1});return}if(s||!a.trial&&(!m||!I||!C))return;const c=Me(u,r);if(!c)return;if(Re({...c,ownerId:r}),a.trial){if(p.trial_available)me(!0);else{const xe=p.can_read_cloud||["active","trial","transition"].includes(p.status);H(xe?"/dashboard":"/cloud",{replace:!0})}return}if(W||oe||le&&C!=="fixed"||b){H("/settings?section=cloud",{replace:!0});return}const d=pe(r),$=f?.pending_orders?.[0],K=d?.order_id||$?.id;K&&Ne.test(K)?(ne.current={ownerId:r,backend:i,orderId:K,opened:!1},A({order:K},{replace:!0})):d?.request_id&&(d.sku!==M||d.provider!==F)?A({sku:d.sku},{replace:!0}):ue(!0)},[u,r,s,h,k?.loading,G,U,_,j,p,B,g,m,I,C,W,oe,le,b,f?.pending_orders,M,F,me,ue,H,A,i]),o.useEffect(()=>{const a=ne.current;!a||a.opened||a.ownerId!==r||a.backend!==i||a.orderId!==s||!ie?.verified||n?.id?.toLowerCase()!==s.toLowerCase()||!n?.checkout_url||l!=="awaiting"||h||!g||!I||b||(a.opened=!0,D(()=>$e(n.checkout_url,{sameTab:!0})))},[r,s,n?.id,n?.checkout_url,ie?.verified,X?.nextPath,l,h,g,I,b,D,i]);const De=()=>D(async()=>{await ee("reconcile",{auth:z,body:{id:s}}),!(!y.current||N.current!==r)&&(await J(),await q())}),tt=()=>D(async()=>{const a=Ct(r,n);Le(!0);try{const c=await ee("restart-checkout",{auth:z,body:{id:n.id,request_id:a.retry_request_id}});if(ze(r,{sku:n.sku,provider:n.provider,request_id:a.retry_request_id,order_id:c.order.id}),!y.current||N.current!==r||Ee.current!==n.id)return;ae({...c,ownerId:r,backend:i}),A({order:c.order.id},{replace:!0})}finally{y.current&&Le(!1)}}),rt=()=>D(async()=>{await $e(n.checkout_url)}),ve=S?.limits?.trial_days||7,we=wt(),Z=we&&!pt(),at=new Date(Date.now()+ve*864e5).toISOString(),he=L?t("cloud.checkout.starting_trial"):t("cloud.checkout.creating"),st={review:L?t("cloud.checkout.trial_title"):t("cloud.checkout.title"),creating:he,awaiting:t("cloud.checkout.awaiting"),activating:t("cloud.checkout.activating"),success:t("cloud.checkout.success"),canceled:t("cloud.checkout.canceled"),expired:n?.status==="paid"?t("cloud.checkout.term_ended"):t("cloud.checkout.expired"),refunded:t("cloud.checkout.refunded"),trial_success:t("cloud.checkout.trial_success")};let O=null;if(!r)O=e.jsx("div",{className:"space-y-5",children:e.jsx(x,{onClick:()=>te({nextPath:u,subtitle:de,closePath:"/cloud"}),className:"w-full",disabled:k?.loading,children:t("cloud.action.sign_in_continue")})});else if(ge||h&&!n)O=e.jsxs("p",{role:"status",className:"flex items-center gap-2 text-sm",children:[e.jsx(Ue,{className:"motion-safe:animate-spin",size:17,"aria-hidden":!0}),ge?t("cloud.checkout.loading"):he]});else if(l==="trial_success"||l==="success")O=e.jsxs("div",{className:"space-y-5",children:[e.jsx(At,{size:32,className:"text-oai-gray-700 dark:text-oai-gray-200","aria-hidden":!0}),e.jsx("p",{className:"text-sm leading-6",children:l==="trial_success"?t("cloud.trial.ends",{date:je(p.trial_ends_at)}):t("cloud.membership.expires",{date:je(p.expires_at)})}),Z||!we?e.jsx("p",{className:"text-sm leading-6 text-oai-gray-500 dark:text-oai-gray-400",children:t(we?"cloud.onboarding.local_next":"cloud.onboarding.web_next")}):null,e.jsx(x,{as:w,to:Z?"/settings?section=cloud":"/dashboard",className:"w-full no-underline",children:t(Z?"cloud.action.setup_sync":"cloud.action.open_dashboard")}),e.jsx(w,{to:Z?"/dashboard":"/settings?section=cloud",className:"flex min-h-10 items-center justify-center text-sm underline underline-offset-4",children:t(Z?"cloud.action.open_dashboard":"cloud.action.manage_membership")})]});else if(l==="review"&&!s&&W)O=e.jsxs("div",{className:"space-y-5",children:[e.jsx(E,{children:t("cloud.gift.error_active")}),e.jsx(x,{as:w,to:"/settings?section=cloud",variant:"secondary",className:"w-full no-underline",children:t("cloud.action.manage_membership")})]});else if(l==="review"&&!s&&L)O=e.jsxs("div",{className:"space-y-5",children:[e.jsx("p",{className:"text-sm leading-6",children:t("cloud.trial.disclosure",{days:ve,date:je(at)})}),e.jsx("p",{className:"text-sm leading-6 text-oai-gray-500 dark:text-oai-gray-400",children:t("cloud.trial.expiry")}),f?.membership&&!f.membership.trial_available?e.jsxs("div",{className:"space-y-3",children:[e.jsx(E,{children:t("cloud.error.trial")}),m?null:e.jsx(x,{as:w,to:"/cloud",variant:"secondary",className:"w-full no-underline",children:t("cloud.action.view_plans")})]}):null,e.jsx(x,{onClick:me,disabled:h||!g||!f?.membership?.trial_available,className:"w-full",children:t("cloud.action.start_trial",{days:ve})}),m&&g&&I&&!h?e.jsx(x,{as:w,to:`/billing/checkout?sku=${encodeURIComponent(m.sku)}`,variant:"ghost",className:"mx-auto flex w-fit no-underline",children:t("cloud.plan.skip_trial")}):null]});else if(l==="review"&&!s&&m)O=e.jsxs("div",{className:"space-y-5",children:[e.jsx("p",{className:"text-sm leading-6",children:t("cloud.checkout.review")}),e.jsxs("p",{className:"inline-flex items-center gap-2 text-sm",children:[e.jsx(Et,{size:16,"aria-hidden":!0}),t("cloud.checkout.waffo")]}),C?e.jsx("p",{className:"text-sm leading-6 text-oai-gray-500 dark:text-oai-gray-400",children:C==="fixed"?t("cloud.checkout.methods_fixed"):t("cloud.checkout.methods_recurring")}):null,C?e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx("p",{className:"text-sm leading-6 text-oai-gray-500 dark:text-oai-gray-400",children:C==="fixed"?t("cloud.renewal.manual"):t("cloud.renewal.auto")}),qe?e.jsx(Lt,{checked:C==="recurring",onChange:Ze,ariaLabel:t("cloud.billing_mode.recurring")}):null]}):null,v?.order_id?e.jsx(x,{as:w,to:`/billing/checkout?order=${encodeURIComponent(v.order_id)}`,className:"w-full no-underline",children:t("cloud.action.resume_order")}):null,v?.request_id&&!v.order_id&&v.sku!==M?e.jsx(x,{as:w,to:`/billing/checkout?sku=${encodeURIComponent(v.sku)}`,className:"w-full no-underline",children:t("cloud.action.resume_purchase")}):null,!v?.order_id&&!(v?.request_id&&v.sku!==M)?e.jsx(x,{onClick:ue,disabled:h||!g||!I||!C||!!v?.order_id||b,className:"w-full",children:t("cloud.action.create_checkout",{amount:gt(Qe,Ke)})}):null]});else if(n){const a={creating:t("cloud.checkout.pending_creation"),awaiting:t("cloud.checkout.pending_payment"),activating:t("cloud.checkout.received"),expired:n?.status==="paid"?t("cloud.checkout.term_ended_detail"):t("cloud.checkout.expired_detail"),canceled:t("cloud.checkout.canceled_detail"),refunded:t("cloud.checkout.refunded_detail")};O=e.jsxs("div",{className:"space-y-5",children:[e.jsx("p",{className:"text-sm leading-6 text-oai-gray-500 dark:text-oai-gray-400",children:a[l]}),l==="awaiting"&&n.checkout_url&&g&&I&&!b?e.jsxs(x,{onClick:rt,disabled:h,className:"w-full",children:[t("cloud.action.open_payment"),e.jsx(Pt,{size:15,className:"ml-2","aria-hidden":!0})]}):null,l!=="refunded"?e.jsxs(e.Fragment,{children:[e.jsx(x,{onClick:De,disabled:h,variant:"ghost",className:"mx-auto flex underline underline-offset-4",children:h?t("cloud.action.checking"):t("cloud.action.check_payment")}),e.jsx("p",{className:"text-xs leading-5 text-oai-gray-500 dark:text-oai-gray-400",children:t("cloud.checkout.recovery_hint")})]}):null,Ye?e.jsxs("details",{open:l!=="awaiting",className:"border-t border-oai-gray-200 pt-4 dark:border-oai-gray-800",children:[e.jsx("summary",{className:"min-h-10 cursor-pointer text-sm font-medium leading-10 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2",children:t("cloud.checkout.help_title")}),e.jsxs("div",{className:"space-y-3 pt-2",children:[e.jsx("p",{className:"text-xs leading-5 text-oai-gray-500 dark:text-oai-gray-400",children:t("cloud.checkout.restart_detail")}),e.jsx(x,{onClick:tt,disabled:h,variant:l==="awaiting"?"secondary":"primary",className:"w-full",children:We?t("cloud.action.restarting_checkout"):t("cloud.action.restart_checkout")})]})]}):null,["canceled","expired"].includes(l)&&!b?e.jsx(w,{to:"/cloud",className:"flex min-h-10 items-center justify-center text-sm underline underline-offset-4",children:n.status==="paid"?t("cloud.action.renew"):t("cloud.action.choose_plan")}):null,l==="refunded"?e.jsx(x,{as:w,to:"/settings?section=cloud",className:"w-full no-underline",children:t("cloud.action.manage_membership")}):null,e.jsxs("details",{className:"border-t border-oai-gray-200 pt-4 dark:border-oai-gray-800",children:[e.jsxs("summary",{className:"min-h-10 cursor-pointer text-xs leading-10 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2",children:[t("cloud.checkout.order_id")," · ",n.id.slice(0,8)]}),e.jsx("p",{className:"mb-2 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:_t(n.provider)}),e.jsx("p",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400",children:t("cloud.checkout.order_id")}),e.jsx("p",{className:"mt-1 break-all font-mono text-xs select-all",children:n.id}),n.status!=="paid"&&n.expires_at?e.jsx("p",{className:"mt-2 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:t("cloud.checkout.expires",{date:kt(n.expires_at)})}):null]})]})}else O=e.jsx(E,{children:s?t("cloud.error.order_not_found"):t("cloud.checkout.choose_plan")});const Oe=e.jsxs("div",{className:"space-y-3",children:[R?e.jsx(E,{error:R,onRetry:s?Se?J:De:void 0}):null,R&&["subscription_already_exists","fixed_term_still_active","checkout_request_conflict","pending_checkout_exists","gift_membership_active"].includes(R.code||R.message)?e.jsx(x,{as:w,to:"/settings?section=cloud",variant:"secondary",className:"no-underline",children:t("cloud.action.manage_membership")}):null,R&&["authentication_required","invalid_token","invalid_authentication"].includes(R.code||R.message)?e.jsx(x,{onClick:async()=>{await k?.signOut?.(),re.current=u,te({nextPath:u,subtitle:de,closePath:"/cloud"})},variant:"secondary",children:t("cloud.action.sign_in_continue")}):null,j?e.jsx(E,{error:j,onRetry:Ce}):null,U?e.jsx(E,{error:U,onRetry:q}):null,!j&&_?e.jsx(E,{children:t("cloud.catalog.loading")}):null,!j&&!_&&!g?e.jsx(E,{children:t("cloud.catalog.preview")}):null,!j&&!_&&g&&!L&&!R&&!I&&["review","creating","awaiting"].includes(l)?e.jsx(E,{children:t("cloud.catalog.provider_unavailable")}):null,!j&&!_&&g&&S?.environment==="sandbox"?e.jsx(E,{children:t("cloud.catalog.sandbox")}):null]});return B?e.jsx(yt,{}):!r&&!s?e.jsx(e.Fragment,{children:e.jsx(Rt,{catalogState:{catalog:S,loading:_,error:j,refresh:Ce},accountState:{account:f,auth:k,loading:G,error:U,refresh:q},selection:{termMonths:Xe,billingMode:C}})}):et&&r&&!s?e.jsx("div",{className:"tt-cloud-theme flex flex-1 flex-col font-oai text-oai-black dark:text-oai-white",children:e.jsxs("main",{className:"mx-auto w-full max-w-lg px-4 py-12 sm:px-6",children:[e.jsxs(w,{to:"/cloud",onClick:()=>bt(u),className:"mb-6 inline-flex min-h-10 items-center gap-2 text-sm text-oai-gray-500 dark:text-oai-gray-400",children:[e.jsx(Fe,{size:16,"aria-hidden":!0}),t("cloud.checkout.back")]}),e.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:he}),h||k?.loading||_||G?e.jsxs("p",{role:"status",className:"mt-5 flex items-center gap-2 text-sm text-oai-gray-500 dark:text-oai-gray-400",children:[e.jsx(Ue,{className:"motion-safe:animate-spin",size:17,"aria-hidden":!0}),he]}):null,e.jsx("div",{className:"mt-5",children:Oe}),R&&!h?e.jsx(x,{onClick:()=>L?me(!0):ue(!0),disabled:G||!!U||_||!!j||!g||(L?!p?.trial_available:!m||!I||b||W||le&&C!=="fixed"||oe),className:"mt-5 w-full",children:t("cloud.action.retry")}):null]})}):e.jsx("div",{className:"tt-cloud-theme flex flex-1 flex-col font-oai text-oai-black dark:text-oai-white",children:e.jsxs("main",{className:"mx-auto w-full max-w-xl px-4 py-8 sm:px-6 sm:py-12",children:[e.jsxs(w,{to:"/cloud",className:"mb-7 inline-flex min-h-10 items-center gap-2 text-sm text-oai-gray-500 dark:text-oai-gray-400 hover:text-oai-brand focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand",children:[e.jsx(Fe,{size:16,"aria-hidden":!0}),t("cloud.checkout.back")]}),e.jsx("h1",{className:"text-3xl font-semibold tracking-tight","aria-live":"polite",children:ge?t("cloud.checkout.loading"):st[l]}),S?.environment==="sandbox"&&!L?e.jsx("p",{className:"mt-2 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:t("cloud.price.draft")}):null,b?e.jsx("div",{className:"mt-5",children:e.jsx(vt,{})}):null,e.jsx("div",{className:"mt-7",children:e.jsxs(St,{bodyClassName:"sm:p-7",children:[O,Be?e.jsxs("div",{className:"mt-5 space-y-3 border-t border-oai-gray-200 pt-5 dark:border-oai-gray-800",children:[e.jsx("p",{className:"text-sm leading-6 text-oai-gray-500 dark:text-oai-gray-400",children:t("cloud.checkout.return_app_hint")}),e.jsx("a",{href:Be,className:"inline-flex min-h-10 items-center text-sm underline underline-offset-4",children:t("cloud.action.open_app")})]}):null]})}),e.jsx("div",{className:"mt-5",children:Oe})]})})}export{Kt as CloudCheckoutPage};
|
|
1
|
+
import{o as nt,d as ct,u as it,r as o,e as ot,a0 as lt,a1 as dt,a2 as ut,a3 as mt,a4 as Te,c as t,t as ht,v as xt,p as ft,a5 as ee,a6 as Me,a7 as pt,j as e,B as x,a8 as je,L as w,a9 as E,aa as gt,ab as _t,ac as kt,ad as yt,ae as bt,af as vt,ag as wt}from"./__vite-browser-external-Go6WKt6Z.js";import{c as fe,r as pe,C as Ne,a as jt,g as Nt,s as ze,o as $e,b as Ct}from"./cloud-checkout-CoRQjKEu.js";import{d as It}from"./os-DMmhX9tk.js";import{C as St}from"./Card-BHHCCnqR.js";import{T as Lt}from"./Controls-CQlxw03i.js";import{CloudPlanView as Rt}from"./CloudPage-Y6JgOXcJ.js";import{L as Ue}from"./loader-circle-B9GqzQyC.js";import{S as Et}from"./shield-check-ByUPtUmu.js";import{E as Pt}from"./external-link-DZWnR9gS.js";import{A as Fe}from"./arrow-left--eOVP_Dk.js";import"./arrow-right-DJYhwBMz.js";import"./chevron-down-CbJ2QGDU.js";import"./server-DtMUoEq0.js";import"./check-UztXSVYi.js";const He={name:"circle-check",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 9-5.5 5.5L8 12",key:"xofnsj"}]],aliases:["check-circle-2"]};He.node;const At=nt(He);function Kt(){const H=ct(),{openLoginModal:te}=it(),re=o.useRef(null),[P,A]=ot();o.useEffect(()=>{if(!P.has("_ptxn"))return;const a=new URLSearchParams(P);a.delete("_ptxn"),A(a,{replace:!0})},[P,A]);const{catalog:S,loading:_,error:j,refresh:Ce}=lt(),{account:f,auth:k,loading:G,error:U,refresh:q}=dt(),s=P.get("order")||"",L=P.get("intent")==="trial",Ge=P.get("sku"),u=`/billing/checkout?${P}`,[V,ae]=o.useState(null),[h,Ie]=o.useState(!1),[ge,_e]=o.useState(!!s),[Se,Q]=o.useState(null),[ke,Ve]=o.useState(null),[se,ye]=o.useState(null),[We,Le]=o.useState(!1),[X,Re]=o.useState(null),ne=o.useRef(null),ce=o.useRef(!1),Y=o.useRef(0),be=o.useRef(null),y=o.useRef(!0),r=k?.signedIn?k.user?.id:null,i=ut(),T=o.useRef(i);T.current=i;const Ee=o.useRef(s);Ee.current=s;const N=o.useRef(r);N.current=r;const ie=V?.ownerId===r&&V?.backend===i&&(s?V.order?.id?.toLowerCase()===s.toLowerCase():!V.verified&&V.createdFrom===u)?V:null,Pe=ke?.ownerId===r&&ke?.backend===i?ke:null,Je=se?.ownerId===r&&se?.backend===i&&se?.orderId===s?se.error:null,R=Se||Je,n=ie?.order,p=Pe||ie?.membership||f?.membership,B=S?.policy?.hosting_mode==="self_hosted"||p?.status==="self_hosted",M=n?.sku||Ge,m=S?.prices?.find(a=>a.sku===M),Ke=n?.currency||m?.currency,Qe=n?.amount_cents??m?.amount_cents,C=n?.billing_mode||m?.billing_mode,Xe=n?.term_months||m?.term_months,F=n?.provider||"waffo",l=Pe?"trial_success":h&&!n?"creating":fe(n,p),g=mt(S),I=!!S?.providers?.[F],b=!!(n?.retry_payment_conflict_at||[...f?.conflict_orders||[],...f?.pending_orders||[]].some(a=>a.retry_payment_conflict_at)),W=p?.has_gift===!0||p?.access_source==="gift"||f?.membership?.has_gift===!0||f?.gifts?.some(a=>["active","pending"].includes(a.state)),Ye=n?.provider==="waffo"&&n.payment_state==="unpaid"&&n.status!=="paid"&&["awaiting","expired","canceled"].includes(l)&&g&&I&&!b&&!W,z=k?.getAccessToken,v=pe(r),oe=f?.subscriptions?.some(a=>["active","trialing","past_due","paused"].includes(a.status)&&!a.cancel_at_period_end),le=p?.status==="active"||f?.payments?.some(a=>a.refunded_cents<a.amount_cents&&Date.parse(a.ends_at)>Date.now()),Ae=["fixed","recurring"].includes(m?.billing_mode)?S?.prices?.find(a=>a.currency===m.currency&&a.term_months===m.term_months&&a.billing_mode===(m.billing_mode==="recurring"?"fixed":"recurring")):null,qe=!!(r&&p&&!k?.loading&&!G&&!U&&l==="review"&&!L&&!s&&!n&&!h&&g&&I&&!_&&!j&&Ae&&!le&&!W&&!oe&&!b&&!v?.request_id&&!v?.order_id&&!f?.pending_orders?.length),Ze=()=>{if(!qe||ce.current)return;const a=pe(r);if(a?.request_id||a?.order_id)return;const c=new URLSearchParams(P);c.set("sku",Ae.sku),A(c,{replace:!0})},et=Te(u,r)||(X?.nextPath===u&&X?.ownerId===r&&X?.backend===i?X:null),de=t(L?"cloud.login.trial_context":"cloud.login.purchase_context");o.useEffect(()=>{if(r){re.current=null;return}k?.loading||_||B||re.current===u||(re.current=u,te({nextPath:u,subtitle:de,closePath:"/cloud"}))},[r,k?.loading,_,B,u,de,te]);const Be=S?.environment==="live"&&!L&&P.getAll("order").length===1&&Ne.test(s)&&["mac","windows"].includes(It())&&!(navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1)&&!ht()&&!xt()&&!ft()?`tokentracker://billing/return?order=${s.toLowerCase()}`:null;o.useEffect(()=>(y.current=!0,()=>{y.current=!1}),[]);const J=o.useCallback(async()=>{if(B||!s||!r||N.current!==r)return null;if(!Ne.test(s))return Q({code:"order_not_found"}),_e(!1),null;const a=++Y.current;try{const c=await ee("order",{auth:z,params:{id:s}});if(a!==Y.current||N.current!==r||T.current!==i)return null;ae({...c,ownerId:r,backend:i,verified:!0}),Q(null);const d=fe(c.order,c.membership);if(d==="success"&&ye(null),["success","refunded"].includes(d)){const $=`${r}:${s}:${d}`;be.current!==$&&(be.current=$,q())}if(["success","expired","canceled","refunded"].includes(fe(c.order,c.membership))){const $=pe(r),K=c.order.payment_state==="unpaid"&&c.order.status!=="paid"&&["expired","canceled"].includes(fe(c.order,c.membership))&&$?.retry_order_id===s&&$?.retry_request_id;$?.order_id===s&&!K&&jt(r)}return c}catch(c){return a===Y.current&&Q(c),null}finally{a===Y.current&&_e(!1)}},[s,r,z,B,q,i]);o.useEffect(()=>(ae(null),Q(null),be.current=null,_e(!!(s&&r)),J(),()=>{Y.current+=1}),[J,s,r]),o.useEffect(()=>{if(B||!s||!r||["success","canceled","expired","refunded"].includes(l))return;const a=()=>{document.visibilityState==="visible"&&J()},c=window.setInterval(a,5e3);return window.addEventListener("focus",a),document.addEventListener("visibilitychange",a),()=>{window.clearInterval(c),window.removeEventListener("focus",a),document.removeEventListener("visibilitychange",a)}},[s,r,l,J,B]);const D=o.useCallback(async a=>{if(!ce.current){ce.current=!0,Ie(!0),Q(null),ye(null);try{await a()}catch(c){y.current&&N.current===r&&T.current===i&&ye({ownerId:r,backend:i,orderId:s,error:c})}finally{ce.current=!1,y.current&&Ie(!1)}}},[r,s,i]),ue=o.useCallback((a=!1)=>D(async()=>{const c=Nt(r,M,F),d=await ee("checkout",{auth:z,body:{sku:M,provider:F,request_id:c.request_id,mobile:window.matchMedia("(max-width: 640px)").matches}});T.current===i&&(ze(r,{...c,order_id:d.order.id}),!(!y.current||N.current!==r)&&(a===!0&&(ne.current={ownerId:r,backend:i,orderId:d.order.id,opened:!1}),ae({...d,ownerId:r,backend:i,createdFrom:u,order:{...m,provider:F,...d.order}}),A({order:d.order.id},{replace:!0})))}),[D,r,M,F,z,m,A,i,u]),me=o.useCallback((a=!1)=>D(async()=>{let c;try{c=await ee("trial",{auth:z,body:{}})}catch(d){if(a===!0&&(d.code||d.message)==="trial_unavailable"){y.current&&N.current===r&&T.current===i&&(await q(),y.current&&N.current===r&&T.current===i&&H("/cloud",{replace:!0}));return}throw d}!y.current||N.current!==r||T.current!==i||(Ve({...c.membership,ownerId:r,backend:i}),a===!0?(await q(),y.current&&N.current===r&&T.current===i&&H("/dashboard",{replace:!0})):q())}),[D,z,r,q,H,i]);o.useEffect(()=>{const a=Te(u,r);if(!a||!r||h||k?.loading||G||U||_||j||!p||B||!g)return;if(a.orderId){if(a.orderId!==s)return;const xe=Me(u,r);if(!xe)return;Re({...xe,ownerId:r}),b||(ne.current={ownerId:r,backend:i,orderId:s,opened:!1});return}if(s||!a.trial&&(!m||!I||!C))return;const c=Me(u,r);if(!c)return;if(Re({...c,ownerId:r}),a.trial){if(p.trial_available)me(!0);else{const xe=p.can_read_cloud||["active","trial","transition"].includes(p.status);H(xe?"/dashboard":"/cloud",{replace:!0})}return}if(W||oe||le&&C!=="fixed"||b){H("/settings?section=cloud",{replace:!0});return}const d=pe(r),$=f?.pending_orders?.[0],K=d?.order_id||$?.id;K&&Ne.test(K)?(ne.current={ownerId:r,backend:i,orderId:K,opened:!1},A({order:K},{replace:!0})):d?.request_id&&(d.sku!==M||d.provider!==F)?A({sku:d.sku},{replace:!0}):ue(!0)},[u,r,s,h,k?.loading,G,U,_,j,p,B,g,m,I,C,W,oe,le,b,f?.pending_orders,M,F,me,ue,H,A,i]),o.useEffect(()=>{const a=ne.current;!a||a.opened||a.ownerId!==r||a.backend!==i||a.orderId!==s||!ie?.verified||n?.id?.toLowerCase()!==s.toLowerCase()||!n?.checkout_url||l!=="awaiting"||h||!g||!I||b||(a.opened=!0,D(()=>$e(n.checkout_url,{sameTab:!0})))},[r,s,n?.id,n?.checkout_url,ie?.verified,X?.nextPath,l,h,g,I,b,D,i]);const De=()=>D(async()=>{await ee("reconcile",{auth:z,body:{id:s}}),!(!y.current||N.current!==r)&&(await J(),await q())}),tt=()=>D(async()=>{const a=Ct(r,n);Le(!0);try{const c=await ee("restart-checkout",{auth:z,body:{id:n.id,request_id:a.retry_request_id}});if(ze(r,{sku:n.sku,provider:n.provider,request_id:a.retry_request_id,order_id:c.order.id}),!y.current||N.current!==r||Ee.current!==n.id)return;ae({...c,ownerId:r,backend:i}),A({order:c.order.id},{replace:!0})}finally{y.current&&Le(!1)}}),rt=()=>D(async()=>{await $e(n.checkout_url)}),ve=S?.limits?.trial_days||7,we=wt(),Z=we&&!pt(),at=new Date(Date.now()+ve*864e5).toISOString(),he=L?t("cloud.checkout.starting_trial"):t("cloud.checkout.creating"),st={review:L?t("cloud.checkout.trial_title"):t("cloud.checkout.title"),creating:he,awaiting:t("cloud.checkout.awaiting"),activating:t("cloud.checkout.activating"),success:t("cloud.checkout.success"),canceled:t("cloud.checkout.canceled"),expired:n?.status==="paid"?t("cloud.checkout.term_ended"):t("cloud.checkout.expired"),refunded:t("cloud.checkout.refunded"),trial_success:t("cloud.checkout.trial_success")};let O=null;if(!r)O=e.jsx("div",{className:"space-y-5",children:e.jsx(x,{onClick:()=>te({nextPath:u,subtitle:de,closePath:"/cloud"}),className:"w-full",disabled:k?.loading,children:t("cloud.action.sign_in_continue")})});else if(ge||h&&!n)O=e.jsxs("p",{role:"status",className:"flex items-center gap-2 text-sm",children:[e.jsx(Ue,{className:"motion-safe:animate-spin",size:17,"aria-hidden":!0}),ge?t("cloud.checkout.loading"):he]});else if(l==="trial_success"||l==="success")O=e.jsxs("div",{className:"space-y-5",children:[e.jsx(At,{size:32,className:"text-oai-gray-700 dark:text-oai-gray-200","aria-hidden":!0}),e.jsx("p",{className:"text-sm leading-6",children:l==="trial_success"?t("cloud.trial.ends",{date:je(p.trial_ends_at)}):t("cloud.membership.expires",{date:je(p.expires_at)})}),Z||!we?e.jsx("p",{className:"text-sm leading-6 text-oai-gray-500 dark:text-oai-gray-400",children:t(we?"cloud.onboarding.local_next":"cloud.onboarding.web_next")}):null,e.jsx(x,{as:w,to:Z?"/settings?section=cloud":"/dashboard",className:"w-full no-underline",children:t(Z?"cloud.action.setup_sync":"cloud.action.open_dashboard")}),e.jsx(w,{to:Z?"/dashboard":"/settings?section=cloud",className:"flex min-h-10 items-center justify-center text-sm underline underline-offset-4",children:t(Z?"cloud.action.open_dashboard":"cloud.action.manage_membership")})]});else if(l==="review"&&!s&&W)O=e.jsxs("div",{className:"space-y-5",children:[e.jsx(E,{children:t("cloud.gift.error_active")}),e.jsx(x,{as:w,to:"/settings?section=cloud",variant:"secondary",className:"w-full no-underline",children:t("cloud.action.manage_membership")})]});else if(l==="review"&&!s&&L)O=e.jsxs("div",{className:"space-y-5",children:[e.jsx("p",{className:"text-sm leading-6",children:t("cloud.trial.disclosure",{days:ve,date:je(at)})}),e.jsx("p",{className:"text-sm leading-6 text-oai-gray-500 dark:text-oai-gray-400",children:t("cloud.trial.expiry")}),f?.membership&&!f.membership.trial_available?e.jsxs("div",{className:"space-y-3",children:[e.jsx(E,{children:t("cloud.error.trial")}),m?null:e.jsx(x,{as:w,to:"/cloud",variant:"secondary",className:"w-full no-underline",children:t("cloud.action.view_plans")})]}):null,e.jsx(x,{onClick:me,disabled:h||!g||!f?.membership?.trial_available,className:"w-full",children:t("cloud.action.start_trial",{days:ve})}),m&&g&&I&&!h?e.jsx(x,{as:w,to:`/billing/checkout?sku=${encodeURIComponent(m.sku)}`,variant:"ghost",className:"mx-auto flex w-fit no-underline",children:t("cloud.plan.skip_trial")}):null]});else if(l==="review"&&!s&&m)O=e.jsxs("div",{className:"space-y-5",children:[e.jsx("p",{className:"text-sm leading-6",children:t("cloud.checkout.review")}),e.jsxs("p",{className:"inline-flex items-center gap-2 text-sm",children:[e.jsx(Et,{size:16,"aria-hidden":!0}),t("cloud.checkout.waffo")]}),C?e.jsx("p",{className:"text-sm leading-6 text-oai-gray-500 dark:text-oai-gray-400",children:C==="fixed"?t("cloud.checkout.methods_fixed"):t("cloud.checkout.methods_recurring")}):null,C?e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx("p",{className:"text-sm leading-6 text-oai-gray-500 dark:text-oai-gray-400",children:C==="fixed"?t("cloud.renewal.manual"):t("cloud.renewal.auto")}),qe?e.jsx(Lt,{checked:C==="recurring",onChange:Ze,ariaLabel:t("cloud.billing_mode.recurring")}):null]}):null,v?.order_id?e.jsx(x,{as:w,to:`/billing/checkout?order=${encodeURIComponent(v.order_id)}`,className:"w-full no-underline",children:t("cloud.action.resume_order")}):null,v?.request_id&&!v.order_id&&v.sku!==M?e.jsx(x,{as:w,to:`/billing/checkout?sku=${encodeURIComponent(v.sku)}`,className:"w-full no-underline",children:t("cloud.action.resume_purchase")}):null,!v?.order_id&&!(v?.request_id&&v.sku!==M)?e.jsx(x,{onClick:ue,disabled:h||!g||!I||!C||!!v?.order_id||b,className:"w-full",children:t("cloud.action.create_checkout",{amount:gt(Qe,Ke)})}):null]});else if(n){const a={creating:t("cloud.checkout.pending_creation"),awaiting:t("cloud.checkout.pending_payment"),activating:t("cloud.checkout.received"),expired:n?.status==="paid"?t("cloud.checkout.term_ended_detail"):t("cloud.checkout.expired_detail"),canceled:t("cloud.checkout.canceled_detail"),refunded:t("cloud.checkout.refunded_detail")};O=e.jsxs("div",{className:"space-y-5",children:[e.jsx("p",{className:"text-sm leading-6 text-oai-gray-500 dark:text-oai-gray-400",children:a[l]}),l==="awaiting"&&n.checkout_url&&g&&I&&!b?e.jsxs(x,{onClick:rt,disabled:h,className:"w-full",children:[t("cloud.action.open_payment"),e.jsx(Pt,{size:15,className:"ml-2","aria-hidden":!0})]}):null,l!=="refunded"?e.jsxs(e.Fragment,{children:[e.jsx(x,{onClick:De,disabled:h,variant:"ghost",className:"mx-auto flex underline underline-offset-4",children:h?t("cloud.action.checking"):t("cloud.action.check_payment")}),e.jsx("p",{className:"text-xs leading-5 text-oai-gray-500 dark:text-oai-gray-400",children:t("cloud.checkout.recovery_hint")})]}):null,Ye?e.jsxs("details",{open:l!=="awaiting",className:"border-t border-oai-gray-200 pt-4 dark:border-oai-gray-800",children:[e.jsx("summary",{className:"min-h-10 cursor-pointer text-sm font-medium leading-10 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2",children:t("cloud.checkout.help_title")}),e.jsxs("div",{className:"space-y-3 pt-2",children:[e.jsx("p",{className:"text-xs leading-5 text-oai-gray-500 dark:text-oai-gray-400",children:t("cloud.checkout.restart_detail")}),e.jsx(x,{onClick:tt,disabled:h,variant:l==="awaiting"?"secondary":"primary",className:"w-full",children:We?t("cloud.action.restarting_checkout"):t("cloud.action.restart_checkout")})]})]}):null,["canceled","expired"].includes(l)&&!b?e.jsx(w,{to:"/cloud",className:"flex min-h-10 items-center justify-center text-sm underline underline-offset-4",children:n.status==="paid"?t("cloud.action.renew"):t("cloud.action.choose_plan")}):null,l==="refunded"?e.jsx(x,{as:w,to:"/settings?section=cloud",className:"w-full no-underline",children:t("cloud.action.manage_membership")}):null,e.jsxs("details",{className:"border-t border-oai-gray-200 pt-4 dark:border-oai-gray-800",children:[e.jsxs("summary",{className:"min-h-10 cursor-pointer text-xs leading-10 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2",children:[t("cloud.checkout.order_id")," · ",n.id.slice(0,8)]}),e.jsx("p",{className:"mb-2 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:_t(n.provider)}),e.jsx("p",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400",children:t("cloud.checkout.order_id")}),e.jsx("p",{className:"mt-1 break-all font-mono text-xs select-all",children:n.id}),n.status!=="paid"&&n.expires_at?e.jsx("p",{className:"mt-2 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:t("cloud.checkout.expires",{date:kt(n.expires_at)})}):null]})]})}else O=e.jsx(E,{children:s?t("cloud.error.order_not_found"):t("cloud.checkout.choose_plan")});const Oe=e.jsxs("div",{className:"space-y-3",children:[R?e.jsx(E,{error:R,onRetry:s?Se?J:De:void 0}):null,R&&["subscription_already_exists","fixed_term_still_active","checkout_request_conflict","pending_checkout_exists","gift_membership_active"].includes(R.code||R.message)?e.jsx(x,{as:w,to:"/settings?section=cloud",variant:"secondary",className:"no-underline",children:t("cloud.action.manage_membership")}):null,R&&["authentication_required","invalid_token","invalid_authentication"].includes(R.code||R.message)?e.jsx(x,{onClick:async()=>{await k?.signOut?.(),re.current=u,te({nextPath:u,subtitle:de,closePath:"/cloud"})},variant:"secondary",children:t("cloud.action.sign_in_continue")}):null,j?e.jsx(E,{error:j,onRetry:Ce}):null,U?e.jsx(E,{error:U,onRetry:q}):null,!j&&_?e.jsx(E,{children:t("cloud.catalog.loading")}):null,!j&&!_&&!g?e.jsx(E,{children:t("cloud.catalog.preview")}):null,!j&&!_&&g&&!L&&!R&&!I&&["review","creating","awaiting"].includes(l)?e.jsx(E,{children:t("cloud.catalog.provider_unavailable")}):null,!j&&!_&&g&&S?.environment==="sandbox"?e.jsx(E,{children:t("cloud.catalog.sandbox")}):null]});return B?e.jsx(yt,{}):!r&&!s?e.jsx(e.Fragment,{children:e.jsx(Rt,{catalogState:{catalog:S,loading:_,error:j,refresh:Ce},accountState:{account:f,auth:k,loading:G,error:U,refresh:q},selection:{termMonths:Xe,billingMode:C}})}):et&&r&&!s?e.jsx("div",{className:"tt-cloud-theme flex flex-1 flex-col font-oai text-oai-black dark:text-oai-white",children:e.jsxs("main",{className:"mx-auto w-full max-w-lg px-4 py-12 sm:px-6",children:[e.jsxs(w,{to:"/cloud",onClick:()=>bt(u),className:"mb-6 inline-flex min-h-10 items-center gap-2 text-sm text-oai-gray-500 dark:text-oai-gray-400",children:[e.jsx(Fe,{size:16,"aria-hidden":!0}),t("cloud.checkout.back")]}),e.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:he}),h||k?.loading||_||G?e.jsxs("p",{role:"status",className:"mt-5 flex items-center gap-2 text-sm text-oai-gray-500 dark:text-oai-gray-400",children:[e.jsx(Ue,{className:"motion-safe:animate-spin",size:17,"aria-hidden":!0}),he]}):null,e.jsx("div",{className:"mt-5",children:Oe}),R&&!h?e.jsx(x,{onClick:()=>L?me(!0):ue(!0),disabled:G||!!U||_||!!j||!g||(L?!p?.trial_available:!m||!I||b||W||le&&C!=="fixed"||oe),className:"mt-5 w-full",children:t("cloud.action.retry")}):null]})}):e.jsx("div",{className:"tt-cloud-theme flex flex-1 flex-col font-oai text-oai-black dark:text-oai-white",children:e.jsxs("main",{className:"mx-auto w-full max-w-xl px-4 py-8 sm:px-6 sm:py-12",children:[e.jsxs(w,{to:"/cloud",className:"mb-7 inline-flex min-h-10 items-center gap-2 text-sm text-oai-gray-500 dark:text-oai-gray-400 hover:text-oai-brand focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand",children:[e.jsx(Fe,{size:16,"aria-hidden":!0}),t("cloud.checkout.back")]}),e.jsx("h1",{className:"text-3xl font-semibold tracking-tight","aria-live":"polite",children:ge?t("cloud.checkout.loading"):st[l]}),S?.environment==="sandbox"&&!L?e.jsx("p",{className:"mt-2 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:t("cloud.price.draft")}):null,b?e.jsx("div",{className:"mt-5",children:e.jsx(vt,{})}):null,e.jsx("div",{className:"mt-7",children:e.jsxs(St,{bodyClassName:"sm:p-7",children:[O,Be?e.jsxs("div",{className:"mt-5 space-y-3 border-t border-oai-gray-200 pt-5 dark:border-oai-gray-800",children:[e.jsx("p",{className:"text-sm leading-6 text-oai-gray-500 dark:text-oai-gray-400",children:t("cloud.checkout.return_app_hint")}),e.jsx("a",{href:Be,className:"inline-flex min-h-10 items-center text-sm underline underline-offset-4",children:t("cloud.action.open_app")})]}):null]})}),e.jsx("div",{className:"mt-5",children:Oe})]})})}export{Kt as CloudCheckoutPage};
|