{"version":3,"file":"15.BSG65l07.js","sources":["../../../../../../src/lib/charrecorder/core/plugins/wpm.ts","../../../../../../src/lib/charrecorder/core/plugins/rolling-wpm.ts","../../../../../../src/lib/charrecorder/TrackRollingWpm.svelte","../../../../../../src/routes/(app)/editor/+page.svelte"],"sourcesContent":["import type { ReplayPlayer } from \"../player\";\nimport type { ReplayPlugin, StoreContract } from \"../types\";\n\nexport const avgWordLength = 5;\n\nexport class WpmReplayPlugin implements StoreContract, ReplayPlugin {\n private subscribers = new Set<(value: number) => void>();\n\n register(replay: ReplayPlayer) {\n replay.subscribe(() => {\n if (this.subscribers.size === 0) return;\n const msPerChar =\n ((replay.stepper.text.at(-1)?.stamp ?? 0) - replay.startTime) /\n replay.stepper.text.length;\n\n const value = 60_000 / (msPerChar * avgWordLength);\n for (const subscription of this.subscribers) {\n subscription(value);\n }\n });\n }\n subscribe(subscription: (value: number) => void) {\n this.subscribers.add(subscription);\n return () => this.subscribers.delete(subscription);\n }\n}\n","import type { ReplayPlayer } from \"../player\";\nimport type { ReplayPlugin, StoreContract } from \"../types\";\nimport { avgWordLength } from \"./wpm\";\n\nexport class RollingWpmReplayPlugin\n implements StoreContract, ReplayPlugin\n{\n subscribers = new Set<(value: number) => void>();\n\n register(replay: ReplayPlayer) {\n replay.subscribe(() => {\n if (this.subscribers.size === 0) return;\n let i = 0;\n const index = Math.max(\n 0,\n replay.stepper.text.findLastIndex((char) => {\n if (char.source === \"ghost\") return false;\n if (char.text === \" \" && i < 10) {\n i++;\n } else if (char.text === \" \") {\n return true;\n }\n return false;\n }),\n );\n const length =\n replay.stepper.text.length - replay.stepper.ghostCount - index;\n const msPerChar =\n ((replay.stepper.text[\n replay.stepper.text.length - replay.stepper.ghostCount - 1\n ]?.stamp ?? 0) -\n (replay.stepper.text[index]?.stamp ?? 0)) /\n length;\n\n const value = 60_000 / (msPerChar * avgWordLength);\n if (Number.isFinite(value)) {\n for (const subscription of this.subscribers) {\n subscription(value);\n }\n }\n });\n }\n\n subscribe(subscription: (value: number) => void) {\n this.subscribers.add(subscription);\n return () => this.subscribers.delete(subscription);\n }\n}\n","\n","\n\n\n Editor\n\n\n\n
\n

Editor

\n\n {#if replay}\n
\n \n
\n {/if}\n\n {#key recorder}\n \n \n \n \n \n \n {/key}\n\n
\n
\n \n \n \n
\n\n
\n
{Math.round(wpm)}WPM
\n
\n
\n
\n\n\n"],"names":["avgWordLength","RollingWpmReplayPlugin","replay","i","index","char","length","value","subscription","player","getContext","wpm","$.user_effect","tracker","runReplay","_","recorder","$.proxy","$.get","ReplayRecorder","$.state","chords","handleRawKey","event","keyEvent","clear","$.set","save","blob","url","a","$$anchor","$.transition","div","fade","div_1"],"mappings":"krBAGO,MAAMA,GAAgB,ECCtB,MAAMC,EAEb,CACE,gBAAkB,IAElB,SAASC,EAAsB,CAC7BA,EAAO,UAAU,IAAM,CACjB,GAAA,KAAK,YAAY,OAAS,EAAG,OACjC,IAAIC,EAAI,EACR,MAAMC,EAAQ,KAAK,IACjB,EACAF,EAAO,QAAQ,KAAK,cAAeG,GAAS,CACtC,GAAAA,EAAK,SAAW,QAAgB,MAAA,GACpC,GAAIA,EAAK,OAAS,KAAOF,EAAI,GAC3BA,YACSE,EAAK,OAAS,IAChB,MAAA,GAEF,MAAA,EACR,CAAA,CACH,EACMC,EACJJ,EAAO,QAAQ,KAAK,OAASA,EAAO,QAAQ,WAAaE,EAQrDG,EAAQ,OANVL,EAAO,QAAQ,KACfA,EAAO,QAAQ,KAAK,OAASA,EAAO,QAAQ,WAAa,CAC3D,GAAG,OAAS,IACTA,EAAO,QAAQ,KAAKE,CAAK,GAAG,OAAS,IACxCE,EAEkCN,IAChC,GAAA,OAAO,SAASO,CAAK,EACZ,UAAAC,KAAgB,KAAK,YAC9BA,EAAaD,CAAK,CAEtB,CACD,CAAA,CAGH,UAAUC,EAAuC,CAC1C,YAAA,YAAY,IAAIA,CAAY,EAC1B,IAAM,KAAK,YAAY,OAAOA,CAAY,CAAA,CAErD,gCC1CQC,E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