chirkle 0.4.0 → 0.4.1
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.md +32 -24
- package/bin/release/darwin-amd64/chirkle-server +2 -2
- package/bin/release/darwin-arm64/chirkle-server +0 -0
- package/bin/release/linux-amd64/chirkle-server +0 -0
- package/bin/release/linux-arm64/chirkle-server +0 -0
- package/package.json +2 -1
- package/pb_hooks/lib/account.js +541 -6
- package/pb_hooks/lib/collections.js +4 -4
- package/pb_hooks/lib/dms.js +1 -1
- package/pb_hooks/lib/inbox.js +1 -1
- package/pb_hooks/lib/invites.js +266 -0
- package/pb_hooks/lib/messages.js +11 -2
- package/pb_hooks/lib/moderation.js +1 -1
- package/pb_hooks/lib/retention.js +3 -0
- package/pb_hooks/lib/site.js +1 -1
- package/pb_hooks/lib/users.js +38 -10
- package/pb_hooks/main.pb.js +26 -1
- package/pb_hooks/telegram/api.js +64 -12
- package/pb_hooks/telegram/inbound.js +106 -15
- package/pb_hooks/telegram/outbound.js +63 -37
- package/pb_hooks/telegram/worker.js +59 -15
- package/pb_migrations/1760000052_deleted_accounts.js +19 -0
- package/pb_migrations/1760000053_account_jobs.js +45 -0
- package/pb_migrations/1760000054_room_invites.js +39 -0
- package/pb_migrations/1760000055_invite_barred.js +16 -0
- package/pb_migrations/1760000056_telegram_fetch.js +21 -0
- package/pb_public/assets/{access-PB77EH4F.css → access-GPRLOZOO.css} +2 -2
- package/pb_public/assets/{access-PB77EH4F.css.map → access-GPRLOZOO.css.map} +2 -2
- package/pb_public/assets/access-UK3L54NR.js +2 -0
- package/pb_public/assets/access-UK3L54NR.js.map +7 -0
- package/pb_public/assets/account-CT2BVMAX.css +2 -0
- package/pb_public/assets/account-CT2BVMAX.css.map +7 -0
- package/pb_public/assets/account-api-J6A6IYVX.js +2 -0
- package/pb_public/assets/account-api-J6A6IYVX.js.map +7 -0
- package/pb_public/assets/app-HB3NZHQ2.js +3 -0
- package/pb_public/assets/app-HB3NZHQ2.js.map +7 -0
- package/pb_public/assets/app-XJ73EU5O.css +2 -0
- package/pb_public/assets/app-XJ73EU5O.css.map +7 -0
- package/pb_public/assets/chunk-AG73QNUN.js +2 -0
- package/pb_public/assets/chunk-AG73QNUN.js.map +7 -0
- package/pb_public/assets/chunk-DCLJRQ53.js +2 -0
- package/pb_public/assets/chunk-DCLJRQ53.js.map +7 -0
- package/pb_public/assets/chunk-N2OFGBCZ.js +2 -0
- package/pb_public/assets/{chunk-PWNJABVI.js.map → chunk-N2OFGBCZ.js.map} +4 -4
- package/pb_public/assets/chunk-OKIIBH7O.js +2 -0
- package/pb_public/assets/chunk-OKIIBH7O.js.map +7 -0
- package/pb_public/assets/chunk-UZDXAORM.js +2 -0
- package/pb_public/assets/chunk-UZDXAORM.js.map +7 -0
- package/pb_public/assets/chunk-WR25F7FU.js +2 -0
- package/pb_public/assets/chunk-WR25F7FU.js.map +7 -0
- package/pb_public/assets/invite-OGT5E2MZ.js +2 -0
- package/pb_public/assets/invite-OGT5E2MZ.js.map +7 -0
- package/pb_public/assets/invite-api-7G7XPXQW.js +2 -0
- package/pb_public/assets/invite-api-7G7XPXQW.js.map +7 -0
- package/pb_public/assets/login-TK6K4WGB.js +2 -0
- package/pb_public/assets/{login-ECFBJP6Q.js.map → login-TK6K4WGB.js.map} +1 -1
- package/pb_public/assets/profile-3R6S5QYS.js +2 -0
- package/pb_public/assets/profile-3R6S5QYS.js.map +7 -0
- package/pb_public/assets/stats-GTO2H6PG.js +2 -0
- package/pb_public/assets/stats-GTO2H6PG.js.map +7 -0
- package/pb_public/index.html +7 -5
- package/pb_public/stats.html +1 -1
- package/scripts/service.mjs +201 -0
- package/scripts/start.mjs +7 -1
- package/pb_public/assets/access-LHPD2EHG.js +0 -2
- package/pb_public/assets/access-LHPD2EHG.js.map +0 -7
- package/pb_public/assets/app-6ETOTHXQ.js +0 -3
- package/pb_public/assets/app-6ETOTHXQ.js.map +0 -7
- package/pb_public/assets/app-ZGHECF33.css +0 -2
- package/pb_public/assets/app-ZGHECF33.css.map +0 -7
- package/pb_public/assets/chunk-GXMWOXBX.js +0 -2
- package/pb_public/assets/chunk-GXMWOXBX.js.map +0 -7
- package/pb_public/assets/chunk-IFQGGTSP.js +0 -2
- package/pb_public/assets/chunk-IFQGGTSP.js.map +0 -7
- package/pb_public/assets/chunk-PWNJABVI.js +0 -2
- package/pb_public/assets/login-ECFBJP6Q.js +0 -2
- package/pb_public/assets/profile-NQQLAEDT.js +0 -2
- package/pb_public/assets/profile-NQQLAEDT.js.map +0 -7
- package/pb_public/assets/stats-ARDU576A.js +0 -2
- package/pb_public/assets/stats-ARDU576A.js.map +0 -7
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../web/src/scope.ts", "../../web/src/lib/image.ts", "../../web/src/theme.ts"],
|
|
4
|
-
"sourcesContent": ["// Lifetime of a mounted view or a running service: one place to collect everything to undo on dispose.\n//\n// const scope = createScope();\n// h(\"button\", { on: { click }, signal: scope.signal }); // listeners go away with the scope\n// scope.defer(store.subscribe(render)); // any cleanup function\n// scope.sub(api.subscribeMessages(room, onMessage)); // realtime: unsubscribed once it resolves\n// if (!scope.active) return; // after an await: was it disposed meanwhile?\n\nimport type { Unsubscribe } from \"./api.ts\";\n\nexport interface Scope {\n /** Aborted on dispose: pass to addEventListener / h() / fetches. */\n readonly signal: AbortSignal;\n /** False once disposed. Async work checks it after every await. */\n readonly active: boolean;\n /** Run `fn` on dispose (in reverse order of registration). */\n defer(fn: () => unknown): void;\n /** Unsubscribe a realtime subscription on dispose, even if it is still being set up. */\n sub(subscription: Promise<Unsubscribe>): void;\n dispose(): void;\n}\n\nexport function createScope(): Scope {\n const ac = new AbortController();\n const cleanups: (() => unknown)[] = [];\n return {\n signal: ac.signal,\n get active() {\n return !ac.signal.aborted;\n },\n defer(fn) {\n if (ac.signal.aborted) void fn();\n else cleanups.push(fn);\n },\n sub(subscription) {\n // A subscribe that fails (no connection) stays registered with the realtime client, which sends it again on the\n // next connection: nothing to handle here, and not an unhandled rejection either (QA BUG-68).\n subscription.catch(() => {});\n this.defer(() => subscription.then((off) => off()).catch(() => {}));\n },\n dispose() {\n if (ac.signal.aborted) return;\n ac.abort();\n for (const fn of cleanups.reverse()) {\n try {\n void fn();\n } catch {\n // one failing cleanup must not keep the others from running\n }\n }\n cleanups.length = 0;\n },\n };\n}\n", "// Image preparation before upload (\u00A715.3): scale down and re-encode, which also drops EXIF (GPS location).\n// Best effort: anything that can't be decoded or re-encoded is uploaded as it is, and the server limits decide.\n\n/** Types we re-encode. GIFs are left alone (re-encoding would drop the animation). */\nconst REENCODE = new Set([\"image/jpeg\", \"image/png\", \"image/webp\"]);\n\n/** Size of a `w`\u00D7`h` image scaled down (never up) so its longest edge is at most `maxEdge`. */\nexport function fitWithin(w: number, h: number, maxEdge: number): { width: number; height: number } {\n const scale = Math.min(1, maxEdge / Math.max(w, h, 1));\n return { width: Math.max(1, Math.round(w * scale)), height: Math.max(1, Math.round(h * scale)) };\n}\n\ntype Canvas = OffscreenCanvas | HTMLCanvasElement;\n\nfunction canvas(width: number, height: number): Canvas {\n if (typeof OffscreenCanvas === \"function\") return new OffscreenCanvas(width, height);\n return Object.assign(document.createElement(\"canvas\"), { width, height });\n}\n\nfunction encode(c: Canvas, type: string): Promise<Blob | null> {\n if (\"convertToBlob\" in c) return c.convertToBlob({ type, quality: 0.85 }).catch(() => null);\n return new Promise((ok) => c.toBlob(ok, type, 0.85));\n}\n\n/**\n * `file` scaled to at most `maxEdge` px and re-encoded: PNG as PNG (keeps transparency), the rest as JPEG. Both are\n * formats PocketBase thumbnails in kind; a WebP's thumbnails would be PNGs, often bigger than the image (QA BUG-26).\n */\nexport async function prepareImage(file: File, maxEdge: number): Promise<File> {\n if (!REENCODE.has(file.type) || typeof createImageBitmap !== \"function\") return file;\n let bitmap: ImageBitmap | undefined;\n try {\n bitmap = await createImageBitmap(file);\n const { width, height } = fitWithin(bitmap.width, bitmap.height, maxEdge);\n const c = canvas(width, height);\n const ctx = c.getContext(\"2d\") as OffscreenCanvasRenderingContext2D | CanvasRenderingContext2D | null;\n if (!ctx) return file;\n ctx.drawImage(bitmap, 0, 0, width, height);\n const type = file.type === \"image/png\" ? \"image/png\" : \"image/jpeg\";\n // An encoder that doesn't support a type falls back to PNG: check what we actually got.\n const blob = await encode(c, type);\n if (blob?.type !== type) return file;\n const keepsName = type === \"image/png\" ? /\\.png$/i.test(file.name) : /\\.jpe?g$/i.test(file.name);\n const name = keepsName ? file.name : `${file.name.replace(/\\.[^.]*$/, \"\") || \"image\"}.${type === \"image/png\" ? \"png\" : \"jpg\"}`;\n return new File([blob], name, { type, lastModified: file.lastModified });\n } catch {\n return file;\n } finally {\n bitmap?.close();\n }\n}\n", "// Light, dark or the system's (auto) theme (\u00A77.8): this device's choice, kept in localStorage. index.html's inline\n// script sets <html data-theme> before the first paint; this keeps it, and the browser's bar color, up to date.\n\nexport const THEMES = [\"auto\", \"light\", \"dark\"] as const;\nexport type Theme = (typeof THEMES)[number];\n\n/** Must match index.html's inline script. */\nexport const THEME_KEY = \"chat.theme\";\n\n/** --surface of each theme (tokens.css), for <meta name=\"theme-color\">. */\nconst BAR = { light: \"#f1eefc\", dark: \"#111214\" } as const;\n\nfunction safeLocalStorage(): Storage | null {\n try {\n return globalThis.localStorage ?? null;\n } catch {\n return null;\n }\n}\n\nexport function savedTheme(storage: Storage | null = safeLocalStorage()): Theme {\n try {\n const v = storage?.getItem(THEME_KEY);\n return v === \"light\" || v === \"dark\" ? v : \"auto\";\n } catch {\n return \"auto\";\n }\n}\n\n/** Show `theme` here: the stylesheet goes by <html data-theme>, the browser's bar by the theme-color metas. */\nexport function applyTheme(theme: Theme, doc: Document = document): void {\n const html = doc.documentElement;\n if (theme === \"auto\") delete html.dataset.theme;\n else html.dataset.theme = theme;\n for (const meta of doc.querySelectorAll<HTMLMetaElement>('meta[name=\"theme-color\"]')) {\n // Each meta's own media query says which theme it is for; a chosen theme gives both its color.\n const forTheme = meta.media.includes(\"dark\") ? \"dark\" : \"light\";\n meta.content = BAR[theme === \"auto\" ? forTheme : theme];\n }\n}\n\n/** Save and show `theme`. Storage can throw (private window, quota): the theme still changes for this page. */\nexport function setTheme(theme: Theme, storage: Storage | null = safeLocalStorage()): void {\n try {\n if (theme === \"auto\") storage?.removeItem(THEME_KEY);\n else storage?.setItem(THEME_KEY, theme);\n } catch {}\n applyTheme(theme);\n}\n\n/** Apply the saved theme and follow another tab's changes. Returns a function that stops following. */\nexport function startTheme(storage: Storage | null = safeLocalStorage()): () => void {\n applyTheme(savedTheme(storage));\n const ac = new AbortController();\n addEventListener(\n \"storage\",\n (e) => {\n if (e.key === THEME_KEY || e.key === null) applyTheme(savedTheme(storage));\n },\n { signal: ac.signal },\n );\n return () => ac.abort();\n}\n"],
|
|
5
|
-
"mappings": "AAsBO,SAASA,GAAqB,CACnC,IAAMC,EAAK,IAAI,gBACTC,EAA8B,CAAC,EACrC,MAAO,CACL,OAAQD,EAAG,OACX,IAAI,QAAS,CACX,MAAO,CAACA,EAAG,OAAO,OACpB,EACA,MAAME,EAAI,CACJF,EAAG,OAAO,QAAcE,EAAG,EAC1BD,EAAS,KAAKC,CAAE,CACvB,EACA,IAAIC,EAAc,CAGhBA,EAAa,MAAM,IAAM,CAAC,CAAC,EAC3B,KAAK,MAAM,IAAMA,EAAa,KAAMC,GAAQA,EAAI,CAAC,EAAE,MAAM,IAAM,CAAC,CAAC,CAAC,CACpE,EACA,SAAU,CACR,GAAI,CAAAJ,EAAG,OAAO,QACd,CAAAA,EAAG,MAAM,EACT,QAAWE,KAAMD,EAAS,QAAQ,EAChC,GAAI,CACGC,EAAG,CACV,MAAQ,CAER,CAEFD,EAAS,OAAS,EACpB,CACF,CACF,CCjDA,IAAMI,EAAW,IAAI,IAAI,CAAC,aAAc,YAAa,YAAY,CAAC,EAG3D,SAASC,EAAUC,EAAWC,EAAWC,EAAoD,CAClG,IAAMC,EAAQ,KA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ACf,wBACE,UACCC,GAAM,EACDA,EAAE,MAAQf,GAAae,EAAE,MAAQ,OAAMT,EAAWH,EAAWC,CAAO,CAAC,CAC3E,EACA,CAAE,OAAQU,EAAG,MAAO,CACtB,EACO,IAAMA,EAAG,MAAM,CACxB",
|
|
6
|
-
"names": ["createScope", "ac", "cleanups", "fn", "subscription", "off", "REENCODE", "fitWithin", "w", "h", "maxEdge", "scale", "canvas", "width", "height", "encode", "c", "type", "ok", "prepareImage", "file", "bitmap", "ctx", "blob", "name", "THEMES", "THEME_KEY", "BAR", "safeLocalStorage", "savedTheme", "storage", "v", "applyTheme", "theme", "doc", "html", "meta", "forTheme", "setTheme", "startTheme", "ac", "e"]
|
|
7
|
-
}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
var j={title:"Chirkle",logo:"",inviteOnly:!1,passwordReset:!1};var v=class extends Error{status;response;isAbort;constructor(o,n={},i=!1){super(n.message||"Something went wrong."),this.name="PbError",this.status=o,this.response=n,this.isAbort=i}},q="pocketbase_auth";function F(t){try{let o=t.split(".")[1].replaceAll("-","+").replaceAll("_","/");return Number(JSON.parse(atob(o)).exp)||0}catch{return 0}}function J(t){let o="",n=null,i=new Set,g=a=>{let d={};try{d=JSON.parse(a||"{}")??{}}catch{}o=d.token||"",n=d.record||null},f=(a,d)=>{o=a,n=d;for(let l of[...i])l()};return t&&(g(t.getItem(q)),addEventListener("storage",a=>{a.key===q&&(g(a.newValue),f(o,n))})),{get token(){return o},get record(){return n},get isValid(){return F(o)>Date.now()/1e3},get expiresAt(){return F(o)*1e3},save(a,d){t?.setItem(q,JSON.stringify({token:a,record:d})),f(a,d)},clear(){t?.removeItem(q),f("",null)},onChange(a){return i.add(a),()=>{i.delete(a)}}}}var Q=(t={})=>{let o=[];for(let[n,i]of Object.entries(t))i!==void 0&&o.push(`${encodeURIComponent(n)}=${encodeURIComponent(i)}`);return o.length?`?${o.join("&")}`:""},G=t=>t instanceof Blob||Array.isArray(t)&&t.some(o=>o instanceof Blob);function z(t){let o=new FormData;for(let[n,i]of Object.entries(t))if(i!==void 0)if(G(i))for(let g of[i].flat())o.append(n,g);else typeof i=="string"?o.append(n,i):o.append("@jsonPayload",JSON.stringify({[n]:i}));return o}function K(t,o,n,i,g){return new Promise((f,a)=>{let d=new XMLHttpRequest;d.open(o,t);for(let[l,b]of Object.entries(n))d.setRequestHeader(l,b);d.upload.onprogress=l=>l.lengthComputable&&l.total&&g(l.loaded/l.total),d.onload=()=>f({status:d.status,json:async()=>JSON.parse(d.responseText)}),d.onerror=()=>a(new TypeError("Network request failed")),d.onabort=()=>a(new DOMException("Aborted","AbortError")),d.send(i)})}function le(t,o=J()){let n=t.replace(/\/+$/,"");async function i(d,{method:l="GET",query:b,body:m,signal:h,onUpload:e,tag:r}={}){let s={};o.token&&(s.Authorization=o.token),r?.sent&&Object.assign(s,{"If-None-Match":r.sent,"Cache-Control":"no-cache"});let u;m&&(Object.values(m).some(G)?u=z(m):(s["Content-Type"]="application/json",u=JSON.stringify(m)));let w=_=>!!h?.aborted||_?.name==="AbortError",y,x={},k=n+d+Q(b);try{y=e&&u instanceof FormData?await K(k,l,s,u,e):await fetch(k,{method:l,headers:s,...u?{body:u}:{},...h?{signal:h}:{}});let _=y.headers?.get("ETag");if(_&&r?.got?.(_),y.status===304)return;x=await y.json().catch(C=>{if(w(C)||y.status<300&&y.status!==204)throw C;return{}})}catch(_){throw new v(0,{},w(_))}if(y.status>=400)throw new v(y.status,x??{});return x}let g=X(`${n}/api/realtime`,i),f=o.token,a=f?o.record?.id??"":"";return o.onChange(()=>{if(o.token===f)return;f=o.token;let d=f?o.record?.id??"":"";if(d===a)return g.resubmit();a=d,g.restart()}),{authStore:o,realtime:g,send:i,filter:(d,l)=>d.replace(/\{:(\w+)\}/g,(b,m)=>{if(!Object.hasOwn(l,m))return b;let h=l[m];return typeof h=="string"?JSON.stringify(h):String(h)}),fileUrl:(d,l,b,m)=>`${n}/api/files/${[d,l,b].map(encodeURIComponent).join("/")}${Q(m)}`}}var B=[200,300,500,1e3,1200,1500,2e3],Y=15e3;function X(t,o){let n=null,i="",g=new Map,f=[],a=0,d=!1,l,b,m=[],h=null,e=Promise.resolve(),r=()=>[...g.keys()],s=()=>{let p=r();return p.length!==f.length||p.some(P=>!f.includes(P))},u=new Set,w=p=>{let P=n;!P||u.has(p)||p==="PB_CONNECT"||(u.add(p),P.addEventListener(p,A=>{if(n===P)for(let R of g.get(p)??[])R(A)}))};async function y(){if(i){if(!g.size)return O();if(s()){f=r(),h=new AbortController;try{await o("/api/realtime",{method:"POST",body:{clientId:i,subscriptions:f},signal:h.signal})}catch(p){if(!(p instanceof v&&p.isAbort))throw p}}}}function x(){let p=e.then(y);return e=p.catch(()=>{}),p}function k(){return a>0?Promise.resolve():new Promise((p,P)=>{m.push({resolve:p,reject:P}),m.length===1&&queueMicrotask(_)})}function _(){O(!0),l=setTimeout(()=>C(new Error("EventSource connect took too long.")),Y);let p=new EventSource(t);n=p,u=new Set;for(let A of g.keys())w(A);let P=()=>n===p;p.onerror=()=>P()&&C(new Error("Failed to establish realtime connection.")),p.addEventListener("PB_CONNECT",A=>{P()&&(i=A.lastEventId,f=[],x().then(async()=>{for(let R=3;P()&&s()&&R>0;R--)await x();if(P()){for(let R of m)R.resolve();m=[],a=0,clearTimeout(b),clearTimeout(l);for(let R of g.get("PB_CONNECT")??[])R(A);d=!1,s()&&await x()}}).catch(R=>{P()&&(i="",f=[],C(R))}))})}function C(p){if(clearTimeout(l),clearTimeout(b),d=!0,!i&&!a){for(let P of m)P.reject(p instanceof v?p:new v(0));if(m=[],!g.size)return O()}O(!0),b=setTimeout(_,B[Math.min(a,B.length-1)]),a++}function O(p=!1){if(clearTimeout(l),clearTimeout(b),h?.abort(),h=null,n?.close(),n=null,i="",f=[],!p){a=0;for(let P of m)P.resolve();m=[]}}return{get isConnected(){return!!n&&!!i&&!m.length},get recovered(){return d},async subscribe(p,P,A){let R=A?`${p}?options=${encodeURIComponent(JSON.stringify({query:A}))}`:p,$=N=>{let L;try{L=JSON.parse(N.data)}catch{}P(L||{})},D=g.get(R)??[];return g.set(R,[...D,$]),w(R),!n||!i||m.length?await k():D.length||await x(),async()=>{let N=(g.get(R)??[]).filter(L=>L!==$);N.length?g.set(R,N):g.delete(R),await x()}},async unsubscribe(){g.clear(),await x()},resubmit(){if(!i||!g.size)return;f=[];let p=n;x().catch(()=>n===p&&C(new v(0)))},restart(){!n&&!m.length||(O(),g.size&&k().catch(()=>{}))}}}function ge(t){return{room:t,kind:"latest",args:{}}}function me(t){return{room:t,kind:"first",args:{}}}function pe(t,o){return{room:t,kind:"older",args:{created:o.created,id:o.id}}}function fe(t,o){return{room:t,kind:"newer",args:{created:o.created,id:o.id}}}function be(t,o,n,i){return{room:t,kind:"changed",args:{since:o,from:n.created,to:i.created}}}var he=t=>({...t,files:!0});var T=class extends Error{status;fields;codes;constructor(o,n,i={},g={}){super(o),this.name="ApiError",this.status=n,this.fields=i,this.codes=g}},ee="signup_login_failed";function te(t){return t instanceof T?t.status===0?"Can't reach the server. Check your connection.":t.status===429?"Too many attempts. Wait a few seconds and try again.":t.message:"Something went wrong. Please try again."}var Se=t=>t instanceof T&&Object.values(t.fields)[0]||te(t),re="id,room,text,created,updated,edited_at,deleted,files,file_names,file_sources,file_dims,reactions,previews,author,expand.author.id,expand.author.name,expand.author.avatar,expand.author.no_dms,expand.author.instance,reply_to,expand.reply_to.id,expand.reply_to.author,expand.reply_to.text,expand.reply_to.deleted,expand.reply_to.files,expand.reply_to.expand.author.id,expand.reply_to.expand.author.name,forwarded_from,forward_of,expand.forwarded_from.id,expand.forwarded_from.name,mentions",E={expand:"author,reply_to.author,forwarded_from",fields:re},ne="chat/messages",se="id,name,archived,created_by,kind,visibility,members,posting,writers,last_message_at,created,shared,expand.members.id,expand.members.name,expand.members.avatar,expand.members.no_dms,expand.members.instance,expand.writers.id,expand.writers.name,expand.writers.avatar,expand.writers.no_dms,expand.writers.instance",U={expand:"members,writers",fields:se},H="id,room",oe="id,title,logo,invite_only,password_reset";function W(t){if(t instanceof T)return t;if(t instanceof v){let o=t.response.data??{},n=i=>Object.fromEntries(Object.entries(o).filter(([,g])=>g&&typeof g[i]=="string").map(([g,f])=>[g,f[i]]));return new T(t.message,t.status,n("message"),n("code"))}return new T(t instanceof Error?t.message:String(t),0)}async function c(t){try{return await t}catch(o){throw W(o)}}var S=t=>({id:t.id,name:t.name,avatar:t.avatar??"",...t.no_dms?{no_dms:!0}:{},...t.instance?{instance:t.instance}:{},...t.moderator?{moderator:!0}:{},...t.handle?{handle:t.handle}:{}}),M="id,name,avatar,instance,handle";function V(t,o=50,n=1){return{kind:t.kind,...t.args,...t.files?{files:"1"}:{},...t.q?{q:t.q}:{},limit:o,...n>1?{page:n}:{},...E}}function I(t,o){let n=`/api/collections/${o}`,i=a=>`${n}/records/${encodeURIComponent(a)}`,g=(a,d,l,b)=>t.send(`${n}/records`,{query:{page:a,perPage:d,...l},signal:b}),f=async a=>{let{token:d,record:l}=await a;return t.authStore.save(d,l),l};return{list:g,async fullList(a,d,l=1e3){let b=[];for(let m=1;;m++){let{items:h}=await g(m,l,{skipTotal:!0,...a},d);if(b.push(...h),h.length<l)return b}},get:(a,d,l)=>t.send(i(a),{query:d,signal:l}),create:(a,d,l)=>t.send(`${n}/records`,{method:"POST",body:a,query:d,onUpload:l}),async update(a,d,l){let b=await t.send(i(a),{method:"PATCH",body:d,query:l}),m=t.authStore.record;return m?.id===b.id&&m.collectionName===o&&t.authStore.save(t.authStore.token,{...m,...b}),b},delete:a=>t.send(i(a),{method:"DELETE"}),authWithPassword:(a,d)=>f(t.send(`${n}/auth-with-password`,{method:"POST",body:{identity:a,password:d}})),authRefresh:async()=>{let a=t.authStore.token,{token:d,record:l}=await t.send(`${n}/auth-refresh`,{method:"POST"});return t.authStore.token===a&&t.authStore.save(d,l),l},action:(a,d)=>t.send(`${n}/${a}`,{method:"POST",body:d}),authAt:(a,d)=>f(t.send(a,{method:"POST",body:d}))}}var ie=new Set([400,401,403,404]);function Te(t){let o=new Set,n={authStore:t.authStore,realtime:t.realtime,filter:t.filter,fileUrl:t.fileUrl,async send(e,r={}){let s=t.authStore.token;try{return await t.send(e,r)}catch(u){let w=(r.method??"GET")!=="GET"&&!e.includes("/auth-");if(u instanceof v&&ie.has(u.status)&&w&&s&&s===t.authStore.token)for(let y of[...o])y();throw u}}},i=I(n,"users"),g=I(n,"rooms"),f=I(n,"hidden_rooms"),a=I(n,"messages"),d=I(n,"site"),l=(e,r,s)=>c(n.realtime.subscribe(`${e}/*`,u=>{let{action:w,record:y}=u;r(w,y)},s)),b=e=>c(n.realtime.subscribe(ne,r=>{let{action:s,record:u}=r;e(s,u)})),m=()=>{let e=h.currentUser();if(!e)throw new T("Not logged in.",401);return e.id},h={currentUser(){let e=n.authStore.record;return n.authStore.isValid&&e?.collectionName==="users"?S(e):null},async signUp({email:e,password:r,name:s,inviteCode:u}){let w=u?{invite_code:u}:{};await c(i.create({email:e,password:r,passwordConfirm:r,name:s,...w}));try{return await h.logIn(e,r)}catch(y){let x=W(y);throw new T(x.message,x.status,{},{auth:ee})}},async logIn(e,r){return S(await c(i.authWithPassword(e,r)))},async requestPasswordReset(e){await c(i.action("request-password-reset",{email:e.trim().toLowerCase()}))},async confirmPasswordReset(e,r){await c(i.action("confirm-password-reset",{token:e,password:r,passwordConfirm:r}))},async refreshAuth(){if(!h.currentUser())throw new T("Not logged in.",401);return S(await c(i.authRefresh()))},sessionExpiry:()=>n.authStore.expiresAt,logOut(){n.authStore.clear()},forgetExpired(){let e=n.authStore.record;return!e||n.authStore.isValid?"":(n.authStore.clear(),e.id)},onAuthChange(e){return n.authStore.onChange(()=>e())},onRejected(e){return o.add(e),()=>{o.delete(e)}},async site(e){let{items:r}=await c(d.list(1,1,{sort:"created",skipTotal:!0,fields:oe},e)),s=r[0];return s?{title:s.title||j.title,logo:s.logo?n.fileUrl("site",s.id,s.logo):"",inviteOnly:s.invite_only===!0,passwordReset:s.password_reset===!0}:j},setAvatar:async e=>S(await c(i.update(m(),{avatar:e},{fields:M}))),removeAvatar:async()=>S(await c(i.update(m(),{avatar:null},{fields:M}))),rename:async e=>S(await c(i.update(m(),{name:e},{fields:M}))),setHandle:async e=>S(await c(i.update(m(),{handle:e},{fields:M}))),async changePassword(e,r){return m(),S(await c(i.authAt("/api/chat/password",{oldPassword:e,password:r})))},avatarUrl(e,r){return e.avatar?n.fileUrl("users",e.id,e.avatar,{thumb:`${r}x${r}`}):""},listRooms:e=>c(n.send("/api/chat/rooms",{query:U,signal:e})),getRoom:(e,r)=>c(g.get(e,U,r)),createRoom:async(e,r)=>c(g.create({name:e,created_by:m(),...r?{visibility:r}:{}},U)),setArchived:(e,r)=>c(g.update(e,{archived:r},U)),setAccess:(e,r,s,u,w=[])=>c(g.update(e,{visibility:r,members:r==="private"?[...s]:[],...u?{posting:u,writers:u==="selected"?[...w]:[]}:{}},U)),openDm:e=>c(n.send("/api/chat/dms",{method:"POST",body:{user:e}})),async searchUsers(e,r){return m(),(await c(n.send("/api/chat/users",{query:{q:e},signal:r}))).map(S)},remoteUser:async(e,r)=>S(await c(n.send("/api/chat/remote-users",{method:"POST",body:{address:e,...r?{room:r}:{}}}))),async usersById(e,r){let s=e.slice(0,50);if(!s.length)return[];let u=Object.fromEntries(s.map((y,x)=>[`u${x}`,y])),w={filter:n.filter(s.map((y,x)=>`id = {:u${x}}`).join(" || "),u),fields:M,skipTotal:!0};return(await c(i.list(1,s.length,w,r))).items.map(S)},listHidden:e=>c(f.fullList({fields:H},e)),hideRoom:async e=>c(f.create({user:m(),room:e},{fields:H})),unhideRoom:async e=>{await c(f.delete(e))},unreadCounts:e=>c(n.send("/api/chat/unread",{signal:e})),firstUnread:(e,r)=>c(n.send(`/api/chat/unread/${e}`,{signal:r})),markRead:async(e,r)=>{await c(n.send("/api/chat/reads",{method:"POST",body:{room:e,at:r}}))},page:async(e,r,s)=>{let u=`/api/chat/rooms/${encodeURIComponent(e.room)}/messages`,w=s&&{sent:s.items.length?s.tag:void 0,got:s.got};return await c(n.send(u,{query:V(e),signal:r,tag:w}))??[...s?.items??[]]},getMessage:(e,r)=>c(a.get(e,E,r)),async changes(e,r){let s=[];for(let u=1;;u++){let w=`/api/chat/rooms/${encodeURIComponent(e.room)}/messages`,y=await c(n.send(w,{query:V(e,200,u),signal:r}));if(s.push(...y),y.length<200)return s}},send:async(e,r)=>c(a.create({id:e.id,room:e.room,author:m(),text:e.text,...e.files?.length?{files:e.files}:{},...e.replyTo?{reply_to:e.replyTo}:{},...e.items?.length?{items:e.items}:{}},E,e.files?.length?r:void 0)),edit:(e,r)=>c(a.update(e,{text:r},E)),softDelete:e=>c(a.update(e,{deleted:!0},E)),react:(e,r,s)=>c(n.send("/api/chat/reactions",{method:"POST",body:{message:e,emoji:r,on:s},query:E})),deleteMany:e=>c(n.send("/api/chat/delete",{method:"POST",body:{messages:e},query:E})),isBanned:async(e,r)=>!!(await c(i.get(e,{fields:"id,banned"},r))).banned,setBanned:async(e,r)=>{await c(n.send("/api/chat/ban",{method:"POST",body:{user:e,banned:r}}))},forward:(e,r)=>c(n.send("/api/chat/forward",{method:"POST",body:{messages:e,room:r},query:E})),fileUrl:(e,r,s)=>n.fileUrl("messages",e.forward_of||e.id,r,{thumb:s}),posterUrl:(e,r)=>h.fileUrl(e,r).replace("/api/files/messages/","/api/chat/posters/"),collections:e=>c(n.send("/api/chat/collections",{signal:e})),markSeen:async(e,r)=>{await c(n.send("/api/chat/subs/seen",{method:"POST",body:{collection:e,...r?{at:r}:{}}}))},badges:(e,r)=>c(n.send("/api/chat/badges",{query:{ids:e.join(",")},signal:r})),itemUrl:(e,r)=>n.fileUrl("collection_items",e.id,e.file,{thumb:r}),itemPosterUrl:e=>h.itemUrl(e).replace("/api/files/collection_items/","/api/chat/posters/items/"),async subscribeCollections(e,r){let s=await Promise.all([l("collections",r,{fields:"id",filter:n.filter("owner = {:me}",{me:m()})}),l("collection_subs",r,{fields:"id"}),...e.map(u=>c(n.realtime.subscribe(`collections/${u}`,r,{fields:"id"})))]);return async()=>{await Promise.all(s.map(u=>u()))}},subscribeBadges:e=>c(n.realtime.subscribe("chat/badges",r=>e(r.id))),request:(e,r)=>c(n.send(e,r)),media:(e,r,s)=>c(n.send(`/api/chat/media/${e}`,{query:r,signal:s})),subscribeMessages:(e,r)=>b((s,u)=>u.room===e&&r(s,u)),subscribeRooms:e=>l("rooms",e,U),subscribeHidden:e=>l("hidden_rooms",e,{fields:H}),subscribeAllMessages:e=>b((r,s)=>e(r,{id:s.id,room:s.room,author:s.author,deleted:s.deleted,reply_to:s.reply_to??"",mentions:s.mentions??[]})),subscribeInbox:e=>c(n.realtime.subscribe("chat/inbox",r=>e(r))),subscribeReads:e=>l("room_reads",e,{fields:H}),onConnect(e){let r=n.realtime.isConnected,s=n.realtime.subscribe("PB_CONNECT",()=>{e(r||n.realtime.recovered),r=!0});return s.catch(()=>{}),()=>{s.then(u=>u()).catch(()=>{})}},unsubscribeAll:()=>c(n.realtime.unsubscribe())};return h}var Ae={messageText:2e3,userName:32,roomName:48,passwordMin:8,passwordMaxBytes:71,avatarBytes:2097152,avatarTypes:["image/jpeg","image/png","image/webp","image/gif"],attachments:10,attachmentBytes:20971520,roomMembers:100};function Ee(t){let o=0;for(let n of t)o++;return o}var Ce=50;export{ge as a,me as b,pe as c,fe as d,be as e,he as f,j as g,J as h,le as i,T as j,ee as k,te as l,Se as m,Te as n,Ae as o,Ee as p,Ce as q};
|
|
2
|
-
//# sourceMappingURL=chunk-PWNJABVI.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{v as G}from"./chunk-GXMWOXBX.js";import"./chunk-DZC4SY4M.js";import{g as P,j as u,k as F,l as A,o as m,p as $}from"./chunk-PWNJABVI.js";import"./chunk-RPCBA7VF.js";import{a as o,b as W,c as v}from"./chunk-VTOUI25E.js";var Y=()=>({login:[{name:"email",label:"Email",type:"email",autocomplete:"email"},{name:"password",label:"Password",type:"password",autocomplete:"current-password"}],forgot:[{name:"email",label:"Email",type:"email",autocomplete:"email"}],reset:[{name:"password",label:"New password",type:"password",autocomplete:"new-password",extra:{minlength:m.passwordMin}}],signup:[{name:"name",label:"Display name",type:"text",autocomplete:"nickname"},{name:"email",label:"Email",type:"email",autocomplete:"email"},{name:"password",label:"Password",type:"password",autocomplete:"new-password",extra:{minlength:m.passwordMin}}]}),q={name:"invite_code",label:"Invite code",type:"text",autocomplete:"off"},I={login:"Log in",signup:"Sign up",forgot:"Reset password",reset:"Set a new password"},U=["login","signup"],J={forgot:"Send link",reset:"Set password"},j=()=>({forgot:"Enter your account's email, and we'll send you a link to set a new password.",reset:`At least ${m.passwordMin} characters. Every device logged in to this account is logged out.`});function X(a){try{let f=JSON.parse(atob(a.split(".")[1].replace(/-/g,"+").replace(/_/g,"/")));return typeof f.email=="string"?f.email:""}catch{return""}}function se(a){let f=Y(),N=j(),d=null,e=a.mode??"login",p=!1,L="",h="",s={name:"",email:"",password:"",invite_code:""},w=()=>a.store?.get().site??P,x=i=>i==="signup"&&w().inviteOnly?[...f.signup,q]:f[i],R=()=>{},B=W("login"),S;function r(i={}){d?.abort(),d=new AbortController;let{signal:t}=d,l=n=>()=>{e=n,h="",r()},c=U.map(n=>o("button",{type:"button",role:"tab","aria-selected":String(n===e),on:{click:()=>{n!==e&&(e=n,r())}},signal:t},I[n])),y=o("button",{type:"submit",class:"primary",disabled:p},J[e]??I[e]),E=e==="login"&&w().passwordReset?o("button",{type:"button",class:"link auth-forgot",on:{click:l("forgot")},signal:t},"Forgot password?"):null,k=x(e).map(n=>{let g=`${B}-${n.name}`,M=`${g}-error`,D=i.fields?.[n.name];return o("div",{class:"field"},[o("label",{for:g},n.label),o("input",{id:g,name:n.name,type:n.type,autocomplete:n.autocomplete,required:!0,value:s[n.name],"aria-invalid":D?"true":null,"aria-describedby":M,...n.extra,on:{input:V=>s[n.name]=V.target.value},signal:t}),o("p",{id:M,class:"field-error"},D??"")])}),b=o("form",{class:"auth-form","aria-label":I[e],on:{submit:n=>{n.preventDefault();for(let g of x(e))s[g.name]=b.elements.namedItem(g.name).value;H(y)}},signal:t},[N[e]?o("p",{class:"auth-hint"},N[e]):null,...k,E,o("p",{role:"alert",class:"form-error"},i.form??""),y]),O=h?o("p",{role:"status",class:"auth-hint"},`If an account uses ${h}, a link to set a new password is on its way. It works for 30 minutes.`):null,_=e==="forgot"?o("button",{type:"button",class:"link auth-back",on:{click:l("login")},signal:t},"Back to log in"):o("a",{href:"/login",class:"auth-back"},"Back to log in"),{title:C,logo:T}=w(),K=U.includes(e);v(S),S.append(o("section",{class:"auth"},[o("h1",{class:T?"has-logo":""},[T?o("img",{src:T,alt:"",class:"brand-logo"}):null,C]),G(w(),"p"),o("div",{class:"auth-card"},K?[o("div",{role:"tablist",class:"tabs"},c),b]:[o("h2",{},I[e]),O??b,_]),o("p",{class:"auth-skip"},o("a",{href:"/"},"Just looking? Read the Open Air rooms"))]))}async function H(i){if(!p){if(e==="signup"&&$(s.name.trim())>m.userName){r({fields:{name:`Must be no more than ${m.userName} characters.`}});return}if(e==="signup"&&new TextEncoder().encode(s.password).length>m.passwordMaxBytes){r({fields:{password:"Use at most 71 characters (fewer if some aren't plain Latin letters, digits or punctuation)."}});return}p=!0,i.disabled=!0;try{if(e==="forgot"){await a.api.requestPasswordReset(s.email),p=!1,h=s.email.trim(),r();return}if(e==="reset"){await a.api.confirmPasswordReset(L,s.password);let l=X(L);try{let c=await a.api.logIn(l,s.password);p=!1,a.onLogin(c)}catch{p=!1,e="login",s.email=l,r({form:"Your password was changed. Log in with it."})}return}let t=e==="login"?await a.api.logIn(s.email,s.password):await a.api.signUp({name:s.name,email:s.email,password:s.password,...w().inviteOnly?{inviteCode:s.invite_code}:{}});p=!1,i.disabled=!1,a.onLogin(t)}catch(t){if(p=!1,!d||d.signal.aborted)return;if(t instanceof u&&t.codes.auth===F){e="login",r({form:`Your account was created, but logging in failed: ${A(t)} Log in to continue.`});return}let l=t instanceof u?t.fields:{},c=Object.fromEntries(Object.entries(l).filter(([O])=>x(e).some(_=>_.name===O)));e==="signup"&&t instanceof u&&t.codes.email==="validation_not_unique"&&(c.email="There is already an account with this email. Log in instead.");let y=e==="login"&&t instanceof u&&t.status===400,E=t instanceof u&&!c.invite_code?l.invite_code:void 0,k=e==="reset"&&t instanceof u&&t.codes.token?"This link has expired or was already used. Ask for a new one.":"",b=Object.keys(c).length?"":E||k||(y?"Wrong email or password.":A(t));r({form:b,fields:c})}}}return{mount(i,t){S=i,L=t.token??"",r(),R=a.store?.subscribe((l,c)=>{l.site!==c.site&&!p&&r()})??(()=>{})},unmount(){R(),d?.abort(),d=null,v(S)}}}export{se as createLoginView};
|
|
2
|
-
//# sourceMappingURL=login-ECFBJP6Q.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as Z,b as re,c as D,d as ae,e as ne,f as oe}from"./chunk-IFQGGTSP.js";import{j as O,l as M,o as m,p as se}from"./chunk-PWNJABVI.js";import{a as te}from"./chunk-RPCBA7VF.js";import{a as e,b as ee,c as $}from"./chunk-VTOUI25E.js";var ie=i=>`That image is too large (max ${i} MB).`;var me=512,le="Choose a JPEG, PNG, WebP or GIF image.";function ce(i,c=m){return c.avatarTypes.includes(i.type)?i.size>c.avatarBytes?ie(c.avatarBytes/1024/1024):"":le}function fe(i,c,C,S=m){return i?c.length<S.passwordMin?{next:`Must be at least ${S.passwordMin} characters.`}:c===i?{next:"That is your current password. Choose a new one."}:C!==c?{confirm:"The passwords don't match."}:{}:{current:"Enter your current password."}}function xe({api:i,store:c,logOut:C,notify:S}){let U=(r,s)=>r instanceof O&&r.fields[s]||M(r),n=ee("profile"),l=Z(),{signal:u}=l,A,v=null,f=!1,w=()=>c.get().user,b=e("div",{class:"profile-picture"}),g=e("input",{id:`${n}-file`,type:"file",accept:m.avatarTypes.join(","),class:"visually-hidden"}),H=e("label",{for:`${n}-file`,class:"button"},"Change picture"),L=e("button",{type:"button"},"Remove"),y=e("p",{class:"field-error",role:"alert"}),G=e("p",{class:"field-status"}),W=()=>G.textContent=`Signed in as ${w()?.name??""} on this device.`;W();let E=e("input",{id:`${n}-name`,name:"name",autocomplete:"nickname","aria-describedby":`${n}-name-status`}),B=e("button",{type:"submit",class:"primary"},"Save"),k=e("p",{id:`${n}-name-status`,class:"field-status",role:"status"}),x=e("input",{id:`${n}-handle`,name:"handle",autocomplete:"username",autocapitalize:"none",spellcheck:!1,"aria-describedby":`${n}-handle-status`}),Y=e("button",{type:"submit",class:"primary"},"Save"),F=e("p",{id:`${n}-handle-status`,class:"field-status",role:"status"},"People mention you by it: @handle."),R=(r,s,t)=>{let a=`${n}-pw-${r}`,d=e("input",{id:a,type:"password",name:r,autocomplete:t,required:!0,...r==="current"?{}:{minlength:m.passwordMin},"aria-describedby":`${a}-error`}),o=e("p",{id:`${a}-error`,class:"field-error"}),T=e("div",{class:"field"},[e("label",{for:a},s),d,o]);return{input:d,error:o,el:T}},p={current:R("current","Current password","current-password"),next:R("next","New password","new-password"),confirm:R("confirm","Confirm new password","new-password")},I=e("button",{type:"submit",class:"primary"},"Change password"),h=e("p",{class:"field-status",role:"status"}),de={auto:"Auto",light:"Light",dark:"Dark"},V=new Map,j=e("div",{class:"segmented"},[...D.map(r=>{let s=e("input",{type:"radio",name:`${n}-theme`,value:r});return V.set(r,s),e("label",{},[s,de[r]])})]),z=()=>{let r=ne();for(let[s,t]of V)t.checked=s===r},J=e("div");function N(){v&&URL.revokeObjectURL(v),v=null}function _(){let r=w();if(!r)return;let s=v?e("img",{class:"avatar s96",src:v,width:96,height:96,alt:""}):te(r,96,i.avatarUrl);b.replaceChildren(s),b.classList.toggle("busy",f),L.hidden=!r.avatar||f,g.disabled=f,H.classList.toggle("disabled",f)}async function K(r){if(!r||f)return;y.textContent="";let s=ce(new File([],r.name,{type:r.type}),m);if(s){y.textContent=s;return}f=!0;let t=await re(r,me);if(!l.active)return;let a=ce(t,m);if(a){f=!1,y.textContent=a;return}N(),v=URL.createObjectURL(t),_(),await q(()=>i.setAvatar(t))}async function q(r){f=!0,_();try{let s=await r();if(!l.active)return;c.set({user:s})}catch(s){let t=s instanceof O&&s.codes.avatar==="validation_invalid_mime_type";l.active&&(y.textContent=t?le:U(s,"avatar"))}finally{l.active&&(f=!1,N(),_())}}async function Q(r,s){r.preventDefault();let[t,a,d]=s==="name"?[E,k,B]:[x,F,Y],o=s==="name"?t.value.trim():t.value.trim().replace(/^@/,"").toLowerCase();a.classList.remove("error");let T=s==="handle"?/^[a-z0-9_]{3,24}$/.test(o)?"":"Use 3 to 24 letters a\u2013z, digits or underscores.":o?se(o)>m.userName?`Must be no more than ${m.userName} characters.`:"":"A display name can't be empty.";if(T){a.textContent=T,a.classList.add("error"),t.setAttribute("aria-invalid","true");return}if(a.textContent="",t.removeAttribute("aria-invalid"),o!==w()?.[s]){d.disabled=!0;try{let P=await(s==="name"?i.rename(o):i.setHandle(o));if(!l.active)return;c.set({user:P}),t.value=P[s]??"",a.textContent="Saved."}catch(P){if(!l.active)return;a.textContent=U(P,s),a.classList.add("error"),t.setAttribute("aria-invalid","true")}finally{d.disabled=!1}}}function X(r){for(let[t,a]of Object.entries(p)){let d=r[t]??"";a.error.textContent=d,d?a.input.setAttribute("aria-invalid","true"):a.input.removeAttribute("aria-invalid")}let s=Object.keys(p).find(t=>r[t]);s&&p[s].input.focus()}async function ue(r){r.preventDefault();let s=p.current.input.value,t=p.next.input.value;h.textContent="",h.classList.remove("error");let a=fe(s,t,p.confirm.input.value,m);if(X(a),!Object.keys(a).length){I.disabled=!0;try{let d=await i.changePassword(s,t);if(!l.active)return;c.set({user:d});for(let o of Object.values(p))o.input.value="";h.textContent="Password changed. You were logged out everywhere else."}catch(d){if(!l.active)return;let o=d instanceof O?d.fields:{};o.oldPassword||o.password?X({...o.oldPassword?{current:o.oldPassword}:{},...o.password?{next:o.password}:{}}):(h.textContent=M(d),h.classList.add("error"))}finally{l.active&&(I.disabled=!1)}}}return{mount(r){A=r,E.value=w()?.name??"",x.value=w()?.handle??"",g.addEventListener("change",()=>{let t=g.files?.[0];g.value="",K(t)},{signal:u}),L.addEventListener("click",()=>{q(()=>i.removeAvatar())},{signal:u}),b.addEventListener("dragover",t=>t.preventDefault(),{signal:u}),b.addEventListener("drop",t=>{t.preventDefault(),K(t.dataTransfer?.files[0])},{signal:u});let s=e("section",{class:"profile","aria-labelledby":`${n}-title`},[e("header",{class:"room-header"},[e("a",{href:"/",class:"back ic i-back","aria-label":"Back to rooms"}),e("h1",{id:`${n}-title`},"Settings")]),e("div",{class:"profile-body"},[e("section",{class:"card","aria-label":"Profile"},[e("div",{class:"profile-avatar"},[b,e("div",{},[e("h2",{},"Profile picture"),e("div",{class:"profile-avatar-actions"},[g,H,L])])]),y,e("form",{class:"profile-name",on:{submit:t=>{Q(t,"name")}},signal:u},[e("label",{for:`${n}-name`},"Display name"),e("div",{class:"row"},[E,B]),k]),e("form",{class:"profile-name",on:{submit:t=>{Q(t,"handle")}},signal:u},[e("label",{for:`${n}-handle`},"Handle"),e("div",{class:"row"},[x,Y]),F])]),e("fieldset",{class:"card profile-theme","aria-describedby":`${n}-theme-hint`},[e("legend",{},"Appearance"),e("p",{id:`${n}-theme-hint`,class:"field-status"},"Auto follows your system. Saved on this device."),j]),J,e("form",{class:"card profile-password","aria-labelledby":`${n}-pw-title`,novalidate:!0,on:{submit:t=>{ue(t)}},signal:u},[e("h2",{id:`${n}-pw-title`},"Password"),p.current.el,p.next.el,p.confirm.el,I,h]),c.get().user?.moderator?e("section",{class:"card profile-session","aria-labelledby":`${n}-stats-title`},[e("div",{},[e("h2",{id:`${n}-stats-title`},"Moderation"),e("p",{class:"field-status"},"How many people are online and use the app, as counts.")]),e("a",{href:"/stats"},"Usage statistics")]):null,e("section",{class:"card profile-session","aria-labelledby":`${n}-session-title`},[e("div",{},[e("h2",{id:`${n}-session-title`},"Session"),G]),e("button",{type:"button",class:"danger",on:{click:()=>C()},signal:u},"Log out")])])]);$(A),A.append(s),_(),z(),import("./notify-EPDM772N.js").then(t=>l.active&&J.replaceWith(t.notifySettings({id:n,onChange:S,signal:u})),()=>{}),j.addEventListener("change",t=>{let a=t.target.value;D.includes(a)&&oe(a)},{signal:u}),addEventListener("storage",t=>(t.key===ae||t.key===null)&&z(),{signal:u}),l.defer(c.subscribe((t,a)=>{t.user!==a.user&&(_(),W(),t.user&&E.value.trim()===a.user?.name&&(E.value=t.user.name),t.user&&x.value.trim()===(a.user?.handle??"")&&(x.value=t.user.handle??""))})),l.defer(N)},unmount(){l.dispose(),$(A)}}}export{ce as avatarProblem,xe as createProfileView,fe as passwordProblem};
|
|
2
|
-
//# sourceMappingURL=profile-NQQLAEDT.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../web/src/strings/profile.ts", "../../web/src/views/profile.ts"],
|
|
4
|
-
"sourcesContent": ["// The user-facing text of views/profile.ts (docs/REFACTOR.md item 56): one module per source file, so a lazy\n// screen's text stays in its own chunk. Copy changes here; a translation would replace these.\n\nexport const CHOOSE_A_JPEG_PNG_WEBP_OR = \"Choose a JPEG, PNG, WebP or GIF image.\";\nexport const thatImageIsTooLargeMax = (mb: string | number) => `That image is too large (max ${mb} MB).`;\nexport const ENTER_YOUR_CURRENT_PASSWORD = \"Enter your current password.\";\nexport const mustBeAtLeastCharacters = (passwordMin: string | number) => `Must be at least ${passwordMin} characters.`;\nexport const THAT_IS_YOUR_CURRENT_PASSWORD_CHOOSE = \"That is your current password. Choose a new one.\";\nexport const THE_PASSWORDS_DONT_MATCH = \"The passwords don't match.\";\nexport const CHANGE_PICTURE = \"Change picture\";\nexport const REMOVE = \"Remove\";\nexport const signedInAsOnThisDevice = (name: string | number) => `Signed in as ${name} on this device.`;\nexport const SAVE = \"Save\";\nexport const PEOPLE_MENTION_YOU_BY_IT_HANDLE = \"People mention you by it: @handle.\";\nexport const CURRENT_PASSWORD = \"Current password\";\nexport const NEW_PASSWORD = \"New password\";\nexport const CONFIRM_NEW_PASSWORD = \"Confirm new password\";\nexport const CHANGE_PASSWORD = \"Change password\";\nexport const DARK = \"Dark\";\nexport const LIGHT = \"Light\";\nexport const AUTO = \"Auto\";\nexport const USE_3_TO_24_LETTERS_A = \"Use 3 to 24 letters a\u2013z, digits or underscores.\";\nexport const mustBeNoMoreThanCharacters = (userName: string | number) => `Must be no more than ${userName} characters.`;\nexport const SAVED = \"Saved.\";\nexport const PASSWORD_CHANGED_YOU_WERE_LOGGED_OUT = \"Password changed. You were logged out everywhere else.\";\nexport const BACK_TO_ROOMS = \"Back to rooms\";\nexport const SETTINGS = \"Settings\";\nexport const PROFILE = \"Profile\";\nexport const PROFILE_PICTURE = \"Profile picture\";\nexport const DISPLAY_NAME = \"Display name\";\nexport const HANDLE = \"Handle\";\nexport const APPEARANCE = \"Appearance\";\nexport const AUTO_FOLLOWS_YOUR_SYSTEM_SAVED_ON = \"Auto follows your system. Saved on this device.\";\nexport const PASSWORD = \"Password\";\nexport const MODERATION = \"Moderation\";\nexport const HOW_MANY_PEOPLE_ARE_ONLINE_AND = \"How many people are online and use the app, as counts.\";\nexport const USAGE_STATISTICS = \"Usage statistics\";\nexport const SESSION = \"Session\";\nexport const LOG_OUT = \"Log out\";\nexport const A_DISPLAY_NAME_CANT_BE_EMPTY = \"A display name can't be empty.\";\n", "// Profile (\u00A715.5, \u00A722.2): change or remove your avatar, change your display name (unique, \u00A722.1), pick this\n// device's theme (\u00A77.8) and notifications (\u00A734, a lazy chunk), change your password, log out.\n//\n// A lazy chunk: app.ts loads it for /me.\n\nimport { ApiError, errorMessage } from \"../api.ts\";\nimport type { Ctx } from \"../context.ts\";\nimport { clear, h, uniqueId } from \"../dom.ts\";\nimport { prepareImage } from \"../lib/image.ts\";\nimport { LIMITS, textLength } from \"../lib/limits.ts\";\nimport type { User } from \"../lib/types.ts\";\nimport type { View } from \"../router.ts\";\nimport { createScope } from \"../scope.ts\";\nimport * as S from \"../strings/profile.ts\";\nimport { savedTheme, setTheme, THEME_KEY, THEMES, type Theme } from \"../theme.ts\";\nimport { avatar } from \"../ui/avatar.ts\";\n\n/** Longest edge of an uploaded avatar (\u00A715.3). */\nconst AVATAR_EDGE = 512;\n\nconst NOT_AN_IMAGE = \"Choose a JPEG, PNG, WebP or GIF image.\";\n\n/** Why `file` can't be an avatar (after preparation), or \"\". */\nexport function avatarProblem(file: File, limits = LIMITS): string {\n if (!(limits.avatarTypes as readonly string[]).includes(file.type)) return NOT_AN_IMAGE;\n if (file.size > limits.avatarBytes) return S.thatImageIsTooLargeMax(limits.avatarBytes / 1024 / 1024);\n return \"\";\n}\n\n/** Why a new password can't be used, or \"\" (the server checks again). */\nexport function passwordProblem(\n current: string,\n next: string,\n confirm: string,\n limits = LIMITS,\n): Partial<Record<\"current\" | \"next\" | \"confirm\", string>> {\n if (!current) return { current: \"Enter your current password.\" };\n if (next.length < limits.passwordMin) return { next: `Must be at least ${limits.passwordMin} characters.` };\n if (next === current) return { next: \"That is your current password. Choose a new one.\" };\n if (confirm !== next) return { confirm: \"The passwords don't match.\" };\n return {};\n}\n\nexport function createProfileView({ api, store, logOut, notify }: Pick<Ctx, \"api\" | \"store\" | \"logOut\" | \"notify\">): View {\n const fieldMessage = (e: unknown, field: string) => (e instanceof ApiError && e.fields[field]) || errorMessage(e);\n const vid = uniqueId(\"profile\");\n const scope = createScope();\n const { signal } = scope;\n let root: HTMLElement;\n let preview: string | null = null;\n let busy = false;\n\n const me = () => store.get().user;\n\n const picture = h(\"div\", { class: \"profile-picture\" });\n const fileInput = h(\"input\", {\n id: `${vid}-file`,\n type: \"file\",\n accept: LIMITS.avatarTypes.join(\",\"),\n class: \"visually-hidden\",\n });\n const changeLabel = h(\"label\", { for: `${vid}-file`, class: \"button\" }, \"Change picture\");\n const removeBtn = h(\"button\", { type: \"button\" }, \"Remove\");\n const avatarError = h(\"p\", { class: \"field-error\", role: \"alert\" });\n\n const signedIn = h(\"p\", { class: \"field-status\" });\n const showSignedIn = () => (signedIn.textContent = `Signed in as ${me()?.name ?? \"\"} on this device.`);\n showSignedIn();\n const nameInput = h(\"input\", { id: `${vid}-name`, name: \"name\", autocomplete: \"nickname\", \"aria-describedby\": `${vid}-name-status` });\n const saveBtn = h(\"button\", { type: \"submit\", class: \"primary\" }, \"Save\");\n const nameStatus = h(\"p\", { id: `${vid}-name-status`, class: \"field-status\", role: \"status\" });\n // The handle (\u00A741): what \"@handle\" names in messages.\n const handleInput = h(\"input\", {\n id: `${vid}-handle`,\n name: \"handle\",\n autocomplete: \"username\",\n autocapitalize: \"none\",\n spellcheck: false,\n \"aria-describedby\": `${vid}-handle-status`,\n });\n const handleBtn = h(\"button\", { type: \"submit\", class: \"primary\" }, \"Save\");\n const handleStatus = h(\"p\", { id: `${vid}-handle-status`, class: \"field-status\", role: \"status\" }, \"People mention you by it: @handle.\");\n\n // Password (\u00A722.2): each field with its own error under it.\n const pwField = (key: \"current\" | \"next\" | \"confirm\", label: string, autocomplete: string) => {\n const id = `${vid}-pw-${key}`;\n const input = h(\"input\", {\n id,\n type: \"password\",\n name: key,\n autocomplete,\n required: true,\n ...(key === \"current\" ? {} : { minlength: LIMITS.passwordMin }),\n \"aria-describedby\": `${id}-error`,\n });\n const error = h(\"p\", { id: `${id}-error`, class: \"field-error\" });\n const el = h(\"div\", { class: \"field\" }, [h(\"label\", { for: id }, label), input, error]);\n return { input, error, el };\n };\n const pw = {\n current: pwField(\"current\", \"Current password\", \"current-password\"),\n next: pwField(\"next\", \"New password\", \"new-password\"),\n confirm: pwField(\"confirm\", \"Confirm new password\", \"new-password\"),\n };\n const pwBtn = h(\"button\", { type: \"submit\", class: \"primary\" }, \"Change password\");\n const pwStatus = h(\"p\", { class: \"field-status\", role: \"status\" });\n\n // Appearance (\u00A77.8): this device's theme, not the account's.\n const THEME_LABELS: Record<Theme, string> = { auto: \"Auto\", light: \"Light\", dark: \"Dark\" };\n const themeRadios = new Map<Theme, HTMLInputElement>();\n const themeChoices = h(\"div\", { class: \"segmented\" }, [\n ...THEMES.map((t) => {\n const input = h(\"input\", { type: \"radio\", name: `${vid}-theme`, value: t });\n themeRadios.set(t, input);\n return h(\"label\", {}, [input, THEME_LABELS[t]]);\n }),\n ]);\n const showTheme = () => {\n const theme = savedTheme();\n for (const [t, input] of themeRadios) input.checked = t === theme;\n };\n\n // Notifications (\u00A734): their settings come with notify.ts, a lazy chunk.\n const notifyBox = h(\"div\");\n\n function dropPreview() {\n if (preview) URL.revokeObjectURL(preview);\n preview = null;\n }\n\n function renderPicture() {\n const user = me();\n if (!user) return;\n const shown = preview\n ? h(\"img\", { class: \"avatar s96\", src: preview, width: 96, height: 96, alt: \"\" })\n : avatar(user, 96, api.avatarUrl);\n picture.replaceChildren(shown);\n picture.classList.toggle(\"busy\", busy);\n removeBtn.hidden = !user.avatar || busy;\n fileInput.disabled = busy;\n changeLabel.classList.toggle(\"disabled\", busy);\n }\n\n async function upload(file: File | undefined) {\n if (!file || busy) return;\n avatarError.textContent = \"\";\n // Check the type before decoding; the size after preparation (which usually shrinks it).\n const typeProblem = avatarProblem(new File([], file.name, { type: file.type }), LIMITS);\n if (typeProblem) {\n avatarError.textContent = typeProblem;\n return;\n }\n busy = true;\n const prepared = await prepareImage(file, AVATAR_EDGE);\n if (!scope.active) return;\n const problem = avatarProblem(prepared, LIMITS);\n if (problem) {\n busy = false;\n avatarError.textContent = problem;\n return;\n }\n dropPreview();\n preview = URL.createObjectURL(prepared);\n renderPicture();\n await save(() => api.setAvatar(prepared));\n }\n\n async function save(call: () => Promise<User>) {\n busy = true;\n renderPicture();\n try {\n const user = await call();\n if (!scope.active) return;\n store.set({ user });\n } catch (e) {\n // The server goes by what the file is, not its name: one that only looks like an image (QA BUG-122).\n const notImage = e instanceof ApiError && e.codes.avatar === \"validation_invalid_mime_type\";\n if (scope.active) avatarError.textContent = notImage ? NOT_AN_IMAGE : fieldMessage(e, \"avatar\");\n } finally {\n if (scope.active) {\n busy = false;\n dropPreview();\n renderPicture();\n }\n }\n }\n\n /** Save the display name (\u00A722.1) or the handle (\u00A741), with what is wrong with it said under it. */\n async function saveField(e: Event, key: \"name\" | \"handle\") {\n e.preventDefault();\n const [input, status, btn] = key === \"name\" ? [nameInput, nameStatus, saveBtn] : [handleInput, handleStatus, handleBtn];\n const value = key === \"name\" ? input.value.trim() : input.value.trim().replace(/^@/, \"\").toLowerCase();\n status.classList.remove(\"error\");\n const problem =\n key === \"handle\"\n ? /^[a-z0-9_]{3,24}$/.test(value)\n ? \"\"\n : \"Use 3 to 24 letters a\u2013z, digits or underscores.\"\n : !value\n ? \"A display name can't be empty.\"\n : textLength(value) > LIMITS.userName\n ? `Must be no more than ${LIMITS.userName} characters.`\n : \"\";\n if (problem) {\n status.textContent = problem;\n status.classList.add(\"error\");\n input.setAttribute(\"aria-invalid\", \"true\");\n return;\n }\n // Your own one back (after \"taken\", say): nothing to save, and nothing wrong any more (QA BUG-56).\n status.textContent = \"\";\n input.removeAttribute(\"aria-invalid\");\n if (value === me()?.[key]) return;\n btn.disabled = true;\n try {\n const user = await (key === \"name\" ? api.rename(value) : api.setHandle(value));\n if (!scope.active) return;\n store.set({ user });\n input.value = user[key] ?? \"\";\n status.textContent = \"Saved.\";\n } catch (err) {\n if (!scope.active) return;\n status.textContent = fieldMessage(err, key);\n status.classList.add(\"error\");\n input.setAttribute(\"aria-invalid\", \"true\");\n } finally {\n btn.disabled = false;\n }\n }\n\n function showPasswordErrors(errors: Partial<Record<keyof typeof pw, string>>) {\n for (const [key, f] of Object.entries(pw) as [keyof typeof pw, (typeof pw)[keyof typeof pw]][]) {\n const msg = errors[key] ?? \"\";\n f.error.textContent = msg;\n if (msg) f.input.setAttribute(\"aria-invalid\", \"true\");\n else f.input.removeAttribute(\"aria-invalid\");\n }\n const first = (Object.keys(pw) as (keyof typeof pw)[]).find((k) => errors[k]);\n if (first) pw[first].input.focus();\n }\n\n async function changePassword(e: Event) {\n e.preventDefault();\n const current = pw.current.input.value;\n const next = pw.next.input.value;\n pwStatus.textContent = \"\";\n pwStatus.classList.remove(\"error\");\n const problem = passwordProblem(current, next, pw.confirm.input.value, LIMITS);\n showPasswordErrors(problem);\n if (Object.keys(problem).length) return;\n pwBtn.disabled = true;\n try {\n const user = await api.changePassword(current, next);\n if (!scope.active) return;\n store.set({ user });\n for (const f of Object.values(pw)) f.input.value = \"\";\n pwStatus.textContent = \"Password changed. You were logged out everywhere else.\";\n } catch (err) {\n if (!scope.active) return;\n const fields = err instanceof ApiError ? err.fields : {};\n if (fields.oldPassword || fields.password) {\n showPasswordErrors({\n ...(fields.oldPassword ? { current: fields.oldPassword } : {}),\n ...(fields.password ? { next: fields.password } : {}),\n });\n } else {\n pwStatus.textContent = errorMessage(err);\n pwStatus.classList.add(\"error\");\n }\n } finally {\n if (scope.active) pwBtn.disabled = false;\n }\n }\n\n return {\n mount(el) {\n root = el;\n nameInput.value = me()?.name ?? \"\";\n handleInput.value = me()?.handle ?? \"\";\n fileInput.addEventListener(\n \"change\",\n () => {\n const file = fileInput.files?.[0];\n fileInput.value = \"\"; // picking the same file again must fire `change` again\n void upload(file);\n },\n { signal },\n );\n removeBtn.addEventListener(\"click\", () => void save(() => api.removeAvatar()), { signal });\n // Drag and drop an image onto the picture.\n picture.addEventListener(\"dragover\", (e) => e.preventDefault(), { signal });\n picture.addEventListener(\n \"drop\",\n (e) => {\n e.preventDefault();\n void upload(e.dataTransfer?.files[0]);\n },\n { signal },\n );\n\n const shell = h(\"section\", { class: \"profile\", \"aria-labelledby\": `${vid}-title` }, [\n h(\"header\", { class: \"room-header\" }, [\n h(\"a\", { href: \"/\", class: \"back ic i-back\", \"aria-label\": \"Back to rooms\" }),\n h(\"h1\", { id: `${vid}-title` }, \"Settings\"),\n ]),\n // A card for each: the picture and name, Appearance, Notifications, Password, Session.\n h(\"div\", { class: \"profile-body\" }, [\n h(\"section\", { class: \"card\", \"aria-label\": \"Profile\" }, [\n h(\"div\", { class: \"profile-avatar\" }, [\n picture,\n h(\"div\", {}, [\n h(\"h2\", {}, \"Profile picture\"),\n h(\"div\", { class: \"profile-avatar-actions\" }, [fileInput, changeLabel, removeBtn]),\n ]),\n ]),\n avatarError,\n h(\"form\", { class: \"profile-name\", on: { submit: (e) => void saveField(e, \"name\") }, signal }, [\n h(\"label\", { for: `${vid}-name` }, \"Display name\"),\n h(\"div\", { class: \"row\" }, [nameInput, saveBtn]),\n nameStatus,\n ]),\n h(\"form\", { class: \"profile-name\", on: { submit: (e) => void saveField(e, \"handle\") }, signal }, [\n h(\"label\", { for: `${vid}-handle` }, \"Handle\"),\n h(\"div\", { class: \"row\" }, [handleInput, handleBtn]),\n handleStatus,\n ]),\n ]),\n h(\"fieldset\", { class: \"card profile-theme\", \"aria-describedby\": `${vid}-theme-hint` }, [\n h(\"legend\", {}, \"Appearance\"),\n h(\"p\", { id: `${vid}-theme-hint`, class: \"field-status\" }, \"Auto follows your system. Saved on this device.\"),\n themeChoices,\n ]),\n notifyBox,\n h(\n \"form\",\n {\n class: \"card profile-password\",\n \"aria-labelledby\": `${vid}-pw-title`,\n novalidate: true, // the errors are ours, next to each field\n on: { submit: (e) => void changePassword(e) },\n signal,\n },\n [h(\"h2\", { id: `${vid}-pw-title` }, \"Password\"), pw.current.el, pw.next.el, pw.confirm.el, pwBtn, pwStatus],\n ),\n // Moderators see the usage statistics (\u00A740), a page of its own.\n store.get().user?.moderator\n ? h(\"section\", { class: \"card profile-session\", \"aria-labelledby\": `${vid}-stats-title` }, [\n h(\"div\", {}, [\n h(\"h2\", { id: `${vid}-stats-title` }, \"Moderation\"),\n h(\"p\", { class: \"field-status\" }, \"How many people are online and use the app, as counts.\"),\n ]),\n h(\"a\", { href: \"/stats\" }, \"Usage statistics\"),\n ])\n : null,\n h(\"section\", { class: \"card profile-session\", \"aria-labelledby\": `${vid}-session-title` }, [\n h(\"div\", {}, [h(\"h2\", { id: `${vid}-session-title` }, \"Session\"), signedIn]),\n h(\"button\", { type: \"button\", class: \"danger\", on: { click: () => logOut() }, signal }, \"Log out\"),\n ]),\n ]),\n ]);\n clear(root);\n root.append(shell);\n renderPicture();\n showTheme();\n void import(\"../notify.ts\").then(\n (m) => scope.active && notifyBox.replaceWith(m.notifySettings({ id: vid, onChange: notify, signal })),\n () => {},\n );\n themeChoices.addEventListener(\n \"change\",\n (e) => {\n const t = (e.target as HTMLInputElement).value as Theme;\n if ((THEMES as readonly string[]).includes(t)) setTheme(t);\n },\n { signal },\n );\n // Chosen in another tab (theme.ts applies it): show it here too.\n addEventListener(\"storage\", (e) => (e.key === THEME_KEY || e.key === null) && showTheme(), { signal });\n scope.defer(\n store.subscribe((s, prev) => {\n if (s.user === prev.user) return;\n renderPicture();\n showSignedIn(); // renamed here or in another tab (QA BUG-203)\n // Renamed in another tab: show the new name, unless a change is being typed here. Saving the old one\n // would quietly undo the rename.\n if (s.user && nameInput.value.trim() === prev.user?.name) nameInput.value = s.user.name;\n if (s.user && handleInput.value.trim() === (prev.user?.handle ?? \"\")) handleInput.value = s.user.handle ?? \"\";\n }),\n );\n scope.defer(dropPreview);\n },\n unmount() {\n scope.dispose();\n clear(root);\n },\n };\n}\n"],
|
|
5
|
-
"mappings": "6OAIO,IAAMA,GAA0BC,GAAwB,gCAAgCA,CAAE,QCcjG,IAAMC,GAAc,IAEdC,GAAe,yCAGd,SAASC,GAAcC,EAAYC,EAASC,EAAgB,CACjE,OAAMD,EAAO,YAAkC,SAASD,EAAK,IAAI,EAC7DA,EAAK,KAAOC,EAAO,YAAsBE,GAAuBF,EAAO,YAAc,KAAO,IAAI,EAC7F,GAFoEH,EAG7E,CAGO,SAASM,GACdC,EACAC,EACAC,EACAN,EAASC,EACgD,CACzD,OAAKG,EACDC,EAAK,OAASL,EAAO,YAAoB,CAAE,KAAM,oBAAoBA,EAAO,WAAW,cAAe,EACtGK,IAASD,EAAgB,CAAE,KAAM,kDAAmD,EACpFE,IAAYD,EAAa,CAAE,QAAS,4BAA6B,EAC9D,CAAC,EAJa,CAAE,QAAS,8BAA+B,CAKjE,CAEO,SAASE,GAAkB,CAAE,IAAAC,EAAK,MAAAC,EAAO,OAAAC,EAAQ,OAAAC,CAAO,EAA2D,CACxH,IAAMC,EA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e,CAAE,GAAIxE,EAAK,SAAUN,EAAQ,OAAAU,CAAO,CAAC,CAAC,EACpG,IAAM,CAAC,CACT,EACAgC,EAAa,iBACX,SACCxC,GAAM,CACL,IAAM0C,EAAK1C,EAAE,OAA4B,MACpCyC,EAA6B,SAASC,CAAC,GAAGmC,GAASnC,CAAC,CAC3D,EACA,CAAE,OAAAlC,CAAO,CACX,EAEA,iBAAiB,UAAYR,IAAOA,EAAE,MAAQ8E,IAAa9E,EAAE,MAAQ,OAAS2C,EAAU,EAAG,CAAE,OAAAnC,CAAO,CAAC,EACrGF,EAAM,MACJV,EAAM,UAAU,CAACmF,EAAGC,IAAS,CACvBD,EAAE,OAASC,EAAK,OACpBhC,EAAc,EACd5B,EAAa,EAGT2D,EAAE,MAAQ1D,EAAU,MAAM,KAAK,IAAM2D,EAAK,MAAM,OAAM3D,EAAU,MAAQ0D,EAAE,KAAK,MAC/EA,EAAE,MAAQvD,EAAY,MAAM,KAAK,KAAOwD,EAAK,MAAM,QAAU,MAAKxD,EAAY,MAAQuD,EAAE,KAAK,QAAU,IAC7G,CAAC,CACH,EACAzE,EAAM,MAAMyC,CAAW,CACzB,EACA,SAAU,CACRzC,EAAM,QAAQ,EACdqE,EAAMlE,CAAI,CACZ,CACF,CACF",
|
|
6
|
-
"names": ["thatImageIsTooLargeMax", "mb", "AVATAR_EDGE", "NOT_AN_IMAGE", "avatarProblem", "file", "limits", "LIMITS", "thatImageIsTooLargeMax", "passwordProblem", "current", "next", "confirm", "createProfileView", "api", "store", "logOut", "notify", "fieldMessage", "e", "field", "ApiError", "errorMessage", "vid", "uniqueId", "scope", "createScope", "signal", "root", "preview", "busy", "me", "picture", "h", "fileInput", "changeLabel", "removeBtn", "avatarError", "signedIn", "showSignedIn", "nameInput", "saveBtn", "nameStatus", "handleInput", "handleBtn", "handleStatus", "pwField", "key", "label", "autocomplete", "id", "input", "error", "el", "pw", "pwBtn", "pwStatus", "THEME_LABELS", "themeRadios", "themeChoices", "THEMES", "t", "showTheme", "theme", "savedTheme", "notifyBox", "dropPreview", "renderPicture", "user", "shown", "avatar", "upload", "typeProblem", "prepared", "prepareImage", "problem", "save", "call", "notImage", "saveField", "status", "btn", "value", "textLength", "err", "showPasswordErrors", "errors", "f", "msg", "first", "k", "changePassword", "fields", "shell", "clear", "m", "setTheme", "THEME_KEY", "s", "prev"]
|
|
7
|
-
}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
var De=new Set(["value","checked"]);function a(e,t={},n){let o=document.createElement(e),{class:s,dataset:u,on:i,signal:c,...b}=t;s&&(o.className=s),u&&Object.assign(o.dataset,u);for(let[y,p]of Object.entries(b))p==null||p===!1||(De.has(y)?o[y]=p:o.setAttribute(y,p===!0?"":String(p)));if(i)for(let[y,p]of Object.entries(i))o.addEventListener(y,p,c?{signal:c}:void 0);return Re(o,n),o}function Re(e,t){for(let n of Array.isArray(t)?t:[t])n==null||n===!1||e.appendChild(typeof n=="object"?n:document.createTextNode(String(n)))}function U(e){e.replaceChildren()}var ue=e=>`People online over the last ${e?"24 hours":"7 days"}`;var pe=e=>e===1?"message":"messages",de=e=>e===1?"person posted":"people posted";var me=e=>e?" (running)":"";var fe=(e,t)=>`${t} slow ${e===1?"client":"clients"} dropped since the start`;var q=(e,t)=>`${t} ${e===1?"person":"people"} posted`;var $e="chat.theme",Pe={light:"#f1eefc",dark:"#111214"};function Ce(){try{return globalThis.localStorage??null}catch{return null}}function ge(e=Ce()){try{let t=e?.getItem($e);return t==="light"||t==="dark"?t:"auto"}catch{return"auto"}}function he(e,t=document){let n=t.documentElement;e==="auto"?delete n.dataset.theme:n.dataset.theme=e;for(let o of t.querySelectorAll('meta[name="theme-color"]')){let s=o.media.includes("dark")?"dark":"light";o.content=Pe[e==="auto"?s:e]}}var be=e=>`${e} min`,z=e=>`${e} h`;var ye=e=>`${e} d`,_e=e=>`${e} ago`;var D=864e5;function We(e){let t=new Date(e);return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`}function $(e,t=0){let n=new Date(e);return n.setHours(0,0,0,0),n.setDate(n.getDate()-t),n.getTime()}function Q(e,t,n=30){let o=new Map(e.map(u=>[u.day,u])),s=[];for(let u=n-1;u>=0;u--){let i=We($(t,u)+432e5),c=o.get(i);s.push({day:i,messages:c?.messages??0,people:c?.people??0})}return s}function X(e,t,n){let o=0;for(let s of e)s[0]>=t&&(o+=s[1]);return o*n/60}function P(e,t){let n=null;for(let o of e)o[0]>=t&&(!n||o[1]>n.online)&&(n={online:o[1],at:o[0]});return n&&!n.online?{online:0,at:0}:n}function Ee(e,t,n){let o=[],s=[],u=-1/0;for(let i of e)i[0]<t||(i[0]-u>2*n*6e4&&s.length&&(o.push(s),s=[]),s.push(i),u=i[0]);return s.length&&o.push(s),o}function J(e,t=4){let n=Math.max(e,t),o=10**Math.floor(Math.log10(n));for(let s of[1,2,5,10])if(s*o>=n)return s*o;return 10*o}function Y(e){return e<1?`${Math.round(e*60)} min`:e<10?z((Math.round(e*10)/10).toLocaleString()):`${Math.round(e).toLocaleString()} h`}function C(e,t){return t>0?`${Math.round(e/t*100)}%`:"\u2013"}function H(e){let t=["B","KB","MB","GB","TB"],n=0;for(;e>=1024&&n<t.length-1;)e/=1024,n++;return`${n&&e<10?(Math.round(e*10)/10).toLocaleString():Math.round(e).toLocaleString()} ${t[n]}`}function F(e){return e<60?`${Math.round(e)} s`:e<3600?be(Math.round(e/60)):e<86400?z(String(Math.round(e/3600))):ye(Math.round(e/86400))}function Z(e,t,n="not since the start"){let o=Date.parse(e);return e&&!Number.isNaN(o)?_e(F(Math.max(0,(t-o)/1e3))):n}var Be=3e4,Ge=["pocketbase_auth","__pb_superusers__/_"],Ke="http://www.w3.org/2000/svg",v=document.getElementById("stats"),re=document.getElementById("stats-updated"),l=new Intl.NumberFormat,V=new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}),we=new Intl.DateTimeFormat(void 0,{weekday:"short",hour:"2-digit",minute:"2-digit"}),ee=new Intl.DateTimeFormat(void 0,{weekday:"short",day:"numeric",month:"short"}),ve=new Intl.DateTimeFormat(void 0,{day:"numeric",month:"short"}),A="day",L=null,te=null,ne=!1;function Ae(e=!1){let t=[];for(let n of Ge)try{let o=JSON.parse(localStorage.getItem(n)||"{}"),s=o?.token;if(e&&o?.record?.collectionName!=="_superusers")continue;typeof s=="string"&&s&&t.push(s)}catch{}return t}async function Ue(){let e=-new Date().getTimezoneOffset();for(let t of Ae())try{let n=await fetch(`/api/chat/stats?tz=${e}`,{headers:{Authorization:t}});if(n.ok)return await n.json();if(n.status!==401&&n.status!==403)return null}catch{return null}return"denied"}async function Ye(){for(let e of Ae(!0))try{let t=await fetch("/api/chat/metrics",{headers:{Authorization:e,Accept:"application/json"}});if(t.ok)return await t.json()}catch{return null}return null}function d(e,t,n,o=!1){return a("div",{class:o?"tile big":"tile"},[a("div",{class:"tile-label"},e),a("div",{class:"tile-value"},t),n?a("div",{class:"tile-note"},n):null])}function W(e,t,n){return a("section",{class:"card"},[a("h2",{},e),n?a("p",{class:"hint"},n):null,...t])}function S(e,t={}){let n=document.createElementNS(Ke,e);for(let[o,s]of Object.entries(t))n.setAttribute(o,String(s));return n}function Me(e,t,n){return a("details",{class:"chart-table"},[a("summary",{},"Show as a table"),oe(e,t,n)])}function oe(e,t,n){return a("table",{},[a("caption",{},e),a("thead",{},a("tr",{},t.map(o=>a("th",{scope:"col"},o)))),a("tbody",{},n.map(o=>a("tr",{},o.map((s,u)=>u?a("td",{},typeof s=="number"?l.format(s):s):a("th",{scope:"row"},String(s))))))])}var Fe={telegram:"Telegram",federation:"Linked instances",link_previews:"Link previews",media_thumbs:"Thumbnails to make",media_sizes:"Video shapes to read",media_moves:"Files to move",storage_cleanup:"Storage to clean up",previews:"Link previews",media:"Media",retention:"Daily prune"},R=e=>Fe[e]??e;function Ve(e){let t=Date.parse(e.at)||Date.now(),n=(e.db["data.db"]??0)+(e.db["data.db-wal"]??0),o=(e.db["auxiliary.db"]??0)+(e.db["auxiliary.db-wal"]??0),s=Object.entries(e.queues).sort(([i],[c])=>R(i).localeCompare(R(c))),u=Object.entries(e.workers).sort(([i],[c])=>R(i).localeCompare(R(c)));return W("Server",[a("div",{class:"tiles"},[d("Up for",F(e.uptime_seconds),`Chirkle ${e.version}, PocketBase ${e.pocketbase}`),d("Connections",l.format(e.realtime.clients),"realtime, incl. guests"),d("Live events waiting",l.format(e.realtime.queued),fe(e.realtime.dropped,l.format(e.realtime.dropped))),d("Database",H(n),`logs ${H(o)}`),d("Memory",H(e.process.heap_bytes),`${H(e.process.sys_bytes)} from the system`)]),a("h3",{},"Queues"),a("div",{class:"chart-table"},oe("Rows waiting for a worker",["Queue","Rows","Failed once or more","Oldest"],s.map(([i,c])=>[R(i),c.rows,c.failing,c.rows?F(c.oldest_seconds):"\u2013"]))),a("h3",{},"Workers"),a("div",{class:"chart-table"},oe("When each worker last did its work",["Worker","Last pass","Last error"],u.map(([i,c])=>[R(i),`${Z(c.last_pass,t)}${me(c.running)}`,c.last_error?`${c.last_error} (${Z(c.last_error_at,t)})`:"\u2013"])))],"Only superusers see this. Also at /api/chat/metrics, in Prometheus's format with ?format=prometheus.")}var x=720,O=220,ae=()=>x<520,m={top:12,right:12,bottom:26,left:36};function ke(e,t){for(let n of[0,t/2,t].filter(Number.isInteger)){let o=m.top+(O-m.top-m.bottom)*(1-n/t);e.append(S("line",{x1:m.left,x2:x-m.right,y1:o,y2:o,class:"grid"}));let s=S("text",{x:m.left-6,y:o+4,"text-anchor":"end",class:"axis"});s.textContent=l.format(n),e.append(s)}}function Le(e,t,n){let o=t>x-m.right-32?"end":t<m.left+32?"start":"middle",s=S("text",{x:o==="end"?Math.min(t+6,x-2):t,y:O-8,"text-anchor":o,class:"axis"});s.textContent=n,e.append(s)}function Oe(e){let t=a("div",{class:"tip",role:"status",hidden:!0});return e.append(t),{show(n,o,s){U(t),t.append(a("div",{class:"tip-title"},s));for(let[i,c]of o)t.append(a("div",{},[a("strong",{},i),` ${c}`]));t.hidden=!1;let u=Math.min(Math.max(n*e.clientWidth,t.offsetWidth/2+4),e.clientWidth-t.offsetWidth/2-4);t.style.left=`${u}px`},hide(){t.hidden=!0}}}function je(e){let t=e.at,n=t-(A==="day"?D:7*D),o=Ee(e.samples,n,e.sample_minutes),s=o.flat(),u=J(Math.max(0,...s.map(r=>r[1]))),i=x-m.left-m.right,c=O-m.top-m.bottom,b=r=>m.left+(r-n)/(t-n)*i,y=r=>m.top+c*(1-r/u),p=S("svg",{viewBox:`0 0 ${x} ${O}`,class:"chart",role:"img"});p.setAttribute("aria-label",ue(A==="day"));let g=S("g");p.append(g),ke(g,u);let w=[];if(A==="day"){let r=Math.ceil(n/216e5)*6*36e5;for(let h=r;h<=t;h+=6*36e5)w.push(h)}else for(let r=6;r>=0;r--)(!ae()||r%2===0)&&w.push($(t,r));for(let r of w)r<n||b(r)>x-m.right-28||Le(g,b(r),A==="day"?V.format(r):ve.format(r));let f=y(0);for(let r of o){let h=r.map(T=>`${b(T[0]).toFixed(1)},${y(T[1]).toFixed(1)}`);if(r.length===1){g.append(S("circle",{cx:b(r[0][0]),cy:y(r[0][1]),r:3,class:"dot"}));continue}g.append(S("polygon",{points:`${b(r[0][0])},${f} ${h.join(" ")} ${b(r.at(-1)[0])},${f}`,class:"area"})),g.append(S("polyline",{points:h.join(" "),class:"line"}))}let _=S("line",{y1:m.top,y2:f,class:"cross",visibility:"hidden"}),E=S("circle",{r:4.5,class:"mark",visibility:"hidden"});g.append(_,E);let M=a("div",{class:"chart-box"},[p]);s.length||M.append(a("p",{class:"empty"},e.history?"No samples yet: one is taken every 5 minutes.":"Not recorded."));let I=Oe(M),B=r=>{let h=p.getBoundingClientRect(),T=n+((r-h.left)/h.width*x-m.left)/i*(t-n),N=null;for(let le of s)(!N||Math.abs(le[0]-T)<Math.abs(N[0]-T))&&(N=le);return N},k=r=>{if(!r)return;let h=b(r[0]);for(let T of[_,E])T.setAttribute("visibility","visible");_.setAttribute("x1",String(h)),_.setAttribute("x2",String(h)),E.setAttribute("cx",String(h)),E.setAttribute("cy",String(y(r[1]))),I.show(h/x,[[l.format(r[1]),"people online"],[l.format(r[3]),"on the web"],[l.format(r[4]),"on Android"],[l.format(r[2]),"guests"]],(A==="day"?V:we).format(r[0]))},G=()=>{for(let r of[_,E])r.setAttribute("visibility","hidden");I.hide()};p.addEventListener("pointermove",r=>k(B(r.clientX))),p.addEventListener("pointerleave",G);let K=s.length-1;p.setAttribute("tabindex","0"),p.addEventListener("focus",()=>k(s[K]??null)),p.addEventListener("blur",G),p.addEventListener("keydown",r=>{r.key!=="ArrowLeft"&&r.key!=="ArrowRight"||(r.preventDefault(),K=Math.max(0,Math.min(s.length-1,K+(r.key==="ArrowLeft"?-1:1))),k(s[K]??null))});let j=[];if(A==="day")for(let r=Math.floor(n/36e5)*36e5;r<=t;r+=36e5){let h=P(s.filter(T=>T[0]<r+36e5),r);h&&j.push([V.format(r),h.online])}else for(let r=6;r>=0;r--){let h=$(t,r),T=P(s.filter(N=>N[0]<h+D),h);T&&j.push([ee.format(h),T.online])}let Ne=a("div",{class:"seg",role:"group","aria-label":"Range"},[Se("day","24 hours"),Se("week","7 days")]);return a("div",{},[Ne,M,Me(A==="day"?"Most people online, by hour":"Most people online, by day",[A==="day"?"Hour":"Day","People"],j)])}function Se(e,t){return a("button",{type:"button","aria-pressed":String(A===e),on:{click:()=>{A=e,ne=!0,L&&ie(L)}}},t)}function qe(e){let t=Q(e.messages.days,e.at),n=J(Math.max(0,...t.map(g=>g.messages))),o=x-m.left-m.right,s=O-m.top-m.bottom,u=o/t.length,i=Math.min(16,u-2),c=S("svg",{viewBox:`0 0 ${x} ${O}`,class:"chart",role:"img"});c.setAttribute("aria-label","Messages per day, the last 30 days");let b=S("g");c.append(b),ke(b,n);let y=a("div",{class:"chart-box"},[c]),p=Oe(y);return t.forEach((g,w)=>{let f=m.left+w*u+(u-i)/2,_=g.messages/n*s,E=m.top+s-_,M=Math.min(4,i/2,_);_>0&&b.append(S("path",{d:`M${f},${E+_}V${E+M}Q${f},${E} ${f+M},${E}H${f+i-M}Q${f+i},${E} ${f+i},${E+M}V${E+_}Z`,class:"bar"}));let I=new Date(`${g.day}T12:00:00`),B=ae()?10:5;(w%B===B-1||w===t.length-1)&&Le(b,f+i/2,w===t.length-1?"Today":ve.format(I));let k=S("rect",{x:m.left+w*u,y:m.top,width:u,height:s,class:"hit"}),G=()=>p.show((f+i/2)/x,[[l.format(g.messages),pe(g.messages)],[l.format(g.people),de(g.people)]],ee.format(I));k.addEventListener("pointerenter",G),k.addEventListener("pointerleave",()=>p.hide()),b.append(k)}),a("div",{},[y,Me("Messages per day",["Day","Messages","People who posted"],t.map(g=>[ee.format(new Date(`${g.day}T12:00:00`)),g.messages,g.people]))])}function ie(e){L=e,x=Math.round(Math.min(928,Math.max(280,v.clientWidth-66))),O=ae()?180:220;let t=e.at,n=$(t),o=Q(e.messages.days,t),s=f=>o.slice(-f).reduce((_,E)=>_+E.messages,0),u=s(30),i=P(e.samples,n),c=P(e.samples,t-7*D),b=X(e.samples,n,e.sample_minutes),y=X(e.samples,t-7*D,e.sample_minutes),p=f=>e.history||e.samples.length?f:"\u2013",g=[e.history?null:a("p",{class:"notice",role:"note"},"Recording is off (site settings: no_stats). Live numbers and messages are still shown; what was recorded before is dropped as it ages."),W("Now",[a("div",{class:"tiles"},[d("People online",l.format(e.now.online),void 0,!0),d("On the web",l.format(e.now.web)),d("On Android",l.format(e.now.android)),d("Guests",l.format(e.now.guests),"open tabs, not signed in"),d("Peak today",p(i?l.format(i.online):"\u2013"),i?.at?`at ${V.format(i.at)}`:void 0),d("Peak, 7 days",p(c?l.format(c.online):"\u2013"),c?.at?we.format(c.at):void 0)])]),W("Usage",[a("div",{class:"tiles"},[d("Active, 24 hours",l.format(e.active.day),`${C(e.active.day,e.accounts.total)} of accounts`),d("Active, 7 days",l.format(e.active.week),`${C(e.active.week,e.accounts.total)} of accounts`),d("Active, 30 days",l.format(e.active.month),`${C(e.active.month,e.accounts.total)} of accounts`),d("Time online today",p(Y(b)),"all people together"),d("Time online, 7 days",p(Y(y)),"all people together"),d("Per active person",p(e.active.week?Y(y/e.active.week):"\u2013"),"a week, on average")]),a("h3",{},"People online"),je(e)],"Active: online at least once. Time online is counted every 5 minutes."),W("Messages",[a("div",{class:"tiles"},[d("Today",l.format(o.at(-1)?.messages??0)),d("7 days",l.format(s(7)),q(e.messages.people_week,l.format(e.messages.people_week))),d("30 days",l.format(u),q(e.messages.people_month,l.format(e.messages.people_month))),d("In DMs",C(e.messages.dms_month,u),"of the 30 days'"),d("Files sent",l.format(e.messages.files_month),"30 days"),d("Reactions",l.format(e.messages.reactions_month),"on the 30 days' messages")]),a("h3",{},"Messages per day"),qe(e)]),W("Accounts",[a("div",{class:"tiles"},[d("Accounts",l.format(e.accounts.total)),d("New, 7 days",l.format(e.accounts.new_week)),d("Moderators",l.format(e.accounts.moderators)),d("Banned",l.format(e.accounts.banned))])]),te?Ve(te):null],w=[...v.querySelectorAll("details")].map(f=>f.open);U(v);for(let f of g)f&&v.append(f);v.querySelectorAll("details").forEach((f,_)=>{f.open=!!w[_]}),ne&&v.querySelector(".seg [aria-pressed='true']")?.focus(),ne=!1,re.textContent=`Updated ${new Date(t).toLocaleTimeString()}`}function ze(){document.title="Page not found",U(v),v.append(a("section",{class:"card missing"},[a("h2",{},"Page not found"),a("p",{},"There is no such page, or you can't see it."),a("a",{href:"/"},"Back to the app")])),re.textContent=""}var se=0;async function ce(){clearTimeout(se);let[e,t]=await Promise.all([Ue(),Ye()]);if(e==="denied")return ze();te=t,e?ie(e):re.textContent=L?`Couldn't refresh: showing ${new Date(L.at).toLocaleTimeString()}`:"Couldn't load. Retrying\u2026",document.hidden||(se=window.setTimeout(ce,Be))}he(ge());var xe=v.clientWidth,Te=0;addEventListener("resize",()=>{clearTimeout(Te),Te=window.setTimeout(()=>{!L||Math.abs(v.clientWidth-xe)<8||(xe=v.clientWidth,ie(L))},150)});document.addEventListener("visibilitychange",()=>{document.hidden?clearTimeout(se):ce()});ce();
|
|
2
|
-
//# sourceMappingURL=stats-ARDU576A.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../web/src/dom.ts", "../../web/src/strings/stats-main.ts", "../../web/src/theme.ts", "../../web/src/strings/stats-data.ts", "../../web/src/stats/data.ts", "../../web/src/stats/main.ts"],
|
|
4
|
-
"sourcesContent": ["// Minimal DOM helpers (\u00A77.3). Strings always become text nodes: there is no HTML parsing anywhere.\n\nexport type Child = Node | string | number | null | undefined | false;\n\ntype Listeners = { [K in keyof HTMLElementEventMap]?: (ev: HTMLElementEventMap[K]) => void };\n\nexport interface Attrs {\n class?: string;\n dataset?: Record<string, string>;\n on?: Listeners;\n /** Removes every `on` listener when aborted. */\n signal?: AbortSignal;\n value?: string;\n checked?: boolean;\n [attr: string]: unknown;\n}\n\nconst PROPS = new Set([\"value\", \"checked\"]);\n\nexport function h<K extends keyof HTMLElementTagNameMap>(tag: K, attrs: Attrs = {}, children?: Child | Child[]): HTMLElementTagNameMap[K] {\n const el = document.createElement(tag);\n const { class: cls, dataset, on: listeners, signal, ...rest } = attrs;\n if (cls) el.className = cls;\n if (dataset) Object.assign(el.dataset, dataset);\n for (const [name, v] of Object.entries(rest)) {\n if (v === undefined || v === null || v === false) continue;\n if (PROPS.has(name)) (el as unknown as Record<string, unknown>)[name] = v;\n else el.setAttribute(name, v === true ? \"\" : String(v));\n }\n if (listeners) {\n for (const [type, fn] of Object.entries(listeners)) {\n el.addEventListener(type, fn as EventListener, signal ? { signal } : undefined);\n }\n }\n append(el, children);\n return el;\n}\n\nexport function append(el: Node, children: Child | Child[]): void {\n for (const c of Array.isArray(children) ? children : [children]) {\n if (c === null || c === undefined || c === false) continue;\n el.appendChild(typeof c === \"object\" ? c : document.createTextNode(String(c)));\n }\n}\n\nlet idSeq = 0;\n\n/** A document-unique id for label/aria wiring, e.g. uniqueId(\"room\") \u2192 \"room-3\". */\nexport function uniqueId(prefix: string): string {\n return `${prefix}-${++idSeq}`;\n}\n\nexport function clear(el: Element): void {\n el.replaceChildren();\n}\n\n/**\n * Make `parent`'s children exactly `nodes`, in order, moving only what differs (\u00A77.5: the message list is\n * never fully re-rendered). Nodes already in place keep their identity, focus and scroll anchoring.\n */\nexport function reconcile(parent: Element, nodes: readonly Node[]): void {\n // Drop what goes first: a replaced node left in place would push every node after it down one, and each of them\n // would then be moved (re-inserted, restyled) instead of left alone.\n const keep = new Set(nodes);\n for (const c of [...parent.childNodes]) if (!keep.has(c)) c.remove();\n nodes.forEach((node, i) => {\n const at = parent.childNodes[i];\n if (at !== node) parent.insertBefore(node, at ?? null);\n });\n}\n\n/**\n * Keep what is typed while a lazy chunk loads (a search field that isn't there yet), for the field once it shows:\n * printable keys and Backspace, not shortcuts, and Enter after some text (as \"\\n\": a name typed and Enter pressed before\n * the field showed went nowhere, QA BUG-272). `take()` stops holding and says what was typed (QA BUG-243, BUG-252).\n */\nexport function holdKeys(signal: AbortSignal): { take(): string } {\n let early = \"\";\n const hold = (e: KeyboardEvent) => {\n if (e.ctrlKey || e.metaKey || e.altKey || e.isComposing) return;\n if (e.key === \"Enter\") {\n if (!early.replace(/\\n/g, \"\")) return;\n early += \"\\n\";\n } else if (e.key.length !== 1 && e.key !== \"Backspace\") return;\n else early = e.key === \"Backspace\" ? early.slice(0, -1) : early + e.key;\n e.preventDefault();\n };\n document.addEventListener(\"keydown\", hold, { capture: true, signal });\n return {\n take() {\n document.removeEventListener(\"keydown\", hold, true);\n return early;\n },\n };\n}\n\n/** Put `text` held by holdKeys() in `input`, as if typed there: its characters, then Enter if one was pressed. */\nexport function typeInto(input: HTMLInputElement | null | undefined, text: string): void {\n if (!text || !input) return;\n const chars = text.replace(/\\n/g, \"\");\n if (chars) {\n input.value += chars;\n input.dispatchEvent(new Event(\"input\", { bubbles: true }));\n }\n if (text.includes(\"\\n\")) input.dispatchEvent(new KeyboardEvent(\"keydown\", { key: \"Enter\", bubbles: true, cancelable: true }));\n}\n\n/**\n * A click on an open modal dialog's backdrop (outside its box) closes it, as Escape does: through a cancelable\n * \"cancel\" event, so a dialog that refuses Escape (busy saving, or closing its people search first) does the same\n * here. Both the press and the release must be outside, so a drag that selects text inside and ends outside doesn't\n * close it. One listener for every dialog, installed once by app.ts: the dialogs are in lazy chunks.\n */\nexport function closeDialogsOnBackdrop(): void {\n const outside = (e: MouseEvent): HTMLDialogElement | null => {\n const d = e.target;\n if (!(d instanceof HTMLDialogElement) || !d.open) return null;\n const r = d.getBoundingClientRect();\n return e.clientX < r.left || e.clientX > r.right || e.clientY < r.top || e.clientY > r.bottom ? d : null;\n };\n let pressed: HTMLDialogElement | null = null;\n document.addEventListener(\"pointerdown\", (e) => (pressed = outside(e)), true);\n document.addEventListener(\n \"click\",\n (e) => {\n const d = outside(e);\n const was = pressed;\n pressed = null;\n if (!d || d !== was) return;\n if (d.dispatchEvent(new Event(\"cancel\", { cancelable: true }))) d.close();\n },\n true,\n );\n}\n", "// The user-facing text of stats/main.ts (docs/REFACTOR.md item 56): one module per source file, so a lazy\n// screen's text stays in its own chunk. Copy changes here; a translation would replace these.\n\nexport const SHOW_AS_A_TABLE = \"Show as a table\";\nexport const TELEGRAM = \"Telegram\";\nexport const LINKED_INSTANCES = \"Linked instances\";\nexport const LINK_PREVIEWS = \"Link previews\";\nexport const THUMBNAILS_TO_MAKE = \"Thumbnails to make\";\nexport const VIDEO_SHAPES_TO_READ = \"Video shapes to read\";\nexport const FILES_TO_MOVE = \"Files to move\";\nexport const STORAGE_TO_CLEAN_UP = \"Storage to clean up\";\nexport const MEDIA = \"Media\";\nexport const DAILY_PRUNE = \"Daily prune\";\nexport const SERVER = \"Server\";\nexport const chirklePocketbase = (version: string | number, pocketbase: string | number) => `Chirkle ${version}, PocketBase ${pocketbase}`;\nexport const UP_FOR = \"Up for\";\nexport const CONNECTIONS = \"Connections\";\nexport const LIVE_EVENTS_WAITING = \"Live events waiting\";\nexport const DATABASE = \"Database\";\nexport const MEMORY = \"Memory\";\nexport const QUEUES = \"Queues\";\nexport const ROWS_WAITING_FOR_A_WORKER = \"Rows waiting for a worker\";\nexport const OLDEST = \"Oldest\";\nexport const FAILED_ONCE_OR_MORE = \"Failed once or more\";\nexport const ROWS = \"Rows\";\nexport const QUEUE = \"Queue\";\nexport const WORKERS = \"Workers\";\nexport const WHEN_EACH_WORKER_LAST_DID_ITS = \"When each worker last did its work\";\nexport const LAST_ERROR = \"Last error\";\nexport const LAST_PASS = \"Last pass\";\nexport const WORKER = \"Worker\";\nexport const ONLY_SUPERUSERS_SEE_THIS_ALSO_AT =\n \"Only superusers see this. Also at /api/chat/metrics, in Prometheus's format with ?format=prometheus.\";\nexport const peopleOnlineOverTheLast = (day: boolean) => `People online over the last ${day ? \"24 hours\" : \"7 days\"}`;\nexport const NOT_RECORDED = \"Not recorded.\";\nexport const NO_SAMPLES_YET_ONE_IS_TAKEN = \"No samples yet: one is taken every 5 minutes.\";\nexport const RANGE = \"Range\";\nexport const MOST_PEOPLE_ONLINE_BY_DAY = \"Most people online, by day\";\nexport const MOST_PEOPLE_ONLINE_BY_HOUR = \"Most people online, by hour\";\nexport const PEOPLE = \"People\";\nexport const HOUR = \"Hour\";\nexport const MESSAGES_PER_DAY_THE_LAST_30 = \"Messages per day, the last 30 days\";\nexport const TODAY = \"Today\";\nexport const MESSAGES_PER_DAY = \"Messages per day\";\nexport const PEOPLE_WHO_POSTED = \"People who posted\";\nexport const MESSAGES = \"Messages\";\nexport const RECORDING_IS_OFF_SITE_SETTINGS_NO =\n \"Recording is off (site settings: no_stats). Live numbers and messages are still shown; what was recorded before is dropped as it ages.\";\nexport const PEOPLE_ONLINE = \"People online\";\nexport const ON_THE_WEB = \"On the web\";\nexport const ON_ANDROID = \"On Android\";\nexport const GUESTS = \"Guests\";\nexport const PEAK_TODAY = \"Peak today\";\nexport const PEAK_7_DAYS = \"Peak, 7 days\";\nexport const USAGE = \"Usage\";\nexport const ACTIVE_24_HOURS = \"Active, 24 hours\";\nexport const ACTIVE_7_DAYS = \"Active, 7 days\";\nexport const ACTIVE_30_DAYS = \"Active, 30 days\";\nexport const TIME_ONLINE_TODAY = \"Time online today\";\nexport const TIME_ONLINE_7_DAYS = \"Time online, 7 days\";\nexport const PER_ACTIVE_PERSON = \"Per active person\";\nexport const ACTIVE_ONLINE_AT_LEAST_ONCE_TIME = \"Active: online at least once. Time online is counted every 5 minutes.\";\nexport const IN_DMS = \"In DMs\";\nexport const FILES_SENT = \"Files sent\";\nexport const REACTIONS = \"Reactions\";\nexport const ACCOUNTS = \"Accounts\";\nexport const NEW_7_DAYS = \"New, 7 days\";\nexport const MODERATORS = \"Moderators\";\nexport const BANNED = \"Banned\";\nexport const updated = (time: string | number) => `Updated ${time}`;\nexport const PAGE_NOT_FOUND = \"Page not found\";\nexport const THERE_IS_NO_SUCH_PAGE_OR = \"There is no such page, or you can't see it.\";\nexport const BACK_TO_THE_APP = \"Back to the app\";\nexport const COULDNT_LOAD_RETRYING = \"Couldn't load. Retrying\u2026\";\nexport const couldntRefreshShowing = (time: string | number) => `Couldn't refresh: showing ${time}`;\nexport const TIP_ONLINE = \"people online\";\nexport const TIP_WEB = \"on the web\";\nexport const TIP_ANDROID = \"on Android\";\nexport const TIP_GUESTS = \"guests\";\nexport const tipMessages = (n: number) => (n === 1 ? \"message\" : \"messages\");\nexport const tipPosted = (n: number) => (n === 1 ? \"person posted\" : \"people posted\");\nexport const GUESTS_NOTE = \"open tabs, not signed in\";\nexport const at = (time: string) => `at ${time}`;\nexport const ALL_PEOPLE = \"all people together\";\nexport const WEEK_AVERAGE = \"a week, on average\";\nexport const running = (busy: boolean) => (busy ? \" (running)\" : \"\");\nexport const REALTIME_INCL_GUESTS = \"realtime, incl. guests\";\nexport const slowClientsDroppedSinceTheStart = (n: number, shown: string) =>\n `${shown} slow ${n === 1 ? \"client\" : \"clients\"} dropped since the start`;\nexport const logs = (size: string | number) => `logs ${size}`;\nexport const fromTheSystem = (size: string | number) => `${size} from the system`;\nexport const ofAccounts = (percent: string | number) => `${percent} of accounts`;\nexport const peoplePosted = (n: number, shown: string) => `${shown} ${n === 1 ? \"person\" : \"people\"} posted`;\nexport const HOURS_24 = \"24 hours\";\nexport const DAYS_7 = \"7 days\";\nexport const DAYS_30 = \"30 days\";\nexport const OF_THE_30_DAYS = \"of the 30 days'\";\nexport const ON_THE_30_DAYS_MESSAGES = \"on the 30 days' messages\";\nexport const DAY = \"Day\";\nexport const NOW = \"Now\";\n", "// Light, dark or the system's (auto) theme (\u00A77.8): this device's choice, kept in localStorage. index.html's inline\n// script sets <html data-theme> before the first paint; this keeps it, and the browser's bar color, up to date.\n\nexport const THEMES = [\"auto\", \"light\", \"dark\"] as const;\nexport type Theme = (typeof THEMES)[number];\n\n/** Must match index.html's inline script. */\nexport const THEME_KEY = \"chat.theme\";\n\n/** --surface of each theme (tokens.css), for <meta name=\"theme-color\">. */\nconst BAR = { light: \"#f1eefc\", dark: \"#111214\" } as const;\n\nfunction safeLocalStorage(): Storage | null {\n try {\n return globalThis.localStorage ?? null;\n } catch {\n return null;\n }\n}\n\nexport function savedTheme(storage: Storage | null = safeLocalStorage()): Theme {\n try {\n const v = storage?.getItem(THEME_KEY);\n return v === \"light\" || v === \"dark\" ? v : \"auto\";\n } catch {\n return \"auto\";\n }\n}\n\n/** Show `theme` here: the stylesheet goes by <html data-theme>, the browser's bar by the theme-color metas. */\nexport function applyTheme(theme: Theme, doc: Document = document): void {\n const html = doc.documentElement;\n if (theme === \"auto\") delete html.dataset.theme;\n else html.dataset.theme = theme;\n for (const meta of doc.querySelectorAll<HTMLMetaElement>('meta[name=\"theme-color\"]')) {\n // Each meta's own media query says which theme it is for; a chosen theme gives both its color.\n const forTheme = meta.media.includes(\"dark\") ? \"dark\" : \"light\";\n meta.content = BAR[theme === \"auto\" ? forTheme : theme];\n }\n}\n\n/** Save and show `theme`. Storage can throw (private window, quota): the theme still changes for this page. */\nexport function setTheme(theme: Theme, storage: Storage | null = safeLocalStorage()): void {\n try {\n if (theme === \"auto\") storage?.removeItem(THEME_KEY);\n else storage?.setItem(THEME_KEY, theme);\n } catch {}\n applyTheme(theme);\n}\n\n/** Apply the saved theme and follow another tab's changes. Returns a function that stops following. */\nexport function startTheme(storage: Storage | null = safeLocalStorage()): () => void {\n applyTheme(savedTheme(storage));\n const ac = new AbortController();\n addEventListener(\n \"storage\",\n (e) => {\n if (e.key === THEME_KEY || e.key === null) applyTheme(savedTheme(storage));\n },\n { signal: ac.signal },\n );\n return () => ac.abort();\n}\n", "// The user-facing text of stats/data.ts (docs/REFACTOR.md item 56): one module per source file, so a lazy\n// screen's text stays in its own chunk. Copy changes here; a translation would replace these.\n\nexport const min = (n: number) => `${n} min`;\nexport const hours = (n: string) => `${n} h`;\nexport const sec = (n: number) => `${n} s`;\nexport const days = (n: number) => `${n} d`;\nexport const ago = (span: string) => `${span} ago`;\nexport const NOT_SINCE_START = \"not since the start\";\n", "import * as S from \"../strings/stats-data.ts\";\n// Usage statistics (DESIGN.md \u00A740): what GET /api/chat/stats answers, and the figures the page works out from it.\n// Pure, so tests/unit can check them.\n\n/** A sample: [time (epoch ms), people online, guests, people on the web, people on Android]. */\nexport type Sample = [number, number, number, number, number];\n\nexport interface Stats {\n at: number;\n /** Recording (samples, activity) is on: site.no_stats isn't ticked. */\n history: boolean;\n sample_minutes: number;\n now: { online: number; guests: number; web: number; android: number };\n /** Accounts online in the last 24 hours, 7 days and 30 days. */\n active: { day: number; week: number; month: number };\n accounts: { total: number; new_week: number; moderators: number; banned: number };\n messages: {\n /** The viewer's days (YYYY-MM-DD) with any messages, the last 30. */\n days: { day: string; messages: number; people: number }[];\n people_week: number;\n people_month: number;\n dms_month: number;\n files_month: number;\n reactions_month: number;\n };\n /** The last 7 days', oldest first. */\n samples: Sample[];\n}\n\nexport const DAY_MS = 86_400_000;\n\n/** `t`'s day in this browser's time zone, as YYYY-MM-DD. */\nexport function dayKey(t: number): string {\n const d = new Date(t);\n return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, \"0\")}-${String(d.getDate()).padStart(2, \"0\")}`;\n}\n\n/** Midnight today in this browser's time zone, `back` days before it. */\nexport function midnight(now: number, back = 0): number {\n const d = new Date(now);\n d.setHours(0, 0, 0, 0);\n d.setDate(d.getDate() - back);\n return d.getTime();\n}\n\n/** The last `n` days, oldest first, each with its messages and posters (none for a day without). */\nexport function lastDays(days: Stats[\"messages\"][\"days\"], now: number, n = 30): { day: string; messages: number; people: number }[] {\n const by = new Map(days.map((d) => [d.day, d]));\n const out = [];\n for (let i = n - 1; i >= 0; i--) {\n const day = dayKey(midnight(now, i) + 12 * 3_600_000); // noon: safe across a DST change\n const d = by.get(day);\n out.push({ day, messages: d?.messages ?? 0, people: d?.people ?? 0 });\n }\n return out;\n}\n\n/** Person-hours online since `from`: each sample stands for its interval. */\nexport function personHours(samples: readonly Sample[], from: number, minutes: number): number {\n let sum = 0;\n for (const s of samples) if (s[0] >= from) sum += s[1];\n return (sum * minutes) / 60;\n}\n\n/** The most people online at once since `from`, and when (the first time it was reached); null without samples. */\nexport function peak(samples: readonly Sample[], from: number): { online: number; at: number } | null {\n let best: { online: number; at: number } | null = null;\n for (const s of samples) if (s[0] >= from && (!best || s[1] > best.online)) best = { online: s[1], at: s[0] };\n // Nobody at any time: no time to name (it said \"0 at 02:45 AM\", QA BUG-263).\n return best && !best.online ? { online: 0, at: 0 } : best;\n}\n\n/**\n * The samples since `from` as runs of a line: a gap longer than two intervals (the server was down, or recording was\n * off) ends a run, so the chart doesn't draw a line across it.\n */\nexport function runs(samples: readonly Sample[], from: number, minutes: number): Sample[][] {\n const out: Sample[][] = [];\n let run: Sample[] = [];\n let last = -Infinity;\n for (const s of samples) {\n if (s[0] < from) continue;\n if (s[0] - last > 2 * minutes * 60_000 && run.length) {\n out.push(run);\n run = [];\n }\n run.push(s);\n last = s[0];\n }\n if (run.length) out.push(run);\n return out;\n}\n\n/** A tidy top for an axis from 0: 1, 2 or 5 times a power of ten, at least `max` (and at least `min`). */\nexport function niceMax(max: number, min = 4): number {\n const v = Math.max(max, min);\n const p = 10 ** Math.floor(Math.log10(v));\n for (const m of [1, 2, 5, 10]) if (m * p >= v) return m * p;\n return 10 * p;\n}\n\n/** \"1.5 h\", \"40 min\", \"12 h\": person-time for a tile. */\nexport function formatHours(h: number): string {\n if (h < 1) return `${Math.round(h * 60)} min`;\n if (h < 10) return S.hours((Math.round(h * 10) / 10).toLocaleString());\n return `${Math.round(h).toLocaleString()} h`;\n}\n\n/** `part` of `whole` as a whole percent (\"\u2013\" with nothing to divide). */\nexport function percent(part: number, whole: number): string {\n return whole > 0 ? `${Math.round((part / whole) * 100)}%` : \"\u2013\";\n}\n\n/** What GET /api/chat/metrics answers a superuser (REFACTOR item 51, server/metrics.go). */\nexport interface Metrics {\n at: string;\n version: string;\n pocketbase: string;\n uptime_seconds: number;\n queues: Record<string, { rows: number; failing: number; oldest_seconds: number }>;\n /** last_pass, last_error_at: RFC 3339, \"\" for not since the start. */\n workers: Record<string, { last_pass: string; last_error: string; last_error_at: string; running: boolean }>;\n realtime: { clients: number; senders: number; queued: number; dropped: number };\n db: Record<string, number>;\n process: { goroutines: number; heap_bytes: number; sys_bytes: number; gc_runs: number };\n}\n\n/** \"12 KB\", \"3.4 MB\", \"1.2 GB\". */\nexport function formatBytes(n: number): string {\n const units = [\"B\", \"KB\", \"MB\", \"GB\", \"TB\"];\n let i = 0;\n while (n >= 1024 && i < units.length - 1) {\n n /= 1024;\n i++;\n }\n return `${i && n < 10 ? (Math.round(n * 10) / 10).toLocaleString() : Math.round(n).toLocaleString()} ${units[i]}`;\n}\n\n/** A span of seconds, short: \"40 s\", \"12 min\", \"5 h\", \"3 d\". */\nexport function formatSpan(s: number): string {\n if (s < 60) return `${Math.round(s)} s`;\n if (s < 3600) return S.min(Math.round(s / 60));\n if (s < 86_400) return S.hours(String(Math.round(s / 3600)));\n return S.days(Math.round(s / 86_400));\n}\n\n/** How long before `now` (epoch ms) an RFC 3339 time was, \"12 min ago\"; `never` when there is none. */\nexport function ago(at: string, now: number, never = \"not since the start\"): string {\n const t = Date.parse(at);\n return at && !Number.isNaN(t) ? S.ago(formatSpan(Math.max(0, (now - t) / 1000))) : never;\n}\n", "// The usage statistics page (DESIGN.md \u00A740), /stats: a page of its own (stats.html), not the app's. It asks\n// GET /api/chat/stats with the session this browser has: the app's (a moderator), else the admin UI's (a superuser,\n// signed in at /_/ on this server). Anyone else is told there is no such page. Counts only; refreshed every 30 s\n// while the tab is visible. A superuser also sees the server's state (GET /api/chat/metrics, REFACTOR item 51).\n\nimport { type Child, clear, h } from \"../dom.ts\";\nimport * as S from \"../strings/stats-main.ts\";\nimport { applyTheme, savedTheme } from \"../theme.ts\";\nimport {\n ago,\n DAY_MS,\n formatBytes,\n formatHours,\n formatSpan,\n lastDays,\n type Metrics,\n midnight,\n niceMax,\n peak,\n percent,\n personHours,\n runs,\n type Sample,\n type Stats,\n} from \"./data.ts\";\n\nconst REFRESH_MS = 30_000;\n/** The app's session (web/src/pb.ts), and PocketBase's admin UI's (0.40: \"__pb_superusers__\" + its base path). */\nconst SESSIONS = [\"pocketbase_auth\", \"__pb_superusers__/_\"];\nconst SVG = \"http://www.w3.org/2000/svg\";\n\nconst root = document.getElementById(\"stats\") as HTMLElement;\nconst updated = document.getElementById(\"stats-updated\") as HTMLElement;\nconst num = new Intl.NumberFormat();\nconst time = new Intl.DateTimeFormat(undefined, { hour: \"2-digit\", minute: \"2-digit\" });\nconst dayTime = new Intl.DateTimeFormat(undefined, { weekday: \"short\", hour: \"2-digit\", minute: \"2-digit\" });\nconst dayName = new Intl.DateTimeFormat(undefined, { weekday: \"short\", day: \"numeric\", month: \"short\" });\nconst shortDay = new Intl.DateTimeFormat(undefined, { day: \"numeric\", month: \"short\" });\n\nlet range: \"day\" | \"week\" = \"day\";\nlet last: Stats | null = null;\nlet metrics: Metrics | null = null;\nlet refocus = false;\n\n/** The stored sessions' tokens; `superusers`: only superusers' (QA BUG-275: a moderator was refused the metrics every 30 s). */\nfunction tokens(superusers = false): string[] {\n const out: string[] = [];\n for (const key of SESSIONS) {\n try {\n const session = JSON.parse(localStorage.getItem(key) || \"{}\");\n const token = session?.token;\n if (superusers && session?.record?.collectionName !== \"_superusers\") continue;\n if (typeof token === \"string\" && token) out.push(token);\n } catch {}\n }\n return out;\n}\n\n/** The statistics, with the first session that may see them; \"denied\" when none may; null when it failed. */\nasync function load(): Promise<Stats | \"denied\" | null> {\n const tz = -new Date().getTimezoneOffset();\n for (const token of tokens()) {\n try {\n const res = await fetch(`/api/chat/stats?tz=${tz}`, { headers: { Authorization: token } });\n if (res.ok) return (await res.json()) as Stats;\n if (res.status !== 401 && res.status !== 403) return null;\n } catch {\n return null;\n }\n }\n return \"denied\";\n}\n\n/** The server's metrics, for a superuser's session; null for anyone else, or when they couldn't be had. */\nasync function loadMetrics(): Promise<Metrics | null> {\n for (const token of tokens(true)) {\n try {\n const res = await fetch(\"/api/chat/metrics\", { headers: { Authorization: token, Accept: \"application/json\" } });\n if (res.ok) return (await res.json()) as Metrics;\n } catch {\n return null;\n }\n }\n return null;\n}\n\n// ---- pieces ----\n\nfunction tile(label: string, value: string, note?: string, big = false): HTMLElement {\n return h(\"div\", { class: big ? \"tile big\" : \"tile\" }, [\n h(\"div\", { class: \"tile-label\" }, label),\n h(\"div\", { class: \"tile-value\" }, value),\n note ? h(\"div\", { class: \"tile-note\" }, note) : null,\n ]);\n}\n\nfunction section(title: string, children: Child[], hint?: string): HTMLElement {\n return h(\"section\", { class: \"card\" }, [h(\"h2\", {}, title), hint ? h(\"p\", { class: \"hint\" }, hint) : null, ...children]);\n}\n\nfunction svg<K extends keyof SVGElementTagNameMap>(tag: K, attrs: Record<string, string | number> = {}): SVGElementTagNameMap[K] {\n const el = document.createElementNS(SVG, tag);\n for (const [k, v] of Object.entries(attrs)) el.setAttribute(k, String(v));\n return el;\n}\n\n/** A table of the chart's numbers, folded away: the values without hovering. */\nfunction table(caption: string, head: string[], rows: (string | number)[][]): HTMLElement {\n return h(\"details\", { class: \"chart-table\" }, [h(\"summary\", {}, \"Show as a table\"), grid(caption, head, rows)]);\n}\n\nfunction grid(caption: string, head: string[], rows: (string | number)[][]): HTMLElement {\n return h(\"table\", {}, [\n h(\"caption\", {}, caption),\n h(\n \"thead\",\n {},\n h(\n \"tr\",\n {},\n head.map((c) => h(\"th\", { scope: \"col\" }, c)),\n ),\n ),\n h(\n \"tbody\",\n {},\n rows.map((r) =>\n h(\n \"tr\",\n {},\n r.map((c, i) => (i ? h(\"td\", {}, typeof c === \"number\" ? num.format(c) : c) : h(\"th\", { scope: \"row\" }, String(c)))),\n ),\n ),\n ),\n ]);\n}\n\n/** The queues' and workers' names as people read them. */\nconst LABELS: Record<string, string> = {\n telegram: \"Telegram\",\n federation: \"Linked instances\",\n link_previews: \"Link previews\",\n media_thumbs: \"Thumbnails to make\",\n media_sizes: \"Video shapes to read\",\n media_moves: \"Files to move\",\n storage_cleanup: \"Storage to clean up\",\n previews: \"Link previews\",\n media: \"Media\",\n retention: \"Daily prune\",\n};\nconst named = (k: string) => LABELS[k] ?? k;\n\n/** The server's state, for a superuser (GET /api/chat/metrics). */\nfunction serverSection(m: Metrics): HTMLElement {\n const now = Date.parse(m.at) || Date.now();\n const db = (m.db[\"data.db\"] ?? 0) + (m.db[\"data.db-wal\"] ?? 0);\n const logs = (m.db[\"auxiliary.db\"] ?? 0) + (m.db[\"auxiliary.db-wal\"] ?? 0);\n const queues = Object.entries(m.queues).sort(([a], [b]) => named(a).localeCompare(named(b)));\n const workers = Object.entries(m.workers).sort(([a], [b]) => named(a).localeCompare(named(b)));\n return section(\n \"Server\",\n [\n h(\"div\", { class: \"tiles\" }, [\n tile(\"Up for\", formatSpan(m.uptime_seconds), `Chirkle ${m.version}, PocketBase ${m.pocketbase}`),\n tile(\"Connections\", num.format(m.realtime.clients), \"realtime, incl. guests\"),\n tile(\n \"Live events waiting\",\n num.format(m.realtime.queued),\n S.slowClientsDroppedSinceTheStart(m.realtime.dropped, num.format(m.realtime.dropped)),\n ),\n tile(\"Database\", formatBytes(db), `logs ${formatBytes(logs)}`),\n tile(\"Memory\", formatBytes(m.process.heap_bytes), `${formatBytes(m.process.sys_bytes)} from the system`),\n ]),\n h(\"h3\", {}, \"Queues\"),\n h(\n \"div\",\n { class: \"chart-table\" },\n grid(\n \"Rows waiting for a worker\",\n [\"Queue\", \"Rows\", \"Failed once or more\", \"Oldest\"],\n queues.map(([k, q]) => [named(k), q.rows, q.failing, q.rows ? formatSpan(q.oldest_seconds) : \"\u2013\"]),\n ),\n ),\n h(\"h3\", {}, \"Workers\"),\n h(\n \"div\",\n { class: \"chart-table\" },\n grid(\n \"When each worker last did its work\",\n [\"Worker\", \"Last pass\", \"Last error\"],\n workers.map(([k, w]) => [\n named(k),\n `${ago(w.last_pass, now)}${S.running(w.running)}`,\n w.last_error ? `${w.last_error} (${ago(w.last_error_at, now)})` : \"\u2013\",\n ]),\n ),\n ),\n ],\n \"Only superusers see this. Also at /api/chat/metrics, in Prometheus's format with ?format=prometheus.\",\n );\n}\n\n// The charts are drawn at their box's own width (set by render), so their text stays its size on a phone.\nlet W = 720;\nlet H = 220;\n/** Narrow: fewer labels along the bottom. */\nconst narrow = () => W < 520;\nconst PAD = { top: 12, right: 12, bottom: 26, left: 36 };\n\n/** Gridlines and y labels at 0, half (when a whole number) and the top. */\nfunction yAxis(g: SVGGElement, top: number) {\n for (const v of [0, top / 2, top].filter(Number.isInteger)) {\n const y = PAD.top + (H - PAD.top - PAD.bottom) * (1 - v / top);\n g.append(svg(\"line\", { x1: PAD.left, x2: W - PAD.right, y1: y, y2: y, class: \"grid\" }));\n const t = svg(\"text\", { x: PAD.left - 6, y: y + 4, \"text-anchor\": \"end\", class: \"axis\" });\n t.textContent = num.format(v);\n g.append(t);\n }\n}\n\n/** A label along the bottom at `x`; near an edge it is anchored inward, so it isn't cut off. */\nfunction xLabel(g: SVGGElement, x: number, text: string) {\n const anchor = x > W - PAD.right - 32 ? \"end\" : x < PAD.left + 32 ? \"start\" : \"middle\";\n const t = svg(\"text\", { x: anchor === \"end\" ? Math.min(x + 6, W - 2) : x, y: H - 8, \"text-anchor\": anchor, class: \"axis\" });\n t.textContent = text;\n g.append(t);\n}\n\n/** The tooltip of a chart, placed over its box at `x` (0..1 of the width). */\nfunction tooltip(box: HTMLElement) {\n const tip = h(\"div\", { class: \"tip\", role: \"status\", hidden: true });\n box.append(tip);\n return {\n show(x: number, lines: [string, string][], title: string) {\n clear(tip);\n tip.append(h(\"div\", { class: \"tip-title\" }, title));\n for (const [value, label] of lines) tip.append(h(\"div\", {}, [h(\"strong\", {}, value), ` ${label}`]));\n tip.hidden = false;\n const left = Math.min(Math.max(x * box.clientWidth, tip.offsetWidth / 2 + 4), box.clientWidth - tip.offsetWidth / 2 - 4);\n tip.style.left = `${left}px`;\n },\n hide() {\n tip.hidden = true;\n },\n };\n}\n\n/** People online over the last 24 hours or 7 days: a line with a light area under it, and a crosshair. */\nfunction onlineChart(s: Stats): HTMLElement {\n const now = s.at;\n const from = now - (range === \"day\" ? DAY_MS : 7 * DAY_MS);\n const parts = runs(s.samples, from, s.sample_minutes);\n const shown = parts.flat();\n const top = niceMax(Math.max(0, ...shown.map((x) => x[1])));\n const plotW = W - PAD.left - PAD.right;\n const plotH = H - PAD.top - PAD.bottom;\n const xOf = (t: number) => PAD.left + ((t - from) / (now - from)) * plotW;\n const yOf = (v: number) => PAD.top + plotH * (1 - v / top);\n\n const chart = svg(\"svg\", { viewBox: `0 0 ${W} ${H}`, class: \"chart\", role: \"img\" });\n chart.setAttribute(\"aria-label\", S.peopleOnlineOverTheLast(range === \"day\"));\n const g = svg(\"g\");\n chart.append(g);\n yAxis(g, top);\n // x labels: every 6 hours, or each day at midnight.\n const ticks: number[] = [];\n if (range === \"day\") {\n const first = Math.ceil(from / (6 * 3_600_000)) * 6 * 3_600_000;\n for (let t = first; t <= now; t += 6 * 3_600_000) ticks.push(t);\n } else {\n for (let i = 6; i >= 0; i--) if (!narrow() || i % 2 === 0) ticks.push(midnight(now, i));\n }\n for (const t of ticks) {\n // A tick at either edge goes unlabeled: its label would run off or into the next.\n if (t < from || xOf(t) > W - PAD.right - 28) continue;\n xLabel(g, xOf(t), range === \"day\" ? time.format(t) : shortDay.format(t));\n }\n const base = yOf(0);\n for (const run of parts) {\n const pts = run.map((x) => `${xOf(x[0]).toFixed(1)},${yOf(x[1]).toFixed(1)}`);\n if (run.length === 1) {\n g.append(svg(\"circle\", { cx: xOf(run[0]![0]), cy: yOf(run[0]![1]), r: 3, class: \"dot\" }));\n continue;\n }\n g.append(svg(\"polygon\", { points: `${xOf(run[0]![0])},${base} ${pts.join(\" \")} ${xOf(run.at(-1)![0])},${base}`, class: \"area\" }));\n g.append(svg(\"polyline\", { points: pts.join(\" \"), class: \"line\" }));\n }\n const cross = svg(\"line\", { y1: PAD.top, y2: base, class: \"cross\", visibility: \"hidden\" });\n const mark = svg(\"circle\", { r: 4.5, class: \"mark\", visibility: \"hidden\" });\n g.append(cross, mark);\n\n const box = h(\"div\", { class: \"chart-box\" }, [chart]);\n if (!shown.length) box.append(h(\"p\", { class: \"empty\" }, s.history ? \"No samples yet: one is taken every 5 minutes.\" : \"Not recorded.\"));\n const tip = tooltip(box);\n const nearest = (clientX: number): Sample | null => {\n const r = chart.getBoundingClientRect();\n const t = from + ((((clientX - r.left) / r.width) * W - PAD.left) / plotW) * (now - from);\n let best: Sample | null = null;\n for (const x of shown) if (!best || Math.abs(x[0] - t) < Math.abs(best[0] - t)) best = x;\n return best;\n };\n const show = (x: Sample | null) => {\n if (!x) return;\n const cx = xOf(x[0]);\n for (const el of [cross, mark]) el.setAttribute(\"visibility\", \"visible\");\n cross.setAttribute(\"x1\", String(cx));\n cross.setAttribute(\"x2\", String(cx));\n mark.setAttribute(\"cx\", String(cx));\n mark.setAttribute(\"cy\", String(yOf(x[1])));\n tip.show(\n cx / W,\n [\n [num.format(x[1]), \"people online\"],\n [num.format(x[3]), \"on the web\"],\n [num.format(x[4]), \"on Android\"],\n [num.format(x[2]), \"guests\"],\n ],\n (range === \"day\" ? time : dayTime).format(x[0]),\n );\n };\n const hide = () => {\n for (const el of [cross, mark]) el.setAttribute(\"visibility\", \"hidden\");\n tip.hide();\n };\n chart.addEventListener(\"pointermove\", (e) => show(nearest(e.clientX)));\n chart.addEventListener(\"pointerleave\", hide);\n // Keys: the chart takes focus, and \u2190 \u2192 step through the samples.\n let at = shown.length - 1;\n chart.setAttribute(\"tabindex\", \"0\");\n chart.addEventListener(\"focus\", () => show(shown[at] ?? null));\n chart.addEventListener(\"blur\", hide);\n chart.addEventListener(\"keydown\", (e) => {\n if (e.key !== \"ArrowLeft\" && e.key !== \"ArrowRight\") return;\n e.preventDefault();\n at = Math.max(0, Math.min(shown.length - 1, at + (e.key === \"ArrowLeft\" ? -1 : 1)));\n show(shown[at] ?? null);\n });\n\n // The table: hourly in the last 24 hours, else daily peaks.\n const rows: (string | number)[][] = [];\n if (range === \"day\") {\n for (let t = Math.floor(from / 3_600_000) * 3_600_000; t <= now; t += 3_600_000) {\n const p = peak(\n shown.filter((x) => x[0] < t + 3_600_000),\n t,\n );\n if (p) rows.push([time.format(t), p.online]);\n }\n } else {\n for (let i = 6; i >= 0; i--) {\n const start = midnight(now, i);\n const p = peak(\n shown.filter((x) => x[0] < start + DAY_MS),\n start,\n );\n if (p) rows.push([dayName.format(start), p.online]);\n }\n }\n\n const picker = h(\"div\", { class: \"seg\", role: \"group\", \"aria-label\": \"Range\" }, [\n rangeButton(\"day\", \"24 hours\"),\n rangeButton(\"week\", \"7 days\"),\n ]);\n return h(\"div\", {}, [\n picker,\n box,\n table(range === \"day\" ? \"Most people online, by hour\" : \"Most people online, by day\", [range === \"day\" ? \"Hour\" : \"Day\", \"People\"], rows),\n ]);\n}\n\nfunction rangeButton(value: typeof range, label: string): HTMLElement {\n return h(\n \"button\",\n {\n type: \"button\",\n \"aria-pressed\": String(range === value),\n on: {\n click: () => {\n range = value;\n refocus = true;\n if (last) render(last);\n },\n },\n },\n label,\n );\n}\n\n/** Messages per day, the last 30 days: columns, each with its tooltip. */\nfunction messagesChart(s: Stats): HTMLElement {\n const days = lastDays(s.messages.days, s.at);\n const top = niceMax(Math.max(0, ...days.map((d) => d.messages)));\n const plotW = W - PAD.left - PAD.right;\n const plotH = H - PAD.top - PAD.bottom;\n const slot = plotW / days.length;\n const bw = Math.min(16, slot - 2);\n const chart = svg(\"svg\", { viewBox: `0 0 ${W} ${H}`, class: \"chart\", role: \"img\" });\n chart.setAttribute(\"aria-label\", \"Messages per day, the last 30 days\");\n const g = svg(\"g\");\n chart.append(g);\n yAxis(g, top);\n const box = h(\"div\", { class: \"chart-box\" }, [chart]);\n const tip = tooltip(box);\n days.forEach((d, i) => {\n const x = PAD.left + i * slot + (slot - bw) / 2;\n const bh = (d.messages / top) * plotH;\n const y = PAD.top + plotH - bh;\n const r = Math.min(4, bw / 2, bh);\n // A column, rounded at the top, square at the baseline.\n if (bh > 0) {\n g.append(\n svg(\"path\", {\n d: `M${x},${y + bh}V${y + r}Q${x},${y} ${x + r},${y}H${x + bw - r}Q${x + bw},${y} ${x + bw},${y + r}V${y + bh}Z`,\n class: \"bar\",\n }),\n );\n }\n const date = new Date(`${d.day}T12:00:00`);\n const every = narrow() ? 10 : 5;\n if (i % every === every - 1 || i === days.length - 1) {\n xLabel(g, x + bw / 2, i === days.length - 1 ? \"Today\" : shortDay.format(date));\n }\n // The hit target: the whole slot, top to bottom.\n const hit = svg(\"rect\", { x: PAD.left + i * slot, y: PAD.top, width: slot, height: plotH, class: \"hit\" });\n const show = () =>\n tip.show(\n (x + bw / 2) / W,\n [\n [num.format(d.messages), S.tipMessages(d.messages)],\n [num.format(d.people), S.tipPosted(d.people)],\n ],\n dayName.format(date),\n );\n hit.addEventListener(\"pointerenter\", show);\n hit.addEventListener(\"pointerleave\", () => tip.hide());\n g.append(hit);\n });\n return h(\"div\", {}, [\n box,\n table(\n \"Messages per day\",\n [\"Day\", \"Messages\", \"People who posted\"],\n days.map((d) => [dayName.format(new Date(`${d.day}T12:00:00`)), d.messages, d.people]),\n ),\n ]);\n}\n\n// ---- the page ----\n\nfunction render(s: Stats) {\n last = s;\n // The card's inner width: the page's, less its padding and the card's.\n W = Math.round(Math.min(928, Math.max(280, root.clientWidth - 66)));\n H = narrow() ? 180 : 220;\n const now = s.at;\n const today = midnight(now);\n const days = lastDays(s.messages.days, now);\n const sum = (n: number) => days.slice(-n).reduce((a, d) => a + d.messages, 0);\n const month = sum(30);\n const peakToday = peak(s.samples, today);\n const peakWeek = peak(s.samples, now - 7 * DAY_MS);\n const hoursToday = personHours(s.samples, today, s.sample_minutes);\n const hoursWeek = personHours(s.samples, now - 7 * DAY_MS, s.sample_minutes);\n const recorded = (v: string) => (s.history || s.samples.length ? v : \"\u2013\");\n\n const sections = [\n !s.history ? h(\"p\", { class: \"notice\", role: \"note\" }, \"Recording is off (site settings: no_stats). Live numbers and messages are still shown; what was recorded before is dropped as it ages.\") : null,\n section(\"Now\", [\n h(\"div\", { class: \"tiles\" }, [\n tile(\"People online\", num.format(s.now.online), undefined, true),\n tile(\"On the web\", num.format(s.now.web)),\n tile(\"On Android\", num.format(s.now.android)),\n tile(\"Guests\", num.format(s.now.guests), \"open tabs, not signed in\"),\n tile(\n \"Peak today\",\n recorded(peakToday ? num.format(peakToday.online) : \"\u2013\"),\n peakToday?.at ? `at ${time.format(peakToday.at)}` : undefined,\n ),\n tile(\"Peak, 7 days\", recorded(peakWeek ? num.format(peakWeek.online) : \"\u2013\"), peakWeek?.at ? dayTime.format(peakWeek.at) : undefined),\n ]),\n ]),\n section(\n \"Usage\",\n [\n h(\"div\", { class: \"tiles\" }, [\n tile(\"Active, 24 hours\", num.format(s.active.day), `${percent(s.active.day, s.accounts.total)} of accounts`),\n tile(\"Active, 7 days\", num.format(s.active.week), `${percent(s.active.week, s.accounts.total)} of accounts`),\n tile(\"Active, 30 days\", num.format(s.active.month), `${percent(s.active.month, s.accounts.total)} of accounts`),\n tile(\"Time online today\", recorded(formatHours(hoursToday)), \"all people together\"),\n tile(\"Time online, 7 days\", recorded(formatHours(hoursWeek)), \"all people together\"),\n tile(\"Per active person\", recorded(s.active.week ? formatHours(hoursWeek / s.active.week) : \"\u2013\"), \"a week, on average\"),\n ]),\n h(\"h3\", {}, \"People online\"),\n onlineChart(s),\n ],\n \"Active: online at least once. Time online is counted every 5 minutes.\",\n ),\n section(\"Messages\", [\n h(\"div\", { class: \"tiles\" }, [\n tile(\"Today\", num.format(days.at(-1)?.messages ?? 0)),\n tile(\"7 days\", num.format(sum(7)), S.peoplePosted(s.messages.people_week, num.format(s.messages.people_week))),\n tile(\"30 days\", num.format(month), S.peoplePosted(s.messages.people_month, num.format(s.messages.people_month))),\n tile(\"In DMs\", percent(s.messages.dms_month, month), \"of the 30 days'\"),\n tile(\"Files sent\", num.format(s.messages.files_month), \"30 days\"),\n tile(\"Reactions\", num.format(s.messages.reactions_month), \"on the 30 days' messages\"),\n ]),\n h(\"h3\", {}, \"Messages per day\"),\n messagesChart(s),\n ]),\n section(\"Accounts\", [\n h(\"div\", { class: \"tiles\" }, [\n tile(\"Accounts\", num.format(s.accounts.total)),\n tile(\"New, 7 days\", num.format(s.accounts.new_week)),\n tile(\"Moderators\", num.format(s.accounts.moderators)),\n tile(\"Banned\", num.format(s.accounts.banned)),\n ]),\n ]),\n metrics ? serverSection(metrics) : null,\n ];\n // Keep the open tables open across a refresh.\n const open = [...root.querySelectorAll(\"details\")].map((d) => d.open);\n clear(root);\n for (const el of sections) if (el) root.append(el);\n root.querySelectorAll(\"details\").forEach((d, i) => {\n d.open = !!open[i];\n });\n // A range button was pressed: it is a new one now, focused as the old one was.\n if (refocus) root.querySelector<HTMLElement>(\".seg [aria-pressed='true']\")?.focus();\n refocus = false;\n updated.textContent = `Updated ${new Date(now).toLocaleTimeString()}`;\n}\n\nfunction denied() {\n document.title = \"Page not found\";\n clear(root);\n root.append(\n h(\"section\", { class: \"card missing\" }, [\n h(\"h2\", {}, \"Page not found\"),\n h(\"p\", {}, \"There is no such page, or you can't see it.\"),\n h(\"a\", { href: \"/\" }, \"Back to the app\"),\n ]),\n );\n updated.textContent = \"\";\n}\n\nlet timer = 0;\nasync function refresh() {\n clearTimeout(timer);\n const [got, m] = await Promise.all([load(), loadMetrics()]);\n if (got === \"denied\") return denied();\n metrics = m;\n if (got) render(got);\n else updated.textContent = last ? `Couldn't refresh: showing ${new Date(last.at).toLocaleTimeString()}` : \"Couldn't load. Retrying\u2026\";\n if (!document.hidden) timer = window.setTimeout(refresh, REFRESH_MS);\n}\n\napplyTheme(savedTheme());\nlet drawnFor = root.clientWidth;\nlet resizing = 0;\naddEventListener(\"resize\", () => {\n clearTimeout(resizing);\n resizing = window.setTimeout(() => {\n if (!last || Math.abs(root.clientWidth - drawnFor) < 8) return;\n drawnFor = root.clientWidth;\n render(last);\n }, 150);\n});\ndocument.addEventListener(\"visibilitychange\", () => {\n if (!document.hidden) void refresh();\n else clearTimeout(timer);\n});\nvoid refresh();\n"],
|
|
5
|
-
"mappings": "AAiBA,IAAMA,GAAQ,IAAI,IAAI,CAAC,QAAS,SAAS,CAAC,EAEnC,SAASC,EAAyCC,EAAQC,EAAe,CAAC,EAAGC,EAAsD,CACxI,IAAMC,EAAK,SAAS,cAAcH,CAAG,EAC/B,CAAE,MAAOI,EAAK,QAAAC,EAAS,GAAIC,EAAW,OAAAC,EAAQ,GAAGC,CAAK,EAAIP,EAC5DG,IAAKD,EAAG,UAAYC,GACpBC,GAAS,OAAO,OAAOF,EAAG,QAASE,CAAO,EAC9C,OAAW,CAACI,EAAMC,CAAC,IAAK,OAAO,QAAQF,CAAI,EAClBE,GAAM,MAAQA,IAAM,KACvCZ,GAAM,IAAIW,CAAI,EAAIN,EAA0CM,CAAI,EAAIC,EACnEP,EAAG,aAAaM,EAAMC,IAAM,GAAO,GAAK,OAAOA,CAAC,CAAC,GAExD,GAAIJ,EACF,OAAW,CAACK,EAAMC,CAAE,IAAK,OAAO,QAAQN,CAAS,EAC/CH,EAAG,iBAAiBQ,EAAMC,EAAq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C,GAAW,CAAC,EACvB,IAAIC,GAAWvJ,EAAK,YAChBwJ,GAAW,EACf,iBAAiB,SAAU,IAAM,CAC/B,aAAaA,EAAQ,EACrBA,GAAW,OAAO,WAAW,IAAM,CAC7B,CAAChJ,GAAQ,KAAK,IAAIR,EAAK,YAAcuJ,EAAQ,EAAI,IACrDA,GAAWvJ,EAAK,YAChBqH,GAAO7G,CAAI,EACb,EAAG,GAAG,CACR,CAAC,EACD,SAAS,iBAAiB,mBAAoB,IAAM,CAC7C,SAAS,OACT,aAAa0I,EAAK,EADIC,GAAQ,CAErC,CAAC,EACIA,GAAQ",
|
|
6
|
-
"names": ["PROPS", "h", "tag", "attrs", "children", "el", "cls", "dataset", "listeners", "signal", "rest", "name", "v", "type", "fn", "append", "c", "clear", "el", "peopleOnlineOverTheLast", "day", "tipMessages", "n", "tipPosted", "running", "busy", "slowClientsDroppedSinceTheStart", "n", "shown", "peoplePosted", "n", "shown", "THEME_KEY", "BAR", "safeLocalStorage", "savedTheme", "storage", "v", "applyTheme", "theme", "doc", "html", "meta", "forTheme", "min", "n", "hours", "days", "n", "ago", "span", "DAY_MS", "dayKey", "t", "d", "midnight", "now", "back", "lastDays", "days", "by", "out", "i", "day", "personHours", "samples", "from", "minutes", "sum", "peak", "best", "s", "runs", "run", "last", "niceMax", "max", "min", "v", "p", "m", "formatHours", "h", "hours", "percent", "part", "whole", "formatBytes", "n", "units", "formatSpan", "ago", "at", "never", "REFRESH_MS", "SESSIONS", "SVG", "root", "updated", "num", "time", "dayTime", "dayName", "shortDay", "range", "last", "metrics", "refocus", "tokens", "superusers", "out", "key", "session", "token", "load", "tz", "res", "loadMetrics", "tile", "label", "value", "note", "big", "h", "section", "title", "children", "hint", "svg", "tag", "attrs", "el", "k", "v", "table", "caption", "head", "rows", "grid", "c", "r", "i", "LABELS", "named", "serverSection", "m", "now", "db", "logs", "queues", "a", "b", "workers", "formatSpan", "slowClientsDroppedSinceTheStart", "formatBytes", "q", "w", "ago", "running", "W", "H", "narrow", "PAD", "yAxis", "g", "top", "y", "t", "xLabel", "x", "text", "anchor", "tooltip", "box", "tip", "lines", "clear", "left", "onlineChart", "s", "from", "DAY_MS", "parts", "runs", "shown", "niceMax", "plotW", "plotH", "xOf", "yOf", "chart", "peopleOnlineOverTheLast", "ticks", "first", "midnight", "base", "run", "pts", "cross", "mark", "nearest", "clientX", "best", "show", "cx", "hide", "e", "at", "p", "peak", "start", "picker", "rangeButton", "render", "messagesChart", "days", "lastDays", "d", "slot", "bw", "bh", "date", "every", "hit", "tipMessages", "tipPosted", "today", "sum", "n", "month", "peakToday", "peakWeek", "hoursToday", "personHours", "hoursWeek", "recorded", "sections", "percent", "formatHours", "peoplePosted", "open", "denied", "timer", "refresh", "got", "applyTheme", "savedTheme", "drawnFor", "resizing"]
|
|
7
|
-
}
|