Wayed11 commited on
Commit
bf82b8a
·
verified ·
1 Parent(s): b56ca73

Wheelie home screen, intro and sign-in

Browse files
Files changed (1) hide show
  1. springboard.js +258 -0
springboard.js ADDED
@@ -0,0 +1,258 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Wheelie Home: cinematic intro, sign-in, iPhone-style home screen */
2
+ (function(){
3
+ 'use strict';
4
+ if(window.__wsb)return;window.__wsb=1;
5
+ var SB='https://yzzxvjrzniuhxebqqrsy.supabase.co',KEY='sb_publishable_DKyw5S1dkCuu_g98yfx1xA_FgeTNtyJ';
6
+ var P='#FF6FB5',B='#5BC0F8';
7
+ function ls(k,v){try{if(v===undefined)return localStorage.getItem(k);if(v===null)localStorage.removeItem(k);else localStorage.setItem(k,v)}catch(e){return null}}
8
+ function ss(k,v){try{if(v===undefined)return sessionStorage.getItem(k);sessionStorage.setItem(k,v)}catch(e){return null}}
9
+ var reduce=false;try{reduce=matchMedia('(prefers-reduced-motion: reduce)').matches}catch(e){}
10
+ var $=function(s,r){return (r||document).querySelector(s)};
11
+
12
+ /* ---------- icons ---------- */
13
+ var G={
14
+ talk:'<path d="M20 14.6a2 2 0 0 1-2 2H8.4L4 20.6V6a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2z"/><path d="M8 9h8M8 12.4h5"/>',
15
+ mic:'<rect x="9" y="2.6" width="6" height="11.4" rx="3"/><path d="M5.4 11a6.6 6.6 0 0 0 13.2 0M12 17.6V21.4M8.6 21.4h6.8"/>',
16
+ read:'<path d="M12 6.6C10.4 5 8 4.4 3.6 4.6v13.6c4.4-.2 6.8.4 8.4 2 1.6-1.6 4-2.2 8.4-2V4.6C16 4.4 13.6 5 12 6.6z"/><path d="M12 6.6v13.6"/>',
17
+ listen:'<path d="M4 15.4v-3.2a8 8 0 0 1 16 0v3.2"/><rect x="3.4" y="13.6" width="4.6" height="7" rx="2"/><rect x="16" y="13.6" width="4.6" height="7" rx="2"/>',
18
+ trips:'<rect x="5" y="3" width="14" height="15" rx="3"/><path d="M5 11h14M9 6.5h6M8.5 18v2.6M15.5 18v2.6"/><circle cx="8.6" cy="14.4" r=".6"/><circle cx="15.4" cy="14.4" r=".6"/>',
19
+ fly:'<path d="M21 15.5v-1.8l-7.6-4.9V3.9a1.4 1.4 0 0 0-2.8 0v4.9L3 13.7v1.8l7.6-2.3v4.7l-2 1.5V21l3.4-.9 3.4.9v-1.6l-2-1.5v-4.7z"/>',
20
+ create:'<rect x="3" y="7.4" width="13" height="11" rx="2.6"/><path d="m16 11.4 5-3v9l-5-3"/><path d="M6.6 3.6l1 1.8M11 3l-.2 2"/>',
21
+ todo:'<rect x="4.4" y="3.6" width="15.2" height="17.4" rx="3"/><path d="m8 9 1.4 1.4L12 8M8 14.4l1.4 1.4L12 13.4M14 9.4h2.4M14 14.8h2.4"/>',
22
+ chats:'<path d="M16.4 10.6a5.8 5.8 0 0 1-8.2 5.3L4 17.2l1.3-3.8a5.8 5.8 0 1 1 11.1-2.8z"/><path d="M19.4 9.6a5.4 5.4 0 0 1 .7 6.6l.9 3.4-3.3-1a5.6 5.6 0 0 1-5.4.2"/>',
23
+ tour:'<circle cx="12" cy="12" r="8.6"/><path d="m10 8.4 5.6 3.6-5.6 3.6z"/>',
24
+ memory:'<path d="M9.4 4a3 3 0 0 0-3 3 3 3 0 0 0-2 5.4A3.2 3.2 0 0 0 7.6 17a3 3 0 0 0 4.4 2.4V5.4A3 3 0 0 0 9.4 4zM14.6 4a3 3 0 0 1 3 3 3 3 0 0 1 2 5.4 3.2 3.2 0 0 1-3.2 4.6 3 3 0 0 1-4.4 2.4"/>',
25
+ studio:'<circle cx="12" cy="12" r="8.6"/><circle cx="12" cy="12" r="2.6"/><path d="M12 3.4v3M12 17.6v3M3.4 12h3M17.6 12h3"/>',
26
+ account:'<circle cx="12" cy="8.4" r="3.8"/><path d="M4.6 20.4a7.4 7.4 0 0 1 14.8 0"/>',
27
+ help:'<circle cx="12" cy="12" r="8.6"/><circle cx="12" cy="12" r="3.8"/><path d="m5.9 5.9 3.4 3.4M14.7 14.7l3.4 3.4M18.1 5.9l-3.4 3.4M9.3 14.7l-3.4 3.4"/>'
28
+ };
29
+ function svg(n,w){return '<svg viewBox="0 0 24 24" width="'+(w||30)+'" height="'+(w||30)+'" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">'+G[n]+'</svg>'}
30
+
31
+ /* ---------- style ---------- */
32
+ var css=document.createElement('style');css.id='wsbCss';
33
+ css.textContent=
34
+ /* hide the old Home while the springboard is up */
35
+ 'html body.whon.wsb #whome{visibility:hidden!important}html body.whon.wsb #wnvBox,html body.whon.wsb .wtg,html body.whon.wsb #wnvBox *{display:none!important}'+
36
+ '#wSpring{position:fixed;inset:0;z-index:2147483620;display:none;color:#fff;font-family:-apple-system,"SF Pro Text",system-ui,sans-serif;overflow:hidden;background:#000;-webkit-user-select:none;user-select:none}'+
37
+ 'html body.whon.wsb #wSpring{display:block}'+
38
+ '#wSpring .wall{position:absolute;inset:-20%;pointer-events:none}'+
39
+ '#wSpring .wall i{position:absolute;border-radius:50%;filter:blur(60px);opacity:.55;animation:wsDrift 18s ease-in-out infinite alternate}'+
40
+ '#wSpring .wall .a{width:70vw;height:70vw;left:4%;top:8%;background:'+P+';opacity:.32}'+
41
+ '#wSpring .wall .b{width:80vw;height:80vw;right:2%;bottom:6%;background:'+B+';opacity:.26;animation-delay:-9s}'+
42
+ '@keyframes wsDrift{to{transform:translate(8%,6%) scale(1.12)}}'+
43
+ '#wSpring .scr{position:absolute;inset:0;overflow-y:auto;-webkit-overflow-scrolling:touch;padding:calc(env(safe-area-inset-top,0px) + 22px) 20px calc(env(safe-area-inset-bottom,0px) + 150px)}'+
44
+ '#wSpring .hd{display:flex;align-items:flex-end;justify-content:space-between;margin:4px 4px 18px}'+
45
+ '#wSpring .hd b{display:block;font:700 34px/1.05 -apple-system,"SF Pro Display",system-ui;letter-spacing:-.8px}'+
46
+ '#wSpring .hd small{display:block;font:600 15px -apple-system,system-ui;color:rgba(255,255,255,.62);margin-top:6px;letter-spacing:.2px}'+
47
+ /* widgets */
48
+ '#wSpring .wg{display:grid;grid-template-columns:1fr 1fr;gap:16px;margin-bottom:26px}'+
49
+ '#wSpring .wd{position:relative;aspect-ratio:1;max-width:100%;border-radius:26px;padding:16px;box-sizing:border-box;border:1px solid rgba(255,255,255,.14);background:rgba(30,30,36,.55);-webkit-backdrop-filter:blur(30px) saturate(1.6);backdrop-filter:blur(30px) saturate(1.6);overflow:hidden;text-align:left;color:#fff;font:inherit;display:flex;flex-direction:column;justify-content:space-between}'+
50
+ '#wSpring .wd .wsFace{width:66px;height:66px;border-radius:50%;background:url(wheelie.jpg) center/cover;box-shadow:0 0 0 3px #000,0 0 0 5.5px '+P+',0 0 26px rgba(255,111,181,.55);animation:wsBreath 3.6s ease-in-out infinite}'+
51
+ '@keyframes wsBreath{50%{box-shadow:0 0 0 3px #000,0 0 0 5.5px '+B+',0 0 30px rgba(91,192,248,.6)}}'+
52
+ '#wSpring .wd b{font:700 19px/1.15 -apple-system,system-ui;letter-spacing:-.3px}'+
53
+ '#wSpring .wd small{display:flex;align-items:center;gap:6px;font:600 14px -apple-system,system-ui;color:rgba(255,255,255,.7);margin-top:3px}'+
54
+ '#wSpring .wd .eq{display:inline-flex;gap:2.5px;align-items:center;height:14px}#wSpring .wd .eq s{width:3px;border-radius:2px;background:'+P+';height:40%;animation:wsEq 1s ease-in-out infinite}'+
55
+ '#wSpring .wd .eq s:nth-child(2){animation-delay:.15s;background:'+B+'}#wSpring .wd .eq s:nth-child(3){animation-delay:.3s}#wSpring .wd .eq s:nth-child(4){animation-delay:.45s;background:'+B+'}'+
56
+ '@keyframes wsEq{50%{height:100%}}'+
57
+ '#wSpring .day{font:700 15px -apple-system,system-ui;color:'+P+';letter-spacing:.6px;text-transform:uppercase}'+
58
+ '#wSpring .num{font:300 64px/1 -apple-system,"SF Pro Display",system-ui;letter-spacing:-2px;margin-top:2px}'+
59
+ '#wSpring .tm{font:600 15px -apple-system,system-ui;color:rgba(255,255,255,.72)}'+
60
+ /* app grid */
61
+ '#wSpring .grid{display:grid;grid-template-columns:repeat(4,1fr);row-gap:22px;column-gap:8px;justify-items:center}'+
62
+ '#wSpring .ap{border:0;background:none;color:#fff;padding:0;display:flex;flex-direction:column;align-items:center;gap:8px;width:100%;font:inherit;-webkit-tap-highlight-color:transparent}'+
63
+ '#wSpring .ic{width:64px;height:64px;border-radius:50%;display:flex;align-items:center;justify-content:center;color:var(--c);background:radial-gradient(circle at 32% 24%,rgba(255,255,255,.2),rgba(22,22,28,.92) 62%);box-shadow:inset 0 0 0 2px var(--c),0 8px 22px rgba(0,0,0,.55),0 0 22px color-mix(in srgb,var(--c) 38%,transparent);transition:transform .35s cubic-bezier(.2,1.5,.35,1)}'+
64
+ '#wSpring .ic svg{filter:drop-shadow(0 0 6px color-mix(in srgb,var(--c) 75%,transparent))}'+
65
+ '#wSpring .ap:active .ic,#wSpring .dk button:active .ic{transform:scale(.88);transition-duration:.08s}'+
66
+ '#wSpring .ap span{font:600 12.5px -apple-system,system-ui;letter-spacing:.1px;text-shadow:0 1px 4px rgba(0,0,0,.8);max-width:84px;text-align:center;line-height:1.15}'+
67
+ '#wSpring .wd:active{transform:scale(.96)}#wSpring .wd{transition:transform .35s cubic-bezier(.2,1.5,.35,1)}'+
68
+ /* ask pill */
69
+ '#wSpring .ask{position:absolute;left:50%;transform:translateX(-50%);bottom:calc(env(safe-area-inset-bottom,0px) + 122px);height:36px;padding:0 16px;border-radius:999px;border:0;display:flex;align-items:center;gap:7px;color:#fff;font:600 14px -apple-system,system-ui;background:rgba(60,60,68,.55);-webkit-backdrop-filter:blur(24px);backdrop-filter:blur(24px)}'+
70
+ /* dock */
71
+ '#wSpring .dk{position:absolute;left:12px;right:12px;bottom:calc(env(safe-area-inset-bottom,0px) + 12px);height:96px;border-radius:34px;display:flex;align-items:center;justify-content:space-around;padding:0 6px;background:rgba(48,48,56,.48);-webkit-backdrop-filter:blur(34px) saturate(1.7);backdrop-filter:blur(34px) saturate(1.7);border:1px solid rgba(255,255,255,.12)}'+
72
+ '#wSpring .dk button{border:0;background:none;padding:0;color:#fff;display:flex;flex-direction:column;align-items:center;gap:5px;font:600 11.5px -apple-system,system-ui}'+
73
+ '#wSpring .dk .ic{width:58px;height:58px}'+
74
+ '#wSpring .dk .orb .ic{width:72px;height:72px;color:#010101;background:'+P+';box-shadow:0 0 0 3px #000,0 0 0 5.5px #fff,0 0 30px rgba(255,111,181,.7);margin-top:-10px}'+
75
+ '#wSpring .dk .orb .ic svg{filter:none}'+
76
+ '#wSpring .dk .orb .ic::after{content:"";position:absolute;width:72px;height:72px;border-radius:50%;box-shadow:0 0 0 0 rgba(255,111,181,.6);animation:wsPing 2.4s ease-out infinite}'+
77
+ '@keyframes wsPing{to{box-shadow:0 0 0 22px rgba(255,111,181,0)}}'+
78
+ /* entrance */
79
+ '#wSpring.in .hd,#wSpring.in .wd,#wSpring.in .ap,#wSpring.in .dk,#wSpring.in .ask{animation:wsIn .7s cubic-bezier(.16,1,.3,1) both;animation-delay:calc(var(--i,0)*28ms)}'+
80
+ '@keyframes wsIn{from{opacity:0;transform:scale(1.35) translateY(10px)}to{opacity:1;transform:none}}'+
81
+ '#wSpring.in .ask{animation-name:wsInA}@keyframes wsInA{from{opacity:0;transform:translateX(-50%) scale(1.3)}to{opacity:1;transform:translateX(-50%)}}'+
82
+ /* app-open zoom */
83
+ '.wsZoom{position:fixed;z-index:2147483647;border-radius:50%;pointer-events:none;background:#000;box-shadow:inset 0 0 0 3px var(--c),0 0 60px color-mix(in srgb,var(--c) 60%,transparent);display:flex;align-items:center;justify-content:center;color:var(--c);transition:all .42s cubic-bezier(.3,.9,.2,1)}'+
84
+ '.wsZoom.full{left:0!important;top:0!important;width:100vw!important;height:100vh!important;border-radius:0;box-shadow:inset 0 0 0 0 var(--c)}'+
85
+ '.wsZoom svg{transition:transform .42s cubic-bezier(.3,.9,.2,1),opacity .4s}.wsZoom.full svg{transform:scale(3);opacity:.9}.wsZoom.out{opacity:0;transition:opacity .3s}'+
86
+ /* sheets: intro + sign-in + help */
87
+ '.wsLayer{position:fixed;inset:0;z-index:2147483647;background:#000;color:#fff;font-family:-apple-system,"SF Pro Text",system-ui,sans-serif;display:flex;flex-direction:column;align-items:center;justify-content:center;overflow:hidden;text-align:center}'+
88
+ '.wsLayer.bye{opacity:0;transform:scale(1.06);transition:opacity .6s ease,transform .6s ease}'+
89
+ /* intro */
90
+ '#wIntro .ln{position:absolute;top:50%;height:2px;width:120vw;border-radius:2px;margin-top:-90px}'+
91
+ '#wIntro .ln.p{background:'+P+';box-shadow:0 0 18px '+P+',0 0 40px '+P+';left:-130vw;animation:wiLp 1.1s cubic-bezier(.6,0,.2,1) .15s forwards}'+
92
+ '#wIntro .ln.b{background:'+B+';box-shadow:0 0 18px '+B+',0 0 40px '+B+';right:-130vw;margin-top:-86px;animation:wiLb 1.1s cubic-bezier(.6,0,.2,1) .15s forwards}'+
93
+ '@keyframes wiLp{60%{opacity:1}to{left:100vw;opacity:0}}@keyframes wiLb{60%{opacity:1}to{right:100vw;opacity:0}}'+
94
+ '#wIntro .fl{position:absolute;top:50%;left:50%;width:60px;height:60px;margin:-120px 0 0 -30px;border-radius:50%;background:radial-gradient(closest-side,#fff,rgba(255,255,255,.5) 40%,rgba(255,255,255,0));opacity:0;animation:wiFl .7s ease-out .72s forwards}'+
95
+ '@keyframes wiFl{30%{opacity:1;transform:scale(1.6)}to{opacity:0;transform:scale(9)}}'+
96
+ '#wIntro .ring{width:168px;height:168px;border-radius:50%;padding:6px;background:conic-gradient('+P+' 0 50%,'+B+' 50% 100%);opacity:0;transform:scale(.4) rotate(-90deg);animation:wiRing 1.1s cubic-bezier(.2,1.3,.3,1) .85s forwards;box-shadow:0 0 70px rgba(255,111,181,.45),0 0 120px rgba(91,192,248,.3)}'+
97
+ '#wIntro .ring i{display:block;width:100%;height:100%;border-radius:50%;border:5px solid #000;box-sizing:border-box;background:url(wheelie.jpg) center/cover}'+
98
+ '@keyframes wiRing{to{opacity:1;transform:none}}'+
99
+ '#wIntro h1{margin:30px 0 0;font:800 56px/1 -apple-system,"SF Pro Display",system-ui;letter-spacing:-2px;display:flex;justify-content:center}'+
100
+ '#wIntro h1 span{display:inline-block;opacity:0;transform:translateY(40px);filter:blur(8px);animation:wiCh .8s cubic-bezier(.16,1,.3,1) forwards}'+
101
+ '@keyframes wiCh{to{opacity:1;transform:none;filter:none}}'+
102
+ '#wIntro p{margin:14px 0 0;font:500 19px -apple-system,system-ui;color:rgba(255,255,255,.72);opacity:0;animation:wiCh .9s ease 2.05s forwards;transform:translateY(12px)}'+
103
+ '#wIntro .sk{position:absolute;bottom:calc(env(safe-area-inset-bottom,0px) + 26px);font:600 14px -apple-system,system-ui;color:rgba(255,255,255,.45);opacity:0;animation:wiCh .6s ease 1.4s forwards}'+
104
+ /* sign-in */
105
+ '#wSign{justify-content:flex-start;padding:calc(env(safe-area-inset-top,0px) + 12vh) 24px calc(env(safe-area-inset-bottom,0px) + 26px);box-sizing:border-box;animation:wsFade .6s ease both}'+
106
+ '@keyframes wsFade{from{opacity:0}}'+
107
+ '#wSign .wall{position:absolute;inset:-20%;pointer-events:none}#wSign .wall i{position:absolute;border-radius:50%;filter:blur(70px)}'+
108
+ '#wSign .wall .a{width:80vw;height:80vw;left:-10%;top:-6%;background:'+P+';opacity:.28}#wSign .wall .b{width:80vw;height:80vw;right:-14%;bottom:-4%;background:'+B+';opacity:.22}'+
109
+ '#wSign .wsAv{position:relative;width:118px;height:118px;border-radius:50%;padding:5px;background:conic-gradient('+P+' 0 50%,'+B+' 50% 100%);box-shadow:0 0 50px rgba(255,111,181,.4);animation:wiRing .9s cubic-bezier(.2,1.3,.3,1) both}'+
110
+ '#wSign .wsAv i{display:block;width:100%;height:100%;border-radius:50%;border:4px solid #000;box-sizing:border-box;background:url(wheelie.jpg) center/cover}'+
111
+ '#wSign h2{position:relative;margin:26px 0 8px;font:800 34px/1.1 -apple-system,"SF Pro Display",system-ui;letter-spacing:-1px;animation:wiCh .8s cubic-bezier(.16,1,.3,1) .15s both}'+
112
+ '#wSign .sub{position:relative;margin:0 0 auto;max-width:320px;font:500 17px/1.4 -apple-system,system-ui;color:rgba(255,255,255,.7);animation:wiCh .8s ease .3s both}'+
113
+ '#wSign .wsBt{position:relative;width:100%;max-width:380px;display:flex;flex-direction:column;gap:12px;margin-top:28px;animation:wiCh .8s cubic-bezier(.16,1,.3,1) .45s both}'+
114
+ '#wSign .sb{height:58px;border-radius:16px;border:0;display:flex;align-items:center;justify-content:center;gap:10px;font:600 19px -apple-system,system-ui;letter-spacing:-.2px;transition:transform .3s cubic-bezier(.2,1.5,.35,1)}'+
115
+ '#wSign .sb:active{transform:scale(.96)}'+
116
+ '#wSign .sb.wsA{background:#fefefe!important;color:#010101!important;border:0!important}#wSign .sb.wsG{background:#1c1c22!important;color:#fff!important;border:1px solid rgba(255,255,255,.22)!important}#wSign button:focus{outline:none}#wSign button:focus-visible{outline:3px solid '+P+';outline-offset:3px}'+
117
+ '#wSign .nn{border:0;background:none;color:rgba(255,255,255,.7);font:600 17px -apple-system,system-ui;height:48px;margin-top:2px}'+
118
+ '#wSign .wsNote{min-height:22px;font:500 15px/1.35 -apple-system,system-ui;color:'+B+';margin-top:4px}'+
119
+ '#wSign .fine{font:500 12.5px/1.4 -apple-system,system-ui;color:rgba(255,255,255,.4);margin-top:8px}'+
120
+ /* help sheet */
121
+ '#wHelp{background:rgba(0,0,0,.6);justify-content:flex-end;animation:wsFade .3s ease both}'+
122
+ '#wHelp .bx{width:100%;box-sizing:border-box;background:#1a1a20;border-radius:28px 28px 0 0;padding:22px 20px calc(env(safe-area-inset-bottom,0px) + 22px);display:flex;flex-direction:column;gap:12px;animation:wsUp .45s cubic-bezier(.16,1,.3,1) both;text-align:left}'+
123
+ '@keyframes wsUp{from{transform:translateY(100%)}}'+
124
+ '#wHelp h3{margin:0 0 4px;font:800 26px -apple-system,system-ui}'+
125
+ '#wHelp a,#wHelp button{height:60px;border-radius:18px;border:0;display:flex;align-items:center;gap:12px;padding:0 18px;font:700 18px -apple-system,system-ui;text-decoration:none;color:#fff;background:#2a2a32}'+
126
+ '#wHelp .r{background:#d42a3a}'+
127
+ (reduce?'#wSpring *,#wIntro *,#wSign *,.wsZoom{animation:none!important;transition:none!important}#wIntro .ring,#wIntro h1 span,#wIntro p{opacity:1!important;transform:none!important;filter:none!important}':'');
128
+ (document.head||document.documentElement).appendChild(css);
129
+
130
+ /* ---------- auth ---------- */
131
+ function auth(){try{return JSON.parse(ls('wAuth')||'null')}catch(e){return null}}
132
+ function firstName(){var a=auth();var n=(a&&a.name)||ls('wMyName')||'Wayed';return String(n).split(' ')[0]}
133
+ (function catchReturn(){
134
+ var h=location.hash||'';if(h.indexOf('access_token=')<0)return;
135
+ var q={};h.slice(1).split('&').forEach(function(kv){var p=kv.split('=');q[p[0]]=decodeURIComponent(p[1]||'')});
136
+ try{history.replaceState(null,'',location.pathname+location.search)}catch(e){}
137
+ ls('wAuth',JSON.stringify({token:q.access_token,refresh:q.refresh_token,at:Date.now()}));
138
+ fetch(SB+'/auth/v1/user',{headers:{apikey:KEY,Authorization:'Bearer '+q.access_token}}).then(function(r){return r.json()}).then(function(u){
139
+ var m=(u&&u.user_metadata)||{};var a=auth()||{};a.email=u.email;a.name=m.full_name||m.name||'';a.id=u.id;ls('wAuth',JSON.stringify(a));if(a.name)ls('wMyName',a.name.split(' ')[0]);paint();
140
+ }).catch(function(){});
141
+ })();
142
+ var provs=null;
143
+ function providers(){return provs||(provs=fetch(SB+'/auth/v1/settings',{headers:{apikey:KEY}}).then(function(r){return r.json()}).then(function(j){return j.external||{}}).catch(function(){return {}}))}
144
+ function signIn(p,msg){
145
+ providers().then(function(x){
146
+ if(x[p]){location.href=SB+'/auth/v1/authorize?provider='+p+'&redirect_to='+encodeURIComponent(location.origin+location.pathname);return}
147
+ msg.textContent=(p=='apple'?'Sign in with Apple':'Google sign-in')+' turns on very soon. Tap "Not now" and everything still works.';
148
+ });
149
+ }
150
+
151
+ /* ---------- layers ---------- */
152
+ function layer(id,html){var d=document.createElement('div');d.id=id;d.className='wsLayer';d.innerHTML=html;document.body.appendChild(d);return d}
153
+ function close(d,cb){if(!d)return cb&&cb();d.classList.add('bye');setTimeout(function(){d.remove();cb&&cb()},reduce?0:600)}
154
+
155
+ function intro(done){
156
+ var word='Wheelie'.split('').map(function(c,i){return '<span style="animation-delay:'+(1.35+i*.07)+'s">'+c+'</span>'}).join('');
157
+ var d=layer('wIntro','<i class="ln p"></i><i class="ln b"></i><i class="fl"></i><div class="ring"><i></i></div><h1 aria-label="Wheelie">'+word+'</h1><p>Your friend for every day.</p><div class="sk">Tap to skip</div>');
158
+ d.setAttribute('role','img');d.setAttribute('aria-label','Wheelie');
159
+ var t=setTimeout(go,reduce?600:3500),gone=false;
160
+ function go(){if(gone)return;gone=true;clearTimeout(t);close(d,done)}
161
+ d.addEventListener('click',go);
162
+ }
163
+ function signSheet(force,done){
164
+ var a=auth();
165
+ var d=layer('wSign','<div class="wall"><i class="a"></i><i class="b"></i></div><div class="wsAv"><i></i></div>'+
166
+ (a&&a.token?'<h2>You’re signed in</h2><p class="sub">'+(a.email||'Welcome back')+'</p>':'<h2>Welcome to Wheelie</h2><p class="sub">Sign in so your books, trips and chats follow you to every device.</p>')+
167
+ '<div class="wsBt">'+(a&&a.token?'<button class="sb wsG" id="wsOut">Sign out</button><button class="nn" id="wsNo">Done</button>':
168
+ '<button class="sb wsA" id="wsApple"><svg width="20" height="22" viewBox="0 0 17 20" aria-hidden="true"><path fill="#010101" d="M14.1 10.6c0-2.6 2.1-3.8 2.2-3.9-1.2-1.8-3.1-2-3.7-2-1.6-.2-3.1.9-3.9.9-.8 0-2-.9-3.4-.9C3.6 4.8 2 5.8 1.1 7.3c-1.8 3.2-.5 7.9 1.3 10.5.9 1.3 1.9 2.7 3.3 2.6 1.3-.1 1.8-.9 3.4-.9s2 .9 3.4.8c1.4 0 2.3-1.3 3.2-2.6 1-1.5 1.4-2.9 1.4-3-.1 0-2.9-1.1-3-4.1zM11.5 3c.7-.9 1.2-2.1 1.1-3.3-1 0-2.3.7-3 1.6-.7.8-1.3 2-1.1 3.2 1.1.1 2.3-.6 3-1.5z"/></svg>Sign in with Apple</button>'+
169
+ '<button class="sb wsG" id="wsGoogle"><svg width="20" height="20" viewBox="0 0 48 48" aria-hidden="true"><path fill="#FFC107" d="M43.6 20.5H42V20H24v8h11.3C33.7 32.7 29.2 36 24 36c-6.6 0-12-5.4-12-12s5.4-12 12-12c3.1 0 5.8 1.2 7.9 3.1l5.7-5.7C34 6.1 29.3 4 24 4 12.9 4 4 12.9 4 24s8.9 20 20 20 20-8.9 20-20c0-1.3-.1-2.4-.4-3.5z"/><path fill="#FF3D00" d="m6.3 14.7 6.6 4.8C14.7 15.1 19 12 24 12c3.1 0 5.8 1.2 7.9 3.1l5.7-5.7C34 6.1 29.3 4 24 4 16.3 4 9.7 8.3 6.3 14.7z"/><path fill="#4CAF50" d="M24 44c5.2 0 9.9-2 13.4-5.2l-6.2-5.2C29.2 35.1 26.7 36 24 36c-5.2 0-9.6-3.3-11.3-8l-6.5 5C9.5 39.6 16.2 44 24 44z"/><path fill="#1976D2" d="M43.6 20.5H42V20H24v8h11.3c-.8 2.2-2.2 4.2-4.1 5.6l6.2 5.2C37 39.2 44 34 44 24c0-1.3-.1-2.4-.4-3.5z"/></svg>Continue with Google</button>'+
170
+ '<div class="wsNote" id="wsMsg" role="status" aria-live="polite"></div><button class="nn" id="wsNo">Not now</button><div class="fine">Wheelie is free. We never sell your information.</div>')+'</div>');
171
+ d.setAttribute('role','dialog');d.setAttribute('aria-label','Sign in');
172
+ var m=$('#wsMsg',d);
173
+ var ap=$('#wsApple',d),gg=$('#wsGoogle',d),no=$('#wsNo',d),out=$('#wsOut',d);
174
+ if(ap)ap.onclick=function(){signIn('apple',m)};
175
+ if(gg)gg.onclick=function(){signIn('google',m)};
176
+ if(out)out.onclick=function(){ls('wAuth',null);close(d,done);paint()};
177
+ no.onclick=function(){ls('wSignSkip','1');close(d,done)};
178
+ }
179
+ function helpSheet(){
180
+ var d=layer('wHelp','<div class="bx" role="dialog" aria-label="Help"><h3>Need help?</h3><a class="r" href="tel:911">'+svg('help',26)+'Call 911</a><a href="trips.html">'+svg('trips',26)+'More help in Trips</a><button id="whX">Close</button></div>');
181
+ d.onclick=function(e){if(e.target===d||e.target.id=='whX')d.remove()};
182
+ }
183
+
184
+ /* ---------- springboard ---------- */
185
+ function leave(){document.body.classList.remove('whon');var h=$('#whome');h&&h.classList.remove('on')}
186
+ function tab(t){leave();setTimeout(function(){var b=$('#menu [data-tab='+t+']')||$('[data-tab='+t+']');b&&b.click()},30)}
187
+ var APPS={
188
+ talk:['Talk',P,'mic',function(){window.whSayT=Date.now()+3000;try{whGo('talk','')}catch(e){}try{whTalkNow()}catch(e){}}],
189
+ chat:['Ask',P,'talk',function(){try{whGo('talk','')}catch(e){}setTimeout(function(){var t=$('#t');t&&t.focus()},300)}],
190
+ read:['Read',P,'read',function(){whGo('read',"Let's read together.")}],
191
+ listen:['Listen',B,'listen',function(){whGo('listen',"Let's listen.")}],
192
+ trips:['Trips',B,'trips','trips.html'],
193
+ fly:['Flights',B,'fly','flights.html'],
194
+ create:['Create',P,'create',function(){whGo('create',"Let's make something.")}],
195
+ todo:['To-do',B,'todo',function(){whGo('todo','Here are your reminders')}],
196
+ chats:['Chats',P,'chats',function(){try{wThr()}catch(e){whGo('talk','')}}],
197
+ tour:['Tour',B,'tour','tour.html'],
198
+ memory:['Memory',P,'memory',function(){tab('mem')}],
199
+ studio:['Studio',B,'studio',function(){tab('studio')}],
200
+ account:['Account',P,'account',function(){signSheet(true)}],
201
+ help:['Help','#FF4D6A','help',function(){helpSheet()}]
202
+ };
203
+ var GRID=['create','todo','chats','tour','memory','studio','account','help'];
204
+ var DOCK=['read','listen','talk','trips','fly'];
205
+ function iconBtn(k,cls,i){var a=APPS[k];return '<button class="'+cls+'" data-app="'+k+'" style="--c:'+a[1]+';--i:'+i+'" aria-label="'+a[0]+'"><i class="ic">'+svg(a[2],cls.indexOf('orb')>-1?34:30)+'</i><span>'+(k=='talk'?'Talk':a[0])+'</span></button>'}
206
+ var S=null;
207
+ function greet(){var h=new Date().getHours();return h<5?'Good night':h<12?'Good morning':h<17?'Good afternoon':'Good evening'}
208
+ function paint(){
209
+ if(!S)return;
210
+ var d=new Date(),DAYS=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],MON=['January','February','March','April','May','June','July','August','September','October','November','December'];
211
+ $('.hd b',S).textContent=greet()+', '+firstName();
212
+ $('.hd small',S).textContent=DAYS[d.getDay()]+', '+MON[d.getMonth()]+' '+d.getDate();
213
+ $('.day',S).textContent=DAYS[d.getDay()].slice(0,3);
214
+ $('.num',S).textContent=d.getDate();
215
+ $('.tm',S).textContent=d.toLocaleTimeString([],{hour:'numeric',minute:'2-digit'});
216
+ }
217
+ function build(){
218
+ S=document.createElement('div');S.id='wSpring';S.setAttribute('role','region');S.setAttribute('aria-label','Wheelie home screen');
219
+ var i=0;
220
+ S.innerHTML='<div class="wall" aria-hidden="true"><i class="a"></i><i class="b"></i></div><div class="scr">'+
221
+ '<div class="hd" style="--i:0"><div><b></b><small></small></div></div>'+
222
+ '<div class="wg"><button class="wd" data-app="talk" style="--i:1" aria-label="Talk to Wheelie"><i class="wsFace"></i><div><b>Wheelie</b><small><span class="eq"><s></s><s></s><s></s><s></s></span>Tap to talk</small></div></button>'+
223
+ '<button class="wd" data-app="todo" style="--i:2" aria-label="Today and your to-do list"><div><div class="day"></div><div class="num"></div></div><div><b>Today</b><small class="tm"></small></div></button></div>'+
224
+ '<div class="grid">'+GRID.map(function(k){return iconBtn(k,'ap',3+(i++))}).join('')+'</div></div>'+
225
+ '<button class="ask" data-app="chat" style="--i:14">'+svg('talk',16)+'Ask Wheelie</button>'+
226
+ '<nav class="dk" style="--i:15" aria-label="Dock">'+DOCK.map(function(k){return iconBtn(k,k=='talk'?'orb':'',16)}).join('')+'</nav>';
227
+ document.body.appendChild(S);
228
+ S.addEventListener('click',function(e){var b=e.target.closest('[data-app]');if(!b)return;open(b)});
229
+ paint();setInterval(paint,30000);
230
+ }
231
+ function open(btn){
232
+ var k=btn.getAttribute('data-app'),a=APPS[k];if(!a)return;
233
+ try{navigator.vibrate&&navigator.vibrate(8)}catch(e){}
234
+ if(k=='account'||k=='help'){a[3]();return}
235
+ var ic=btn.querySelector('.ic')||btn,r=ic.getBoundingClientRect();
236
+ var z=document.createElement('div');z.className='wsZoom';z.style.cssText='--c:'+a[1]+';left:'+r.left+'px;top:'+r.top+'px;width:'+r.width+'px;height:'+r.height+'px';
237
+ z.innerHTML=svg(a[2],30);document.body.appendChild(z);
238
+ requestAnimationFrame(function(){requestAnimationFrame(function(){z.classList.add('full')})});
239
+ setTimeout(function(){
240
+ if(typeof a[3]=='string'){location.href=a[3];setTimeout(function(){z.remove()},4000);return}
241
+ try{a[3]()}catch(e){}
242
+ z.classList.add('out');setTimeout(function(){z.remove()},320);
243
+ },reduce?0:400);
244
+ }
245
+ function replay(){if(!S||reduce)return;S.classList.remove('in');void S.offsetWidth;S.classList.add('in');paint()}
246
+
247
+ function start(){
248
+ document.body.classList.add('wsb');build();
249
+ new MutationObserver(function(){var on=document.body.classList.contains('whon');if(on&&!S.__on){S.__on=1;try{wClose(true)}catch(e){}replay()}else if(!on)S.__on=0}).observe(document.body,{attributes:true,attributeFilter:['class']});
250
+ if(document.body.classList.contains('whon')){S.__on=1;replay()}
251
+ window.addEventListener('pageshow',function(e){if(e.persisted){var z=document.querySelector('.wsZoom');z&&z.remove()}});
252
+ var a=auth();
253
+ var first=!ss('wIntro')&&!ls('wGoTalk');
254
+ if(first){ss('wIntro','1');intro(function(){if(!(a&&a.token)&&!ls('wSignSkip'))signSheet();else replay()})}
255
+ }
256
+ if(document.readyState==='loading')document.addEventListener('DOMContentLoaded',function(){setTimeout(start,0)});else start();
257
+ window.wSignIn=signSheet;
258
+ })();