Skip to content

Unofficial YouTube Music / Spotify Premium client for Android, built in Liquid Glass. Audio effects, Spotify Connect, listening history, 8 languages. Rust core on librespot.

Play YouTube songs that need an account, group the settings, and choose a lyrics source

Leloniocc951bb8bc60
diff --git a/app/build.gradle.kts b/app/build.gradle.kts
index 213d040..b866937 100644
--- a/app/build.gradle.kts
+++ b/app/build.gradle.kts
@@ -188,6 +188,8 @@ android {
dependencies {
testImplementation("junit:junit:4.13.2")
+ // The real org.json for the JVM tests: android.jar carries only stubs.
+ testImplementation("org.json:json:20240303")
implementation(libs.timber)
implementation(libs.androidx.core.ktx)
// Installs baseline-prof.txt on first run, so the code the bar and the
@@ -195,6 +197,9 @@ dependencies {
implementation(libs.androidx.profileinstaller)
implementation(libs.androidx.activity.compose)
implementation(libs.androidx.browser)
+ // An isolated JavaScript engine, no page around it: runs the challenge
+ // solver YouTube's signed-in streams need; see PlayerChallenges.
+ implementation(libs.androidx.javascriptengine)
implementation(libs.reorderable)
implementation(libs.androidx.security.crypto)
implementation(libs.androidx.lifecycle.runtime.compose)
diff --git a/app/src/main/assets/ejs/yt.solver.core.min.js b/app/src/main/assets/ejs/yt.solver.core.min.js
new file mode 100644
index 0000000..66f7978
--- /dev/null
+++ b/app/src/main/assets/ejs/yt.solver.core.min.js
@@ -0,0 +1,5 @@
+/*!
+ * SPDX-License-Identifier: Unlicense
+ * This file was automatically generated by https://github.com/yt-dlp/ejs
+ */
+var jsc=function(e,n){"use strict";function t(e,n){if(Array.isArray(n))return!!Array.isArray(e)&&(n.length===e.length&&n.every((n,o)=>t(e[o],n)));if("object"==typeof n){if(!e)return!n;if("or"in n)return n.or.some(n=>t(e,n));if("anykey"in n&&Array.isArray(n.anykey)){const o=Array.isArray(e)?e:Object.values(e);return n.anykey.every(e=>o.some(n=>t(n,e)))}for(const[o,s]of Object.entries(n))if(!t(e[o],s))return!1;return!0}return n===e}function o(n){return e.parse(n).body[0].expression}function s(e){let n,t=e[0],o=1;for(;o<e.length;){const s=e[o],r=e[o+1];if(o+=2,("optionalAccess"===s||"optionalCall"===s)&&null==t)return;"access"===s||"optionalAccess"===s?(n=t,t=r(t)):"call"!==s&&"optionalCall"!==s||(t=r((...e)=>t.call(n,...e)),n=void 0)}return t}const r={or:[{type:"ExpressionStatement",expression:{type:"AssignmentExpression",operator:"=",left:{or:[{type:"Identifier"},{type:"MemberExpression"}]},right:{type:"FunctionExpression",async:!1}}},{type:"FunctionDeclaration",async:!1,id:{type:"Identifier"}},{type:"VariableDeclaration",declarations:{anykey:[{type:"VariableDeclarator",init:{type:"FunctionExpression",async:!1}}]}}]},i={type:"ExpressionStatement",expression:{type:"CallExpression",callee:{type:"MemberExpression",object:{type:"Identifier"},property:{},optional:!1},arguments:[{type:"Literal",value:"alr"},{type:"Literal",value:"yes"}],optional:!1}};function p(e){if(!t(e,r))return null;const n=[];if("FunctionDeclaration"===e.type)e.id&&s([e,"access",e=>e.body,"optionalAccess",e=>e.body])&&n.push({name:e.id,statements:s([e,"access",e=>e.body,"optionalAccess",e=>e.body])});else if("ExpressionStatement"===e.type){if("AssignmentExpression"!==e.expression.type)return null;const t=e.expression.left,o=s([e.expression.right,"optionalAccess",e=>e.body,"optionalAccess",e=>e.body]);t&&o&&n.push({name:t,statements:o})}else if("VariableDeclaration"===e.type)for(const t of e.declarations){const e=t.id,o=s([t.init,"optionalAccess",e=>e.body,"optionalAccess",e=>e.body]);e&&o&&n.push({name:e,statements:o})}for(const{name:e,statements:o}of n)if(t(o,{anykey:[i]}))return a(e);return null}function a(e){return o(`\n({sig, n}) => {\n const url = (${n.generate(e)})("https://youtube.com/watch?v=yt-dlp-wins", "s", sig ? encodeURIComponent(sig) : undefined);\n url.set("n", n);\n const proto = Object.getPrototypeOf(url);\n const keys = Object.keys(proto).concat(Object.getOwnPropertyNames(proto));\n for (const key of keys) {\n if (!["constructor", "set", "get", "clone"].includes(key)) {\n url[key]();\n break;\n }\n }\n const s = url.get("s");\n return {\n sig: s ? decodeURIComponent(s) : null,\n n: url.get("n") ?? null,\n };\n}\n`)}const l=e.parse('\nif (typeof globalThis.XMLHttpRequest === "undefined") {\n globalThis.XMLHttpRequest = { prototype: {} };\n}\nif (typeof URL === "undefined") {\n globalThis.location = {\n hash: "",\n host: "www.youtube.com",\n hostname: "www.youtube.com",\n href: "https://www.youtube.com/watch?v=yt-dlp-wins",\n origin: "https://www.youtube.com",\n password: "",\n pathname: "/watch",\n port: "",\n protocol: "https:",\n search: "?v=yt-dlp-wins",\n username: "",\n };\n} else {\n globalThis.location = new URL("https://www.youtube.com/watch?v=yt-dlp-wins");\n}\nif (typeof globalThis.document === "undefined") {\n globalThis.document = Object.create(null);\n}\nif (typeof globalThis.navigator === "undefined") {\n globalThis.navigator = Object.create(null);\n}\nif (typeof globalThis.self === "undefined") {\n globalThis.self = globalThis;\n}\nif (typeof globalThis.window === "undefined") {\n globalThis.window = globalThis;\n}\n').body;function c(e){let n,t=e[0],o=1;for(;o<e.length;){const s=e[o],r=e[o+1];if(o+=2,("optionalAccess"===s||"optionalCall"===s)&&null==t)return;"access"===s||"optionalAccess"===s?(n=t,t=r(t)):"call"!==s&&"optionalCall"!==s||(t=r((...e)=>t.call(n,...e)),n=void 0)}return t}function u(t){const o=e.parse(t),s=function(e){const n=e.body,t=(()=>{switch(n.length){case 1:{const e=n[0];if("ExpressionStatement"===c([e,"optionalAccess",e=>e.type])&&"CallExpression"===e.expression.type&&"MemberExpression"===e.expression.callee.type&&"FunctionExpression"===e.expression.callee.object.type)return e.expression.callee.object.body;break}case 2:{const e=n[1];if("ExpressionStatement"===c([e,"optionalAccess",e=>e.type])&&"CallExpression"===e.expression.type&&"FunctionExpression"===e.expression.callee.type){const n=e.expression.callee.body;return n.body.splice(0,1),n}break}}throw"unexpected structure"})();return t.body=t.body.filter(e=>"ExpressionStatement"!==e.type||("AssignmentExpression"===e.expression.type||"Literal"===e.expression.type)),t.body}(o),r=function(e){const n={n:[],sig:[]};for(const t of e){const e=p(t);e&&(n.n.push(y(e,{type:"Identifier",name:"n"})),n.sig.push(y(e,{type:"Identifier",name:"sig"})))}return n}(s);for(const[e,n]of Object.entries(r))s.push({type:"ExpressionStatement",expression:{type:"AssignmentExpression",operator:"=",left:{type:"MemberExpression",computed:!1,object:{type:"Identifier",name:"_result"},property:{type:"Identifier",name:e},optional:!1},right:f(n)}});return o.body.splice(0,0,...l),n.generate(o)}function y(e,n){return{type:"ArrowFunctionExpression",params:[n],body:{type:"MemberExpression",object:{type:"CallExpression",callee:e,arguments:[{type:"ObjectExpression",properties:[{type:"Property",key:n,value:n,kind:"init",computed:!1,method:!1,shorthand:!0}]}],optional:!1},computed:!1,property:n,optional:!1},async:!1,expression:!0,generator:!1}}function f(e){return o(`\n(_input) => {\n const _results = new Set();\n const errors = [];\n for (const _generator of ${n.generate({type:"ArrayExpression",elements:e})}) {\n try {\n _results.add(_generator(_input));\n } catch (e) {\n errors.push(e);\n }\n }\n if (!_results.size) {\n throw \`no solutions: \${errors.join(", ")}\`;\n }\n if (_results.size !== 1) {\n throw \`invalid solutions: \${[..._results].map(x => JSON.stringify(x)).join(", ")}\`;\n }\n return _results.values().next().value;\n}\n`)}return function(e){const n="player"===e.type?u(e.player):e.preprocessed_player,t=function(e){const n={n:null,sig:null};return Function("_result",e)(n),n}(n),o={type:"result",responses:e.requests.map(e=>{if(!function(e,...n){return n.includes(e)}(e.type,"n","sig"))return{type:"error",error:`Unknown request type: ${e.type}`};const n=t[e.type];if(!n)return{type:"error",error:`Failed to extract ${e.type} function`};try{return{type:"result",data:Object.fromEntries(e.challenges.map(e=>[e,n(e)]))}}catch(e){return{type:"error",error:e instanceof Error?`${e.message}\n${e.stack}`:`${e}`}}})};return"player"===e.type&&e.output_preprocessed&&(o.preprocessed_player=n),o}}(meriyah,astring);
\ No newline at end of file
diff --git a/app/src/main/assets/ejs/yt.solver.lib.min.js b/app/src/main/assets/ejs/yt.solver.lib.min.js
new file mode 100644
index 0000000..7fbd088
--- /dev/null
+++ b/app/src/main/assets/ejs/yt.solver.lib.min.js
@@ -0,0 +1,52 @@
+/*!
+ * SPDX-License-Identifier: Unlicense
+ * This file was automatically generated by https://github.com/yt-dlp/ejs
+ *
+ * Bundled Dependencies:
+ *
+ * ---
+ * Name: meriyah
+ * Version: 6.1.4
+ * License: ISC
+ * Repository: git+https://github.com/meriyah/meriyah.git
+ * Author: Kenny F. (https://github.com/KFlash)
+ *
+ * ISC License
+ *
+ * Copyright (c) 2019 and later, KFlash and others.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * ---
+ *
+ * ---
+ * Name: astring
+ * Version: 1.9.0
+ * License: MIT
+ * Repository: https://github.com/davidbonnet/astring.git
+ * Author: David Bonnet <[email protected]>
+ *
+ * Copyright (c) 2015, David Bonnet <[email protected]>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ * ---
+ */
+var lib=function(e){"use strict";const t=((e,t)=>{const r=new Uint32Array(69632);let n=0,o=0;for(;n<2571;){const i=e[n++];if(i<0)o-=i;else{let a=e[n++];2&i&&(a=t[a]),1&i?r.fill(a,o,o+=e[n++]):r[o++]=a}}return r})([-1,2,26,2,27,2,5,-1,0,77595648,3,44,2,3,0,14,2,63,2,64,3,0,3,0,3168796671,0,4294956992,2,1,2,0,2,41,3,0,4,0,4294966523,3,0,4,2,16,2,65,2,0,0,4294836735,0,3221225471,0,4294901942,2,66,0,134152192,3,0,2,0,4294951935,3,0,2,0,2683305983,0,2684354047,2,18,2,0,0,4294961151,3,0,2,2,19,2,0,0,608174079,2,0,2,60,2,7,2,6,0,4286611199,3,0,2,2,1,3,0,3,0,4294901711,2,40,0,4089839103,0,2961209759,0,1342439375,0,4294543342,0,3547201023,0,1577204103,0,4194240,0,4294688750,2,2,0,80831,0,4261478351,0,4294549486,2,2,0,2967484831,0,196559,0,3594373100,0,3288319768,0,8469959,0,65472,2,3,0,4093640191,0,660618719,0,65487,0,4294828015,0,4092591615,0,1616920031,0,982991,2,3,2,0,0,2163244511,0,4227923919,0,4236247022,2,71,0,4284449919,0,851904,2,4,2,12,0,67076095,-1,2,72,0,1073741743,0,4093607775,-1,0,50331649,0,3265266687,2,33,0,4294844415,0,4278190047,2,20,2,137,-1,3,0,2,2,23,2,0,2,10,2,0,2,15,2,22,3,0,10,2,74,2,0,2,75,2,76,2,77,2,0,2,78,2,0,2,11,0,261632,2,25,3,0,2,2,13,2,4,3,0,18,2,79,2,5,3,0,2,2,80,0,2151677951,2,29,2,9,0,909311,3,0,2,0,814743551,2,49,0,67090432,3,0,2,2,42,2,0,2,6,2,0,2,30,2,8,0,268374015,2,110,2,51,2,0,2,81,0,134153215,-1,2,7,2,0,2,8,0,2684354559,0,67044351,0,3221160064,2,17,-1,3,0,2,2,53,0,1046528,3,0,3,2,9,2,0,2,54,0,4294960127,2,10,2,6,2,11,0,4294377472,2,12,3,0,16,2,13,2,0,2,82,2,10,2,0,2,83,2,84,2,85,0,12288,2,55,0,1048577,2,86,2,14,-1,2,14,0,131042,2,87,2,88,2,89,2,0,2,34,-83,3,0,7,0,1046559,2,0,2,15,2,0,0,2147516671,2,21,3,90,2,2,0,-16,2,91,0,524222462,2,4,2,0,0,4269801471,2,4,3,0,2,2,28,2,16,3,0,2,2,17,2,0,-1,2,18,-16,3,0,206,-2,3,0,692,2,73,-1,2,18,2,10,3,0,8,2,93,2,133,2,0,0,3220242431,3,0,3,2,19,2,94,2,95,3,0,2,2,96,2,0,2,97,2,46,2,0,0,4351,2,0,2,9,3,0,2,0,67043391,0,3909091327,2,0,2,24,2,9,2,20,3,0,2,0,67076097,2,8,2,0,2,21,0,67059711,0,4236247039,3,0,2,0,939524103,0,8191999,2,101,2,102,2,22,2,23,3,0,3,0,67057663,3,0,349,2,103,2,104,2,7,-264,3,0,11,2,24,3,0,2,2,32,-1,0,3774349439,2,105,2,106,3,0,2,2,19,2,107,3,0,10,2,10,2,18,2,0,2,47,2,0,2,31,2,108,2,25,0,1638399,0,57344,2,109,3,0,3,2,20,2,26,2,27,2,5,2,28,2,0,2,8,2,111,-1,2,112,2,113,2,114,-1,3,0,3,2,12,-2,2,0,2,29,-3,0,536870912,-4,2,20,2,0,2,36,0,1,2,0,2,67,2,6,2,12,2,10,2,0,2,115,-1,3,0,4,2,10,2,23,2,116,2,7,2,0,2,117,2,0,2,118,2,119,2,120,2,0,2,9,3,0,9,2,21,2,30,2,31,2,121,2,122,-2,2,123,2,124,2,30,2,21,2,8,-2,2,125,2,30,2,32,-2,2,0,2,39,-2,0,4277137519,0,2269118463,-1,3,20,2,-1,2,33,2,38,2,0,3,30,2,2,35,2,19,-3,3,0,2,2,34,-1,2,0,2,35,2,0,2,35,2,0,2,48,2,0,0,4294950463,2,37,-7,2,0,0,203775,2,57,0,4026531840,2,20,2,43,2,36,2,18,2,37,2,18,2,126,2,21,3,0,2,2,38,0,2151677888,2,0,2,12,0,4294901764,2,144,2,0,2,58,2,56,0,5242879,3,0,2,0,402644511,-1,2,128,2,39,0,3,-1,2,129,2,130,2,0,0,67045375,2,40,0,4226678271,0,3766565279,0,2039759,2,132,2,41,0,1046437,0,6,3,0,2,0,3288270847,0,3,3,0,2,0,67043519,-5,2,0,0,4282384383,0,1056964609,-1,3,0,2,0,67043345,-1,2,0,2,42,2,23,2,50,2,11,2,61,2,38,-5,2,0,2,12,-3,3,0,2,0,2147484671,2,134,0,4190109695,2,52,-2,2,135,0,4244635647,0,27,2,0,2,8,2,43,2,0,2,68,2,18,2,0,2,42,-6,2,0,2,45,2,59,2,44,2,45,2,46,2,47,0,8388351,-2,2,136,0,3028287487,2,48,2,138,0,33259519,2,49,-9,2,21,0,4294836223,0,3355443199,0,134152199,-2,2,69,-2,3,0,28,2,32,-3,3,0,3,2,17,3,0,6,2,50,-81,2,18,3,0,2,2,36,3,0,33,2,25,2,30,3,0,124,2,12,3,0,18,2,38,-213,2,0,2,32,-54,3,0,17,2,42,2,8,2,23,2,0,2,8,2,23,2,51,2,0,2,21,2,52,2,139,2,25,-13,2,0,2,53,-6,3,0,2,-4,3,0,2,0,4294936575,2,0,0,4294934783,-2,0,196635,3,0,191,2,54,3,0,38,2,30,2,55,2,34,-278,2,140,3,0,9,2,141,2,142,2,56,3,0,11,2,7,-72,3,0,3,2,143,0,1677656575,-130,2,26,-16,2,0,2,24,2,38,-16,0,4161266656,0,4071,0,15360,-4,2,57,-13,3,0,2,2,58,2,0,2,145,2,146,2,62,2,0,2,147,2,148,2,149,3,0,10,2,150,2,151,2,22,3,58,2,3,152,2,3,59,2,0,4294954999,2,0,-16,2,0,2,92,2,0,0,2105343,0,4160749584,0,65534,-34,2,8,2,154,-6,0,4194303871,0,4294903771,2,0,2,60,2,100,-3,2,0,0,1073684479,0,17407,-9,2,18,2,17,2,0,2,32,-14,2,18,2,32,-6,2,18,2,12,-15,2,155,3,0,6,0,8323103,-1,3,0,2,2,61,-37,2,62,2,156,2,157,2,158,2,159,2,160,-105,2,26,-32,3,0,1335,-1,3,0,129,2,32,3,0,6,2,10,3,0,180,2,161,3,0,233,2,162,3,0,18,2,10,-77,3,0,16,2,10,-47,3,0,154,2,6,3,0,130,2,25,-22250,3,0,7,2,25,-6130,3,5,2,-1,0,69207040,3,44,2,3,0,14,2,63,2,64,-3,0,3168731136,0,4294956864,2,1,2,0,2,41,3,0,4,0,4294966275,3,0,4,2,16,2,65,2,0,2,34,-1,2,18,2,66,-1,2,0,0,2047,0,4294885376,3,0,2,0,3145727,0,2617294944,0,4294770688,2,25,2,67,3,0,2,0,131135,2,98,0,70256639,0,71303167,0,272,2,42,2,6,0,32511,2,0,2,49,-1,2,99,2,68,0,4278255616,0,4294836227,0,4294549473,0,600178175,0,2952806400,0,268632067,0,4294543328,0,57540095,0,1577058304,0,1835008,0,4294688736,2,70,2,69,0,33554435,2,131,2,70,0,2952790016,0,131075,0,3594373096,0,67094296,2,69,-1,0,4294828e3,0,603979263,0,654311424,0,3,0,4294828001,0,602930687,0,1610612736,0,393219,0,4294828016,0,671088639,0,2154840064,0,4227858435,0,4236247008,2,71,2,38,-1,2,4,0,917503,2,38,-1,2,72,0,537788335,0,4026531935,-1,0,1,-1,2,33,2,73,0,7936,-3,2,0,0,2147485695,0,1010761728,0,4292984930,0,16387,2,0,2,15,2,22,3,0,10,2,74,2,0,2,75,2,76,2,77,2,0,2,78,2,0,2,12,-1,2,25,3,0,2,2,13,2,4,3,0,18,2,79,2,5,3,0,2,2,80,0,2147745791,3,19,2,0,122879,2,0,2,9,0,276824064,-2,3,0,2,2,42,2,0,0,4294903295,2,0,2,30,2,8,-1,2,18,2,51,2,0,2,81,2,49,-1,2,21,2,0,2,29,-2,0,128,-2,2,28,2,9,0,8160,-1,2,127,0,4227907585,2,0,2,37,2,0,2,50,0,4227915776,2,10,2,6,2,11,-1,0,74440192,3,0,6,-2,3,0,8,2,13,2,0,2,82,2,10,2,0,2,83,2,84,2,85,-3,2,86,2,14,-3,2,87,2,88,2,89,2,0,2,34,-83,3,0,7,0,817183,2,0,2,15,2,0,0,33023,2,21,3,90,2,-17,2,91,0,524157950,2,4,2,0,2,92,2,4,2,0,2,22,2,28,2,16,3,0,2,2,17,2,0,-1,2,18,-16,3,0,206,-2,3,0,692,2,73,-1,2,18,2,10,3,0,8,2,93,0,3072,2,0,0,2147516415,2,10,3,0,2,2,25,2,94,2,95,3,0,2,2,96,2,0,2,97,2,46,0,4294965179,0,7,2,0,2,9,2,95,2,9,-1,0,1761345536,2,98,0,4294901823,2,38,2,20,2,99,2,35,2,100,0,2080440287,2,0,2,34,2,153,0,3296722943,2,0,0,1046675455,0,939524101,0,1837055,2,101,2,102,2,22,2,23,3,0,3,0,7,3,0,349,2,103,2,104,2,7,-264,3,0,11,2,24,3,0,2,2,32,-1,0,2700607615,2,105,2,106,3,0,2,2,19,2,107,3,0,10,2,10,2,18,2,0,2,47,2,0,2,31,2,108,-3,2,109,3,0,3,2,20,-1,3,5,2,2,110,2,0,2,8,2,111,-1,2,112,2,113,2,114,-1,3,0,3,2,12,-2,2,0,2,29,-8,2,20,2,0,2,36,-1,2,0,2,67,2,6,2,30,2,10,2,0,2,115,-1,3,0,4,2,10,2,18,2,116,2,7,2,0,2,117,2,0,2,118,2,119,2,120,2,0,2,9,3,0,9,2,21,2,30,2,31,2,121,2,122,-2,2,123,2,124,2,30,2,21,2,8,-2,2,125,2,30,2,32,-2,2,0,2,39,-2,0,4277075969,2,30,-1,3,20,2,-1,2,33,2,126,2,0,3,30,2,2,35,2,19,-3,3,0,2,2,34,-1,2,0,2,35,2,0,2,35,2,0,2,50,2,98,0,4294934591,2,37,-7,2,0,0,197631,2,57,-1,2,20,2,43,2,37,2,18,0,3,2,18,2,126,2,21,2,127,2,54,-1,0,2490368,2,127,2,25,2,18,2,34,2,127,2,38,0,4294901904,0,4718591,2,127,2,35,0,335544350,-1,2,128,0,2147487743,0,1,-1,2,129,2,130,2,8,-1,2,131,2,70,0,3758161920,0,3,2,132,0,12582911,0,655360,-1,2,0,2,29,0,2147485568,0,3,2,0,2,25,0,176,-5,2,0,2,17,0,251658240,-1,2,0,2,25,0,16,-1,2,0,0,16779263,-2,2,12,-1,2,38,-5,2,0,2,133,-3,3,0,2,2,55,2,134,0,2147549183,0,2,-2,2,135,2,36,0,10,0,4294965249,0,67633151,0,4026597376,2,0,0,536871935,2,18,2,0,2,42,-6,2,0,0,1,2,59,2,17,0,1,2,46,2,25,-3,2,136,2,36,2,137,2,138,0,16778239,-10,2,35,0,4294836212,2,9,-3,2,69,-2,3,0,28,2,32,-3,3,0,3,2,17,3,0,6,2,50,-81,2,18,3,0,2,2,36,3,0,33,2,25,0,126,3,0,124,2,12,3,0,18,2,38,-213,2,10,-55,3,0,17,2,42,2,8,2,18,2,0,2,8,2,18,2,60,2,0,2,25,2,50,2,139,2,25,-13,2,0,2,73,-6,3,0,2,-4,3,0,2,0,67583,-1,2,107,-2,0,11,3,0,191,2,54,3,0,38,2,30,2,55,2,34,-278,2,140,3,0,9,2,141,2,142,2,56,3,0,11,2,7,-72,3,0,3,2,143,2,144,-187,3,0,2,2,58,2,0,2,145,2,146,2,62,2,0,2,147,2,148,2,149,3,0,10,2,150,2,151,2,22,3,58,2,3,152,2,3,59,2,2,153,-57,2,8,2,154,-7,2,18,2,0,2,60,-4,2,0,0,1065361407,0,16384,-9,2,18,2,60,2,0,2,133,-14,2,18,2,133,-6,2,18,0,81919,-15,2,155,3,0,6,2,126,-1,3,0,2,0,2063,-37,2,62,2,156,2,157,2,158,2,159,2,160,-138,3,0,1335,-1,3,0,129,2,32,3,0,6,2,10,3,0,180,2,161,3,0,233,2,162,3,0,18,2,10,-77,3,0,16,2,10,-47,3,0,154,2,6,3,0,130,2,25,-28386],[4294967295,4294967291,4092460543,4294828031,4294967294,134217726,4294903807,268435455,2147483647,1048575,1073741823,3892314111,134217727,1061158911,536805376,4294910143,4294901759,32767,4294901760,262143,536870911,8388607,4160749567,4294902783,4294918143,65535,67043328,2281701374,4294967264,2097151,4194303,255,67108863,4294967039,511,524287,131071,63,127,3238002687,4294549487,4290772991,33554431,4294901888,4286578687,67043329,4294705152,4294770687,67043583,1023,15,2047999,67043343,67051519,16777215,2147483648,4294902e3,28,4292870143,4294966783,16383,67047423,4294967279,262083,20511,41943039,493567,4294959104,603979775,65536,602799615,805044223,4294965206,8191,1031749119,4294917631,2134769663,4286578493,4282253311,4294942719,33540095,4294905855,2868854591,1608515583,265232348,534519807,2147614720,1060109444,4093640016,17376,2139062143,224,4169138175,4294909951,4286578688,4294967292,4294965759,535511039,4294966272,4294967280,32768,8289918,4294934399,4294901775,4294965375,1602223615,4294967259,4294443008,268369920,4292804608,4294967232,486341884,4294963199,3087007615,1073692671,4128527,4279238655,4294902015,4160684047,4290246655,469499899,4294967231,134086655,4294966591,2445279231,3670015,31,4294967288,4294705151,3221208447,4294902271,4294549472,4294921215,4095,4285526655,4294966527,4294966143,64,4294966719,3774873592,1877934080,262151,2555904,536807423,67043839,3758096383,3959414372,3755993023,2080374783,4294835295,4294967103,4160749565,4294934527,4087,2016,2147446655,184024726,2862017156,1593309078,268434431,268434414,4294901763,4294901761]),r=e=>!!(1&t[(e>>>5)+34816]>>>e);function n(e){return e.column++,e.currentChar=e.source.charCodeAt(++e.index)}function o(e){const t=e.currentChar;if(55296!=(64512&t))return 0;const r=e.source.charCodeAt(e.index+1);return 56320!=(64512&r)?0:65536+((1023&t)<<10)+(1023&r)}function i(e,t){e.currentChar=e.source.charCodeAt(++e.index),e.flags|=1,4&t||(e.column=0,e.line++)}function a(e){e.flags|=1,e.currentChar=e.source.charCodeAt(++e.index),e.column=0,e.line++}function s(e){return 160===e||65279===e||133===e||5760===e||e>=8192&&e<=8203||8239===e||8287===e||12288===e||8201===e||65519===e}function c(e){return e<65?e-48:e-65+10&15}function l(e){switch(e){case 134283266:return"NumericLiteral";case 134283267:return"StringLiteral";case 86021:case 86022:return"BooleanLiteral";case 86023:return"NullLiteral";case 65540:return"RegularExpression";case 67174408:case 67174409:case 131:return"TemplateLiteral";default:return 143360&~e?4096&~e?"Punctuator":"Keyword":"Identifier"}}const u=[0,0,0,0,0,0,0,0,0,0,1032,0,0,2056,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8192,0,3,0,0,8192,0,0,0,256,0,33024,0,0,242,242,114,114,114,114,114,114,594,594,0,0,16384,0,0,0,0,67,67,67,67,67,67,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,0,1,0,0,4099,0,71,71,71,71,71,71,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,16384,0,0,0,0],p=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0],d=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0];function g(e){return e<=127?p[e]>0:r(e)}function f(e){return e<=127?d[e]>0:(e=>!!(1&t[(e>>>5)+0]>>>e))(e)||8204===e||8205===e}const h=["SingleLine","MultiLine","HTMLOpen","HTMLClose","HashbangComment"];function k(e,t,r,n,o,i){return 2&n&&e.report(0),m(e,t,r,o,i)}function m(e,t,r,o,i){const{index:s}=e;for(e.tokenIndex=e.index,e.tokenLine=e.line,e.tokenColumn=e.column;e.index<e.end;){if(8&u[e.currentChar]){const r=13===e.currentChar;a(e),r&&e.index<e.end&&10===e.currentChar&&(e.currentChar=t.charCodeAt(++e.index));break}if((8232^e.currentChar)<=1){a(e);break}n(e),e.tokenIndex=e.index,e.tokenLine=e.line,e.tokenColumn=e.column}if(e.options.onComment){const r={start:{line:i.line,column:i.column},end:{line:e.tokenLine,column:e.tokenColumn}};e.options.onComment(h[255&o],t.slice(s,e.tokenIndex),i.index,e.tokenIndex,r)}return 1|r}function b(e,t,r){const{index:o}=e;for(;e.index<e.end;)if(e.currentChar<43){let s=!1;for(;42===e.currentChar;)if(s||(r&=-5,s=!0),47===n(e)){if(n(e),e.options.onComment){const r={start:{line:e.tokenLine,column:e.tokenColumn},end:{line:e.line,column:e.column}};e.options.onComment(h[1],t.slice(o,e.index-2),o-2,e.index,r)}return e.tokenIndex=e.index,e.tokenLine=e.line,e.tokenColumn=e.column,r}if(s)continue;8&u[e.currentChar]?13===e.currentChar?(r|=5,a(e)):(i(e,r),r=-5&r|1):n(e)}else(8232^e.currentChar)<=1?(r=-5&r|1,a(e)):(r&=-5,n(e));e.report(18)}var w,y;function T(e){const t=e.index;let r=w.Empty;e:for(;;){const t=e.currentChar;if(n(e),r&w.Escape)r&=~w.Escape;else switch(t){case 47:if(r)break;break e;case 92:r|=w.Escape;break;case 91:r|=w.Class;break;case 93:r&=w.Escape}if(13!==t&&10!==t&&8232!==t&&8233!==t||e.report(34),e.index>=e.source.length)return e.report(34)}const o=e.index-1;let i=y.Empty,a=e.currentChar;const{index:s}=e;for(;f(a);){switch(a){case 103:i&y.Global&&e.report(36,"g"),i|=y.Global;break;case 105:i&y.IgnoreCase&&e.report(36,"i"),i|=y.IgnoreCase;break;case 109:i&y.Multiline&&e.report(36,"m"),i|=y.Multiline;break;case 117:i&y.Unicode&&e.report(36,"u"),i&y.UnicodeSets&&e.report(36,"vu"),i|=y.Unicode;break;case 118:i&y.Unicode&&e.report(36,"uv"),i&y.UnicodeSets&&e.report(36,"v"),i|=y.UnicodeSets;break;case 121:i&y.Sticky&&e.report(36,"y"),i|=y.Sticky;break;case 115:i&y.DotAll&&e.report(36,"s"),i|=y.DotAll;break;case 100:i&y.Indices&&e.report(36,"d"),i|=y.Indices;break;default:e.report(35)}a=n(e)}const c=e.source.slice(s,e.index),l=e.source.slice(t,o);return e.tokenRegExp={pattern:l,flags:c},e.options.raw&&(e.tokenRaw=e.source.slice(e.tokenIndex,e.index)),e.tokenValue=function(e,t,r){try{return new RegExp(t,r)}catch{try{return new RegExp(t,r),null}catch{e.report(34)}}}(e,l,c),65540}function x(e,t,r){const{index:o}=e;let i="",a=n(e),s=e.index;for(;!(8&u[a]);){if(a===r)return i+=e.source.slice(s,e.index),n(e),e.options.raw&&(e.tokenRaw=e.source.slice(o,e.index)),e.tokenValue=i,134283267;if(8&~a||92!==a)8232!==a&&8233!==a||(e.column=-1,e.line++);else{if(i+=e.source.slice(s,e.index),a=n(e),a<127||8232===a||8233===a){const r=S(e,t,a);r>=0?i+=String.fromCodePoint(r):v(e,r,0)}else i+=String.fromCodePoint(a);s=e.index+1}e.index>=e.end&&e.report(16),a=n(e)}e.report(16)}function S(e,t,r,o=0){switch(r){case 98:return 8;case 102:return 12;case 114:return 13;case 110:return 10;case 116:return 9;case 118:return 11;case 13:if(e.index<e.end){const t=e.source.charCodeAt(e.index+1);10===t&&(e.index=e.index+1,e.currentChar=t)}case 10:case 8232:case 8233:return e.column=-1,e.line++,-1;case 48:case 49:case 50:case 51:{let n=r-48,i=e.index+1,a=e.column+1;if(i<e.end){const r=e.source.charCodeAt(i);if(32&u[r]){if(1&t||o)return-2;if(e.currentChar=r,n=n<<3|r-48,i++,a++,i<e.end){const t=e.source.charCodeAt(i);32&u[t]&&(e.currentChar=t,n=n<<3|t-48,i++,a++)}e.flags|=64}else if(0!==n||512&u[r]){if(1&t||o)return-2;e.flags|=64}e.index=i-1,e.column=a-1}return n}case 52:case 53:case 54:case 55:{if(o||1&t)return-2;let n=r-48;const i=e.index+1,a=e.column+1;if(i<e.end){const t=e.source.charCodeAt(i);32&u[t]&&(n=n<<3|t-48,e.currentChar=t,e.index=i,e.column=a)}return e.flags|=64,n}case 120:{const t=n(e);if(!(64&u[t]))return-4;const r=c(t),o=n(e);if(!(64&u[o]))return-4;return r<<4|c(o)}case 117:{const t=n(e);if(123===e.currentChar){let t=0;for(;64&u[n(e)];)if(t=t<<4|c(e.currentChar),t>1114111)return-5;return e.currentChar<1||125!==e.currentChar?-4:t}{if(!(64&u[t]))return-4;const r=e.source.charCodeAt(e.index+1);if(!(64&u[r]))return-4;const n=e.source.charCodeAt(e.index+2);if(!(64&u[n]))return-4;const o=e.source.charCodeAt(e.index+3);return 64&u[o]?(e.index+=3,e.column+=3,e.currentChar=e.source.charCodeAt(e.index),c(t)<<12|c(r)<<8|c(n)<<4|c(o)):-4}}case 56:case 57:if(o||!e.options.webcompat||1&t)return-3;e.flags|=4096;default:return r}}function v(e,t,r){switch(t){case-1:return;case-2:e.report(r?2:1);case-3:e.report(r?3:14);case-4:e.report(7);case-5:e.report(104)}}function C(e,t){const{index:r}=e;let o=67174409,i="",a=n(e);for(;96!==a;){if(36===a&&123===e.source.charCodeAt(e.index+1)){n(e),o=67174408;break}if(92===a)if(a=n(e),a>126)i+=String.fromCodePoint(a);else{const{index:r,line:n,column:s}=e,c=S(e,1|t,a,1);if(c>=0)i+=String.fromCodePoint(c);else{if(-1!==c&&64&t){e.index=r,e.line=n,e.column=s,i=null,a=E(e,a),a<0&&(o=67174408);break}v(e,c,1)}}else e.index<e.end&&(13===a&&10===e.source.charCodeAt(e.index)&&(i+=String.fromCodePoint(a),e.currentChar=e.source.charCodeAt(++e.index)),((83&a)<3&&10===a||(8232^a)<=1)&&(e.column=-1,e.line++),i+=String.fromCodePoint(a));e.index>=e.end&&e.report(17),a=n(e)}return n(e),e.tokenValue=i,e.tokenRaw=e.source.slice(r+1,e.index-(67174409===o?1:2)),o}function E(e,t){for(;96!==t;){switch(t){case 36:{const r=e.index+1;if(r<e.end&&123===e.source.charCodeAt(r))return e.index=r,e.column++,-t;break}case 10:case 8232:case 8233:e.column=-1,e.line++}e.index>=e.end&&e.report(17),t=n(e)}return t}function q(e,t){return e.index>=e.end&&e.report(0),e.index--,e.column--,C(e,t)}!function(e){e[e.Empty=0]="Empty",e[e.Escape=1]="Escape",e[e.Class=2]="Class"}(w||(w={})),function(e){e[e.Empty=0]="Empty",e[e.IgnoreCase=1]="IgnoreCase",e[e.Global=2]="Global",e[e.Multiline=4]="Multiline",e[e.Unicode=16]="Unicode",e[e.Sticky=8]="Sticky",e[e.DotAll=32]="DotAll",e[e.Indices=64]="Indices",e[e.UnicodeSets=128]="UnicodeSets"}(y||(y={}));const N={0:"Unexpected token",30:"Unexpected token: '%0'",1:"Octal escape sequences are not allowed in strict mode",2:"Octal escape sequences are not allowed in template strings",3:"\\8 and \\9 are not allowed in template strings",4:"Private identifier #%0 is not defined",5:"Illegal Unicode escape sequence",6:"Invalid code point %0",7:"Invalid hexadecimal escape sequence",9:"Octal literals are not allowed in strict mode",8:"Decimal integer literals with a leading zero are forbidden in strict mode",10:"Expected number in radix %0",151:"Invalid left-hand side assignment to a destructible right-hand side",11:"Non-number found after exponent indicator",12:"Invalid BigIntLiteral",13:"No identifiers allowed directly after numeric literal",14:"Escapes \\8 or \\9 are not syntactically valid escapes",15:"Escapes \\8 or \\9 are not allowed in strict mode",16:"Unterminated string literal",17:"Unterminated template literal",18:"Multiline comment was not closed properly",19:"The identifier contained dynamic unicode escape that was not closed",20:"Illegal character '%0'",21:"Missing hexadecimal digits",22:"Invalid implicit octal",23:"Invalid line break in string literal",24:"Only unicode escapes are legal in identifier names",25:"Expected '%0'",26:"Invalid left-hand side in assignment",27:"Invalid left-hand side in async arrow",28:'Calls to super must be in the "constructor" method of a class expression or class declaration that has a superclass',29:"Member access on super must be in a method",31:"Await expression not allowed in formal parameter",32:"Yield expression not allowed in formal parameter",95:"Unexpected token: 'escaped keyword'",33:"Unary expressions as the left operand of an exponentiation expression must be disambiguated with parentheses",123:"Async functions can only be declared at the top level or inside a block",34:"Unterminated regular expression",35:"Unexpected regular expression flag",36:"Duplicate regular expression flag '%0'",37:"%0 functions must have exactly %1 argument%2",38:"Setter function argument must not be a rest parameter",39:"%0 declaration must have a name in this context",40:"Function name may not contain any reserved words or be eval or arguments in strict mode",41:"The rest operator is missing an argument",42:"A getter cannot be a generator",43:"A setter cannot be a generator",44:"A computed property name must be followed by a colon or paren",134:"Object literal keys that are strings or numbers must be a method or have a colon",46:"Found `* async x(){}` but this should be `async * x(){}`",45:"Getters and setters can not be generators",47:"'%0' can not be generator method",48:"No line break is allowed after '=>'",49:"The left-hand side of the arrow can only be destructed through assignment",50:"The binding declaration is not destructible",51:"Async arrow can not be followed by new expression",52:"Classes may not have a static property named 'prototype'",53:"Class constructor may not be a %0",54:"Duplicate constructor method in class",55:"Invalid increment/decrement operand",56:"Invalid use of `new` keyword on an increment/decrement expression",57:"`=>` is an invalid assignment target",58:"Rest element may not have a trailing comma",59:"Missing initializer in %0 declaration",60:"'for-%0' loop head declarations can not have an initializer",61:"Invalid left-hand side in for-%0 loop: Must have a single binding",62:"Invalid shorthand property initializer",63:"Property name __proto__ appears more than once in object literal",64:"Let is disallowed as a lexically bound name",65:"Invalid use of '%0' inside new expression",66:"Illegal 'use strict' directive in function with non-simple parameter list",67:'Identifier "let" disallowed as left-hand side expression in strict mode',68:"Illegal continue statement",69:"Illegal break statement",70:"Cannot have `let[...]` as a var name in strict mode",71:"Invalid destructuring assignment target",72:"Rest parameter may not have a default initializer",73:"The rest argument must the be last parameter",74:"Invalid rest argument",76:"In strict mode code, functions can only be declared at top level or inside a block",77:"In non-strict mode code, functions can only be declared at top level, inside a block, or as the body of an if statement",78:"Without web compatibility enabled functions can not be declared at top level, inside a block, or as the body of an if statement",79:"Class declaration can't appear in single-statement context",80:"Invalid left-hand side in for-%0",81:"Invalid assignment in for-%0",82:"for await (... of ...) is only valid in async functions and async generators",83:"The first token after the template expression should be a continuation of the template",85:"`let` declaration not allowed here and `let` cannot be a regular var name in strict mode",84:"`let \n [` is a restricted production at the start of a statement",86:"Catch clause requires exactly one parameter, not more (and no trailing comma)",87:"Catch clause parameter does not support default values",88:"Missing catch or finally after try",89:"More than one default clause in switch statement",90:"Illegal newline after throw",91:"Strict mode code may not include a with statement",92:"Illegal return statement",93:"The left hand side of the for-header binding declaration is not destructible",94:"new.target only allowed within functions or static blocks",96:"'#' not followed by identifier",102:"Invalid keyword",101:"Can not use 'let' as a class name",100:"'A lexical declaration can't define a 'let' binding",99:"Can not use `let` as variable name in strict mode",97:"'%0' may not be used as an identifier in this context",98:"Await is only valid in async functions",103:"The %0 keyword can only be used with the module goal",104:"Unicode codepoint must not be greater than 0x10FFFF",105:"%0 source must be string",106:"Only a identifier or string can be used to indicate alias",107:"Only '*' or '{...}' can be imported after default",108:"Trailing decorator may be followed by method",109:"Decorators can't be used with a constructor",110:"Can not use `await` as identifier in module or async func",111:"Can not use `await` as identifier in module",112:"HTML comments are only allowed with web compatibility (Annex B)",113:"The identifier 'let' must not be in expression position in strict mode",114:"Cannot assign to `eval` and `arguments` in strict mode",115:"The left-hand side of a for-of loop may not start with 'let'",116:"Block body arrows can not be immediately invoked without a group",117:"Block body arrows can not be immediately accessed without a group",118:"Unexpected strict mode reserved word",119:"Unexpected eval or arguments in strict mode",120:"Decorators must not be followed by a semicolon",121:"Calling delete on expression not allowed in strict mode",122:"Pattern can not have a tail",124:"Can not have a `yield` expression on the left side of a ternary",125:"An arrow function can not have a postfix update operator",126:"Invalid object literal key character after generator star",127:"Private fields can not be deleted",129:"Classes may not have a field called constructor",128:"Classes may not have a private element named constructor",130:"A class field initializer or static block may not contain arguments",131:"Generators can only be declared at the top level or inside a block",132:"Async methods are a restricted production and cannot have a newline following it",133:"Unexpected character after object literal property name",135:"Invalid key token",136:"Label '%0' has already been declared",137:"continue statement must be nested within an iteration statement",138:"Undefined label '%0'",139:"Trailing comma is disallowed inside import(...) arguments",140:"Invalid binding in JSON import",141:"import() requires exactly one argument",142:"Cannot use new with import(...)",143:"... is not allowed in import()",144:"Expected '=>'",145:"Duplicate binding '%0'",146:"Duplicate private identifier #%0",147:"Cannot export a duplicate name '%0'",150:"Duplicate %0 for-binding",148:"Exported binding '%0' needs to refer to a top-level declared variable",149:"Unexpected private field",153:"Numeric separators are not allowed at the end of numeric literals",152:"Only one underscore is allowed as numeric separator",154:"JSX value should be either an expression or a quoted JSX text",155:"Expected corresponding JSX closing tag for %0",156:"Adjacent JSX elements must be wrapped in an enclosing tag",157:"JSX attributes must only be assigned a non-empty 'expression'",158:"'%0' has already been declared",159:"'%0' shadowed a catch clause binding",160:"Dot property must be an identifier",161:"Encountered invalid input after spread/rest argument",162:"Catch without try",163:"Finally without try",164:"Expected corresponding closing tag for JSX fragment",165:"Coalescing and logical operators used together in the same expression must be disambiguated with parentheses",166:"Invalid tagged template on optional chain",167:"Invalid optional chain from super property",168:"Invalid optional chain from new expression",169:'Cannot use "import.meta" outside a module',170:"Leading decorators must be attached to a class declaration",171:"An export name cannot include a lone surrogate, found %0",172:"A string literal cannot be used as an exported binding without `from`",173:"Private fields can't be accessed on super",174:"The only valid meta property for import is 'import.meta'",175:"'import.meta' must not contain escaped characters",176:'cannot use "await" as identifier inside an async function',177:'cannot use "await" in static blocks'};class L extends SyntaxError{start;end;range;loc;description;constructor(e,t,r,...n){const o=N[r].replace(/%(\d+)/g,(e,t)=>n[t]);super("["+e.line+":"+e.column+"-"+t.line+":"+t.column+"]: "+o),this.start=e.index,this.end=t.index,this.range=[e.index,t.index],this.loc={start:{line:e.line,column:e.column},end:{line:t.line,column:t.column}},this.description=o}}function A(e,t,r){let o=e.currentChar,i=0,a=9,s=64&r?0:1,l=0,p=0;if(64&r)i="."+I(e,o),o=e.currentChar,110===o&&e.report(12);else{if(48===o)if(o=n(e),120==(32|o)){for(r=136,o=n(e);4160&u[o];)95!==o?(p=1,i=16*i+c(o),l++,o=n(e)):(p||e.report(152),p=0,o=n(e));0!==l&&p||e.report(0===l?21:153)}else if(111==(32|o)){for(r=132,o=n(e);4128&u[o];)95!==o?(p=1,i=8*i+(o-48),l++,o=n(e)):(p||e.report(152),p=0,o=n(e));0!==l&&p||e.report(0===l?0:153)}else if(98==(32|o)){for(r=130,o=n(e);4224&u[o];)95!==o?(p=1,i=2*i+(o-48),l++,o=n(e)):(p||e.report(152),p=0,o=n(e));0!==l&&p||e.report(0===l?0:153)}else if(32&u[o])for(1&t&&e.report(1),r=1;16&u[o];){if(512&u[o]){r=32,s=0;break}i=8*i+(o-48),o=n(e)}else 512&u[o]?(1&t&&e.report(1),e.flags|=64,r=32):95===o&&e.report(0);if(48&r){if(s){for(;a>=0&&4112&u[o];)if(95!==o)p=0,i=10*i+(o-48),o=n(e),--a;else{if(o=n(e),95===o||32&r)throw new L(e.currentLocation,{index:e.index+1,line:e.line,column:e.column},152);p=1}if(p)throw new L(e.currentLocation,{index:e.index+1,line:e.line,column:e.column},153);if(a>=0&&!g(o)&&46!==o)return e.tokenValue=i,e.options.raw&&(e.tokenRaw=e.source.slice(e.tokenIndex,e.index)),134283266}i+=I(e,o),o=e.currentChar,46===o&&(95===n(e)&&e.report(0),r=64,i+="."+I(e,e.currentChar),o=e.currentChar)}}const d=e.index;let f=0;if(110===o&&128&r)f=1,o=n(e);else if(101==(32|o)){o=n(e),256&u[o]&&(o=n(e));const{index:t}=e;16&u[o]||e.report(11),i+=e.source.substring(d,t)+I(e,o),o=e.currentChar}return(e.index<e.end&&16&u[o]||g(o))&&e.report(13),f?(e.tokenRaw=e.source.slice(e.tokenIndex,e.index),e.tokenValue=BigInt(e.tokenRaw.slice(0,-1).replaceAll("_","")),134283388):(e.tokenValue=15&r?i:32&r?parseFloat(e.source.substring(e.tokenIndex,e.index)):+i,e.options.raw&&(e.tokenRaw=e.source.slice(e.tokenIndex,e.index)),134283266)}function I(e,t){let r=0,o=e.index,i="";for(;4112&u[t];){if(95===t){const{index:a}=e;if(95===(t=n(e)))throw new L(e.currentLocation,{index:e.index+1,line:e.line,column:e.column},152);r=1,i+=e.source.substring(o,a),o=e.index;continue}r=0,t=n(e)}if(r)throw new L(e.currentLocation,{index:e.index+1,line:e.line,column:e.column},153);return i+e.source.substring(o,e.index)}const D=["end of source","identifier","number","string","regular expression","false","true","null","template continuation","template tail","=>","(","{",".","...","}",")",";",",","[","]",":","?","'",'"',"++","--","=","<<=",">>=",">>>=","**=","+=","-=","*=","/=","%=","^=","|=","&=","||=","&&=","??=","typeof","delete","void","!","~","+","-","in","instanceof","*","%","/","**","&&","||","===","!==","==","!=","<=",">=","<",">","<<",">>",">>>","&","|","^","var","let","const","break","case","catch","class","continue","debugger","default","do","else","export","extends","finally","for","function","if","import","new","return","super","switch","this","throw","try","while","with","implements","interface","package","private","protected","public","static","yield","as","async","await","constructor","get","set","accessor","from","of","enum","eval","arguments","escaped keyword","escaped future reserved keyword","reserved if strict","#","BigIntLiteral","??","?.","WhiteSpace","Illegal","LineTerminator","PrivateField","Template","@","target","meta","LineFeed","Escaped","JSXText"],V={this:86111,function:86104,if:20569,return:20572,var:86088,else:20563,for:20567,new:86107,in:8673330,typeof:16863275,while:20578,case:20556,break:20555,try:20577,catch:20557,delete:16863276,throw:86112,switch:86110,continue:20559,default:20561,instanceof:8411187,do:20562,void:16863277,finally:20566,async:209005,await:209006,class:86094,const:86090,constructor:12399,debugger:20560,export:20564,extends:20565,false:86021,from:209011,get:209008,implements:36964,import:86106,interface:36965,let:241737,null:86023,of:471156,package:36966,private:36967,protected:36968,public:36969,set:209009,static:36970,super:86109,true:86022,with:20579,yield:241771,enum:86133,eval:537079926,as:77932,arguments:537079927,target:209029,meta:209030,accessor:12402};function P(e,t){!(1&e.flags)&&1048576&~e.getToken()&&e.report(30,D[255&e.getToken()]),U(e,t,1074790417)||e.options.onInsertedSemicolon?.(e.startIndex)}function R(e,t,r,n){return t-r<13&&"use strict"===n&&(!(1048576&~e.getToken())||1&e.flags)?1:0}function B(e,t,r){return e.getToken()!==r?0:(ee(e,t),1)}function U(e,t,r){return e.getToken()===r&&(ee(e,t),!0)}function O(e,t,r){e.getToken()!==r&&e.report(25,D[255&r]),ee(e,t)}function M(e,t){switch(t.type){case"ArrayExpression":{t.type="ArrayPattern";const{elements:r}=t;for(let t=0,n=r.length;t<n;++t){const n=r[t];n&&M(e,n)}return}case"ObjectExpression":{t.type="ObjectPattern";const{properties:r}=t;for(let t=0,n=r.length;t<n;++t)M(e,r[t]);return}case"AssignmentExpression":return t.type="AssignmentPattern","="!==t.operator&&e.report(71),delete t.operator,void M(e,t.left);case"Property":return void M(e,t.value);case"SpreadElement":t.type="RestElement",M(e,t.argument)}}function j(e,t,r,n,o){1&t&&(36864&~n||e.report(118),o||537079808&~n||e.report(119)),20480&~n&&-2147483528!==n||e.report(102),24&r&&73==(255&n)&&e.report(100),2050&t&&209006===n&&e.report(110),1025&t&&241771===n&&e.report(97,"yield")}function F(e,t,r){1&t&&(36864&~r||e.report(118),537079808&~r||e.report(119),-2147483527===r&&e.report(95),-2147483528===r&&e.report(95)),20480&~r||e.report(102),2050&t&&209006===r&&e.report(110),1025&t&&241771===r&&e.report(97,"yield")}function G(e,t,r){return 209006===r&&(2050&t&&e.report(110),e.destructible|=128),241771===r&&1024&t&&e.report(97,"yield"),!(20480&~r&&36864&~r&&-2147483527!=r)}function J(e,t,r,n){for(;t;){if(t["$"+r])return n&&e.report(137),1;n&&t.loop&&(n=0),t=t.$}return 0}function z(e){switch(e.type){case"JSXIdentifier":return e.name;case"JSXNamespacedName":return e.namespace+":"+e.name;case"JSXMemberExpression":return z(e.object)+"."+z(e.property)}}function H(e,t){return 1025&e?!(2&e&&209006===t)&&(!(1024&e&&241771===t)&&!(12288&~t)):!(12288&~t&&36864&~t)}function X(e,t,r){537079808&~r||(1&t&&e.report(119),e.flags|=512),H(t,r)||e.report(0)}function $(e,t){return Object.hasOwn(e,t)?e[t]:void 0}function W(e,t,r){for(;d[n(e)];);return e.tokenValue=e.source.slice(e.tokenIndex,e.index),92!==e.currentChar&&e.currentChar<=126?$(V,e.tokenValue)??208897:Y(e,t,0,r)}function _(e,t){const r=K(e);return g(r)||e.report(5),e.tokenValue=String.fromCodePoint(r),Y(e,t,1,4&u[r])}function Y(e,t,r,i){let a=e.index;for(;e.index<e.end;)if(92===e.currentChar){e.tokenValue+=e.source.slice(a,e.index),r=1;const t=K(e);f(t)||e.report(5),i=i&&4&u[t],e.tokenValue+=String.fromCodePoint(t),a=e.index}else{const t=o(e);if(t>0)f(t)||e.report(20,String.fromCodePoint(t)),e.currentChar=t,e.index++,e.column++;else if(!f(e.currentChar))break;n(e)}e.index<=e.end&&(e.tokenValue+=e.source.slice(a,e.index));const{length:s}=e.tokenValue;if(i&&s>=2&&s<=11){const n=$(V,e.tokenValue);return void 0===n?208897|(r?-2147483648:0):r?209006===n?2050&t?-2147483528:-2147483648|n:1&t?36970===n?-2147483527:36864&~n?20480&~n?-2147274630:262144&t&&!(8&t)?-2147483648|n:-2147483528:-2147483527:!(262144&t)||8&t||20480&~n?241771===n?262144&t?-2147274630:1024&t?-2147483528:-2147483648|n:209005===n?-2147274630:36864&~n?-2147483528:12288|n|-2147483648:-2147483648|n:n}return 208897|(r?-2147483648:0)}function Z(e){let t=n(e);if(92===t)return 130;const r=o(e);return r&&(t=r),g(t)||e.report(96),130}function K(e){return 117!==e.source.charCodeAt(e.index+1)&&e.report(5),e.currentChar=e.source.charCodeAt(e.index+=2),e.column+=2,function(e){let t=0;const r=e.currentChar;if(123===r){const r=e.index-2;for(;64&u[n(e)];)if(t=t<<4|c(e.currentChar),t>1114111)throw new L({index:r,line:e.line,column:e.column},e.currentLocation,104);if(125!==e.currentChar)throw new L({index:r,line:e.line,column:e.column},e.currentLocation,7);return n(e),t}64&u[r]||e.report(7);const o=e.source.charCodeAt(e.index+1);64&u[o]||e.report(7);const i=e.source.charCodeAt(e.index+2);64&u[i]||e.report(7);const a=e.source.charCodeAt(e.index+3);64&u[a]||e.report(7);return t=c(r)<<12|c(o)<<8|c(i)<<4|c(a),e.currentChar=e.source.charCodeAt(e.index+=4),e.column+=4,t}(e)}const Q=[128,128,128,128,128,128,128,128,128,127,135,127,127,129,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,127,16842798,134283267,130,208897,8391477,8390213,134283267,67174411,16,8391476,25233968,18,25233969,67108877,8457014,134283266,134283266,134283266,134283266,134283266,134283266,134283266,134283266,134283266,134283266,21,1074790417,8456256,1077936155,8390721,22,132,208897,208897,208897,208897,208897,208897,208897,208897,208897,208897,208897,208897,208897,208897,208897,208897,208897,208897,208897,208897,208897,208897,208897,208897,208897,208897,69271571,136,20,8389959,208897,131,4096,4096,4096,4096,4096,4096,4096,208897,4096,208897,208897,4096,208897,4096,208897,4096,208897,4096,4096,4096,208897,4096,4096,208897,4096,4096,2162700,8389702,1074790415,16842799,128];function ee(e,t){e.flags=1^(1|e.flags),e.startIndex=e.index,e.startColumn=e.column,e.startLine=e.line,e.setToken(te(e,t,0))}function te(e,t,c){const l=0===e.index,{source:u}=e;let p=e.currentLocation;for(;e.index<e.end;){e.tokenIndex=e.index,e.tokenColumn=e.column,e.tokenLine=e.line;let d=e.currentChar;if(d<=126){const r=Q[d];switch(r){case 67174411:case 16:case 2162700:case 1074790415:case 69271571:case 20:case 21:case 1074790417:case 18:case 16842799:case 132:case 128:return n(e),r;case 208897:return W(e,t,0);case 4096:return W(e,t,1);case 134283266:return A(e,t,144);case 134283267:return x(e,t,d);case 131:return C(e,t);case 136:return _(e,t);case 130:return Z(e);case 127:n(e);break;case 129:c|=5,a(e);break;case 135:i(e,c),c=-5&c|1;break;case 8456256:{const r=n(e);if(e.index<e.end){if(60===r)return e.index<e.end&&61===n(e)?(n(e),4194332):8390978;if(61===r)return n(e),8390718;if(33===r){const r=e.index+1;if(r+1<e.end&&45===u.charCodeAt(r)&&45==u.charCodeAt(r+1)){e.column+=3,e.currentChar=u.charCodeAt(e.index+=3),c=k(e,u,c,t,2,e.tokenStart),p=e.tokenStart;continue}return 8456256}}return 8456256}case 1077936155:{n(e);const t=e.currentChar;return 61===t?61===n(e)?(n(e),8390458):8390460:62===t?(n(e),10):1077936155}case 16842798:return 61!==n(e)?16842798:61!==n(e)?8390461:(n(e),8390459);case 8391477:return 61!==n(e)?8391477:(n(e),4194340);case 8391476:{if(n(e),e.index>=e.end)return 8391476;const t=e.currentChar;return 61===t?(n(e),4194338):42!==t?8391476:61!==n(e)?8391735:(n(e),4194335)}case 8389959:return 61!==n(e)?8389959:(n(e),4194341);case 25233968:{n(e);const t=e.currentChar;return 43===t?(n(e),33619993):61===t?(n(e),4194336):25233968}case 25233969:{n(e);const r=e.currentChar;if(45===r){if(n(e),(1&c||l)&&62===e.currentChar){e.options.webcompat||e.report(112),n(e),c=k(e,u,c,t,3,p),p=e.tokenStart;continue}return 33619994}return 61===r?(n(e),4194337):25233969}case 8457014:if(n(e),e.index<e.end){const r=e.currentChar;if(47===r){n(e),c=m(e,u,c,0,e.tokenStart),p=e.tokenStart;continue}if(42===r){n(e),c=b(e,u,c),p=e.tokenStart;continue}if(32&t)return T(e);if(61===r)return n(e),4259875}return 8457014;case 67108877:{const r=n(e);if(r>=48&&r<=57)return A(e,t,80);if(46===r){const t=e.index+1;if(t<e.end&&46===u.charCodeAt(t))return e.column+=2,e.currentChar=u.charCodeAt(e.index+=2),14}return 67108877}case 8389702:{n(e);const t=e.currentChar;return 124===t?(n(e),61===e.currentChar?(n(e),4194344):8913465):61===t?(n(e),4194342):8389702}case 8390721:{n(e);const t=e.currentChar;if(61===t)return n(e),8390719;if(62!==t)return 8390721;if(n(e),e.index<e.end){const t=e.currentChar;if(62===t)return 61===n(e)?(n(e),4194334):8390980;if(61===t)return n(e),4194333}return 8390979}case 8390213:{n(e);const t=e.currentChar;return 38===t?(n(e),61===e.currentChar?(n(e),4194345):8913720):61===t?(n(e),4194343):8390213}case 22:{let t=n(e);if(63===t)return n(e),61===e.currentChar?(n(e),4194346):276824445;if(46===t){const r=e.index+1;if(r<e.end&&(t=u.charCodeAt(r),!(t>=48&&t<=57)))return n(e),67108990}return 22}}}else{if((8232^d)<=1){c=-5&c|1,a(e);continue}const i=o(e);if(i>0&&(d=i),r(d))return e.tokenValue="",Y(e,t,0,0);if(s(d)){n(e);continue}e.report(20,String.fromCodePoint(d))}}return 1048576}const re={AElig:"Æ",AMP:"&",Aacute:"Á",Abreve:"Ă",Acirc:"Â",Acy:"А",Afr:"𝔄",Agrave:"À",Alpha:"Α",Amacr:"Ā",And:"⩓",Aogon:"Ą",Aopf:"𝔸",ApplyFunction:"⁡",Aring:"Å",Ascr:"𝒜",Assign:"≔",Atilde:"Ã",Auml:"Ä",Backslash:"∖",Barv:"⫧",Barwed:"⌆",Bcy:"Б",Because:"∵",Bernoullis:"ℬ",Beta:"Β",Bfr:"𝔅",Bopf:"𝔹",Breve:"˘",Bscr:"ℬ",Bumpeq:"≎",CHcy:"Ч",COPY:"©",Cacute:"Ć",Cap:"⋒",CapitalDifferentialD:"ⅅ",Cayleys:"ℭ",Ccaron:"Č",Ccedil:"Ç",Ccirc:"Ĉ",Cconint:"∰",Cdot:"Ċ",Cedilla:"¸",CenterDot:"·",Cfr:"ℭ",Chi:"Χ",CircleDot:"⊙",CircleMinus:"⊖",CirclePlus:"⊕",CircleTimes:"⊗",ClockwiseContourIntegral:"∲",CloseCurlyDoubleQuote:"”",CloseCurlyQuote:"’",Colon:"∷",Colone:"⩴",Congruent:"≡",Conint:"∯",ContourIntegral:"∮",Copf:"ℂ",Coproduct:"∐",CounterClockwiseContourIntegral:"∳",Cross:"⨯",Cscr:"𝒞",Cup:"⋓",CupCap:"≍",DD:"ⅅ",DDotrahd:"⤑",DJcy:"Ђ",DScy:"Ѕ",DZcy:"Џ",Dagger:"‡",Darr:"↡",Dashv:"⫤",Dcaron:"Ď",Dcy:"Д",Del:"∇",Delta:"Δ",Dfr:"𝔇",DiacriticalAcute:"´",DiacriticalDot:"˙",DiacriticalDoubleAcute:"˝",DiacriticalGrave:"`",DiacriticalTilde:"˜",Diamond:"⋄",DifferentialD:"ⅆ",Dopf:"𝔻",Dot:"¨",DotDot:"⃜",DotEqual:"≐",DoubleContourIntegral:"∯",DoubleDot:"¨",DoubleDownArrow:"⇓",DoubleLeftArrow:"⇐",DoubleLeftRightArrow:"⇔",DoubleLeftTee:"⫤",DoubleLongLeftArrow:"⟸",DoubleLongLeftRightArrow:"⟺",DoubleLongRightArrow:"⟹",DoubleRightArrow:"⇒",DoubleRightTee:"⊨",DoubleUpArrow:"⇑",DoubleUpDownArrow:"⇕",DoubleVerticalBar:"∥",DownArrow:"↓",DownArrowBar:"⤓",DownArrowUpArrow:"⇵",DownBreve:"̑",DownLeftRightVector:"⥐",DownLeftTeeVector:"⥞",DownLeftVector:"↽",DownLeftVectorBar:"⥖",DownRightTeeVector:"⥟",DownRightVector:"⇁",DownRightVectorBar:"⥗",DownTee:"⊤",DownTeeArrow:"↧",Downarrow:"⇓",Dscr:"𝒟",Dstrok:"Đ",ENG:"Ŋ",ETH:"Ð",Eacute:"É",Ecaron:"Ě",Ecirc:"Ê",Ecy:"Э",Edot:"Ė",Efr:"𝔈",Egrave:"È",Element:"∈",Emacr:"Ē",EmptySmallSquare:"◻",EmptyVerySmallSquare:"▫",Eogon:"Ę",Eopf:"𝔼",Epsilon:"Ε",Equal:"⩵",EqualTilde:"≂",Equilibrium:"⇌",Escr:"ℰ",Esim:"⩳",Eta:"Η",Euml:"Ë",Exists:"∃",ExponentialE:"ⅇ",Fcy:"Ф",Ffr:"𝔉",FilledSmallSquare:"◼",FilledVerySmallSquare:"▪",Fopf:"𝔽",ForAll:"∀",Fouriertrf:"ℱ",Fscr:"ℱ",GJcy:"Ѓ",GT:">",Gamma:"Γ",Gammad:"Ϝ",Gbreve:"Ğ",Gcedil:"Ģ",Gcirc:"Ĝ",Gcy:"Г",Gdot:"Ġ",Gfr:"𝔊",Gg:"⋙",Gopf:"𝔾",GreaterEqual:"≥",GreaterEqualLess:"⋛",GreaterFullEqual:"≧",GreaterGreater:"⪢",GreaterLess:"≷",GreaterSlantEqual:"⩾",GreaterTilde:"≳",Gscr:"𝒢",Gt:"≫",HARDcy:"Ъ",Hacek:"ˇ",Hat:"^",Hcirc:"Ĥ",Hfr:"ℌ",HilbertSpace:"ℋ",Hopf:"ℍ",HorizontalLine:"─",Hscr:"ℋ",Hstrok:"Ħ",HumpDownHump:"≎",HumpEqual:"≏",IEcy:"Е",IJlig:"IJ",IOcy:"Ё",Iacute:"Í",Icirc:"Î",Icy:"И",Idot:"İ",Ifr:"ℑ",Igrave:"Ì",Im:"ℑ",Imacr:"Ī",ImaginaryI:"ⅈ",Implies:"⇒",Int:"∬",Integral:"∫",Intersection:"⋂",InvisibleComma:"⁣",InvisibleTimes:"⁢",Iogon:"Į",Iopf:"𝕀",Iota:"Ι",Iscr:"ℐ",Itilde:"Ĩ",Iukcy:"І",Iuml:"Ï",Jcirc:"Ĵ",Jcy:"Й",Jfr:"𝔍",Jopf:"𝕁",Jscr:"𝒥",Jsercy:"Ј",Jukcy:"Є",KHcy:"Х",KJcy:"Ќ",Kappa:"Κ",Kcedil:"Ķ",Kcy:"К",Kfr:"𝔎",Kopf:"𝕂",Kscr:"𝒦",LJcy:"Љ",LT:"<",Lacute:"Ĺ",Lambda:"Λ",Lang:"⟪",Laplacetrf:"ℒ",Larr:"↞",Lcaron:"Ľ",Lcedil:"Ļ",Lcy:"Л",LeftAngleBracket:"⟨",LeftArrow:"←",LeftArrowBar:"⇤",LeftArrowRightArrow:"⇆",LeftCeiling:"⌈",LeftDoubleBracket:"⟦",LeftDownTeeVector:"⥡",LeftDownVector:"⇃",LeftDownVectorBar:"⥙",LeftFloor:"⌊",LeftRightArrow:"↔",LeftRightVector:"⥎",LeftTee:"⊣",LeftTeeArrow:"↤",LeftTeeVector:"⥚",LeftTriangle:"⊲",LeftTriangleBar:"⧏",LeftTriangleEqual:"⊴",LeftUpDownVector:"⥑",LeftUpTeeVector:"⥠",LeftUpVector:"↿",LeftUpVectorBar:"⥘",LeftVector:"↼",LeftVectorBar:"⥒",Leftarrow:"⇐",Leftrightarrow:"⇔",LessEqualGreater:"⋚",LessFullEqual:"≦",LessGreater:"≶",LessLess:"⪡",LessSlantEqual:"⩽",LessTilde:"≲",Lfr:"𝔏",Ll:"⋘",Lleftarrow:"⇚",Lmidot:"Ŀ",LongLeftArrow:"⟵",LongLeftRightArrow:"⟷",LongRightArrow:"⟶",Longleftarrow:"⟸",Longleftrightarrow:"⟺",Longrightarrow:"⟹",Lopf:"𝕃",LowerLeftArrow:"↙",LowerRightArrow:"↘",Lscr:"ℒ",Lsh:"↰",Lstrok:"Ł",Lt:"≪",Map:"⤅",Mcy:"М",MediumSpace:" ",Mellintrf:"ℳ",Mfr:"𝔐",MinusPlus:"∓",Mopf:"𝕄",Mscr:"ℳ",Mu:"Μ",NJcy:"Њ",Nacute:"Ń",Ncaron:"Ň",Ncedil:"Ņ",Ncy:"Н",NegativeMediumSpace:"​",NegativeThickSpace:"​",NegativeThinSpace:"​",NegativeVeryThinSpace:"​",NestedGreaterGreater:"≫",NestedLessLess:"≪",NewLine:"\n",Nfr:"𝔑",NoBreak:"⁠",NonBreakingSpace:" ",Nopf:"ℕ",Not:"⫬",NotCongruent:"≢",NotCupCap:"≭",NotDoubleVerticalBar:"∦",NotElement:"∉",NotEqual:"≠",NotEqualTilde:"≂̸",NotExists:"∄",NotGreater:"≯",NotGreaterEqual:"≱",NotGreaterFullEqual:"≧̸",NotGreaterGreater:"≫̸",NotGreaterLess:"≹",NotGreaterSlantEqual:"⩾̸",NotGreaterTilde:"≵",NotHumpDownHump:"≎̸",NotHumpEqual:"≏̸",NotLeftTriangle:"⋪",NotLeftTriangleBar:"⧏̸",NotLeftTriangleEqual:"⋬",NotLess:"≮",NotLessEqual:"≰",NotLessGreater:"≸",NotLessLess:"≪̸",NotLessSlantEqual:"⩽̸",NotLessTilde:"≴",NotNestedGreaterGreater:"⪢̸",NotNestedLessLess:"⪡̸",NotPrecedes:"⊀",NotPrecedesEqual:"⪯̸",NotPrecedesSlantEqual:"⋠",NotReverseElement:"∌",NotRightTriangle:"⋫",NotRightTriangleBar:"⧐̸",NotRightTriangleEqual:"⋭",NotSquareSubset:"⊏̸",NotSquareSubsetEqual:"⋢",NotSquareSuperset:"⊐̸",NotSquareSupersetEqual:"⋣",NotSubset:"⊂⃒",NotSubsetEqual:"⊈",NotSucceeds:"⊁",NotSucceedsEqual:"⪰̸",NotSucceedsSlantEqual:"⋡",NotSucceedsTilde:"≿̸",NotSuperset:"⊃⃒",NotSupersetEqual:"⊉",NotTilde:"≁",NotTildeEqual:"≄",NotTildeFullEqual:"≇",NotTildeTilde:"≉",NotVerticalBar:"∤",Nscr:"𝒩",Ntilde:"Ñ",Nu:"Ν",OElig:"Œ",Oacute:"Ó",Ocirc:"Ô",Ocy:"О",Odblac:"Ő",Ofr:"𝔒",Ograve:"Ò",Omacr:"Ō",Omega:"Ω",Omicron:"Ο",Oopf:"𝕆",OpenCurlyDoubleQuote:"“",OpenCurlyQuote:"‘",Or:"⩔",Oscr:"𝒪",Oslash:"Ø",Otilde:"Õ",Otimes:"⨷",Ouml:"Ö",OverBar:"‾",OverBrace:"⏞",OverBracket:"⎴",OverParenthesis:"⏜",PartialD:"∂",Pcy:"П",Pfr:"𝔓",Phi:"Φ",Pi:"Π",PlusMinus:"±",Poincareplane:"ℌ",Popf:"ℙ",Pr:"⪻",Precedes:"≺",PrecedesEqual:"⪯",PrecedesSlantEqual:"≼",PrecedesTilde:"≾",Prime:"″",Product:"∏",Proportion:"∷",Proportional:"∝",Pscr:"𝒫",Psi:"Ψ",QUOT:'"',Qfr:"𝔔",Qopf:"ℚ",Qscr:"𝒬",RBarr:"⤐",REG:"®",Racute:"Ŕ",Rang:"⟫",Rarr:"↠",Rarrtl:"⤖",Rcaron:"Ř",Rcedil:"Ŗ",Rcy:"Р",Re:"ℜ",ReverseElement:"∋",ReverseEquilibrium:"⇋",ReverseUpEquilibrium:"⥯",Rfr:"ℜ",Rho:"Ρ",RightAngleBracket:"⟩",RightArrow:"→",RightArrowBar:"⇥",RightArrowLeftArrow:"⇄",RightCeiling:"⌉",RightDoubleBracket:"⟧",RightDownTeeVector:"⥝",RightDownVector:"⇂",RightDownVectorBar:"⥕",RightFloor:"⌋",RightTee:"⊢",RightTeeArrow:"↦",RightTeeVector:"⥛",RightTriangle:"⊳",RightTriangleBar:"⧐",RightTriangleEqual:"⊵",RightUpDownVector:"⥏",RightUpTeeVector:"⥜",RightUpVector:"↾",RightUpVectorBar:"⥔",RightVector:"⇀",RightVectorBar:"⥓",Rightarrow:"⇒",Ropf:"ℝ",RoundImplies:"⥰",Rrightarrow:"⇛",Rscr:"ℛ",Rsh:"↱",RuleDelayed:"⧴",SHCHcy:"Щ",SHcy:"Ш",SOFTcy:"Ь",Sacute:"Ś",Sc:"⪼",Scaron:"Š",Scedil:"Ş",Scirc:"Ŝ",Scy:"С",Sfr:"𝔖",ShortDownArrow:"↓",ShortLeftArrow:"←",ShortRightArrow:"→",ShortUpArrow:"↑",Sigma:"Σ",SmallCircle:"∘",Sopf:"𝕊",Sqrt:"√",Square:"□",SquareIntersection:"⊓",SquareSubset:"⊏",SquareSubsetEqual:"⊑",SquareSuperset:"⊐",SquareSupersetEqual:"⊒",SquareUnion:"⊔",Sscr:"𝒮",Star:"⋆",Sub:"⋐",Subset:"⋐",SubsetEqual:"⊆",Succeeds:"≻",SucceedsEqual:"⪰",SucceedsSlantEqual:"≽",SucceedsTilde:"≿",SuchThat:"∋",Sum:"∑",Sup:"⋑",Superset:"⊃",SupersetEqual:"⊇",Supset:"⋑",THORN:"Þ",TRADE:"™",TSHcy:"Ћ",TScy:"Ц",Tab:"\t",Tau:"Τ",Tcaron:"Ť",Tcedil:"Ţ",Tcy:"Т",Tfr:"𝔗",Therefore:"∴",Theta:"Θ",ThickSpace:"  ",ThinSpace:" ",Tilde:"∼",TildeEqual:"≃",TildeFullEqual:"≅",TildeTilde:"≈",Topf:"𝕋",TripleDot:"⃛",Tscr:"𝒯",Tstrok:"Ŧ",Uacute:"Ú",Uarr:"↟",Uarrocir:"⥉",Ubrcy:"Ў",Ubreve:"Ŭ",Ucirc:"Û",Ucy:"У",Udblac:"Ű",Ufr:"𝔘",Ugrave:"Ù",Umacr:"Ū",UnderBar:"_",UnderBrace:"⏟",UnderBracket:"⎵",UnderParenthesis:"⏝",Union:"⋃",UnionPlus:"⊎",Uogon:"Ų",Uopf:"𝕌",UpArrow:"↑",UpArrowBar:"⤒",UpArrowDownArrow:"⇅",UpDownArrow:"↕",UpEquilibrium:"⥮",UpTee:"⊥",UpTeeArrow:"↥",Uparrow:"⇑",Updownarrow:"⇕",UpperLeftArrow:"↖",UpperRightArrow:"↗",Upsi:"ϒ",Upsilon:"Υ",Uring:"Ů",Uscr:"𝒰",Utilde:"Ũ",Uuml:"Ü",VDash:"⊫",Vbar:"⫫",Vcy:"В",Vdash:"⊩",Vdashl:"⫦",Vee:"⋁",Verbar:"‖",Vert:"‖",VerticalBar:"∣",VerticalLine:"|",VerticalSeparator:"❘",VerticalTilde:"≀",VeryThinSpace:" ",Vfr:"𝔙",Vopf:"𝕍",Vscr:"𝒱",Vvdash:"⊪",Wcirc:"Ŵ",Wedge:"⋀",Wfr:"𝔚",Wopf:"𝕎",Wscr:"𝒲",Xfr:"𝔛",Xi:"Ξ",Xopf:"𝕏",Xscr:"𝒳",YAcy:"Я",YIcy:"Ї",YUcy:"Ю",Yacute:"Ý",Ycirc:"Ŷ",Ycy:"Ы",Yfr:"𝔜",Yopf:"𝕐",Yscr:"𝒴",Yuml:"Ÿ",ZHcy:"Ж",Zacute:"Ź",Zcaron:"Ž",Zcy:"З",Zdot:"Ż",ZeroWidthSpace:"​",Zeta:"Ζ",Zfr:"ℨ",Zopf:"ℤ",Zscr:"𝒵",aacute:"á",abreve:"ă",ac:"∾",acE:"∾̳",acd:"∿",acirc:"â",acute:"´",acy:"а",aelig:"æ",af:"⁡",afr:"𝔞",agrave:"à",alefsym:"ℵ",aleph:"ℵ",alpha:"α",amacr:"ā",amalg:"⨿",amp:"&",and:"∧",andand:"⩕",andd:"⩜",andslope:"⩘",andv:"⩚",ang:"∠",ange:"⦤",angle:"∠",angmsd:"∡",angmsdaa:"⦨",angmsdab:"⦩",angmsdac:"⦪",angmsdad:"⦫",angmsdae:"⦬",angmsdaf:"⦭",angmsdag:"⦮",angmsdah:"⦯",angrt:"∟",angrtvb:"⊾",angrtvbd:"⦝",angsph:"∢",angst:"Å",angzarr:"⍼",aogon:"ą",aopf:"𝕒",ap:"≈",apE:"⩰",apacir:"⩯",ape:"≊",apid:"≋",apos:"'",approx:"≈",approxeq:"≊",aring:"å",ascr:"𝒶",ast:"*",asymp:"≈",asympeq:"≍",atilde:"ã",auml:"ä",awconint:"∳",awint:"⨑",bNot:"⫭",backcong:"≌",backepsilon:"϶",backprime:"‵",backsim:"∽",backsimeq:"⋍",barvee:"⊽",barwed:"⌅",barwedge:"⌅",bbrk:"⎵",bbrktbrk:"⎶",bcong:"≌",bcy:"б",bdquo:"„",becaus:"∵",because:"∵",bemptyv:"⦰",bepsi:"϶",bernou:"ℬ",beta:"β",beth:"ℶ",between:"≬",bfr:"𝔟",bigcap:"⋂",bigcirc:"◯",bigcup:"⋃",bigodot:"⨀",bigoplus:"⨁",bigotimes:"⨂",bigsqcup:"⨆",bigstar:"★",bigtriangledown:"▽",bigtriangleup:"△",biguplus:"⨄",bigvee:"⋁",bigwedge:"⋀",bkarow:"⤍",blacklozenge:"⧫",blacksquare:"▪",blacktriangle:"▴",blacktriangledown:"▾",blacktriangleleft:"◂",blacktriangleright:"▸",blank:"␣",blk12:"▒",blk14:"░",blk34:"▓",block:"█",bne:"=⃥",bnequiv:"≡⃥",bnot:"⌐",bopf:"𝕓",bot:"⊥",bottom:"⊥",bowtie:"⋈",boxDL:"╗",boxDR:"╔",boxDl:"╖",boxDr:"╓",boxH:"═",boxHD:"╦",boxHU:"╩",boxHd:"╤",boxHu:"╧",boxUL:"╝",boxUR:"╚",boxUl:"╜",boxUr:"╙",boxV:"║",boxVH:"╬",boxVL:"╣",boxVR:"╠",boxVh:"╫",boxVl:"╢",boxVr:"╟",boxbox:"⧉",boxdL:"╕",boxdR:"╒",boxdl:"┐",boxdr:"┌",boxh:"─",boxhD:"╥",boxhU:"╨",boxhd:"┬",boxhu:"┴",boxminus:"⊟",boxplus:"⊞",boxtimes:"⊠",boxuL:"╛",boxuR:"╘",boxul:"┘",boxur:"└",boxv:"│",boxvH:"╪",boxvL:"╡",boxvR:"╞",boxvh:"┼",boxvl:"┤",boxvr:"├",bprime:"‵",breve:"˘",brvbar:"¦",bscr:"𝒷",bsemi:"⁏",bsim:"∽",bsime:"⋍",bsol:"\\",bsolb:"⧅",bsolhsub:"⟈",bull:"•",bullet:"•",bump:"≎",bumpE:"⪮",bumpe:"≏",bumpeq:"≏",cacute:"ć",cap:"∩",capand:"⩄",capbrcup:"⩉",capcap:"⩋",capcup:"⩇",capdot:"⩀",caps:"∩︀",caret:"⁁",caron:"ˇ",ccaps:"⩍",ccaron:"č",ccedil:"ç",ccirc:"ĉ",ccups:"⩌",ccupssm:"⩐",cdot:"ċ",cedil:"¸",cemptyv:"⦲",cent:"¢",centerdot:"·",cfr:"𝔠",chcy:"ч",check:"✓",checkmark:"✓",chi:"χ",cir:"○",cirE:"⧃",circ:"ˆ",circeq:"≗",circlearrowleft:"↺",circlearrowright:"↻",circledR:"®",circledS:"Ⓢ",circledast:"⊛",circledcirc:"⊚",circleddash:"⊝",cire:"≗",cirfnint:"⨐",cirmid:"⫯",cirscir:"⧂",clubs:"♣",clubsuit:"♣",colon:":",colone:"≔",coloneq:"≔",comma:",",commat:"@",comp:"∁",compfn:"∘",complement:"∁",complexes:"ℂ",cong:"≅",congdot:"⩭",conint:"∮",copf:"𝕔",coprod:"∐",copy:"©",copysr:"℗",crarr:"↵",cross:"✗",cscr:"𝒸",csub:"⫏",csube:"⫑",csup:"⫐",csupe:"⫒",ctdot:"⋯",cudarrl:"⤸",cudarrr:"⤵",cuepr:"⋞",cuesc:"⋟",cularr:"↶",cularrp:"⤽",cup:"∪",cupbrcap:"⩈",cupcap:"⩆",cupcup:"⩊",cupdot:"⊍",cupor:"⩅",cups:"∪︀",curarr:"↷",curarrm:"⤼",curlyeqprec:"⋞",curlyeqsucc:"⋟",curlyvee:"⋎",curlywedge:"⋏",curren:"¤",curvearrowleft:"↶",curvearrowright:"↷",cuvee:"⋎",cuwed:"⋏",cwconint:"∲",cwint:"∱",cylcty:"⌭",dArr:"⇓",dHar:"⥥",dagger:"†",daleth:"ℸ",darr:"↓",dash:"‐",dashv:"⊣",dbkarow:"⤏",dblac:"˝",dcaron:"ď",dcy:"д",dd:"ⅆ",ddagger:"‡",ddarr:"⇊",ddotseq:"⩷",deg:"°",delta:"δ",demptyv:"⦱",dfisht:"⥿",dfr:"𝔡",dharl:"⇃",dharr:"⇂",diam:"⋄",diamond:"⋄",diamondsuit:"♦",diams:"♦",die:"¨",digamma:"ϝ",disin:"⋲",div:"÷",divide:"÷",divideontimes:"⋇",divonx:"⋇",djcy:"ђ",dlcorn:"⌞",dlcrop:"⌍",dollar:"$",dopf:"𝕕",dot:"˙",doteq:"≐",doteqdot:"≑",dotminus:"∸",dotplus:"∔",dotsquare:"⊡",doublebarwedge:"⌆",downarrow:"↓",downdownarrows:"⇊",downharpoonleft:"⇃",downharpoonright:"⇂",drbkarow:"⤐",drcorn:"⌟",drcrop:"⌌",dscr:"𝒹",dscy:"ѕ",dsol:"⧶",dstrok:"đ",dtdot:"⋱",dtri:"▿",dtrif:"▾",duarr:"⇵",duhar:"⥯",dwangle:"⦦",dzcy:"џ",dzigrarr:"⟿",eDDot:"⩷",eDot:"≑",eacute:"é",easter:"⩮",ecaron:"ě",ecir:"≖",ecirc:"ê",ecolon:"≕",ecy:"э",edot:"ė",ee:"ⅇ",efDot:"≒",efr:"𝔢",eg:"⪚",egrave:"è",egs:"⪖",egsdot:"⪘",el:"⪙",elinters:"⏧",ell:"ℓ",els:"⪕",elsdot:"⪗",emacr:"ē",empty:"∅",emptyset:"∅",emptyv:"∅",emsp13:" ",emsp14:" ",emsp:" ",eng:"ŋ",ensp:" ",eogon:"ę",eopf:"𝕖",epar:"⋕",eparsl:"⧣",eplus:"⩱",epsi:"ε",epsilon:"ε",epsiv:"ϵ",eqcirc:"≖",eqcolon:"≕",eqsim:"≂",eqslantgtr:"⪖",eqslantless:"⪕",equals:"=",equest:"≟",equiv:"≡",equivDD:"⩸",eqvparsl:"⧥",erDot:"≓",erarr:"⥱",escr:"ℯ",esdot:"≐",esim:"≂",eta:"η",eth:"ð",euml:"ë",euro:"€",excl:"!",exist:"∃",expectation:"ℰ",exponentiale:"ⅇ",fallingdotseq:"≒",fcy:"ф",female:"♀",ffilig:"ffi",fflig:"ff",ffllig:"ffl",ffr:"𝔣",filig:"fi",fjlig:"fj",flat:"♭",fllig:"fl",fltns:"▱",fnof:"ƒ",fopf:"𝕗",forall:"∀",fork:"⋔",forkv:"⫙",fpartint:"⨍",frac12:"½",frac13:"⅓",frac14:"¼",frac15:"⅕",frac16:"⅙",frac18:"⅛",frac23:"⅔",frac25:"⅖",frac34:"¾",frac35:"⅗",frac38:"⅜",frac45:"⅘",frac56:"⅚",frac58:"⅝",frac78:"⅞",frasl:"⁄",frown:"⌢",fscr:"𝒻",gE:"≧",gEl:"⪌",gacute:"ǵ",gamma:"γ",gammad:"ϝ",gap:"⪆",gbreve:"ğ",gcirc:"ĝ",gcy:"г",gdot:"ġ",ge:"≥",gel:"⋛",geq:"≥",geqq:"≧",geqslant:"⩾",ges:"⩾",gescc:"⪩",gesdot:"⪀",gesdoto:"⪂",gesdotol:"⪄",gesl:"⋛︀",gesles:"⪔",gfr:"𝔤",gg:"≫",ggg:"⋙",gimel:"ℷ",gjcy:"ѓ",gl:"≷",glE:"⪒",gla:"⪥",glj:"⪤",gnE:"≩",gnap:"⪊",gnapprox:"⪊",gne:"⪈",gneq:"⪈",gneqq:"≩",gnsim:"⋧",gopf:"𝕘",grave:"`",gscr:"ℊ",gsim:"≳",gsime:"⪎",gsiml:"⪐",gt:">",gtcc:"⪧",gtcir:"⩺",gtdot:"⋗",gtlPar:"⦕",gtquest:"⩼",gtrapprox:"⪆",gtrarr:"⥸",gtrdot:"⋗",gtreqless:"⋛",gtreqqless:"⪌",gtrless:"≷",gtrsim:"≳",gvertneqq:"≩︀",gvnE:"≩︀",hArr:"⇔",hairsp:" ",half:"½",hamilt:"ℋ",hardcy:"ъ",harr:"↔",harrcir:"⥈",harrw:"↭",hbar:"ℏ",hcirc:"ĥ",hearts:"♥",heartsuit:"♥",hellip:"…",hercon:"⊹",hfr:"𝔥",hksearow:"⤥",hkswarow:"⤦",hoarr:"⇿",homtht:"∻",hookleftarrow:"↩",hookrightarrow:"↪",hopf:"𝕙",horbar:"―",hscr:"𝒽",hslash:"ℏ",hstrok:"ħ",hybull:"⁃",hyphen:"‐",iacute:"í",ic:"⁣",icirc:"î",icy:"и",iecy:"е",iexcl:"¡",iff:"⇔",ifr:"𝔦",igrave:"ì",ii:"ⅈ",iiiint:"⨌",iiint:"∭",iinfin:"⧜",iiota:"℩",ijlig:"ij",imacr:"ī",image:"ℑ",imagline:"ℐ",imagpart:"ℑ",imath:"ı",imof:"⊷",imped:"Ƶ",in:"∈",incare:"℅",infin:"∞",infintie:"⧝",inodot:"ı",int:"∫",intcal:"⊺",integers:"ℤ",intercal:"⊺",intlarhk:"⨗",intprod:"⨼",iocy:"ё",iogon:"į",iopf:"𝕚",iota:"ι",iprod:"⨼",iquest:"¿",iscr:"𝒾",isin:"∈",isinE:"⋹",isindot:"⋵",isins:"⋴",isinsv:"⋳",isinv:"∈",it:"⁢",itilde:"ĩ",iukcy:"і",iuml:"ï",jcirc:"ĵ",jcy:"й",jfr:"𝔧",jmath:"ȷ",jopf:"𝕛",jscr:"𝒿",jsercy:"ј",jukcy:"є",kappa:"κ",kappav:"ϰ",kcedil:"ķ",kcy:"к",kfr:"𝔨",kgreen:"ĸ",khcy:"х",kjcy:"ќ",kopf:"𝕜",kscr:"𝓀",lAarr:"⇚",lArr:"⇐",lAtail:"⤛",lBarr:"⤎",lE:"≦",lEg:"⪋",lHar:"⥢",lacute:"ĺ",laemptyv:"⦴",lagran:"ℒ",lambda:"λ",lang:"⟨",langd:"⦑",langle:"⟨",lap:"⪅",laquo:"«",larr:"←",larrb:"⇤",larrbfs:"⤟",larrfs:"⤝",larrhk:"↩",larrlp:"↫",larrpl:"⤹",larrsim:"⥳",larrtl:"↢",lat:"⪫",latail:"⤙",late:"⪭",lates:"⪭︀",lbarr:"⤌",lbbrk:"❲",lbrace:"{",lbrack:"[",lbrke:"⦋",lbrksld:"⦏",lbrkslu:"⦍",lcaron:"ľ",lcedil:"ļ",lceil:"⌈",lcub:"{",lcy:"л",ldca:"⤶",ldquo:"“",ldquor:"„",ldrdhar:"⥧",ldrushar:"⥋",ldsh:"↲",le:"≤",leftarrow:"←",leftarrowtail:"↢",leftharpoondown:"↽",leftharpoonup:"↼",leftleftarrows:"⇇",leftrightarrow:"↔",leftrightarrows:"⇆",leftrightharpoons:"⇋",leftrightsquigarrow:"↭",leftthreetimes:"⋋",leg:"⋚",leq:"≤",leqq:"≦",leqslant:"⩽",les:"⩽",lescc:"⪨",lesdot:"⩿",lesdoto:"⪁",lesdotor:"⪃",lesg:"⋚︀",lesges:"⪓",lessapprox:"⪅",lessdot:"⋖",lesseqgtr:"⋚",lesseqqgtr:"⪋",lessgtr:"≶",lesssim:"≲",lfisht:"⥼",lfloor:"⌊",lfr:"𝔩",lg:"≶",lgE:"⪑",lhard:"↽",lharu:"↼",lharul:"⥪",lhblk:"▄",ljcy:"љ",ll:"≪",llarr:"⇇",llcorner:"⌞",llhard:"⥫",lltri:"◺",lmidot:"ŀ",lmoust:"⎰",lmoustache:"⎰",lnE:"≨",lnap:"⪉",lnapprox:"⪉",lne:"⪇",lneq:"⪇",lneqq:"≨",lnsim:"⋦",loang:"⟬",loarr:"⇽",lobrk:"⟦",longleftarrow:"⟵",longleftrightarrow:"⟷",longmapsto:"⟼",longrightarrow:"⟶",looparrowleft:"↫",looparrowright:"↬",lopar:"⦅",lopf:"𝕝",loplus:"⨭",lotimes:"⨴",lowast:"∗",lowbar:"_",loz:"◊",lozenge:"◊",lozf:"⧫",lpar:"(",lparlt:"⦓",lrarr:"⇆",lrcorner:"⌟",lrhar:"⇋",lrhard:"⥭",lrm:"‎",lrtri:"⊿",lsaquo:"‹",lscr:"𝓁",lsh:"↰",lsim:"≲",lsime:"⪍",lsimg:"⪏",lsqb:"[",lsquo:"‘",lsquor:"‚",lstrok:"ł",lt:"<",ltcc:"⪦",ltcir:"⩹",ltdot:"⋖",lthree:"⋋",ltimes:"⋉",ltlarr:"⥶",ltquest:"⩻",ltrPar:"⦖",ltri:"◃",ltrie:"⊴",ltrif:"◂",lurdshar:"⥊",luruhar:"⥦",lvertneqq:"≨︀",lvnE:"≨︀",mDDot:"∺",macr:"¯",male:"♂",malt:"✠",maltese:"✠",map:"↦",mapsto:"↦",mapstodown:"↧",mapstoleft:"↤",mapstoup:"↥",marker:"▮",mcomma:"⨩",mcy:"м",mdash:"—",measuredangle:"∡",mfr:"𝔪",mho:"℧",micro:"µ",mid:"∣",midast:"*",midcir:"⫰",middot:"·",minus:"−",minusb:"⊟",minusd:"∸",minusdu:"⨪",mlcp:"⫛",mldr:"…",mnplus:"∓",models:"⊧",mopf:"𝕞",mp:"∓",mscr:"𝓂",mstpos:"∾",mu:"μ",multimap:"⊸",mumap:"⊸",nGg:"⋙̸",nGt:"≫⃒",nGtv:"≫̸",nLeftarrow:"⇍",nLeftrightarrow:"⇎",nLl:"⋘̸",nLt:"≪⃒",nLtv:"≪̸",nRightarrow:"⇏",nVDash:"⊯",nVdash:"⊮",nabla:"∇",nacute:"ń",nang:"∠⃒",nap:"≉",napE:"⩰̸",napid:"≋̸",napos:"ʼn",napprox:"≉",natur:"♮",natural:"♮",naturals:"ℕ",nbsp:" ",nbump:"≎̸",nbumpe:"≏̸",ncap:"⩃",ncaron:"ň",ncedil:"ņ",ncong:"≇",ncongdot:"⩭̸",ncup:"⩂",ncy:"н",ndash:"–",ne:"≠",neArr:"⇗",nearhk:"⤤",nearr:"↗",nearrow:"↗",nedot:"≐̸",nequiv:"≢",nesear:"⤨",nesim:"≂̸",nexist:"∄",nexists:"∄",nfr:"𝔫",ngE:"≧̸",nge:"≱",ngeq:"≱",ngeqq:"≧̸",ngeqslant:"⩾̸",nges:"⩾̸",ngsim:"≵",ngt:"≯",ngtr:"≯",nhArr:"⇎",nharr:"↮",nhpar:"⫲",ni:"∋",nis:"⋼",nisd:"⋺",niv:"∋",njcy:"њ",nlArr:"⇍",nlE:"≦̸",nlarr:"↚",nldr:"‥",nle:"≰",nleftarrow:"↚",nleftrightarrow:"↮",nleq:"≰",nleqq:"≦̸",nleqslant:"⩽̸",nles:"⩽̸",nless:"≮",nlsim:"≴",nlt:"≮",nltri:"⋪",nltrie:"⋬",nmid:"∤",nopf:"𝕟",not:"¬",notin:"∉",notinE:"⋹̸",notindot:"⋵̸",notinva:"∉",notinvb:"⋷",notinvc:"⋶",notni:"∌",notniva:"∌",notnivb:"⋾",notnivc:"⋽",npar:"∦",nparallel:"∦",nparsl:"⫽⃥",npart:"∂̸",npolint:"⨔",npr:"⊀",nprcue:"⋠",npre:"⪯̸",nprec:"⊀",npreceq:"⪯̸",nrArr:"⇏",nrarr:"↛",nrarrc:"⤳̸",nrarrw:"↝̸",nrightarrow:"↛",nrtri:"⋫",nrtrie:"⋭",nsc:"⊁",nsccue:"⋡",nsce:"⪰̸",nscr:"𝓃",nshortmid:"∤",nshortparallel:"∦",nsim:"≁",nsime:"≄",nsimeq:"≄",nsmid:"∤",nspar:"∦",nsqsube:"⋢",nsqsupe:"⋣",nsub:"⊄",nsubE:"⫅̸",nsube:"⊈",nsubset:"⊂⃒",nsubseteq:"⊈",nsubseteqq:"⫅̸",nsucc:"⊁",nsucceq:"⪰̸",nsup:"⊅",nsupE:"⫆̸",nsupe:"⊉",nsupset:"⊃⃒",nsupseteq:"⊉",nsupseteqq:"⫆̸",ntgl:"≹",ntilde:"ñ",ntlg:"≸",ntriangleleft:"⋪",ntrianglelefteq:"⋬",ntriangleright:"⋫",ntrianglerighteq:"⋭",nu:"ν",num:"#",numero:"№",numsp:" ",nvDash:"⊭",nvHarr:"⤄",nvap:"≍⃒",nvdash:"⊬",nvge:"≥⃒",nvgt:">⃒",nvinfin:"⧞",nvlArr:"⤂",nvle:"≤⃒",nvlt:"<⃒",nvltrie:"⊴⃒",nvrArr:"⤃",nvrtrie:"⊵⃒",nvsim:"∼⃒",nwArr:"⇖",nwarhk:"⤣",nwarr:"↖",nwarrow:"↖",nwnear:"⤧",oS:"Ⓢ",oacute:"ó",oast:"⊛",ocir:"⊚",ocirc:"ô",ocy:"о",odash:"⊝",odblac:"ő",odiv:"⨸",odot:"⊙",odsold:"⦼",oelig:"œ",ofcir:"⦿",ofr:"𝔬",ogon:"˛",ograve:"ò",ogt:"⧁",ohbar:"⦵",ohm:"Ω",oint:"∮",olarr:"↺",olcir:"⦾",olcross:"⦻",oline:"‾",olt:"⧀",omacr:"ō",omega:"ω",omicron:"ο",omid:"⦶",ominus:"⊖",oopf:"𝕠",opar:"⦷",operp:"⦹",oplus:"⊕",or:"∨",orarr:"↻",ord:"⩝",order:"ℴ",orderof:"ℴ",ordf:"ª",ordm:"º",origof:"⊶",oror:"⩖",orslope:"⩗",orv:"⩛",oscr:"ℴ",oslash:"ø",osol:"⊘",otilde:"õ",otimes:"⊗",otimesas:"⨶",ouml:"ö",ovbar:"⌽",par:"∥",para:"¶",parallel:"∥",parsim:"⫳",parsl:"⫽",part:"∂",pcy:"п",percnt:"%",period:".",permil:"‰",perp:"⊥",pertenk:"‱",pfr:"𝔭",phi:"φ",phiv:"ϕ",phmmat:"ℳ",phone:"☎",pi:"π",pitchfork:"⋔",piv:"ϖ",planck:"ℏ",planckh:"ℎ",plankv:"ℏ",plus:"+",plusacir:"⨣",plusb:"⊞",pluscir:"⨢",plusdo:"∔",plusdu:"⨥",pluse:"⩲",plusmn:"±",plussim:"⨦",plustwo:"⨧",pm:"±",pointint:"⨕",popf:"𝕡",pound:"£",pr:"≺",prE:"⪳",prap:"⪷",prcue:"≼",pre:"⪯",prec:"≺",precapprox:"⪷",preccurlyeq:"≼",preceq:"⪯",precnapprox:"⪹",precneqq:"⪵",precnsim:"⋨",precsim:"≾",prime:"′",primes:"ℙ",prnE:"⪵",prnap:"⪹",prnsim:"⋨",prod:"∏",profalar:"⌮",profline:"⌒",profsurf:"⌓",prop:"∝",propto:"∝",prsim:"≾",prurel:"⊰",pscr:"𝓅",psi:"ψ",puncsp:" ",qfr:"𝔮",qint:"⨌",qopf:"𝕢",qprime:"⁗",qscr:"𝓆",quaternions:"ℍ",quatint:"⨖",quest:"?",questeq:"≟",quot:'"',rAarr:"⇛",rArr:"⇒",rAtail:"⤜",rBarr:"⤏",rHar:"⥤",race:"∽̱",racute:"ŕ",radic:"√",raemptyv:"⦳",rang:"⟩",rangd:"⦒",range:"⦥",rangle:"⟩",raquo:"»",rarr:"→",rarrap:"⥵",rarrb:"⇥",rarrbfs:"⤠",rarrc:"⤳",rarrfs:"⤞",rarrhk:"↪",rarrlp:"↬",rarrpl:"⥅",rarrsim:"⥴",rarrtl:"↣",rarrw:"↝",ratail:"⤚",ratio:"∶",rationals:"ℚ",rbarr:"⤍",rbbrk:"❳",rbrace:"}",rbrack:"]",rbrke:"⦌",rbrksld:"⦎",rbrkslu:"⦐",rcaron:"ř",rcedil:"ŗ",rceil:"⌉",rcub:"}",rcy:"р",rdca:"⤷",rdldhar:"⥩",rdquo:"”",rdquor:"”",rdsh:"↳",real:"ℜ",realine:"ℛ",realpart:"ℜ",reals:"ℝ",rect:"▭",reg:"®",rfisht:"⥽",rfloor:"⌋",rfr:"𝔯",rhard:"⇁",rharu:"⇀",rharul:"⥬",rho:"ρ",rhov:"ϱ",rightarrow:"→",rightarrowtail:"↣",rightharpoondown:"⇁",rightharpoonup:"⇀",rightleftarrows:"⇄",rightleftharpoons:"⇌",rightrightarrows:"⇉",rightsquigarrow:"↝",rightthreetimes:"⋌",ring:"˚",risingdotseq:"≓",rlarr:"⇄",rlhar:"⇌",rlm:"‏",rmoust:"⎱",rmoustache:"⎱",rnmid:"⫮",roang:"⟭",roarr:"⇾",robrk:"⟧",ropar:"⦆",ropf:"𝕣",roplus:"⨮",rotimes:"⨵",rpar:")",rpargt:"⦔",rppolint:"⨒",rrarr:"⇉",rsaquo:"›",rscr:"𝓇",rsh:"↱",rsqb:"]",rsquo:"’",rsquor:"’",rthree:"⋌",rtimes:"⋊",rtri:"▹",rtrie:"⊵",rtrif:"▸",rtriltri:"⧎",ruluhar:"⥨",rx:"℞",sacute:"ś",sbquo:"‚",sc:"≻",scE:"⪴",scap:"⪸",scaron:"š",sccue:"≽",sce:"⪰",scedil:"ş",scirc:"ŝ",scnE:"⪶",scnap:"⪺",scnsim:"⋩",scpolint:"⨓",scsim:"≿",scy:"с",sdot:"⋅",sdotb:"⊡",sdote:"⩦",seArr:"⇘",searhk:"⤥",searr:"↘",searrow:"↘",sect:"§",semi:";",seswar:"⤩",setminus:"∖",setmn:"∖",sext:"✶",sfr:"𝔰",sfrown:"⌢",sharp:"♯",shchcy:"щ",shcy:"ш",shortmid:"∣",shortparallel:"∥",shy:"­",sigma:"σ",sigmaf:"ς",sigmav:"ς",sim:"∼",simdot:"⩪",sime:"≃",simeq:"≃",simg:"⪞",simgE:"⪠",siml:"⪝",simlE:"⪟",simne:"≆",simplus:"⨤",simrarr:"⥲",slarr:"←",smallsetminus:"∖",smashp:"⨳",smeparsl:"⧤",smid:"∣",smile:"⌣",smt:"⪪",smte:"⪬",smtes:"⪬︀",softcy:"ь",sol:"/",solb:"⧄",solbar:"⌿",sopf:"𝕤",spades:"♠",spadesuit:"♠",spar:"∥",sqcap:"⊓",sqcaps:"⊓︀",sqcup:"⊔",sqcups:"⊔︀",sqsub:"⊏",sqsube:"⊑",sqsubset:"⊏",sqsubseteq:"⊑",sqsup:"⊐",sqsupe:"⊒",sqsupset:"⊐",sqsupseteq:"⊒",squ:"□",square:"□",squarf:"▪",squf:"▪",srarr:"→",sscr:"𝓈",ssetmn:"∖",ssmile:"⌣",sstarf:"⋆",star:"☆",starf:"★",straightepsilon:"ϵ",straightphi:"ϕ",strns:"¯",sub:"⊂",subE:"⫅",subdot:"⪽",sube:"⊆",subedot:"⫃",submult:"⫁",subnE:"⫋",subne:"⊊",subplus:"⪿",subrarr:"⥹",subset:"⊂",subseteq:"⊆",subseteqq:"⫅",subsetneq:"⊊",subsetneqq:"⫋",subsim:"⫇",subsub:"⫕",subsup:"⫓",succ:"≻",succapprox:"⪸",succcurlyeq:"≽",succeq:"⪰",succnapprox:"⪺",succneqq:"⪶",succnsim:"⋩",succsim:"≿",sum:"∑",sung:"♪",sup1:"¹",sup2:"²",sup3:"³",sup:"⊃",supE:"⫆",supdot:"⪾",supdsub:"⫘",supe:"⊇",supedot:"⫄",suphsol:"⟉",suphsub:"⫗",suplarr:"⥻",supmult:"⫂",supnE:"⫌",supne:"⊋",supplus:"⫀",supset:"⊃",supseteq:"⊇",supseteqq:"⫆",supsetneq:"⊋",supsetneqq:"⫌",supsim:"⫈",supsub:"⫔",supsup:"⫖",swArr:"⇙",swarhk:"⤦",swarr:"↙",swarrow:"↙",swnwar:"⤪",szlig:"ß",target:"⌖",tau:"τ",tbrk:"⎴",tcaron:"ť",tcedil:"ţ",tcy:"т",tdot:"⃛",telrec:"⌕",tfr:"𝔱",there4:"∴",therefore:"∴",theta:"θ",thetasym:"ϑ",thetav:"ϑ",thickapprox:"≈",thicksim:"∼",thinsp:" ",thkap:"≈",thksim:"∼",thorn:"þ",tilde:"˜",times:"×",timesb:"⊠",timesbar:"⨱",timesd:"⨰",tint:"∭",toea:"⤨",top:"⊤",topbot:"⌶",topcir:"⫱",topf:"𝕥",topfork:"⫚",tosa:"⤩",tprime:"‴",trade:"™",triangle:"▵",triangledown:"▿",triangleleft:"◃",trianglelefteq:"⊴",triangleq:"≜",triangleright:"▹",trianglerighteq:"⊵",tridot:"◬",trie:"≜",triminus:"⨺",triplus:"⨹",trisb:"⧍",tritime:"⨻",trpezium:"⏢",tscr:"𝓉",tscy:"ц",tshcy:"ћ",tstrok:"ŧ",twixt:"≬",twoheadleftarrow:"↞",twoheadrightarrow:"↠",uArr:"⇑",uHar:"⥣",uacute:"ú",uarr:"↑",ubrcy:"ў",ubreve:"ŭ",ucirc:"û",ucy:"у",udarr:"⇅",udblac:"ű",udhar:"⥮",ufisht:"⥾",ufr:"𝔲",ugrave:"ù",uharl:"↿",uharr:"↾",uhblk:"▀",ulcorn:"⌜",ulcorner:"⌜",ulcrop:"⌏",ultri:"◸",umacr:"ū",uml:"¨",uogon:"ų",uopf:"𝕦",uparrow:"↑",updownarrow:"↕",upharpoonleft:"↿",upharpoonright:"↾",uplus:"⊎",upsi:"υ",upsih:"ϒ",upsilon:"υ",upuparrows:"⇈",urcorn:"⌝",urcorner:"⌝",urcrop:"⌎",uring:"ů",urtri:"◹",uscr:"𝓊",utdot:"⋰",utilde:"ũ",utri:"▵",utrif:"▴",uuarr:"⇈",uuml:"ü",uwangle:"⦧",vArr:"⇕",vBar:"⫨",vBarv:"⫩",vDash:"⊨",vangrt:"⦜",varepsilon:"ϵ",varkappa:"ϰ",varnothing:"∅",varphi:"ϕ",varpi:"ϖ",varpropto:"∝",varr:"↕",varrho:"ϱ",varsigma:"ς",varsubsetneq:"⊊︀",varsubsetneqq:"⫋︀",varsupsetneq:"⊋︀",varsupsetneqq:"⫌︀",vartheta:"ϑ",vartriangleleft:"⊲",vartriangleright:"⊳",vcy:"в",vdash:"⊢",vee:"∨",veebar:"⊻",veeeq:"≚",vellip:"⋮",verbar:"|",vert:"|",vfr:"𝔳",vltri:"⊲",vnsub:"⊂⃒",vnsup:"⊃⃒",vopf:"𝕧",vprop:"∝",vrtri:"⊳",vscr:"𝓋",vsubnE:"⫋︀",vsubne:"⊊︀",vsupnE:"⫌︀",vsupne:"⊋︀",vzigzag:"⦚",wcirc:"ŵ",wedbar:"⩟",wedge:"∧",wedgeq:"≙",weierp:"℘",wfr:"𝔴",wopf:"𝕨",wp:"℘",wr:"≀",wreath:"≀",wscr:"𝓌",xcap:"⋂",xcirc:"◯",xcup:"⋃",xdtri:"▽",xfr:"𝔵",xhArr:"⟺",xharr:"⟷",xi:"ξ",xlArr:"⟸",xlarr:"⟵",xmap:"⟼",xnis:"⋻",xodot:"⨀",xopf:"𝕩",xoplus:"⨁",xotime:"⨂",xrArr:"⟹",xrarr:"⟶",xscr:"𝓍",xsqcup:"⨆",xuplus:"⨄",xutri:"△",xvee:"⋁",xwedge:"⋀",yacute:"ý",yacy:"я",ycirc:"ŷ",ycy:"ы",yen:"¥",yfr:"𝔶",yicy:"ї",yopf:"𝕪",yscr:"𝓎",yucy:"ю",yuml:"ÿ",zacute:"ź",zcaron:"ž",zcy:"з",zdot:"ż",zeetrf:"ℨ",zeta:"ζ",zfr:"𝔷",zhcy:"ж",zigrarr:"⇝",zopf:"𝕫",zscr:"𝓏",zwj:"‍",zwnj:"‌"},ne={0:65533,128:8364,130:8218,131:402,132:8222,133:8230,134:8224,135:8225,136:710,137:8240,138:352,139:8249,140:338,142:381,145:8216,146:8217,147:8220,148:8221,149:8226,150:8211,151:8212,152:732,153:8482,154:353,155:8250,156:339,158:382,159:376};function oe(e){return e.replace(/&(?:[a-zA-Z]+|#[xX][\da-fA-F]+|#\d+);/g,e=>{if("#"===e.charAt(1)){const t=e.charAt(2);return function(e){if(e>=55296&&e<=57343||e>1114111)return"�";return String.fromCodePoint($(ne,e)??e)}("X"===t||"x"===t?parseInt(e.slice(3),16):parseInt(e.slice(2),10))}return $(re,e.slice(1,-1))??e})}function ie(e,t){return e.startIndex=e.tokenIndex=e.index,e.startColumn=e.tokenColumn=e.column,e.startLine=e.tokenLine=e.line,e.setToken(8192&u[e.currentChar]?function(e){const t=e.currentChar;let r=n(e);const o=e.index;for(;r!==t;)e.index>=e.end&&e.report(16),r=n(e);r!==t&&e.report(16);e.tokenValue=e.source.slice(o,e.index),n(e),e.options.raw&&(e.tokenRaw=e.source.slice(e.tokenIndex,e.index));return 134283267}(e):te(e,t,0)),e.getToken()}function ae(e){if(e.startIndex=e.tokenIndex=e.index,e.startColumn=e.tokenColumn=e.column,e.startLine=e.tokenLine=e.line,e.index>=e.end)return void e.setToken(1048576);if(60===e.currentChar)return n(e),void e.setToken(8456256);if(123===e.currentChar)return n(e),void e.setToken(2162700);let t=0;for(;e.index<e.end;){const r=u[e.source.charCodeAt(e.index)];if(1024&r?(t|=5,a(e)):2048&r?(i(e,t),t=-5&t|1):n(e),16384&u[e.currentChar])break}e.tokenIndex===e.index&&e.report(0);const r=e.source.slice(e.tokenIndex,e.index);e.options.raw&&(e.tokenRaw=r),e.tokenValue=oe(r),e.setToken(137)}function se(e){if(!(143360&~e.getToken())){const{index:t}=e;let r=e.currentChar;for(;32770&u[r];)r=n(e);e.tokenValue+=e.source.slice(t,e.index),e.setToken(208897,!0)}return e.getToken()}class ce{parser;type;parent;scopeError;variableBindings=new Map;constructor(e,t=2,r){this.parser=e,this.type=t,this.parent=r}createChildScope(e){return new ce(this.parser,e,this)}addVarOrBlock(e,t,r,n){4&r?this.addVarName(e,t,r):this.addBlockName(e,t,r,n),64&n&&this.parser.declareUnboundVariable(t)}addVarName(e,t,r){const{parser:n}=this;let o=this;for(;o&&!(128&o.type);){const{variableBindings:i}=o,a=i.get(t);a&&248&a&&(!n.options.webcompat||1&e||!(128&r&&68&a||128&a&&68&r))&&n.report(145,t),o===this&&a&&1&a&&1&r&&o.recordScopeError(145,t),a&&(256&a||512&a&&!n.options.webcompat)&&n.report(145,t),o.variableBindings.set(t,r),o=o.parent}}hasVariable(e){return this.variableBindings.has(e)}addBlockName(e,t,r,n){const{parser:o}=this,i=this.variableBindings.get(t);!i||2&i||(1&r?this.recordScopeError(145,t):o.options.webcompat&&!(1&e)&&2&n&&64===i&&64===r||o.report(145,t)),64&this.type&&this.parent?.hasVariable(t)&&!(2&this.parent.variableBindings.get(t))&&o.report(145,t),512&this.type&&i&&!(2&i)&&1&r&&this.recordScopeError(145,t),32&this.type&&768&this.parent.variableBindings.get(t)&&o.report(159,t),this.variableBindings.set(t,r)}recordScopeError(e,...t){this.scopeError={type:e,params:t,start:this.parser.tokenStart,end:this.parser.currentLocation}}reportScopeError(){const{scopeError:e}=this;if(e)throw new L(e.start,e.end,e.type,...e.params)}}function le(e,t,r){const n=e.createScope().createChildScope(512);return n.addBlockName(t,r,1,0),n}class ue{parser;parent;refs=Object.create(null);privateIdentifiers=new Map;constructor(e,t){this.parser=e,this.parent=t}addPrivateIdentifier(e,t){const{privateIdentifiers:r}=this;let n=800&t;768&n||(n|=768);const o=r.get(e);this.hasPrivateIdentifier(e)&&((32&o)!=(32&n)||o&n&768)&&this.parser.report(146,e),r.set(e,this.hasPrivateIdentifier(e)?o|n:n)}addPrivateIdentifierRef(e){this.refs[e]??=[],this.refs[e].push(this.parser.tokenStart)}isPrivateIdentifierDefined(e){return this.hasPrivateIdentifier(e)||Boolean(this.parent?.isPrivateIdentifierDefined(e))}validatePrivateIdentifierRefs(){for(const e in this.refs)if(!this.isPrivateIdentifierDefined(e)){const{index:t,line:r,column:n}=this.refs[e][0];throw new L({index:t,line:r,column:n},{index:t+e.length,line:r,column:n+e.length},4,e)}}hasPrivateIdentifier(e){return this.privateIdentifiers.has(e)}}class pe{source;options;lastOnToken=null;token=1048576;flags=0;index=0;line=1;column=0;startIndex=0;end=0;tokenIndex=0;startColumn=0;tokenColumn=0;tokenLine=1;startLine=1;tokenValue="";tokenRaw="";tokenRegExp=void 0;currentChar=0;exportedNames=new Set;exportedBindings=new Set;assignable=1;destructible=0;leadingDecorators={decorators:[]};constructor(e,t={}){this.source=e,this.options=t,this.end=e.length,this.currentChar=e.charCodeAt(0)}getToken(){return this.token}setToken(e,t=!1){this.token=e;const{onToken:r}=this.options;if(r)if(1048576!==e){const n={start:{line:this.tokenLine,column:this.tokenColumn},end:{line:this.line,column:this.column}};!t&&this.lastOnToken&&r(...this.lastOnToken),this.lastOnToken=[l(e),this.tokenIndex,this.index,n]}else this.lastOnToken&&(r(...this.lastOnToken),this.lastOnToken=null);return e}get tokenStart(){return{index:this.tokenIndex,line:this.tokenLine,column:this.tokenColumn}}get currentLocation(){return{index:this.index,line:this.line,column:this.column}}finishNode(e,t,r){if(this.options.ranges){e.start=t.index;const n=r?r.index:this.startIndex;e.end=n,e.range=[t.index,n]}return this.options.loc&&(e.loc={start:{line:t.line,column:t.column},end:r?{line:r.line,column:r.column}:{line:this.startLine,column:this.startColumn}},this.options.source&&(e.loc.source=this.options.source)),e}addBindingToExports(e){this.exportedBindings.add(e)}declareUnboundVariable(e){const{exportedNames:t}=this;t.has(e)&&this.report(147,e),t.add(e)}report(e,...t){throw new L(this.tokenStart,this.currentLocation,e,...t)}createScopeIfLexical(e,t){if(this.options.lexical)return this.createScope(e,t)}createScope(e,t){return new ce(this,e,t)}createPrivateScopeIfLexical(e){if(this.options.lexical)return new ue(this,e)}}function de(e,t={},r=0){const o=function(e){const t={...e};return t.onComment&&(t.onComment=Array.isArray(t.onComment)?function(e,t){return function(r,n,o,i,a){const s={type:r,value:n};t.ranges&&(s.start=o,s.end=i,s.range=[o,i]),t.loc&&(s.loc=a),e.push(s)}}(t.onComment,t):t.onComment),t.onToken&&(t.onToken=Array.isArray(t.onToken)?function(e,t){return function(r,n,o,i){const a={token:r};t.ranges&&(a.start=n,a.end=o,a.range=[n,o]),t.loc&&(a.loc=i),e.push(a)}}(t.onToken,t):t.onToken),t}(t);o.module&&(r|=3),o.globalReturn&&(r|=4096),o.impliedStrict&&(r|=1);const i=new pe(e,o);!function(e){const{source:t}=e;35===e.currentChar&&33===t.charCodeAt(e.index+1)&&(n(e),n(e),m(e,t,0,4,e.tokenStart))}(i);const a=i.createScopeIfLexical();let s=[],c="script";if(2&r){if(c="module",s=function(e,t,r){ee(e,32|t);const n=[];for(;134283267===e.getToken();){const{tokenStart:r}=e,o=e.getToken();n.push(ye(e,t,nt(e,t),o,r))}for(;1048576!==e.getToken();)n.push(ge(e,t,r));return n}(i,8|r,a),a)for(const e of i.exportedBindings)a.hasVariable(e)||i.report(148,e)}else s=function(e,t,r){ee(e,262176|t);const n=[];for(;134283267===e.getToken();){const{index:r,tokenValue:o,tokenStart:i,tokenIndex:a}=e,s=e.getToken(),c=nt(e,t);if(R(e,r,a,o)){if(t|=1,64&e.flags)throw new L(e.tokenStart,e.currentLocation,9);if(4096&e.flags)throw new L(e.tokenStart,e.currentLocation,15)}n.push(ye(e,t,c,s,i))}for(;1048576!==e.getToken();)n.push(fe(e,t,r,void 0,4,{}));return n}(i,8|r,a);return i.finishNode({type:"Program",sourceType:c,body:s},{index:0,line:1,column:0},i.currentLocation)}function ge(e,t,r){let n;switch(132===e.getToken()&&Object.assign(e.leadingDecorators,{start:e.tokenStart,decorators:Tt(e,t,void 0)}),e.getToken()){case 20564:n=function(e,t,r){const n=e.leadingDecorators.decorators.length?e.leadingDecorators.start:e.tokenStart;ee(e,32|t);const o=[];let i=null,a=null,s=[];if(U(e,32|t,20561)){switch(e.getToken()){case 86104:i=ot(e,t,r,void 0,4,1,1,0,e.tokenStart);break;case 132:case 86094:i=yt(e,t,r,void 0,1);break;case 209005:{const{tokenStart:n}=e;i=rt(e,t);const{flags:o}=e;1&o||(86104===e.getToken()?i=ot(e,t,r,void 0,4,1,1,1,n):67174411===e.getToken()?(i=wt(e,t,void 0,i,1,1,0,o,n),i=Fe(e,t,void 0,i,0,0,n),i=Re(e,t,void 0,0,0,n,i)):143360&e.getToken()&&(r&&(r=le(e,t,e.tokenValue)),i=rt(e,t),i=ht(e,t,r,void 0,[i],1,n)));break}default:i=De(e,t,void 0,1,0,e.tokenStart),P(e,32|t)}return r&&e.declareUnboundVariable("default"),e.finishNode({type:"ExportDefaultDeclaration",declaration:i},n)}switch(e.getToken()){case 8391476:{ee(e,t);let o=null;U(e,t,77932)&&(r&&e.declareUnboundVariable(e.tokenValue),o=_e(e,t)),O(e,t,209011),134283267!==e.getToken()&&e.report(105,"Export"),a=nt(e,t);const i={type:"ExportAllDeclaration",source:a,exported:o,attributes:Xe(e,t)};return P(e,32|t),e.finishNode(i,n)}case 2162700:{ee(e,t);const n=[],i=[];let c=0;for(;143360&e.getToken()||134283267===e.getToken();){const{tokenStart:a,tokenValue:s}=e,l=_e(e,t);let u;"Literal"===l.type&&(c=1),77932===e.getToken()?(ee(e,t),143360&e.getToken()||134283267===e.getToken()||e.report(106),r&&(n.push(e.tokenValue),i.push(s)),u=_e(e,t)):(r&&(n.push(e.tokenValue),i.push(e.tokenValue)),u=l),o.push(e.finishNode({type:"ExportSpecifier",local:l,exported:u},a)),1074790415!==e.getToken()&&O(e,t,18)}O(e,t,1074790415),U(e,t,209011)?(134283267!==e.getToken()&&e.report(105,"Export"),a=nt(e,t),s=Xe(e,t),r&&n.forEach(t=>e.declareUnboundVariable(t))):(c&&e.report(172),r&&(n.forEach(t=>e.declareUnboundVariable(t)),i.forEach(t=>e.addBindingToExports(t)))),P(e,32|t);break}case 132:case 86094:i=yt(e,t,r,void 0,2);break;case 86104:i=ot(e,t,r,void 0,4,1,2,0,e.tokenStart);break;case 241737:i=Se(e,t,r,void 0,8,64);break;case 86090:i=Se(e,t,r,void 0,16,64);break;case 86088:i=ve(e,t,r,void 0,64);break;case 209005:{const{tokenStart:n}=e;if(ee(e,t),!(1&e.flags)&&86104===e.getToken()){i=ot(e,t,r,void 0,4,1,2,1,n);break}}default:e.report(30,D[255&e.getToken()])}const c={type:"ExportNamedDeclaration",declaration:i,specifiers:o,source:a,attributes:s};return e.finishNode(c,n)}(e,t,r);break;case 86106:n=function(e,t,r){const n=e.tokenStart;ee(e,t);let o=null;const{tokenStart:i}=e;let a=[];if(134283267===e.getToken())o=nt(e,t);else{if(143360&e.getToken()){const n=qe(e,t,r);if(a=[e.finishNode({type:"ImportDefaultSpecifier",local:n},i)],U(e,t,18))switch(e.getToken()){case 8391476:a.push(Ne(e,t,r));break;case 2162700:Le(e,t,r,a);break;default:e.report(107)}}else switch(e.getToken()){case 8391476:a=[Ne(e,t,r)];break;case 2162700:Le(e,t,r,a);break;case 67174411:return Ie(e,t,void 0,n);case 67108877:return Ae(e,t,n);default:e.report(30,D[255&e.getToken()])}o=function(e,t){O(e,t,209011),134283267!==e.getToken()&&e.report(105,"Import");return nt(e,t)}(e,t)}const s=Xe(e,t),c={type:"ImportDeclaration",specifiers:a,source:o,attributes:s};return P(e,32|t),e.finishNode(c,n)}(e,t,r);break;default:n=fe(e,t,r,void 0,4,{})}return e.leadingDecorators?.decorators.length&&e.report(170),n}function fe(e,t,r,n,o,i){const a=e.tokenStart;switch(e.getToken()){case 86104:return ot(e,t,r,n,o,1,0,0,a);case 132:case 86094:return yt(e,t,r,n,0);case 86090:return Se(e,t,r,n,16,0);case 241737:return function(e,t,r,n,o){const{tokenValue:i,tokenStart:a}=e,s=e.getToken();let c=rt(e,t);if(2240512&e.getToken()){const o=Ce(e,t,r,n,8,0);return P(e,32|t),e.finishNode({type:"VariableDeclaration",kind:"let",declarations:o},a)}e.assignable=1,1&t&&e.report(85);if(21===e.getToken())return be(e,t,r,n,o,{},i,c,s,0,a);if(10===e.getToken()){let r;e.options.lexical&&(r=le(e,t,i)),e.flags=128^(128|e.flags),c=ht(e,t,r,n,[c],0,a)}else c=Fe(e,t,n,c,0,0,a),c=Re(e,t,n,0,0,a,c);18===e.getToken()&&(c=Ve(e,t,n,0,a,c));return me(e,t,c,a)}(e,t,r,n,o);case 20564:e.report(103,"export");case 86106:switch(ee(e,t),e.getToken()){case 67174411:return Ie(e,t,n,a);case 67108877:return Ae(e,t,a);default:e.report(103,"import")}case 209005:return we(e,t,r,n,o,i,1);default:return he(e,t,r,n,o,i,1)}}function he(e,t,r,n,o,i,a){switch(e.getToken()){case 86088:return ve(e,t,r,n,0);case 20572:return function(e,t,r){4096&t||e.report(92);const n=e.tokenStart;ee(e,32|t);const o=1&e.flags||1048576&e.getToken()?null:Pe(e,t,r,0,1,e.tokenStart);return P(e,32|t),e.finishNode({type:"ReturnStatement",argument:o},n)}(e,t,n);case 20569:return function(e,t,r,n,o){const i=e.tokenStart;ee(e,t),O(e,32|t,67174411),e.assignable=1;const a=Pe(e,t,n,0,1,e.tokenStart);O(e,32|t,16);const s=Te(e,t,r,n,o);let c=null;20563===e.getToken()&&(ee(e,32|t),c=Te(e,t,r,n,o));return e.finishNode({type:"IfStatement",test:a,consequent:s,alternate:c},i)}(e,t,r,n,i);case 20567:return function(e,t,r,n,o){const i=e.tokenStart;ee(e,t);const a=((2048&t)>0||(2&t)>0&&(8&t)>0)&&U(e,t,209006);O(e,32|t,67174411),r=r?.createChildScope(1);let s,c=null,l=null,u=0,p=null,d=86088===e.getToken()||241737===e.getToken()||86090===e.getToken();const{tokenStart:g}=e,f=e.getToken();if(d)241737===f?(p=rt(e,t),2240512&e.getToken()?(8673330===e.getToken()?1&t&&e.report(67):p=e.finishNode({type:"VariableDeclaration",kind:"let",declarations:Ce(e,131072|t,r,n,8,32)},g),e.assignable=1):1&t?e.report(67):(d=!1,e.assignable=1,p=Fe(e,t,n,p,0,0,g),471156===e.getToken()&&e.report(115))):(ee(e,t),p=e.finishNode(86088===f?{type:"VariableDeclaration",kind:"var",declarations:Ce(e,131072|t,r,n,4,32)}:{type:"VariableDeclaration",kind:"const",declarations:Ce(e,131072|t,r,n,16,32)},g),e.assignable=1);else if(1074790417===f)a&&e.report(82);else if(2097152&~f)p=je(e,131072|t,n,1,0,1);else{const r=e.tokenStart;p=2162700===f?ut(e,t,void 0,n,1,0,0,2,32):at(e,t,void 0,n,1,0,0,2,32),u=e.destructible,64&u&&e.report(63),e.assignable=16&u?2:1,p=Fe(e,131072|t,n,p,0,0,r)}if(!(262144&~e.getToken())){if(471156===e.getToken()){2&e.assignable&&e.report(80,a?"await":"of"),M(e,p),ee(e,32|t),s=De(e,t,n,1,0,e.tokenStart),O(e,32|t,16);const c=xe(e,t,r,n,o);return e.finishNode({type:"ForOfStatement",left:p,right:s,body:c,await:a},i)}2&e.assignable&&e.report(80,"in"),M(e,p),ee(e,32|t),a&&e.report(82),s=Pe(e,t,n,0,1,e.tokenStart),O(e,32|t,16);const c=xe(e,t,r,n,o);return e.finishNode({type:"ForInStatement",body:c,left:p,right:s},i)}a&&e.report(82);d||(8&u&&1077936155!==e.getToken()&&e.report(80,"loop"),p=Re(e,131072|t,n,0,0,g,p));18===e.getToken()&&(p=Ve(e,t,n,0,g,p));O(e,32|t,1074790417),1074790417!==e.getToken()&&(c=Pe(e,t,n,0,1,e.tokenStart));O(e,32|t,1074790417),16!==e.getToken()&&(l=Pe(e,t,n,0,1,e.tokenStart));O(e,32|t,16);const h=xe(e,t,r,n,o);return e.finishNode({type:"ForStatement",init:p,test:c,update:l,body:h},i)}(e,t,r,n,i);case 20562:return function(e,t,r,n,o){const i=e.tokenStart;ee(e,32|t);const a=xe(e,t,r,n,o);O(e,t,20578),O(e,32|t,67174411);const s=Pe(e,t,n,0,1,e.tokenStart);return O(e,32|t,16),U(e,32|t,1074790417),e.finishNode({type:"DoWhileStatement",body:a,test:s},i)}(e,t,r,n,i);case 20578:return function(e,t,r,n,o){const i=e.tokenStart;ee(e,t),O(e,32|t,67174411);const a=Pe(e,t,n,0,1,e.tokenStart);O(e,32|t,16);const s=xe(e,t,r,n,o);return e.finishNode({type:"WhileStatement",test:a,body:s},i)}(e,t,r,n,i);case 86110:return function(e,t,r,n,o){const i=e.tokenStart;ee(e,t),O(e,32|t,67174411);const a=Pe(e,t,n,0,1,e.tokenStart);O(e,t,16),O(e,t,2162700);const s=[];let c=0;r=r?.createChildScope(8);for(;1074790415!==e.getToken();){const{tokenStart:i}=e;let a=null;const l=[];for(U(e,32|t,20556)?a=Pe(e,t,n,0,1,e.tokenStart):(O(e,32|t,20561),c&&e.report(89),c=1),O(e,32|t,21);20556!==e.getToken()&&1074790415!==e.getToken()&&20561!==e.getToken();)l.push(fe(e,4|t,r,n,2,{$:o}));s.push(e.finishNode({type:"SwitchCase",test:a,consequent:l},i))}return O(e,32|t,1074790415),e.finishNode({type:"SwitchStatement",discriminant:a,cases:s},i)}(e,t,r,n,i);case 1074790417:return function(e,t){const r=e.tokenStart;return ee(e,32|t),e.finishNode({type:"EmptyStatement"},r)}(e,t);case 2162700:return ke(e,t,r?.createChildScope(),n,i,e.tokenStart);case 86112:return function(e,t,r){const n=e.tokenStart;ee(e,32|t),1&e.flags&&e.report(90);const o=Pe(e,t,r,0,1,e.tokenStart);return P(e,32|t),e.finishNode({type:"ThrowStatement",argument:o},n)}(e,t,n);case 20555:return function(e,t,r){const n=e.tokenStart;ee(e,32|t);let o=null;if(!(1&e.flags)&&143360&e.getToken()){const{tokenValue:n}=e;o=rt(e,32|t),J(e,r,n,0)||e.report(138,n)}else 132&t||e.report(69);return P(e,32|t),e.finishNode({type:"BreakStatement",label:o},n)}(e,t,i);case 20559:return function(e,t,r){128&t||e.report(68);const n=e.tokenStart;ee(e,t);let o=null;if(!(1&e.flags)&&143360&e.getToken()){const{tokenValue:n}=e;o=rt(e,32|t),J(e,r,n,1)||e.report(138,n)}return P(e,32|t),e.finishNode({type:"ContinueStatement",label:o},n)}(e,t,i);case 20577:return function(e,t,r,n,o){const i=e.tokenStart;ee(e,32|t);const a=r?.createChildScope(16),s=ke(e,t,a,n,{$:o}),{tokenStart:c}=e,l=U(e,32|t,20557)?function(e,t,r,n,o,i){let a=null,s=r;U(e,t,67174411)&&(r=r?.createChildScope(4),a=qt(e,t,r,n,2097152&~e.getToken()?512:256,0),18===e.getToken()?e.report(86):1077936155===e.getToken()&&e.report(87),O(e,32|t,16));s=r?.createChildScope(32);const c=ke(e,t,s,n,{$:o});return e.finishNode({type:"CatchClause",param:a,body:c},i)}(e,t,r,n,o,c):null;let u=null;if(20566===e.getToken()){ee(e,32|t);const i=r?.createChildScope(4);u=ke(e,t,i,n,{$:o})}l||u||e.report(88);return e.finishNode({type:"TryStatement",block:s,handler:l,finalizer:u},i)}(e,t,r,n,i);case 20579:return function(e,t,r,n,o){const i=e.tokenStart;ee(e,t),1&t&&e.report(91);O(e,32|t,67174411);const a=Pe(e,t,n,0,1,e.tokenStart);O(e,32|t,16);const s=he(e,t,r,n,2,o,0);return e.finishNode({type:"WithStatement",object:a,body:s},i)}(e,t,r,n,i);case 20560:return function(e,t){const r=e.tokenStart;return ee(e,32|t),P(e,32|t),e.finishNode({type:"DebuggerStatement"},r)}(e,t);case 209005:return we(e,t,r,n,o,i,0);case 20557:e.report(162);case 20566:e.report(163);case 86104:e.report(1&t?76:e.options.webcompat?77:78);case 86094:e.report(79);default:return function(e,t,r,n,o,i,a){const{tokenValue:s,tokenStart:c}=e,l=e.getToken();let u;if(241737===l)u=rt(e,t),1&t&&e.report(85),69271571===e.getToken()&&e.report(84);else u=Je(e,t,n,2,0,1,0,1,e.tokenStart);if(143360&l&&21===e.getToken())return be(e,t,r,n,o,i,s,u,l,a,c);u=Fe(e,t,n,u,0,0,c),u=Re(e,t,n,0,0,c,u),18===e.getToken()&&(u=Ve(e,t,n,0,c,u));return me(e,t,u,c)}(e,t,r,n,o,i,a)}}function ke(e,t,r,n,o,i=e.tokenStart,a="BlockStatement"){const s=[];for(O(e,32|t,2162700);1074790415!==e.getToken();)s.push(fe(e,t,r,n,2,{$:o}));return O(e,32|t,1074790415),e.finishNode({type:a,body:s},i)}function me(e,t,r,n){return P(e,32|t),e.finishNode({type:"ExpressionStatement",expression:r},n)}function be(e,t,r,n,o,i,a,s,c,l,u){j(e,t,0,c,1),function(e,t,r){let n=t;for(;n;)n["$"+r]&&e.report(136,r),n=n.$;t["$"+r]=1}(e,i,a),ee(e,32|t);const p=!l||1&t||!e.options.webcompat||86104!==e.getToken()?he(e,t,r,n,o,i,l):ot(e,t,r?.createChildScope(),n,o,0,0,0,e.tokenStart);return e.finishNode({type:"LabeledStatement",label:s,body:p},u)}function we(e,t,r,n,o,i,a){const{tokenValue:s,tokenStart:c}=e,l=e.getToken();let u=rt(e,t);if(21===e.getToken())return be(e,t,r,n,o,i,s,u,l,1,c);const p=1&e.flags;if(!p){if(86104===e.getToken())return a||e.report(123),ot(e,t,r,n,o,1,0,1,c);if(H(t,e.getToken()))return u=bt(e,t,n,1,c),18===e.getToken()&&(u=Ve(e,t,n,0,c,u)),me(e,t,u,c)}return 67174411===e.getToken()?u=wt(e,t,n,u,1,1,0,p,c):(10===e.getToken()&&(X(e,t,l),36864&~l||(e.flags|=256),u=gt(e,2048|t,n,e.tokenValue,u,0,1,0,c)),e.assignable=1),u=Fe(e,t,n,u,0,0,c),u=Re(e,t,n,0,0,c,u),e.assignable=1,18===e.getToken()&&(u=Ve(e,t,n,0,c,u)),me(e,t,u,c)}function ye(e,t,r,n,o){const i=e.startIndex;1074790417!==n&&(e.assignable=2,r=Fe(e,t,void 0,r,0,0,o),1074790417!==e.getToken()&&(r=Re(e,t,void 0,0,0,o,r),18===e.getToken()&&(r=Ve(e,t,void 0,0,o,r))),P(e,32|t));const a={type:"ExpressionStatement",expression:r};return"Literal"===r.type&&"string"==typeof r.value&&(a.directive=e.source.slice(o.index+1,i-1)),e.finishNode(a,o)}function Te(e,t,r,n,o){const{tokenStart:i}=e;return 1&t||!e.options.webcompat||86104!==e.getToken()?he(e,t,r,n,0,{$:o},0):ot(e,t,r?.createChildScope(),n,0,0,0,0,i)}function xe(e,t,r,n,o){return he(e,131072^(131072|t)|128,r,n,0,{loop:1,$:o},0)}function Se(e,t,r,n,o,i){const a=e.tokenStart;ee(e,t);const s=Ce(e,t,r,n,o,i);return P(e,32|t),e.finishNode({type:"VariableDeclaration",kind:8&o?"let":"const",declarations:s},a)}function ve(e,t,r,n,o){const i=e.tokenStart;ee(e,t);const a=Ce(e,t,r,n,4,o);return P(e,32|t),e.finishNode({type:"VariableDeclaration",kind:"var",declarations:a},i)}function Ce(e,t,r,n,o,i){let a=1;const s=[Ee(e,t,r,n,o,i)];for(;U(e,t,18);)a++,s.push(Ee(e,t,r,n,o,i));return a>1&&32&i&&262144&e.getToken()&&e.report(61,D[255&e.getToken()]),s}function Ee(e,t,r,n,o,i){const{tokenStart:a}=e,s=e.getToken();let c=null;const l=qt(e,t,r,n,o,i);if(1077936155===e.getToken()){if(ee(e,32|t),c=De(e,t,n,1,0,e.tokenStart),(32&i||!(2097152&s))&&(471156===e.getToken()||8673330===e.getToken()&&(2097152&s||!(4&o)||1&t)))throw new L(a,e.currentLocation,60,471156===e.getToken()?"of":"in")}else(16&o||(2097152&s)>0)&&262144&~e.getToken()&&e.report(59,16&o?"const":"destructuring");return e.finishNode({type:"VariableDeclarator",id:l,init:c},a)}function qe(e,t,r){return H(t,e.getToken())||e.report(118),537079808&~e.getToken()||e.report(119),r?.addBlockName(t,e.tokenValue,8,0),rt(e,t)}function Ne(e,t,r){const{tokenStart:n}=e;if(ee(e,t),O(e,t,77932),!(134217728&~e.getToken()))throw new L(n,e.currentLocation,30,D[255&e.getToken()]);return e.finishNode({type:"ImportNamespaceSpecifier",local:qe(e,t,r)},n)}function Le(e,t,r,n){for(ee(e,t);143360&e.getToken()||134283267===e.getToken();){let{tokenValue:o,tokenStart:i}=e;const a=e.getToken(),s=_e(e,t);let c;U(e,t,77932)?(134217728&~e.getToken()&&18!==e.getToken()?j(e,t,16,e.getToken(),0):e.report(106),o=e.tokenValue,c=rt(e,t)):"Identifier"===s.type?(j(e,t,16,a,0),c=s):e.report(25,D[108]),r?.addBlockName(t,o,8,0),n.push(e.finishNode({type:"ImportSpecifier",local:c,imported:s},i)),1074790415!==e.getToken()&&O(e,t,18)}return O(e,t,1074790415),n}function Ae(e,t,r){let n=ze(e,t,e.finishNode({type:"Identifier",name:"import"},r),r);return n=Fe(e,t,void 0,n,0,0,r),n=Re(e,t,void 0,0,0,r,n),18===e.getToken()&&(n=Ve(e,t,void 0,0,r,n)),me(e,t,n,r)}function Ie(e,t,r,n){let o=He(e,t,r,0,n);return o=Fe(e,t,r,o,0,0,n),18===e.getToken()&&(o=Ve(e,t,r,0,n,o)),me(e,t,o,n)}function De(e,t,r,n,o,i){let a=Je(e,t,r,2,0,n,o,1,i);return a=Fe(e,t,r,a,o,0,i),Re(e,t,r,o,0,i,a)}function Ve(e,t,r,n,o,i){const a=[i];for(;U(e,32|t,18);)a.push(De(e,t,r,1,n,e.tokenStart));return e.finishNode({type:"SequenceExpression",expressions:a},o)}function Pe(e,t,r,n,o,i){const a=De(e,t,r,o,n,i);return 18===e.getToken()?Ve(e,t,r,n,i,a):a}function Re(e,t,r,n,o,i,a){const s=e.getToken();if(!(4194304&~s)){2&e.assignable&&e.report(26),(!o&&1077936155===s&&"ArrayExpression"===a.type||"ObjectExpression"===a.type)&&M(e,a),ee(e,32|t);const c=De(e,t,r,1,n,e.tokenStart);return e.assignable=2,e.finishNode(o?{type:"AssignmentPattern",left:a,right:c}:{type:"AssignmentExpression",left:a,operator:D[255&s],right:c},i)}return 8388608&~s||(a=Oe(e,t,r,n,i,4,s,a)),U(e,32|t,22)&&(a=Ue(e,t,r,a,i)),a}function Be(e,t,r,n,o,i,a){const s=e.getToken();ee(e,32|t);const c=De(e,t,r,1,n,e.tokenStart);return a=e.finishNode(o?{type:"AssignmentPattern",left:a,right:c}:{type:"AssignmentExpression",left:a,operator:D[255&s],right:c},i),e.assignable=2,a}function Ue(e,t,r,n,o){const i=De(e,131072^(131072|t),r,1,0,e.tokenStart);O(e,32|t,21),e.assignable=1;const a=De(e,t,r,1,0,e.tokenStart);return e.assignable=2,e.finishNode({type:"ConditionalExpression",test:n,consequent:i,alternate:a},o)}function Oe(e,t,r,n,o,i,a,s){const c=8673330&-((131072&t)>0);let l,u;for(e.assignable=2;8388608&e.getToken()&&(l=e.getToken(),u=3840&l,(524288&l&&268435456&a||524288&a&&268435456&l)&&e.report(165),!(u+((8391735===l)<<8)-((c===l)<<12)<=i));)ee(e,32|t),s=e.finishNode({type:524288&l||268435456&l?"LogicalExpression":"BinaryExpression",left:s,right:Oe(e,t,r,n,e.tokenStart,u,l,je(e,t,r,0,n,1)),operator:D[255&l]},o);return 1077936155===e.getToken()&&e.report(26),s}function Me(e,t,r,n,o,i,a){const{tokenStart:s}=e;O(e,32|t,2162700);const c=[];if(1074790415!==e.getToken()){for(;134283267===e.getToken();){const{index:r,tokenStart:n,tokenIndex:o,tokenValue:i}=e,s=e.getToken(),l=nt(e,t);if(R(e,r,o,i)){if(t|=1,128&e.flags)throw new L(n,e.currentLocation,66);if(64&e.flags)throw new L(n,e.currentLocation,9);if(4096&e.flags)throw new L(n,e.currentLocation,15);a?.reportScopeError()}c.push(ye(e,t,l,s,n))}1&t&&(i&&(537079808&~i||e.report(119),36864&~i||e.report(40)),512&e.flags&&e.report(119),256&e.flags&&e.report(118))}for(e.flags=4928^(4928|e.flags),e.destructible=256^(256|e.destructible);1074790415!==e.getToken();)c.push(fe(e,t,r,n,4,{}));return O(e,24&o?32|t:t,1074790415),e.flags&=-4289,1077936155===e.getToken()&&e.report(26),e.finishNode({type:"BlockStatement",body:c},s)}function je(e,t,r,n,o,i){const a=e.tokenStart;return Fe(e,t,r,Je(e,t,r,2,0,n,o,i,a),o,0,a)}function Fe(e,t,r,n,o,i,a){if(33619968&~e.getToken()||1&e.flags){if(!(67108864&~e.getToken())){switch(t=131072^(131072|t),e.getToken()){case 67108877:{ee(e,8^(262152|t)),16&t&&130===e.getToken()&&"super"===e.tokenValue&&e.report(173),e.assignable=1;const o=Ge(e,64|t,r);n=e.finishNode({type:"MemberExpression",object:n,computed:!1,property:o,optional:!1},a);break}case 69271571:{let i=!1;2048&~e.flags||(i=!0,e.flags=2048^(2048|e.flags)),ee(e,32|t);const{tokenStart:s}=e,c=Pe(e,t,r,o,1,s);O(e,t,20),e.assignable=1,n=e.finishNode({type:"MemberExpression",object:n,computed:!0,property:c,optional:!1},a),i&&(e.flags|=2048);break}case 67174411:{if(!(1024&~e.flags))return e.flags=1024^(1024|e.flags),n;let i=!1;2048&~e.flags||(i=!0,e.flags=2048^(2048|e.flags));const s=tt(e,t,r,o);e.assignable=2,n=e.finishNode({type:"CallExpression",callee:n,arguments:s,optional:!1},a),i&&(e.flags|=2048);break}case 67108990:ee(e,8^(262152|t)),e.flags|=2048,e.assignable=2,n=function(e,t,r,n,o){let i,a=!1;69271571!==e.getToken()&&67174411!==e.getToken()||2048&~e.flags||(a=!0,e.flags=2048^(2048|e.flags));if(69271571===e.getToken()){ee(e,32|t);const{tokenStart:a}=e,s=Pe(e,t,r,0,1,a);O(e,t,20),e.assignable=2,i=e.finishNode({type:"MemberExpression",object:n,computed:!0,optional:!0,property:s},o)}else if(67174411===e.getToken()){const a=tt(e,t,r,0);e.assignable=2,i=e.finishNode({type:"CallExpression",callee:n,arguments:a,optional:!0},o)}else{const a=Ge(e,t,r);e.assignable=2,i=e.finishNode({type:"MemberExpression",object:n,computed:!1,optional:!0,property:a},o)}a&&(e.flags|=2048);return i}(e,t,r,n,a);break;default:2048&~e.flags||e.report(166),e.assignable=2,n=e.finishNode({type:"TaggedTemplateExpression",tag:n,quasi:67174408===e.getToken()?Ke(e,64|t,r):Ze(e,t)},a)}n=Fe(e,t,r,n,0,1,a)}}else n=function(e,t,r,n){2&e.assignable&&e.report(55);const o=e.getToken();return ee(e,t),e.assignable=2,e.finishNode({type:"UpdateExpression",argument:r,operator:D[255&o],prefix:!1},n)}(e,t,n,a);return 0!==i||2048&~e.flags||(e.flags=2048^(2048|e.flags),n=e.finishNode({type:"ChainExpression",expression:n},a)),n}function Ge(e,t,r){return 143360&e.getToken()||-2147483528===e.getToken()||-2147483527===e.getToken()||130===e.getToken()||e.report(160),130===e.getToken()?Ct(e,t,r,0):rt(e,t)}function Je(e,t,r,n,o,i,a,s,c){if(!(143360&~e.getToken())){switch(e.getToken()){case 209006:return function(e,t,r,n,o,i){o&&(e.destructible|=128),524288&t&&e.report(177);const a=dt(e,t,r);if("ArrowFunctionExpression"===a.type||!(65536&e.getToken())){if(2048&t)throw new L(i,{index:e.startIndex,line:e.startLine,column:e.startColumn},176);if(2&t)throw new L(i,{index:e.startIndex,line:e.startLine,column:e.startColumn},110);if(8192&t&&2048&t)throw new L(i,{index:e.startIndex,line:e.startLine,column:e.startColumn},110);return a}if(8192&t)throw new L(i,{index:e.startIndex,line:e.startLine,column:e.startColumn},31);if(2048&t||2&t&&8&t){if(n)throw new L(i,{index:e.startIndex,line:e.startLine,column:e.startColumn},0);const o=je(e,t,r,0,0,1);return 8391735===e.getToken()&&e.report(33),e.assignable=2,e.finishNode({type:"AwaitExpression",argument:o},i)}if(2&t)throw new L(i,{index:e.startIndex,line:e.startLine,column:e.startColumn},98);return a}(e,t,r,o,a,c);case 241771:return function(e,t,r,n,o,i){if(n&&(e.destructible|=256),1024&t){ee(e,32|t),8192&t&&e.report(32),o||e.report(26),22===e.getToken()&&e.report(124);let n=null,a=!1;return 1&e.flags?8391476===e.getToken()&&e.report(30,D[255&e.getToken()]):(a=U(e,32|t,8391476),(77824&e.getToken()||a)&&(n=De(e,t,r,1,0,e.tokenStart))),e.assignable=2,e.finishNode({type:"YieldExpression",argument:n,delegate:a},i)}return 1&t&&e.report(97,"yield"),dt(e,t,r)}(e,t,r,a,i,c);case 209005:return function(e,t,r,n,o,i,a,s){const c=e.getToken(),l=rt(e,t),{flags:u}=e;if(!(1&u)){if(86104===e.getToken())return it(e,t,r,1,n,s);if(H(t,e.getToken()))return o||e.report(0),36864&~e.getToken()||(e.flags|=256),bt(e,t,r,i,s)}return a||67174411!==e.getToken()?10===e.getToken()?(X(e,t,c),a&&e.report(51),36864&~c||(e.flags|=256),gt(e,t,r,e.tokenValue,l,a,i,0,s)):(e.assignable=1,l):wt(e,t,r,l,i,1,0,u,s)}(e,t,r,a,s,i,o,c)}const{tokenValue:l}=e,u=e.getToken(),p=rt(e,64|t);return 10===e.getToken()?(s||e.report(0),X(e,t,u),36864&~u||(e.flags|=256),gt(e,t,r,l,p,o,i,0,c)):(!(16&t)||32768&t||8192&t||"arguments"!==e.tokenValue||e.report(130),73==(255&u)&&(1&t&&e.report(113),24&n&&e.report(100)),e.assignable=1&t&&!(537079808&~u)?2:1,p)}if(!(134217728&~e.getToken()))return nt(e,t);switch(e.getToken()){case 33619993:case 33619994:return function(e,t,r,n,o,i){n&&e.report(56),o||e.report(0);const a=e.getToken();ee(e,32|t);const s=je(e,t,r,0,0,1);return 2&e.assignable&&e.report(55),e.assignable=2,e.finishNode({type:"UpdateExpression",argument:s,operator:D[255&a],prefix:!0},i)}(e,t,r,o,s,c);case 16863276:case 16842798:case 16842799:case 25233968:case 25233969:case 16863275:case 16863277:return function(e,t,r,n,o){n||e.report(0);const{tokenStart:i}=e,a=e.getToken();ee(e,32|t);const s=je(e,t,r,0,o,1);var c;return 8391735===e.getToken()&&e.report(33),1&t&&16863276===a&&("Identifier"===s.type?e.report(121):(c=s).property&&"PrivateIdentifier"===c.property.type&&e.report(127)),e.assignable=2,e.finishNode({type:"UnaryExpression",operator:D[255&a],argument:s,prefix:!0},i)}(e,t,r,s,a);case 86104:return it(e,t,r,0,a,c);case 2162700:return function(e,t,r,n,o){const i=ut(e,t,void 0,r,n,o,0,2,0);64&e.destructible&&e.report(63);8&e.destructible&&e.report(62);return i}(e,t,r,i?0:1,a);case 69271571:return function(e,t,r,n,o){const i=at(e,t,void 0,r,n,o,0,2,0);64&e.destructible&&e.report(63);8&e.destructible&&e.report(62);return i}(e,t,r,i?0:1,a);case 67174411:return function(e,t,r,n,o,i,a){e.flags=128^(128|e.flags);const s=e.tokenStart;ee(e,262176|t);const c=e.createScopeIfLexical()?.createChildScope(512);if(t=131072^(131072|t),U(e,t,16))return ft(e,t,c,r,[],n,0,a);let l,u=0;e.destructible&=-385;let p=[],d=0,g=0,f=0;const h=e.tokenStart;e.assignable=1;for(;16!==e.getToken();){const{tokenStart:n}=e,a=e.getToken();if(143360&a)c?.addBlockName(t,e.tokenValue,1,0),537079808&~a?36864&~a||(f=1):g=1,l=Je(e,t,r,o,0,1,1,1,n),16===e.getToken()||18===e.getToken()?2&e.assignable&&(u|=16,g=1):(1077936155===e.getToken()?g=1:u|=16,l=Fe(e,t,r,l,1,0,n),16!==e.getToken()&&18!==e.getToken()&&(l=Re(e,t,r,1,0,n,l)));else{if(2097152&~a){if(14===a){l=ct(e,t,c,r,16,o,i,0,1,0),16&e.destructible&&e.report(74),g=1,!d||16!==e.getToken()&&18!==e.getToken()||p.push(l),u|=8;break}if(u|=16,l=De(e,t,r,1,1,n),!d||16!==e.getToken()&&18!==e.getToken()||p.push(l),18===e.getToken()&&(d||(d=1,p=[l])),d){for(;U(e,32|t,18);)p.push(De(e,t,r,1,1,e.tokenStart));e.assignable=2,l=e.finishNode({type:"SequenceExpression",expressions:p},h)}return O(e,t,16),e.destructible=u,e.options.preserveParens?e.finishNode({type:"ParenthesizedExpression",expression:l},s):l}l=2162700===a?ut(e,262144|t,c,r,0,1,0,o,i):at(e,262144|t,c,r,0,1,0,o,i),u|=e.destructible,g=1,e.assignable=2,16!==e.getToken()&&18!==e.getToken()&&(8&u&&e.report(122),l=Fe(e,t,r,l,0,0,n),u|=16,16!==e.getToken()&&18!==e.getToken()&&(l=Re(e,t,r,0,0,n,l)))}if(!d||16!==e.getToken()&&18!==e.getToken()||p.push(l),!U(e,32|t,18))break;if(d||(d=1,p=[l]),16===e.getToken()){u|=8;break}}d&&(e.assignable=2,l=e.finishNode({type:"SequenceExpression",expressions:p},h));O(e,t,16),16&u&&8&u&&e.report(151);if(u|=256&e.destructible?256:128&e.destructible?128:0,10===e.getToken())return 48&u&&e.report(49),2050&t&&128&u&&e.report(31),1025&t&&256&u&&e.report(32),g&&(e.flags|=128),f&&(e.flags|=256),ft(e,t,c,r,d?p:[l],n,0,a);64&u&&e.report(63);8&u&&e.report(144);return e.destructible=256^(256|e.destructible)|u,e.options.preserveParens?e.finishNode({type:"ParenthesizedExpression",expression:l},s):l}(e,64|t,r,i,1,0,c);case 86021:case 86022:case 86023:return function(e,t){const r=e.tokenStart,n=D[255&e.getToken()],o=86023===e.getToken()?null:"true"===n;return ee(e,t),e.assignable=2,e.finishNode(e.options.raw?{type:"Literal",value:o,raw:n}:{type:"Literal",value:o},r)}(e,t);case 86111:return function(e,t){const{tokenStart:r}=e;return ee(e,t),e.assignable=2,e.finishNode({type:"ThisExpression"},r)}(e,t);case 65540:return function(e,t){const{tokenRaw:r,tokenRegExp:n,tokenValue:o,tokenStart:i}=e;ee(e,t),e.assignable=2;const a={type:"Literal",value:o,regex:n};e.options.raw&&(a.raw=r);return e.finishNode(a,i)}(e,t);case 132:case 86094:return function(e,t,r,n,o){let i=null,a=null;const s=Tt(e,t,r);t=16384^(16385|t),ee(e,t),4096&e.getToken()&&20565!==e.getToken()&&(G(e,t,e.getToken())&&e.report(118),537079808&~e.getToken()||e.report(119),i=rt(e,t));let c=t;U(e,32|t,20565)?(a=je(e,t,r,0,n,0),c|=512):c=512^(512|c);const l=St(e,c,t,void 0,r,2,0,n);return e.assignable=2,e.finishNode({type:"ClassExpression",id:i,superClass:a,body:l,...e.options.next?{decorators:s}:null},o)}(e,t,r,a,c);case 86109:return function(e,t){const{tokenStart:r}=e;switch(ee(e,t),e.getToken()){case 67108990:e.report(167);case 67174411:512&t||e.report(28),e.assignable=2;break;case 69271571:case 67108877:256&t||e.report(29),e.assignable=1;break;default:e.report(30,"super")}return e.finishNode({type:"Super"},r)}(e,t);case 67174409:return Ze(e,t);case 67174408:return Ke(e,t,r);case 86107:return function(e,t,r,n){const{tokenStart:o}=e,i=rt(e,32|t),{tokenStart:a}=e;if(U(e,t,67108877)){if(65536&t&&209029===e.getToken())return e.assignable=2,function(e,t,r,n){const o=rt(e,t);return e.finishNode({type:"MetaProperty",meta:r,property:o},n)}(e,t,i,o);e.report(94)}e.assignable=2,16842752&~e.getToken()||e.report(65,D[255&e.getToken()]);const s=Je(e,t,r,2,1,0,n,1,a);t=131072^(131072|t),67108990===e.getToken()&&e.report(168);const c=mt(e,t,r,s,n,a);return e.assignable=2,e.finishNode({type:"NewExpression",callee:c,arguments:67174411===e.getToken()?tt(e,t,r,n):[]},o)}(e,t,r,a);case 134283388:return Ye(e,t);case 130:return Ct(e,t,r,0);case 86106:return function(e,t,r,n,o,i){let a=rt(e,t);if(67108877===e.getToken())return ze(e,t,a,i);n&&e.report(142);return a=He(e,t,r,o,i),e.assignable=2,Fe(e,t,r,a,o,0,i)}(e,t,r,o,a,c);case 8456256:if(e.options.jsx)return Lt(e,t,r,0,e.tokenStart);default:if(H(t,e.getToken()))return dt(e,t,r);e.report(30,D[255&e.getToken()])}}function ze(e,t,r,n){2&t||e.report(169),ee(e,t);const o=e.getToken();return 209030!==o&&"meta"!==e.tokenValue?e.report(174):-2147483648&o&&e.report(175),e.assignable=2,e.finishNode({type:"MetaProperty",meta:r,property:rt(e,t)},n)}function He(e,t,r,n,o){O(e,32|t,67174411),14===e.getToken()&&e.report(143);const i=De(e,t,r,1,n,e.tokenStart);let a=null;if(18===e.getToken()){if(O(e,t,18),16!==e.getToken()){a=De(e,131072^(131072|t),r,1,n,e.tokenStart)}U(e,t,18)}const s={type:"ImportExpression",source:i,options:a};return O(e,t,16),e.finishNode(s,o)}function Xe(e,t){if(!U(e,t,20579))return[];O(e,t,2162700);const r=[],n=new Set;for(;1074790415!==e.getToken();){const o=e.tokenStart,i=We(e,t);O(e,t,21);const a=$e(e,t),s="Literal"===i.type?i.value:i.name;n.has(s)&&e.report(145,`${s}`),n.add(s),r.push(e.finishNode({type:"ImportAttribute",key:i,value:a},o)),1074790415!==e.getToken()&&O(e,t,18)}return O(e,t,1074790415),r}function $e(e,t){if(134283267===e.getToken())return nt(e,t);e.report(30,D[255&e.getToken()])}function We(e,t){return 134283267===e.getToken()?nt(e,t):143360&e.getToken()?rt(e,t):void e.report(30,D[255&e.getToken()])}function _e(e,t){return 134283267===e.getToken()?(function(e,t){const r=t.length;for(let n=0;n<r;n++){const o=t.charCodeAt(n);55296==(64512&o)&&(o>56319||++n>=r||56320!=(64512&t.charCodeAt(n)))&&e.report(171,JSON.stringify(t.charAt(n--)))}}(e,e.tokenValue),nt(e,t)):143360&e.getToken()?rt(e,t):void e.report(30,D[255&e.getToken()])}function Ye(e,t){const{tokenRaw:r,tokenValue:n,tokenStart:o}=e;ee(e,t),e.assignable=2;const i={type:"Literal",value:n,bigint:String(n)};return e.options.raw&&(i.raw=r),e.finishNode(i,o)}function Ze(e,t){e.assignable=2;const{tokenValue:r,tokenRaw:n,tokenStart:o}=e;O(e,t,67174409);const i=[Qe(e,r,n,o,!0)];return e.finishNode({type:"TemplateLiteral",expressions:[],quasis:i},o)}function Ke(e,t,r){t=131072^(131072|t);const{tokenValue:n,tokenRaw:o,tokenStart:i}=e;O(e,-65&t|32,67174408);const a=[Qe(e,n,o,i,!1)],s=[Pe(e,-65&t,r,0,1,e.tokenStart)];for(1074790415!==e.getToken()&&e.report(83);67174409!==e.setToken(q(e,t),!0);){const{tokenValue:n,tokenRaw:o,tokenStart:i}=e;O(e,-65&t|32,67174408),a.push(Qe(e,n,o,i,!1)),s.push(Pe(e,t,r,0,1,e.tokenStart)),1074790415!==e.getToken()&&e.report(83)}{const{tokenValue:r,tokenRaw:n,tokenStart:o}=e;O(e,t,67174409),a.push(Qe(e,r,n,o,!0))}return e.finishNode({type:"TemplateLiteral",expressions:s,quasis:a},i)}function Qe(e,t,r,n,o){const i=e.finishNode({type:"TemplateElement",value:{cooked:t,raw:r},tail:o},n),a=o?1:2;return e.options.ranges&&(i.start+=1,i.range[0]+=1,i.end-=a,i.range[1]-=a),e.options.loc&&(i.loc.start.column+=1,i.loc.end.column-=a),i}function et(e,t,r){const n=e.tokenStart;O(e,32|(t=131072^(131072|t)),14);const o=De(e,t,r,1,0,e.tokenStart);return e.assignable=1,e.finishNode({type:"SpreadElement",argument:o},n)}function tt(e,t,r,n){ee(e,32|t);const o=[];if(16===e.getToken())return ee(e,64|t),o;for(;16!==e.getToken()&&(14===e.getToken()?o.push(et(e,t,r)):o.push(De(e,t,r,1,n,e.tokenStart)),18===e.getToken())&&(ee(e,32|t),16!==e.getToken()););return O(e,64|t,16),o}function rt(e,t){const{tokenValue:r,tokenStart:n}=e,o="await"===r&&!(-2147483648&e.getToken());return ee(e,t|(o?32:0)),e.finishNode({type:"Identifier",name:r},n)}function nt(e,t){const{tokenValue:r,tokenRaw:n,tokenStart:o}=e;return 134283388===e.getToken()?Ye(e,t):(ee(e,t),e.assignable=2,e.finishNode(e.options.raw?{type:"Literal",value:r,raw:n}:{type:"Literal",value:r},o))}function ot(e,t,r,n,o,i,a,s,c){ee(e,32|t);const l=i?B(e,t,8391476):0;let u,p=null,d=r?e.createScope():void 0;if(67174411===e.getToken())1&a||e.report(39,"Function");else{const n=!(4&o)||8&t&&2&t?64|(s?1024:0)|(l?1024:0):4;F(e,t,e.getToken()),r&&(4&n?r.addVarName(t,e.tokenValue,n):r.addBlockName(t,e.tokenValue,n,o),d=d?.createChildScope(128),a&&2&a&&e.declareUnboundVariable(e.tokenValue)),u=e.getToken(),143360&e.getToken()?p=rt(e,t):e.report(30,D[255&e.getToken()])}{const e=28416;t=(t|e)^e|65536|(s?2048:0)|(l?1024:0)|(l?0:262144)}d=d?.createChildScope(256);const g=kt(e,-524289&t|8192,d,n,0,1),f=524428,h=Me(e,36864|(t|f)^f,d?.createChildScope(64),n,8,u,d);return e.finishNode({type:"FunctionDeclaration",id:p,params:g,body:h,async:1===s,generator:1===l},c)}function it(e,t,r,n,o,i){ee(e,32|t);const a=B(e,t,8391476),s=(n?2048:0)|(a?1024:0);let c,l=null,u=e.createScopeIfLexical();const p=552704;143360&e.getToken()&&(F(e,(t|p)^p|s,e.getToken()),u=u?.createChildScope(128),c=e.getToken(),l=rt(e,t)),t=(t|p)^p|65536|s|(a?0:262144),u=u?.createChildScope(256);const d=kt(e,-524289&t|8192,u,r,o,1),g=Me(e,36864|-131229&t,u?.createChildScope(64),r,0,c,u);return e.assignable=2,e.finishNode({type:"FunctionExpression",id:l,params:d,body:g,async:1===n,generator:1===a},i)}function at(e,t,r,n,o,i,a,s,c){const{tokenStart:l}=e;ee(e,32|t);const u=[];let p=0;for(t=131072^(131072|t);20!==e.getToken();)if(U(e,32|t,18))u.push(null);else{let o;const{tokenStart:l,tokenValue:d}=e,g=e.getToken();if(143360&g)if(o=Je(e,t,n,s,0,1,i,1,l),1077936155===e.getToken()){2&e.assignable&&e.report(26),ee(e,32|t),r?.addVarOrBlock(t,d,s,c);const u=De(e,t,n,1,i,e.tokenStart);o=e.finishNode(a?{type:"AssignmentPattern",left:o,right:u}:{type:"AssignmentExpression",operator:"=",left:o,right:u},l),p|=256&e.destructible?256:128&e.destructible?128:0}else 18===e.getToken()||20===e.getToken()?(2&e.assignable?p|=16:r?.addVarOrBlock(t,d,s,c),p|=256&e.destructible?256:128&e.destructible?128:0):(p|=1&s?32:2&s?0:16,o=Fe(e,t,n,o,i,0,l),18!==e.getToken()&&20!==e.getToken()?(1077936155!==e.getToken()&&(p|=16),o=Re(e,t,n,i,a,l,o)):1077936155!==e.getToken()&&(p|=2&e.assignable?16:32));else 2097152&g?(o=2162700===e.getToken()?ut(e,t,r,n,0,i,a,s,c):at(e,t,r,n,0,i,a,s,c),p|=e.destructible,e.assignable=16&e.destructible?2:1,18===e.getToken()||20===e.getToken()?2&e.assignable&&(p|=16):8&e.destructible?e.report(71):(o=Fe(e,t,n,o,i,0,l),p=2&e.assignable?16:0,18!==e.getToken()&&20!==e.getToken()?o=Re(e,t,n,i,a,l,o):1077936155!==e.getToken()&&(p|=2&e.assignable?16:32))):14===g?(o=ct(e,t,r,n,20,s,c,0,i,a),p|=e.destructible,18!==e.getToken()&&20!==e.getToken()&&e.report(30,D[255&e.getToken()])):(o=je(e,t,n,1,0,1),18!==e.getToken()&&20!==e.getToken()?(o=Re(e,t,n,i,a,l,o),3&s||67174411!==g||(p|=16)):2&e.assignable?p|=16:67174411===g&&(p|=1&e.assignable&&3&s?32:16));if(u.push(o),!U(e,32|t,18))break;if(20===e.getToken())break}O(e,t,20);const d=e.finishNode({type:a?"ArrayPattern":"ArrayExpression",elements:u},l);return!o&&4194304&e.getToken()?st(e,t,n,p,i,a,l,d):(e.destructible=p,d)}function st(e,t,r,n,o,i,a,s){1077936155!==e.getToken()&&e.report(26),ee(e,32|t),16&n&&e.report(26),i||M(e,s);const{tokenStart:c}=e,l=De(e,t,r,1,o,c);return e.destructible=72^(72|n)|(128&e.destructible?128:0)|(256&e.destructible?256:0),e.finishNode(i?{type:"AssignmentPattern",left:s,right:l}:{type:"AssignmentExpression",left:s,operator:"=",right:l},a)}function ct(e,t,r,n,o,i,a,s,c,l){const{tokenStart:u}=e;ee(e,32|t);let p=null,d=0;const{tokenValue:g,tokenStart:f}=e;let h=e.getToken();if(143360&h)e.assignable=1,p=Je(e,t,n,i,0,1,c,1,f),h=e.getToken(),p=Fe(e,t,n,p,c,0,f),18!==e.getToken()&&e.getToken()!==o&&(2&e.assignable&&1077936155===e.getToken()&&e.report(71),d|=16,p=Re(e,t,n,c,l,f,p)),2&e.assignable?d|=16:h===o||18===h?r?.addVarOrBlock(t,g,i,a):d|=32,d|=128&e.destructible?128:0;else if(h===o)e.report(41);else{if(!(2097152&h)){d|=32,p=je(e,t,n,1,c,1);const{tokenStart:r}=e,i=e.getToken();return 1077936155===i?(2&e.assignable&&e.report(26),p=Re(e,t,n,c,l,r,p),d|=16):(18===i?d|=16:i!==o&&(p=Re(e,t,n,c,l,r,p)),d|=1&e.assignable?32:16),e.destructible=d,e.getToken()!==o&&18!==e.getToken()&&e.report(161),e.finishNode({type:l?"RestElement":"SpreadElement",argument:p},u)}p=2162700===e.getToken()?ut(e,t,r,n,1,c,l,i,a):at(e,t,r,n,1,c,l,i,a),h=e.getToken(),1077936155!==h&&h!==o&&18!==h?(8&e.destructible&&e.report(71),p=Fe(e,t,n,p,c,0,f),d|=2&e.assignable?16:0,4194304&~e.getToken()?(8388608&~e.getToken()||(p=Oe(e,t,n,1,f,4,h,p)),U(e,32|t,22)&&(p=Ue(e,t,n,p,f)),d|=2&e.assignable?16:32):(1077936155!==e.getToken()&&(d|=16),p=Re(e,t,n,c,l,f,p))):d|=1074790415===o&&1077936155!==h?16:e.destructible}if(e.getToken()!==o)if(1&i&&(d|=s?16:32),U(e,32|t,1077936155)){16&d&&e.report(26),M(e,p);const r=De(e,t,n,1,c,e.tokenStart);p=e.finishNode(l?{type:"AssignmentPattern",left:p,right:r}:{type:"AssignmentExpression",left:p,operator:"=",right:r},f),d=16}else d|=16;return e.destructible=d,e.finishNode({type:l?"RestElement":"SpreadElement",argument:p},u)}function lt(e,t,r,n,o,i){const a=11264|(64&n?0:16896);t=98560|((t|a)^a|(8&n?1024:0)|(16&n?2048:0)|(64&n?16384:0));let s=e.createScopeIfLexical(256);const c=function(e,t,r,n,o,i,a){O(e,t,67174411);const s=[];if(e.flags=128^(128|e.flags),16===e.getToken())return 512&o&&e.report(37,"Setter","one",""),ee(e,t),s;256&o&&e.report(37,"Getter","no","s");512&o&&14===e.getToken()&&e.report(38);t=131072^(131072|t);let c=0,l=0;for(;18!==e.getToken();){let u=null;const{tokenStart:p}=e;if(143360&e.getToken()?(1&t||(36864&~e.getToken()||(e.flags|=256),537079808&~e.getToken()||(e.flags|=512)),u=Nt(e,t,r,1|o,0)):(2162700===e.getToken()?u=ut(e,t,r,n,1,a,1,i,0):69271571===e.getToken()?u=at(e,t,r,n,1,a,1,i,0):14===e.getToken()&&(u=ct(e,t,r,n,16,i,0,0,a,1)),l=1,48&e.destructible&&e.report(50)),1077936155===e.getToken()){ee(e,32|t),l=1;const r=De(e,t,n,1,0,e.tokenStart);u=e.finishNode({type:"AssignmentPattern",left:u,right:r},p)}if(c++,s.push(u),!U(e,t,18))break;if(16===e.getToken())break}512&o&&1!==c&&e.report(37,"Setter","one","");r?.reportScopeError(),l&&(e.flags|=128);return O(e,t,16),s}(e,-524289&t|8192,s,r,n,1,o);s=s?.createChildScope(64);const l=Me(e,36864|-655373&t,s,r,0,void 0,s?.parent);return e.finishNode({type:"FunctionExpression",params:c,body:l,async:(16&n)>0,generator:(8&n)>0,id:null},i)}function ut(e,t,r,n,o,i,a,s,c){const{tokenStart:l}=e;ee(e,t);const u=[];let p=0,d=0;for(t=131072^(131072|t);1074790415!==e.getToken();){const{tokenValue:o,tokenStart:l}=e,g=e.getToken();if(14===g)u.push(ct(e,t,r,n,1074790415,s,c,0,i,a));else{let f,h=0,k=null;if(143360&e.getToken()||-2147483528===e.getToken()||-2147483527===e.getToken())if(-2147483527===e.getToken()&&(p|=16),k=rt(e,t),18===e.getToken()||1074790415===e.getToken()||1077936155===e.getToken())if(h|=4,1&t&&!(537079808&~g)?p|=16:j(e,t,s,g,0),r?.addVarOrBlock(t,o,s,c),U(e,32|t,1077936155)){p|=8;const r=De(e,t,n,1,i,e.tokenStart);p|=256&e.destructible?256:128&e.destructible?128:0,f=e.finishNode({type:"AssignmentPattern",left:e.options.uniqueKeyInPattern?Object.assign({},k):k,right:r},l)}else p|=(209006===g?128:0)|(-2147483528===g?16:0),f=e.options.uniqueKeyInPattern?Object.assign({},k):k;else if(U(e,32|t,21)){const{tokenStart:l}=e;if("__proto__"===o&&d++,143360&e.getToken()){const o=e.getToken(),u=e.tokenValue;f=Je(e,t,n,s,0,1,i,1,l);const d=e.getToken();f=Fe(e,t,n,f,i,0,l),18===e.getToken()||1074790415===e.getToken()?1077936155===d||1074790415===d||18===d?(p|=128&e.destructible?128:0,2&e.assignable?p|=16:143360&~o||r?.addVarOrBlock(t,u,s,c)):p|=1&e.assignable?32:16:4194304&~e.getToken()?(p|=16,8388608&~e.getToken()||(f=Oe(e,t,n,1,l,4,d,f)),U(e,32|t,22)&&(f=Ue(e,t,n,f,l))):(2&e.assignable?p|=16:1077936155!==d?p|=32:r?.addVarOrBlock(t,u,s,c),f=Re(e,t,n,i,a,l,f))}else 2097152&~e.getToken()?(f=je(e,t,n,1,i,1),p|=1&e.assignable?32:16,18===e.getToken()||1074790415===e.getToken()?2&e.assignable&&(p|=16):(f=Fe(e,t,n,f,i,0,l),p=2&e.assignable?16:0,18!==e.getToken()&&1074790415!==g&&(1077936155!==e.getToken()&&(p|=16),f=Re(e,t,n,i,a,l,f)))):(f=69271571===e.getToken()?at(e,t,r,n,0,i,a,s,c):ut(e,t,r,n,0,i,a,s,c),p=e.destructible,e.assignable=16&p?2:1,18===e.getToken()||1074790415===e.getToken()?2&e.assignable&&(p|=16):8&e.destructible?e.report(71):(f=Fe(e,t,n,f,i,0,l),p=2&e.assignable?16:0,4194304&~e.getToken()?(8388608&~e.getToken()||(f=Oe(e,t,n,1,l,4,g,f)),U(e,32|t,22)&&(f=Ue(e,t,n,f,l)),p|=2&e.assignable?16:32):f=Be(e,t,n,i,a,l,f)))}else 69271571===e.getToken()?(p|=16,209005===g&&(h|=16),h|=2|(209008===g?256:209009===g?512:1),k=pt(e,t,n,i),p|=e.assignable,f=lt(e,t,n,h,i,e.tokenStart)):143360&e.getToken()?(p|=16,-2147483528===g&&e.report(95),209005===g?(1&e.flags&&e.report(132),h|=17):209008===g?h|=256:209009===g?h|=512:e.report(0),k=rt(e,t),f=lt(e,t,n,h,i,e.tokenStart)):67174411===e.getToken()?(p|=16,h|=1,f=lt(e,t,n,h,i,e.tokenStart)):8391476===e.getToken()?(p|=16,209008===g?e.report(42):209009===g?e.report(43):209005!==g&&e.report(30,D[52]),ee(e,t),h|=9|(209005===g?16:0),143360&e.getToken()?k=rt(e,t):134217728&~e.getToken()?69271571===e.getToken()?(h|=2,k=pt(e,t,n,i),p|=e.assignable):e.report(30,D[255&e.getToken()]):k=nt(e,t),f=lt(e,t,n,h,i,e.tokenStart)):134217728&~e.getToken()?e.report(133):(209005===g&&(h|=16),h|=209008===g?256:209009===g?512:1,p|=16,k=nt(e,t),f=lt(e,t,n,h,i,e.tokenStart));else if(134217728&~e.getToken())if(69271571===e.getToken())if(k=pt(e,t,n,i),p|=256&e.destructible?256:0,h|=2,21===e.getToken()){ee(e,32|t);const{tokenStart:o,tokenValue:l}=e,u=e.getToken();if(143360&e.getToken()){f=Je(e,t,n,s,0,1,i,1,o);const d=e.getToken();f=Fe(e,t,n,f,i,0,o),4194304&~e.getToken()?18===e.getToken()||1074790415===e.getToken()?1077936155===d||1074790415===d||18===d?2&e.assignable?p|=16:143360&~u||r?.addVarOrBlock(t,l,s,c):p|=1&e.assignable?32:16:(p|=16,f=Re(e,t,n,i,a,o,f)):(p|=2&e.assignable?16:1077936155===d?0:32,f=Be(e,t,n,i,a,o,f))}else 2097152&~e.getToken()?(f=je(e,t,n,1,0,1),p|=1&e.assignable?32:16,18===e.getToken()||1074790415===e.getToken()?2&e.assignable&&(p|=16):(f=Fe(e,t,n,f,i,0,o),p=1&e.assignable?0:16,18!==e.getToken()&&1074790415!==e.getToken()&&(1077936155!==e.getToken()&&(p|=16),f=Re(e,t,n,i,a,o,f)))):(f=69271571===e.getToken()?at(e,t,r,n,0,i,a,s,c):ut(e,t,r,n,0,i,a,s,c),p=e.destructible,e.assignable=16&p?2:1,18===e.getToken()||1074790415===e.getToken()?2&e.assignable&&(p|=16):8&p?e.report(62):(f=Fe(e,t,n,f,i,0,o),p=2&e.assignable?16|p:0,4194304&~e.getToken()?(8388608&~e.getToken()||(f=Oe(e,t,n,1,o,4,g,f)),U(e,32|t,22)&&(f=Ue(e,t,n,f,o)),p|=2&e.assignable?16:32):(1077936155!==e.getToken()&&(p|=16),f=Be(e,t,n,i,a,o,f))))}else 67174411===e.getToken()?(h|=1,f=lt(e,t,n,h,i,e.tokenStart),p=16):e.report(44);else if(8391476===g)if(O(e,32|t,8391476),h|=8,143360&e.getToken()){const r=e.getToken();if(k=rt(e,t),h|=1,67174411!==e.getToken())throw new L(e.tokenStart,e.currentLocation,209005===r?46:209008===r||209009===e.getToken()?45:47,D[255&r]);p|=16,f=lt(e,t,n,h,i,e.tokenStart)}else 134217728&~e.getToken()?69271571===e.getToken()?(p|=16,h|=3,k=pt(e,t,n,i),f=lt(e,t,n,h,i,e.tokenStart)):e.report(126):(p|=16,k=nt(e,t),h|=1,f=lt(e,t,n,h,i,e.tokenStart));else e.report(30,D[255&g]);else if(k=nt(e,t),21===e.getToken()){O(e,32|t,21);const{tokenStart:l}=e;if("__proto__"===o&&d++,143360&e.getToken()){f=Je(e,t,n,s,0,1,i,1,l);const{tokenValue:o}=e,u=e.getToken();f=Fe(e,t,n,f,i,0,l),18===e.getToken()||1074790415===e.getToken()?1077936155===u||1074790415===u||18===u?2&e.assignable?p|=16:r?.addVarOrBlock(t,o,s,c):p|=1&e.assignable?32:16:1077936155===e.getToken()?(2&e.assignable&&(p|=16),f=Re(e,t,n,i,a,l,f)):(p|=16,f=Re(e,t,n,i,a,l,f))}else 2097152&~e.getToken()?(f=je(e,t,n,1,0,1),p|=1&e.assignable?32:16,18===e.getToken()||1074790415===e.getToken()?2&e.assignable&&(p|=16):(f=Fe(e,t,n,f,i,0,l),p=1&e.assignable?0:16,18!==e.getToken()&&1074790415!==e.getToken()&&(1077936155!==e.getToken()&&(p|=16),f=Re(e,t,n,i,a,l,f)))):(f=69271571===e.getToken()?at(e,t,r,n,0,i,a,s,c):ut(e,t,r,n,0,i,a,s,c),p=e.destructible,e.assignable=16&p?2:1,18===e.getToken()||1074790415===e.getToken()?2&e.assignable&&(p|=16):8&~e.destructible&&(f=Fe(e,t,n,f,i,0,l),p=2&e.assignable?16:0,4194304&~e.getToken()?(8388608&~e.getToken()||(f=Oe(e,t,n,1,l,4,g,f)),U(e,32|t,22)&&(f=Ue(e,t,n,f,l)),p|=2&e.assignable?16:32):f=Be(e,t,n,i,a,l,f)))}else 67174411===e.getToken()?(h|=1,f=lt(e,t,n,h,i,e.tokenStart),p=16|e.assignable):e.report(134);p|=128&e.destructible?128:0,e.destructible=p,u.push(e.finishNode({type:"Property",key:k,value:f,kind:768&h?512&h?"set":"get":"init",computed:(2&h)>0,method:(1&h)>0,shorthand:(4&h)>0},l))}if(p|=e.destructible,18!==e.getToken())break;ee(e,t)}O(e,t,1074790415),d>1&&(p|=64);const g=e.finishNode({type:a?"ObjectPattern":"ObjectExpression",properties:u},l);return!o&&4194304&e.getToken()?st(e,t,n,p,i,a,l,g):(e.destructible=p,g)}function pt(e,t,r,n){ee(e,32|t);const o=De(e,131072^(131072|t),r,1,n,e.tokenStart);return O(e,t,20),o}function dt(e,t,r){const{tokenStart:n}=e,{tokenValue:o}=e;let i=0,a=0;537079808&~e.getToken()?36864&~e.getToken()||(a=1):i=1;const s=rt(e,t);if(e.assignable=1,10===e.getToken()){const c=e.options.lexical?le(e,t,o):void 0;return i&&(e.flags|=128),a&&(e.flags|=256),ht(e,t,c,r,[s],0,n)}return s}function gt(e,t,r,n,o,i,a,s,c){a||e.report(57),i&&e.report(51),e.flags&=-129;return ht(e,t,e.options.lexical?le(e,t,n):void 0,r,[o],s,c)}function ft(e,t,r,n,o,i,a,s){i||e.report(57);for(let t=0;t<o.length;++t)M(e,o[t]);return ht(e,t,r,n,o,a,s)}function ht(e,t,r,n,o,i,a){1&e.flags&&e.report(48),O(e,32|t,10);const s=535552;t=(t|s)^s|(i?2048:0);const c=2162700!==e.getToken();let l;if(r?.reportScopeError(),c)e.flags=4928^(4928|e.flags),l=De(e,t,n,1,0,e.tokenStart);else{r=r?.createChildScope(64);const o=131084;switch(l=Me(e,(t|o)^o|4096,r,n,16,void 0,void 0),e.getToken()){case 69271571:1&e.flags||e.report(116);break;case 67108877:case 67174409:case 22:e.report(117);case 67174411:1&e.flags||e.report(116),e.flags|=1024}8388608&~e.getToken()||1&e.flags||e.report(30,D[255&e.getToken()]),33619968&~e.getToken()||e.report(125)}return e.assignable=2,e.finishNode({type:"ArrowFunctionExpression",params:o,body:l,async:1===i,expression:c,generator:!1},a)}function kt(e,t,r,n,o,i){O(e,t,67174411),e.flags=128^(128|e.flags);const a=[];if(U(e,t,16))return a;t=131072^(131072|t);let s=0;for(;18!==e.getToken();){let c;const{tokenStart:l}=e,u=e.getToken();if(143360&u?(1&t||(36864&~u||(e.flags|=256),537079808&~u||(e.flags|=512)),c=Nt(e,t,r,1|i,0)):(2162700===u?c=ut(e,t,r,n,1,o,1,i,0):69271571===u?c=at(e,t,r,n,1,o,1,i,0):14===u?c=ct(e,t,r,n,16,i,0,0,o,1):e.report(30,D[255&u]),s=1,48&e.destructible&&e.report(50)),1077936155===e.getToken()){ee(e,32|t),s=1;const r=De(e,t,n,1,o,e.tokenStart);c=e.finishNode({type:"AssignmentPattern",left:c,right:r},l)}if(a.push(c),!U(e,t,18))break;if(16===e.getToken())break}return s&&(e.flags|=128),(s||1&t)&&r?.reportScopeError(),O(e,t,16),a}function mt(e,t,r,n,o,i){const a=e.getToken();if(67108864&a){if(67108877===a){ee(e,262144|t),e.assignable=1;const o=Ge(e,t,r);return mt(e,t,r,e.finishNode({type:"MemberExpression",object:n,computed:!1,property:o,optional:!1},i),0,i)}if(69271571===a){ee(e,32|t);const{tokenStart:a}=e,s=Pe(e,t,r,o,1,a);return O(e,t,20),e.assignable=1,mt(e,t,r,e.finishNode({type:"MemberExpression",object:n,computed:!0,property:s,optional:!1},i),0,i)}if(67174408===a||67174409===a)return e.assignable=2,mt(e,t,r,e.finishNode({type:"TaggedTemplateExpression",tag:n,quasi:67174408===e.getToken()?Ke(e,64|t,r):Ze(e,64|t)},i),0,i)}return n}function bt(e,t,r,n,o){return 209006===e.getToken()&&e.report(31),1025&t&&241771===e.getToken()&&e.report(32),X(e,t,e.getToken()),36864&~e.getToken()||(e.flags|=256),gt(e,-524289&t|2048,r,e.tokenValue,rt(e,t),0,n,1,o)}function wt(e,t,r,n,o,i,a,s,c){ee(e,32|t);const l=e.createScopeIfLexical()?.createChildScope(512);if(U(e,t=131072^(131072|t),16))return 10===e.getToken()?(1&s&&e.report(48),ft(e,t,l,r,[],o,1,c)):e.finishNode({type:"CallExpression",callee:n,arguments:[],optional:!1},c);let u=0,p=null,d=0;e.destructible=384^(384|e.destructible);const g=[];for(;16!==e.getToken();){const{tokenStart:o}=e,s=e.getToken();if(143360&s)l?.addBlockName(t,e.tokenValue,i,0),537079808&~s?36864&~s||(e.flags|=256):e.flags|=512,p=Je(e,t,r,i,0,1,1,1,o),16===e.getToken()||18===e.getToken()?2&e.assignable&&(u|=16,d=1):(1077936155===e.getToken()?d=1:u|=16,p=Fe(e,t,r,p,1,0,o),16!==e.getToken()&&18!==e.getToken()&&(p=Re(e,t,r,1,0,o,p)));else if(2097152&s)p=2162700===s?ut(e,t,l,r,0,1,0,i,a):at(e,t,l,r,0,1,0,i,a),u|=e.destructible,d=1,16!==e.getToken()&&18!==e.getToken()&&(8&u&&e.report(122),p=Fe(e,t,r,p,0,0,o),u|=16,8388608&~e.getToken()||(p=Oe(e,t,r,1,c,4,s,p)),U(e,32|t,22)&&(p=Ue(e,t,r,p,c)));else{if(14!==s){for(p=De(e,t,r,1,0,o),u=e.assignable,g.push(p);U(e,32|t,18);)g.push(De(e,t,r,1,0,o));return u|=e.assignable,O(e,t,16),e.destructible=16|u,e.assignable=2,e.finishNode({type:"CallExpression",callee:n,arguments:g,optional:!1},c)}p=ct(e,t,l,r,16,i,a,1,1,0),u|=(16===e.getToken()?0:16)|e.destructible,d=1}if(g.push(p),!U(e,32|t,18))break}return O(e,t,16),u|=256&e.destructible?256:128&e.destructible?128:0,10===e.getToken()?(48&u&&e.report(27),(1&e.flags||1&s)&&e.report(48),128&u&&e.report(31),1025&t&&256&u&&e.report(32),d&&(e.flags|=128),ft(e,2048|t,l,r,g,o,1,c)):(64&u&&e.report(63),8&u&&e.report(62),e.assignable=2,e.finishNode({type:"CallExpression",callee:n,arguments:g,optional:!1},c))}function yt(e,t,r,n,o){let i,a;e.leadingDecorators.decorators.length?(132===e.getToken()&&e.report(30,"@"),i=e.leadingDecorators.start,a=[...e.leadingDecorators.decorators],e.leadingDecorators.decorators.length=0):(i=e.tokenStart,a=Tt(e,t,n)),ee(e,t=16384^(16385|t));let s=null,c=null;const{tokenValue:l}=e;4096&e.getToken()&&20565!==e.getToken()?(G(e,t,e.getToken())&&e.report(118),537079808&~e.getToken()||e.report(119),r&&(r.addBlockName(t,l,32,0),o&&2&o&&e.declareUnboundVariable(l)),s=rt(e,t)):1&o||e.report(39,"Class");let u=t;U(e,32|t,20565)?(c=je(e,t,n,0,0,0),u|=512):u=512^(512|u);const p=St(e,u,t,r,n,2,8,0);return e.finishNode({type:"ClassDeclaration",id:s,superClass:c,body:p,...e.options.next?{decorators:a}:null},i)}function Tt(e,t,r){const n=[];if(e.options.next)for(;132===e.getToken();)n.push(xt(e,t,r));return n}function xt(e,t,r){const n=e.tokenStart;ee(e,32|t);let o=Je(e,t,r,2,0,1,0,1,n);return o=Fe(e,t,r,o,0,0,e.tokenStart),e.finishNode({type:"Decorator",expression:o},n)}function St(e,t,r,n,o,i,a,s){const{tokenStart:c}=e,l=e.createPrivateScopeIfLexical(o);O(e,32|t,2162700);const u=655360;t=(t|u)^u;const p=32&e.flags;e.flags=32^(32|e.flags);const d=[];for(;1074790415!==e.getToken();){const o=e.tokenStart,a=Tt(e,t,l);a.length>0&&"constructor"===e.tokenValue&&e.report(109),1074790415===e.getToken()&&e.report(108),U(e,t,1074790417)?a.length>0&&e.report(120):d.push(vt(e,t,n,l,r,i,a,0,s,a.length>0?o:e.tokenStart))}return O(e,8&a?32|t:t,1074790415),l?.validatePrivateIdentifierRefs(),e.flags=-33&e.flags|p,e.finishNode({type:"ClassBody",body:d},c)}function vt(e,t,r,n,o,i,a,s,c,l){let u=s?32:0,p=null;const d=e.getToken();if(176128&d||-2147483528===d)switch(p=rt(e,t),d){case 36970:if(!s&&67174411!==e.getToken()&&1048576&~e.getToken()&&1077936155!==e.getToken())return vt(e,t,r,n,o,i,a,1,c,l);break;case 209005:if(67174411!==e.getToken()&&!(1&e.flags)){if(!(1073741824&~e.getToken()))return Et(e,t,n,p,u,a,l);u|=16|(B(e,t,8391476)?8:0)}break;case 209008:if(67174411!==e.getToken()){if(!(1073741824&~e.getToken()))return Et(e,t,n,p,u,a,l);u|=256}break;case 209009:if(67174411!==e.getToken()){if(!(1073741824&~e.getToken()))return Et(e,t,n,p,u,a,l);u|=512}break;case 12402:if(67174411!==e.getToken()&&!(1&e.flags)){if(!(1073741824&~e.getToken()))return Et(e,t,n,p,u,a,l);e.options.next&&(u|=1024)}}else if(69271571===d)u|=2,p=pt(e,o,n,c);else if(134217728&~d)if(8391476===d)u|=8,ee(e,t);else if(130===e.getToken())u|=8192,p=Ct(e,16|t,n,768);else if(1073741824&~e.getToken()){if(s&&2162700===d)return function(e,t,r,n,o){return r=r?.createChildScope(),ke(e,t=592128|5764^(5764|t),r,n,{},o,"StaticBlock")}(e,16|t,r,n,l);-2147483527===d?(p=rt(e,t),67174411!==e.getToken()&&e.report(30,D[255&e.getToken()])):e.report(30,D[255&e.getToken()])}else u|=128;else p=nt(e,t);if(1816&u&&(143360&e.getToken()||-2147483528===e.getToken()||-2147483527===e.getToken()?p=rt(e,t):134217728&~e.getToken()?69271571===e.getToken()?(u|=2,p=pt(e,t,n,0)):130===e.getToken()?(u|=8192,p=Ct(e,t,n,u)):e.report(135):p=nt(e,t)),2&u||("constructor"===e.tokenValue?(1073741824&~e.getToken()?32&u||67174411!==e.getToken()||(920&u?e.report(53,"accessor"):512&t||(32&e.flags?e.report(54):e.flags|=32)):e.report(129),u|=64):!(8192&u)&&32&u&&"prototype"===e.tokenValue&&e.report(52)),1024&u||67174411!==e.getToken()&&!(768&u))return Et(e,t,n,p,u,a,l);const g=lt(e,16|t,n,u,c,e.tokenStart);return e.finishNode({type:"MethodDefinition",kind:!(32&u)&&64&u?"constructor":256&u?"get":512&u?"set":"method",static:(32&u)>0,computed:(2&u)>0,key:p,value:g,...e.options.next?{decorators:a}:null},l)}function Ct(e,t,r,n){const{tokenStart:o}=e;ee(e,t);const{tokenValue:i}=e;return"constructor"===i&&e.report(128),e.options.lexical&&(r||e.report(4,i),n?r.addPrivateIdentifier(i,n):r.addPrivateIdentifierRef(i)),ee(e,t),e.finishNode({type:"PrivateIdentifier",name:i},o)}function Et(e,t,r,n,o,i,a){let s=null;if(8&o&&e.report(0),1077936155===e.getToken()){ee(e,32|t);const{tokenStart:n}=e;537079927===e.getToken()&&e.report(119);const i=11264|(64&o?0:16896);s=Je(e,16|(t=65792|((t|i)^i|(8&o?1024:0)|(16&o?2048:0)|(64&o?16384:0))),r,2,0,1,0,1,n),!(1073741824&~e.getToken())&&4194304&~e.getToken()||(s=Fe(e,16|t,r,s,0,0,n),s=Re(e,16|t,r,0,0,n,s))}return P(e,t),e.finishNode({type:1024&o?"AccessorProperty":"PropertyDefinition",key:n,value:s,static:(32&o)>0,computed:(2&o)>0,...e.options.next?{decorators:i}:null},a)}function qt(e,t,r,n,o,i){if(143360&e.getToken()||!(1&t)&&-2147483527===e.getToken())return Nt(e,t,r,o,i);2097152&~e.getToken()&&e.report(30,D[255&e.getToken()]);const a=69271571===e.getToken()?at(e,t,r,n,1,0,1,o,i):ut(e,t,r,n,1,0,1,o,i);return 16&e.destructible&&e.report(50),32&e.destructible&&e.report(50),a}function Nt(e,t,r,n,o){const i=e.getToken();1&t&&(537079808&~i?36864&~i&&-2147483527!==i||e.report(118):e.report(119)),20480&~i||e.report(102),241771===i&&(1024&t&&e.report(32),2&t&&e.report(111)),73==(255&i)&&24&n&&e.report(100),209006===i&&(2048&t&&e.report(176),2&t&&e.report(110));const{tokenValue:a,tokenStart:s}=e;return ee(e,t),r?.addVarOrBlock(t,a,n,o),e.finishNode({type:"Identifier",name:a},s)}function Lt(e,t,r,n,o){if(n||O(e,t,8456256),8390721===e.getToken()){const i=function(e,t){return ae(e),e.finishNode({type:"JSXOpeningFragment"},t)}(e,o),[a,s]=function(e,t,r,n){const o=[];for(;;){const i=It(e,t,r,n);if("JSXClosingFragment"===i.type)return[o,i];o.push(i)}}(e,t,r,n);return e.finishNode({type:"JSXFragment",openingFragment:i,children:a,closingFragment:s},o)}8457014===e.getToken()&&e.report(30,D[255&e.getToken()]);let i=null,a=[];const s=function(e,t,r,n,o){143360&~e.getToken()&&4096&~e.getToken()&&e.report(0);const i=Vt(e,t),a=function(e,t,r){const n=[];for(;8457014!==e.getToken()&&8390721!==e.getToken()&&1048576!==e.getToken();)n.push(Rt(e,t,r));return n}(e,t,r),s=8457014===e.getToken();s&&O(e,t,8457014);8390721!==e.getToken()&&e.report(25,D[65]);n||!s?ae(e):ee(e,t);return e.finishNode({type:"JSXOpeningElement",name:i,attributes:a,selfClosing:s},o)}(e,t,r,n,o);if(!s.selfClosing){[a,i]=function(e,t,r,n){const o=[];for(;;){const i=At(e,t,r,n);if("JSXClosingElement"===i.type)return[o,i];o.push(i)}}(e,t,r,n);const o=z(i.name);z(s.name)!==o&&e.report(155,o)}return e.finishNode({type:"JSXElement",children:a,openingElement:s,closingElement:i},o)}function At(e,t,r,n){if(137===e.getToken())return Dt(e,t);if(2162700===e.getToken())return Ut(e,t,r,1,0);if(8456256===e.getToken()){const{tokenStart:o}=e;return ee(e,t),8457014===e.getToken()?function(e,t,r,n){O(e,t,8457014);const o=Vt(e,t);return 8390721!==e.getToken()&&e.report(25,D[65]),r?ae(e):ee(e,t),e.finishNode({type:"JSXClosingElement",name:o},n)}(e,t,n,o):Lt(e,t,r,1,o)}e.report(0)}function It(e,t,r,n){if(137===e.getToken())return Dt(e,t);if(2162700===e.getToken())return Ut(e,t,r,1,0);if(8456256===e.getToken()){const{tokenStart:o}=e;return ee(e,t),8457014===e.getToken()?function(e,t,r,n){return O(e,t,8457014),8390721!==e.getToken()&&e.report(25,D[65]),r?ae(e):ee(e,t),e.finishNode({type:"JSXClosingFragment"},n)}(e,t,n,o):Lt(e,t,r,1,o)}e.report(0)}function Dt(e,t){const r=e.tokenStart;ee(e,t);const n={type:"JSXText",value:e.tokenValue};return e.options.raw&&(n.raw=e.tokenRaw),e.finishNode(n,r)}function Vt(e,t){const{tokenStart:r}=e;se(e);let n=Ot(e,t);if(21===e.getToken())return Bt(e,t,n,r);for(;U(e,t,67108877);)se(e),n=Pt(e,t,n,r);return n}function Pt(e,t,r,n){const o=Ot(e,t);return e.finishNode({type:"JSXMemberExpression",object:r,property:o},n)}function Rt(e,t,r){const{tokenStart:n}=e;if(2162700===e.getToken())return function(e,t,r){const n=e.tokenStart;ee(e,t),O(e,t,14);const o=De(e,t,r,1,0,e.tokenStart);return O(e,t,1074790415),e.finishNode({type:"JSXSpreadAttribute",argument:o},n)}(e,t,r);se(e);let o=null,i=Ot(e,t);if(21===e.getToken()&&(i=Bt(e,t,i,n)),1077936155===e.getToken()){switch(ie(e,t)){case 134283267:o=nt(e,t);break;case 8456256:o=Lt(e,t,r,0,e.tokenStart);break;case 2162700:o=Ut(e,t,r,0,1);break;default:e.report(154)}}return e.finishNode({type:"JSXAttribute",value:o,name:i},n)}function Bt(e,t,r,n){O(e,t,21);const o=Ot(e,t);return e.finishNode({type:"JSXNamespacedName",namespace:r,name:o},n)}function Ut(e,t,r,n,o){const{tokenStart:i}=e;ee(e,32|t);const{tokenStart:a}=e;if(14===e.getToken())return function(e,t,r,n){O(e,t,14);const o=De(e,t,r,1,0,e.tokenStart);return O(e,t,1074790415),e.finishNode({type:"JSXSpreadChild",expression:o},n)}(e,t,r,i);let s=null;return 1074790415===e.getToken()?(o&&e.report(157),s=function(e,t){return e.finishNode({type:"JSXEmptyExpression"},t,e.tokenStart)}(e,{index:e.startIndex,line:e.startLine,column:e.startColumn})):s=De(e,t,r,1,0,a),1074790415!==e.getToken()&&e.report(25,D[15]),n?ae(e):ee(e,t),e.finishNode({type:"JSXExpressionContainer",expression:s},i)}function Ot(e,t){const r=e.tokenStart;143360&e.getToken()||e.report(30,D[255&e.getToken()]);const{tokenValue:n}=e;return ee(e,t),e.finishNode({type:"JSXIdentifier",name:n},r)}const{stringify:Mt}=JSON;if(!String.prototype.repeat)throw new Error("String.prototype.repeat is undefined, see https://github.com/davidbonnet/astring#installation");if(!String.prototype.endsWith)throw new Error("String.prototype.endsWith is undefined, see https://github.com/davidbonnet/astring#installation");const jt={"||":2,"??":3,"&&":4,"|":5,"^":6,"&":7,"==":8,"!=":8,"===":8,"!==":8,"<":9,">":9,"<=":9,">=":9,in:9,instanceof:9,"<<":10,">>":10,">>>":10,"+":11,"-":11,"*":12,"%":12,"/":12,"**":13},Ft=17,Gt={ArrayExpression:20,TaggedTemplateExpression:20,ThisExpression:20,Identifier:20,PrivateIdentifier:20,Literal:18,TemplateLiteral:20,Super:20,SequenceExpression:20,MemberExpression:19,ChainExpression:19,CallExpression:19,NewExpression:19,ArrowFunctionExpression:Ft,ClassExpression:Ft,FunctionExpression:Ft,ObjectExpression:Ft,UpdateExpression:16,UnaryExpression:15,AwaitExpression:15,BinaryExpression:14,LogicalExpression:13,ConditionalExpression:4,AssignmentExpression:3,YieldExpression:2,RestElement:1};function Jt(e,t){const{generator:r}=e;if(e.write("("),null!=t&&t.length>0){r[t[0].type](t[0],e);const{length:n}=t;for(let o=1;o<n;o++){const n=t[o];e.write(", "),r[n.type](n,e)}}e.write(")")}function zt(e,t,r,n){const o=e.expressionsPrecedence[t.type];if(o===Ft)return!0;const i=e.expressionsPrecedence[r.type];return o!==i?!n&&15===o&&14===i&&"**"===r.operator||o<i:(13===o||14===o)&&("**"===t.operator&&"**"===r.operator?!n:13===o&&13===i&&("??"===t.operator||"??"===r.operator)||(n?jt[t.operator]<=jt[r.operator]:jt[t.operator]<jt[r.operator]))}function Ht(e,t,r,n){const{generator:o}=e;zt(e,t,r,n)?(e.write("("),o[t.type](t,e),e.write(")")):o[t.type](t,e)}function Xt(e,t,r,n){const o=t.split("\n"),i=o.length-1;if(e.write(o[0].trim()),i>0){e.write(n);for(let t=1;t<i;t++)e.write(r+o[t].trim()+n);e.write(r+o[i].trim())}}function $t(e,t,r,n){const{length:o}=t;for(let i=0;i<o;i++){const o=t[i];e.write(r),"L"===o.type[0]?e.write("// "+o.value.trim()+"\n",o):(e.write("/*"),Xt(e,o.value,r,n),e.write("*/"+n))}}function Wt(e,t){const{generator:r}=e,{declarations:n}=t;e.write(t.kind+" ");const{length:o}=n;if(o>0){r.VariableDeclarator(n[0],e);for(let t=1;t<o;t++)e.write(", "),r.VariableDeclarator(n[t],e)}}let _t,Yt,Zt,Kt,Qt,er;const tr={Program(e,t){const r=t.indent.repeat(t.indentLevel),{lineEnd:n,writeComments:o}=t;o&&null!=e.comments&&$t(t,e.comments,r,n);const i=e.body,{length:a}=i;for(let e=0;e<a;e++){const a=i[e];o&&null!=a.comments&&$t(t,a.comments,r,n),t.write(r),this[a.type](a,t),t.write(n)}o&&null!=e.trailingComments&&$t(t,e.trailingComments,r,n)},BlockStatement:er=function(e,t){const r=t.indent.repeat(t.indentLevel++),{lineEnd:n,writeComments:o}=t,i=r+t.indent;t.write("{");const a=e.body;if(null!=a&&a.length>0){t.write(n),o&&null!=e.comments&&$t(t,e.comments,i,n);const{length:s}=a;for(let e=0;e<s;e++){const r=a[e];o&&null!=r.comments&&$t(t,r.comments,i,n),t.write(i),this[r.type](r,t),t.write(n)}t.write(r)}else o&&null!=e.comments&&(t.write(n),$t(t,e.comments,i,n),t.write(r));o&&null!=e.trailingComments&&$t(t,e.trailingComments,i,n),t.write("}"),t.indentLevel--},ClassBody:er,StaticBlock(e,t){t.write("static "),this.BlockStatement(e,t)},EmptyStatement(e,t){t.write(";")},ExpressionStatement(e,t){const r=t.expressionsPrecedence[e.expression.type];r===Ft||3===r&&"O"===e.expression.left.type[0]?(t.write("("),this[e.expression.type](e.expression,t),t.write(")")):this[e.expression.type](e.expression,t),t.write(";")},IfStatement(e,t){t.write("if ("),this[e.test.type](e.test,t),t.write(") "),this[e.consequent.type](e.consequent,t),null!=e.alternate&&(t.write(" else "),this[e.alternate.type](e.alternate,t))},LabeledStatement(e,t){this[e.label.type](e.label,t),t.write(": "),this[e.body.type](e.body,t)},BreakStatement(e,t){t.write("break"),null!=e.label&&(t.write(" "),this[e.label.type](e.label,t)),t.write(";")},ContinueStatement(e,t){t.write("continue"),null!=e.label&&(t.write(" "),this[e.label.type](e.label,t)),t.write(";")},WithStatement(e,t){t.write("with ("),this[e.object.type](e.object,t),t.write(") "),this[e.body.type](e.body,t)},SwitchStatement(e,t){const r=t.indent.repeat(t.indentLevel++),{lineEnd:n,writeComments:o}=t;t.indentLevel++;const i=r+t.indent,a=i+t.indent;t.write("switch ("),this[e.discriminant.type](e.discriminant,t),t.write(") {"+n);const{cases:s}=e,{length:c}=s;for(let e=0;e<c;e++){const r=s[e];o&&null!=r.comments&&$t(t,r.comments,i,n),r.test?(t.write(i+"case "),this[r.test.type](r.test,t),t.write(":"+n)):t.write(i+"default:"+n);const{consequent:c}=r,{length:l}=c;for(let e=0;e<l;e++){const r=c[e];o&&null!=r.comments&&$t(t,r.comments,a,n),t.write(a),this[r.type](r,t),t.write(n)}}t.indentLevel-=2,t.write(r+"}")},ReturnStatement(e,t){t.write("return"),e.argument&&(t.write(" "),this[e.argument.type](e.argument,t)),t.write(";")},ThrowStatement(e,t){t.write("throw "),this[e.argument.type](e.argument,t),t.write(";")},TryStatement(e,t){if(t.write("try "),this[e.block.type](e.block,t),e.handler){const{handler:r}=e;null==r.param?t.write(" catch "):(t.write(" catch ("),this[r.param.type](r.param,t),t.write(") ")),this[r.body.type](r.body,t)}e.finalizer&&(t.write(" finally "),this[e.finalizer.type](e.finalizer,t))},WhileStatement(e,t){t.write("while ("),this[e.test.type](e.test,t),t.write(") "),this[e.body.type](e.body,t)},DoWhileStatement(e,t){t.write("do "),this[e.body.type](e.body,t),t.write(" while ("),this[e.test.type](e.test,t),t.write(");")},ForStatement(e,t){if(t.write("for ("),null!=e.init){const{init:r}=e;"V"===r.type[0]?Wt(t,r):this[r.type](r,t)}t.write("; "),e.test&&this[e.test.type](e.test,t),t.write("; "),e.update&&this[e.update.type](e.update,t),t.write(") "),this[e.body.type](e.body,t)},ForInStatement:_t=function(e,t){t.write(`for ${e.await?"await ":""}(`);const{left:r}=e;"V"===r.type[0]?Wt(t,r):this[r.type](r,t),t.write("I"===e.type[3]?" in ":" of "),this[e.right.type](e.right,t),t.write(") "),this[e.body.type](e.body,t)},ForOfStatement:_t,DebuggerStatement(e,t){t.write("debugger;",e)},FunctionDeclaration:Yt=function(e,t){t.write((e.async?"async ":"")+(e.generator?"function* ":"function ")+(e.id?e.id.name:""),e),Jt(t,e.params),t.write(" "),this[e.body.type](e.body,t)},FunctionExpression:Yt,VariableDeclaration(e,t){Wt(t,e),t.write(";")},VariableDeclarator(e,t){this[e.id.type](e.id,t),null!=e.init&&(t.write(" = "),this[e.init.type](e.init,t))},ClassDeclaration(e,t){if(t.write("class "+(e.id?`${e.id.name} `:""),e),e.superClass){t.write("extends ");const{superClass:r}=e,{type:n}=r,o=t.expressionsPrecedence[n];"C"===n[0]&&"l"===n[1]&&"E"===n[5]||!(o===Ft||o<t.expressionsPrecedence.ClassExpression)?this[r.type](r,t):(t.write("("),this[e.superClass.type](r,t),t.write(")")),t.write(" ")}this.ClassBody(e.body,t)},ImportDeclaration(e,t){t.write("import ");const{specifiers:r,attributes:n}=e,{length:o}=r;let i=0;if(o>0){for(;i<o;){i>0&&t.write(", ");const e=r[i],n=e.type[6];if("D"===n)t.write(e.local.name,e),i++;else{if("N"!==n)break;t.write("* as "+e.local.name,e),i++}}if(i<o){for(t.write("{");;){const e=r[i],{name:n}=e.imported;if(t.write(n,e),n!==e.local.name&&t.write(" as "+e.local.name),!(++i<o))break;t.write(", ")}t.write("}")}t.write(" from ")}if(this.Literal(e.source,t),n&&n.length>0){t.write(" with { ");for(let e=0;e<n.length;e++)this.ImportAttribute(n[e],t),e<n.length-1&&t.write(", ");t.write(" }")}t.write(";")},ImportAttribute(e,t){this.Identifier(e.key,t),t.write(": "),this.Literal(e.value,t)},ImportExpression(e,t){t.write("import("),this[e.source.type](e.source,t),t.write(")")},ExportDefaultDeclaration(e,t){t.write("export default "),this[e.declaration.type](e.declaration,t),null!=t.expressionsPrecedence[e.declaration.type]&&"F"!==e.declaration.type[0]&&t.write(";")},ExportNamedDeclaration(e,t){if(t.write("export "),e.declaration)this[e.declaration.type](e.declaration,t);else{t.write("{");const{specifiers:r}=e,{length:n}=r;if(n>0)for(let e=0;;){const o=r[e],{name:i}=o.local;if(t.write(i,o),i!==o.exported.name&&t.write(" as "+o.exported.name),!(++e<n))break;t.write(", ")}if(t.write("}"),e.source&&(t.write(" from "),this.Literal(e.source,t)),e.attributes&&e.attributes.length>0){t.write(" with { ");for(let r=0;r<e.attributes.length;r++)this.ImportAttribute(e.attributes[r],t),r<e.attributes.length-1&&t.write(", ");t.write(" }")}t.write(";")}},ExportAllDeclaration(e,t){if(null!=e.exported?t.write("export * as "+e.exported.name+" from "):t.write("export * from "),this.Literal(e.source,t),e.attributes&&e.attributes.length>0){t.write(" with { ");for(let r=0;r<e.attributes.length;r++)this.ImportAttribute(e.attributes[r],t),r<e.attributes.length-1&&t.write(", ");t.write(" }")}t.write(";")},MethodDefinition(e,t){e.static&&t.write("static ");const r=e.kind[0];"g"!==r&&"s"!==r||t.write(e.kind+" "),e.value.async&&t.write("async "),e.value.generator&&t.write("*"),e.computed?(t.write("["),this[e.key.type](e.key,t),t.write("]")):this[e.key.type](e.key,t),Jt(t,e.value.params),t.write(" "),this[e.value.body.type](e.value.body,t)},ClassExpression(e,t){this.ClassDeclaration(e,t)},ArrowFunctionExpression(e,t){t.write(e.async?"async ":"",e);const{params:r}=e;null!=r&&(1===r.length&&"I"===r[0].type[0]?t.write(r[0].name,r[0]):Jt(t,e.params)),t.write(" => "),"O"===e.body.type[0]?(t.write("("),this.ObjectExpression(e.body,t),t.write(")")):this[e.body.type](e.body,t)},ThisExpression(e,t){t.write("this",e)},Super(e,t){t.write("super",e)},RestElement:Zt=function(e,t){t.write("..."),this[e.argument.type](e.argument,t)},SpreadElement:Zt,YieldExpression(e,t){t.write(e.delegate?"yield*":"yield"),e.argument&&(t.write(" "),this[e.argument.type](e.argument,t))},AwaitExpression(e,t){t.write("await ",e),Ht(t,e.argument,e)},TemplateLiteral(e,t){const{quasis:r,expressions:n}=e;t.write("`");const{length:o}=n;for(let e=0;e<o;e++){const o=n[e],i=r[e];t.write(i.value.raw,i),t.write("${"),this[o.type](o,t),t.write("}")}const i=r[r.length-1];t.write(i.value.raw,i),t.write("`")},TemplateElement(e,t){t.write(e.value.raw,e)},TaggedTemplateExpression(e,t){Ht(t,e.tag,e),this[e.quasi.type](e.quasi,t)},ArrayExpression:Qt=function(e,t){if(t.write("["),e.elements.length>0){const{elements:r}=e,{length:n}=r;for(let e=0;;){const o=r[e];if(null!=o&&this[o.type](o,t),!(++e<n)){null==o&&t.write(", ");break}t.write(", ")}}t.write("]")},ArrayPattern:Qt,ObjectExpression(e,t){const r=t.indent.repeat(t.indentLevel++),{lineEnd:n,writeComments:o}=t,i=r+t.indent;if(t.write("{"),e.properties.length>0){t.write(n),o&&null!=e.comments&&$t(t,e.comments,i,n);const a=","+n,{properties:s}=e,{length:c}=s;for(let e=0;;){const r=s[e];if(o&&null!=r.comments&&$t(t,r.comments,i,n),t.write(i),this[r.type](r,t),!(++e<c))break;t.write(a)}t.write(n),o&&null!=e.trailingComments&&$t(t,e.trailingComments,i,n),t.write(r+"}")}else o?null!=e.comments?(t.write(n),$t(t,e.comments,i,n),null!=e.trailingComments&&$t(t,e.trailingComments,i,n),t.write(r+"}")):null!=e.trailingComments?(t.write(n),$t(t,e.trailingComments,i,n),t.write(r+"}")):t.write("}"):t.write("}");t.indentLevel--},Property(e,t){e.method||"i"!==e.kind[0]?this.MethodDefinition(e,t):(e.shorthand||(e.computed?(t.write("["),this[e.key.type](e.key,t),t.write("]")):this[e.key.type](e.key,t),t.write(": ")),this[e.value.type](e.value,t))},PropertyDefinition(e,t){e.static&&t.write("static "),e.computed&&t.write("["),this[e.key.type](e.key,t),e.computed&&t.write("]"),null!=e.value?(t.write(" = "),this[e.value.type](e.value,t),t.write(";")):"F"!==e.key.type[0]&&t.write(";")},ObjectPattern(e,t){if(t.write("{"),e.properties.length>0){const{properties:r}=e,{length:n}=r;for(let e=0;this[r[e].type](r[e],t),++e<n;)t.write(", ")}t.write("}")},SequenceExpression(e,t){Jt(t,e.expressions)},UnaryExpression(e,t){if(e.prefix){const{operator:r,argument:n,argument:{type:o}}=e;t.write(r);const i=zt(t,n,e);i||!(r.length>1)&&("U"!==o[0]||"n"!==o[1]&&"p"!==o[1]||!n.prefix||n.operator[0]!==r||"+"!==r&&"-"!==r)||t.write(" "),i?(t.write(r.length>1?" (":"("),this[o](n,t),t.write(")")):this[o](n,t)}else this[e.argument.type](e.argument,t),t.write(e.operator)},UpdateExpression(e,t){e.prefix?(t.write(e.operator),this[e.argument.type](e.argument,t)):(this[e.argument.type](e.argument,t),t.write(e.operator))},AssignmentExpression(e,t){this[e.left.type](e.left,t),t.write(" "+e.operator+" "),this[e.right.type](e.right,t)},AssignmentPattern(e,t){this[e.left.type](e.left,t),t.write(" = "),this[e.right.type](e.right,t)},BinaryExpression:Kt=function(e,t){const r="in"===e.operator;r&&t.write("("),Ht(t,e.left,e,!1),t.write(" "+e.operator+" "),Ht(t,e.right,e,!0),r&&t.write(")")},LogicalExpression:Kt,ConditionalExpression(e,t){const{test:r}=e,n=t.expressionsPrecedence[r.type];n===Ft||n<=t.expressionsPrecedence.ConditionalExpression?(t.write("("),this[r.type](r,t),t.write(")")):this[r.type](r,t),t.write(" ? "),this[e.consequent.type](e.consequent,t),t.write(" : "),this[e.alternate.type](e.alternate,t)},NewExpression(e,t){t.write("new ");const r=t.expressionsPrecedence[e.callee.type];r===Ft||r<t.expressionsPrecedence.CallExpression||function(e){let t=e;for(;null!=t;){const{type:e}=t;if("C"===e[0]&&"a"===e[1])return!0;if("M"!==e[0]||"e"!==e[1]||"m"!==e[2])return!1;t=t.object}}(e.callee)?(t.write("("),this[e.callee.type](e.callee,t),t.write(")")):this[e.callee.type](e.callee,t),Jt(t,e.arguments)},CallExpression(e,t){const r=t.expressionsPrecedence[e.callee.type];r===Ft||r<t.expressionsPrecedence.CallExpression?(t.write("("),this[e.callee.type](e.callee,t),t.write(")")):this[e.callee.type](e.callee,t),e.optional&&t.write("?."),Jt(t,e.arguments)},ChainExpression(e,t){this[e.expression.type](e.expression,t)},MemberExpression(e,t){const r=t.expressionsPrecedence[e.object.type];r===Ft||r<t.expressionsPrecedence.MemberExpression?(t.write("("),this[e.object.type](e.object,t),t.write(")")):this[e.object.type](e.object,t),e.computed?(e.optional&&t.write("?."),t.write("["),this[e.property.type](e.property,t),t.write("]")):(e.optional?t.write("?."):t.write("."),this[e.property.type](e.property,t))},MetaProperty(e,t){t.write(e.meta.name+"."+e.property.name,e)},Identifier(e,t){t.write(e.name,e)},PrivateIdentifier(e,t){t.write(`#${e.name}`,e)},Literal(e,t){null!=e.raw?t.write(e.raw,e):null!=e.regex?this.RegExpLiteral(e,t):null!=e.bigint?t.write(e.bigint+"n",e):t.write(Mt(e.value),e)},RegExpLiteral(e,t){const{regex:r}=e;t.write(`/${r.pattern}/${r.flags}`,e)}},rr={};class nr{constructor(e){const t=null==e?rr:e;this.output="",null!=t.output?(this.output=t.output,this.write=this.writeToStream):this.output="",this.generator=null!=t.generator?t.generator:tr,this.expressionsPrecedence=null!=t.expressionsPrecedence?t.expressionsPrecedence:Gt,this.indent=null!=t.indent?t.indent:" ",this.lineEnd=null!=t.lineEnd?t.lineEnd:"\n",this.indentLevel=null!=t.startingIndentLevel?t.startingIndentLevel:0,this.writeComments=!!t.comments&&t.comments,null!=t.sourceMap&&(this.write=null==t.output?this.writeAndMap:this.writeToStreamAndMap,this.sourceMap=t.sourceMap,this.line=1,this.column=0,this.lineEndSize=this.lineEnd.split("\n").length-1,this.mapping={original:null,generated:this,name:void 0,source:t.sourceMap.file||t.sourceMap._file})}write(e){this.output+=e}writeToStream(e){this.output.write(e)}writeAndMap(e,t){this.output+=e,this.map(e,t)}writeToStreamAndMap(e,t){this.output.write(e),this.map(e,t)}map(e,t){if(null!=t){const{type:r}=t;if("L"===r[0]&&"n"===r[2])return this.column=0,void this.line++;if(null!=t.loc){const{mapping:e}=this;e.original=t.loc.start,e.name=t.name,this.sourceMap.addMapping(e)}if("T"===r[0]&&"E"===r[8]||"L"===r[0]&&"i"===r[1]&&"string"==typeof t.value){const{length:t}=e;let{column:r,line:n}=this;for(let o=0;o<t;o++)"\n"===e[o]?(r=0,n++):r++;return this.column=r,void(this.line=n)}}const{length:r}=e,{lineEnd:n}=this;r>0&&(this.lineEndSize>0&&(1===n.length?e[r-1]===n:e.endsWith(n))?(this.line+=this.lineEndSize,this.column=0):this.column+=r)}toString(){return this.output}}const or={parse:function(e,t){return de(e,t)}},ir={generate:function(e,t){const r=new nr(t);return r.generator[e.type](e,r),r.output}};return e.astring=ir,e.meriyah=or,e}({});
\ No newline at end of file
diff --git a/app/src/main/java/dev/lelonio/square/SquareApplication.kt b/app/src/main/java/dev/lelonio/square/SquareApplication.kt
index a6459ac..d2096df 100644
--- a/app/src/main/java/dev/lelonio/square/SquareApplication.kt
+++ b/app/src/main/java/dev/lelonio/square/SquareApplication.kt
@@ -66,7 +66,12 @@ class SquareApplication : Application(), ImageLoaderFactory {
// the difference between a page that opens on the right picture and one
// that opens on Spotify's and changes it a second later.
dev.lelonio.square.data.AppleCatalog.attach(this)
- dev.lelonio.square.backend.lyrics.LyricsLibrary.attach(this)
+ dev.lelonio.square.data.LocalFileBindings.attach(this)
+ dev.lelonio.square.backend.lyrics.LyricsLibrary.attach(
+ this,
+ spicyKey = { preferences.spicyLyricsKey.value },
+ preferred = { preferences.preferredLyricsSource.value },
+ )
// Two things feed the offline state, and one thing reads it out to the
// engine. The switch below is the listener's; the watch is the network
diff --git a/app/src/main/java/dev/lelonio/square/backend/lyrics/LyricsLibrary.kt b/app/src/main/java/dev/lelonio/square/backend/lyrics/LyricsLibrary.kt
index 66924be..0585c07 100644
--- a/app/src/main/java/dev/lelonio/square/backend/lyrics/LyricsLibrary.kt
+++ b/app/src/main/java/dev/lelonio/square/backend/lyrics/LyricsLibrary.kt
@@ -18,6 +18,7 @@ import kotlinx.serialization.json.Json
/** Where a song's words can come from; see [LyricsLibrary]. */
enum class LyricsSource(val label: String) {
AMLL("AMLL"),
+ SPICY_LYRICS("Spicy Lyrics"),
APPLE_MUSIC("Apple Music"),
BETTER_LYRICS("Better Lyrics"),
SPOTIFY("Spotify"),
@@ -48,17 +49,46 @@ object LyricsLibrary {
private val json = Json { ignoreUnknownKeys = true }
private var directory: File? = null
- fun attach(context: Context) {
+ fun attach(context: Context, spicyKey: () -> String = { "" }, preferred: () -> String = { "" }) {
directory = File(context.applicationContext.cacheDir, "lyrics").apply { mkdirs() }
+ SpicyLyrics.key = spicyKey
+ this.preferred = preferred
}
+ /** The source picked in the settings by name, or blank for the best one; see [preferredFor]. */
+ private var preferred: () -> String = { "" }
+
+ /**
+ * The one source the listener wants words from, where it can be asked
+ * about this song. Only its words are shown: a song it has nothing for
+ * shows none, however much the others have, unless the listener picks
+ * another source for that song themselves.
+ */
+ fun preferredFor(uri: String): LyricsSource? =
+ LyricsSource.entries.firstOrNull { it.name == preferred() }?.takeIf { it in sourcesFor(uri) }
+
+ /** Whether these words may be shown for the song, by the source the listener prefers. */
+ fun shows(uri: String, lyrics: Lyrics): Boolean =
+ preferredFor(uri)?.let { it.name == lyrics.source } ?: true
+
+ /**
+ * Whether words already in hand are worth asking the sources about again:
+ * not timed to the word, not saying where they came from, or not from the
+ * source the listener prefers.
+ */
+ fun worthAskingAgain(uri: String, lyrics: Lyrics): Boolean =
+ !isWordTimed(lyrics) || lyrics.source == null ||
+ preferredFor(uri)?.let { it.name != lyrics.source } == true
+
/** Asked in this order when nobody has chosen; the first answer wins. */
fun sourcesFor(uri: String): List<LyricsSource> =
if (uri.startsWith("spotify:track:")) {
// AMLL is keyed on the Spotify id, and Spotify's own words exist
// only for its own tracks.
- listOf(
- LyricsSource.AMLL, LyricsSource.APPLE_MUSIC, LyricsSource.BETTER_LYRICS,
+ // Spicy Lyrics only for a listener who has entered a key for it.
+ listOfNotNull(
+ LyricsSource.AMLL, LyricsSource.SPICY_LYRICS.takeIf { SpicyLyrics.enabled },
+ LyricsSource.APPLE_MUSIC, LyricsSource.BETTER_LYRICS,
LyricsSource.SPOTIFY, LyricsSource.LRCLIB, LyricsSource.NETEASE,
LyricsSource.KUGOU, LyricsSource.LYRICS_OVH,
)
@@ -74,6 +104,7 @@ object LyricsLibrary {
val (_, title, artist, duration) = query
when (source) {
LyricsSource.AMLL -> Amll.lyrics(query.uri)
+ LyricsSource.SPICY_LYRICS -> SpicyLyrics.lyrics(query.uri)
LyricsSource.APPLE_MUSIC -> Lossless.lyrics(title, artist, duration)
LyricsSource.BETTER_LYRICS -> BetterLyrics.lyrics(title, artist, duration)
LyricsSource.SPOTIFY -> Catalog.lyrics(query.uri)
@@ -107,66 +138,203 @@ object LyricsLibrary {
*/
val upgrades: kotlinx.coroutines.flow.SharedFlow<Pair<String, Lyrics>> = _upgrades
+ /**
+ * Every source asked about a song, once, together: shared by the choice
+ * below and the panel listing the sources, so opening the panel shows what
+ * is already known instead of asking all over again. Kept for the last
+ * few songs of the session.
+ */
+ private val surveys = android.util.LruCache<String, Map<LyricsSource, kotlinx.coroutines.Deferred<Lyrics?>>>(16)
+
+ fun survey(query: LyricsQuery): Map<LyricsSource, kotlinx.coroutines.Deferred<Lyrics?>> = synchronized(surveys) {
+ // By the song and the names it was asked by: most sources search by
+ // title, and a song asked about under the one before it's title (the
+ // two do not always change in the same instant) has a survey of its
+ // own rather than the answers for the other song.
+ val key = "${query.uri}\n${same(query.title)}\n${same(query.artist)}"
+ surveys.get(key) ?: sourcesFor(query.uri).associateWith { source ->
+ scope.async { withTimeoutOrNull(ASK_TIMEOUT_MS) { fetch(source, query) } }
+ }.also { surveys.put(key, it) }
+ }
+
+ /**
+ * The words to show, from what the sources have answered so far.
+ *
+ * The first source in the order with words timed to the word wins, as
+ * soon as every source before it has answered without any. With none
+ * timed to the word, the first timed to the line, then the first at all.
+ * Null while a source further up could still change the answer, unless
+ * [final], when the best of what is in is taken.
+ */
+ internal fun winner(
+ order: List<LyricsSource>,
+ answered: Map<LyricsSource, Lyrics?>,
+ final: Boolean,
+ preferred: LyricsSource? = null,
+ ): Lyrics? {
+ // The listener's own pick, and nothing else: what it has, or nothing.
+ if (preferred != null) return answered[preferred]
+ for (source in order) {
+ if (source !in answered) {
+ if (final) continue else return null
+ }
+ val lyrics = answered[source] ?: continue
+ if (rank(lyrics) == 2) return lyrics
+ }
+ val present = order.mapNotNull { answered[it] }
+ val best = present.maxOfOrNull(::rank) ?: return null
+ return present.first { rank(it) == best }
+ }
+
+ private fun answeredSoFar(survey: Map<LyricsSource, kotlinx.coroutines.Deferred<Lyrics?>>): Map<LyricsSource, Lyrics?> =
+ survey.filterValues { it.isCompleted }.mapValues { (_, answer) -> runCatching { answer.getCompleted() }.getOrNull() }
+
/**
* The words for a song: what was kept for it, or the best the sources have.
*
- * Asked in the order, and the first answer timed to the word is the one.
- * An answer timed only to the line is shown at once rather than held back,
- * and the sources after it are asked in the background for one timed to
- * the word; when one has it, it is kept and offered through [upgrades].
- * A song whose word-timed lyrics only one archive held used to be shown
- * line by line from the first source that answered at all.
+ * Every source is asked at once, and the order decides between them: the
+ * first with words timed to the word wins. Waited for up to a few seconds;
+ * past that, the best answer in by then is shown, and anything better that
+ * arrives later replaces it through [upgrades]. Asking one source at a time
+ * and stopping at the first line-timed answer showed a song line by line
+ * when a source further down had it word by word.
*/
suspend fun lyrics(query: LyricsQuery): Lyrics? {
- val sources = sourcesFor(query.uri)
- cached(query.uri)?.let { entry ->
- // Kept from before word timing was looked for everywhere: asked
- // again in the background, once a session, unless it was chosen.
- if (!entry.chosen && rank(entry.lyrics) < 2 && rechecked.add(query.uri)) {
- scope.launch { lookForWordTiming(query, sources.filter { it.name != entry.lyrics.source }) }
+ cached(query.uri, query.title)?.takeIf { it.chosen || shows(query.uri, it.lyrics) }?.let { entry ->
+ // Picked by an older rule, or before a source existed: looked at
+ // again once a session, unless the listener chose it.
+ // Kept with no source named, from before sources were: the same
+ // look tells which one it was.
+ val unnamed = entry.lyrics.source == null
+ val preferred = preferredFor(query.uri)
+ val stale = unnamed || (preferred == null && !entry.chosen && rank(entry.lyrics) < 2)
+ if (stale && rechecked.add("${query.uri}|${preferred?.name}")) {
+ improveLater(query, entry.lyrics)
}
return entry.lyrics
}
- var best: Lyrics? = null
- for ((index, source) in sources.withIndex()) {
- val found = fetch(source, query) ?: continue
- if (best == null || rank(found) > rank(best)) best = found
- if (rank(found) == 2) break
- // Timed to the line: good enough to show now, and the rest are
- // asked meanwhile.
- if (rank(found) == 1) {
- keep(query.uri, found, chosen = false)
- val rest = sources.drop(index + 1)
- scope.launch { lookForWordTiming(query, rest) }
- return found
+ val order = sourcesFor(query.uri)
+ val preferred = preferredFor(query.uri)
+ val survey = survey(query)
+ // One source to wait for, and its answer is the answer.
+ if (preferred != null) {
+ val found = survey[preferred]?.let { runCatching { it.await() }.getOrNull() }
+ found?.let { keep(query.uri, it, chosen = false, title = query.title) }
+ return found
+ }
+ val decided = withTimeoutOrNull(DECIDE_MS) {
+ var found: Lyrics? = null
+ var settled = false
+ while (!settled) {
+ val answered = answeredSoFar(survey)
+ val all = answered.size == survey.size
+ found = winner(order, answered, final = all, preferred = preferred)
+ settled = found != null || all
+ if (!settled) kotlinx.coroutines.delay(POLL_MS)
}
+ found
}
- best?.let { keep(query.uri, it, chosen = false) }
- return best
+ // Past the wait, the best of what is in; and with nothing in yet, the
+ // rest is waited for rather than answering "no lyrics" for a song
+ // whose words are still on their way.
+ var shown = decided ?: winner(order, answeredSoFar(survey), final = true, preferred = preferred)
+ if (shown == null) {
+ survey.values.forEach { runCatching { it.await() } }
+ shown = winner(order, answeredSoFar(survey), final = true, preferred = preferred)
+ }
+ val all = answeredSoFar(survey).size == survey.size
+ shown?.let { keep(query.uri, it, chosen = false, title = query.title) }
+ if (!all) improveLater(query, shown)
+ return shown
}
- private suspend fun lookForWordTiming(query: LyricsQuery, sources: List<LyricsSource>) {
- if (sources.isEmpty()) return
- val answers = coroutineScope {
- sources.map { source -> async { withTimeoutOrNull(ASK_TIMEOUT_MS) { fetch(source, query) } } }.awaitAll()
+ /**
+ * Waits for every source and offers something better than [current], if
+ * there is one: words timed more finely, or any words where there were
+ * none. Never over a choice the listener has made.
+ */
+ fun improveLater(query: LyricsQuery, current: Lyrics?) {
+ scope.launch {
+ val survey = survey(query)
+ val answered = survey.mapValues { (_, answer) -> runCatching { answer.await() }.getOrNull() }
+ val preferred = preferredFor(query.uri)
+ val best = winner(sourcesFor(query.uri), answered, final = true, preferred = preferred)
+ val free = cached(query.uri, query.title)?.chosen != true
+ // The preferred source's words are not replaced by finer ones,
+ // and replace anything that is not theirs.
+ val holdsPreferred = preferred != null && current?.source == preferred.name
+ val bringsPreferred = preferred != null && best?.source == preferred.name && !holdsPreferred
+ val better = best != null && free && !holdsPreferred &&
+ (current == null || bringsPreferred || rank(best) > rank(current))
+ // Words that say nothing of their source, and that no source
+ // answers word for word any more: the order picks again, as it
+ // would for a song never shown, rather than leaving the source
+ // button with nothing to name.
+ val named = current?.source != null || current == null || name(query, current, answered)
+ if (better || (!named && best != null && free)) {
+ keep(query.uri, best!!, chosen = false, title = query.title)
+ // A download's copy too, which is read before anything else:
+ // left as it was, it would be the one shown on the next play.
+ if (keptForGood(best)) withContext(Dispatchers.IO) {
+ runCatching {
+ val download = dev.lelonio.square.download.DownloadExtras
+ if (download.lyrics(query.uri) != null) {
+ download.rememberLyrics(query.uri, json.encodeToString(Lyrics.serializer(), best))
+ }
+ }
+ }
+ android.util.Log.i("LyricsLibrary", "better lyrics for ${query.uri} from ${best.source}")
+ _upgrades.tryEmit(query.uri to best)
+ }
}
- val better = answers.firstOrNull { it != null && rank(it) == 2 } ?: return
- // Not over a choice the listener made in the meantime.
- if (cached(query.uri)?.chosen == true) return
- keep(query.uri, better, chosen = false)
- android.util.Log.i("LyricsLibrary", "word-timed lyrics for ${query.uri} from ${better.source}")
- _upgrades.tryEmit(query.uri to better)
}
+ /**
+ * Words kept before their source was written down, given its name.
+ *
+ * A download's copy and the words this phone kept from before sources
+ * were recorded say nothing of where they came from, and the player's
+ * source button could only read "Sources" for them while it named every
+ * other song's. The source is whichever one answers the same lines now;
+ * the copies are written again with its name, so this is asked once.
+ */
+ private suspend fun name(query: LyricsQuery, current: Lyrics, answered: Map<LyricsSource, Lyrics?>): Boolean {
+ val uri = query.uri
+ val text = lines(current)
+ val source = sourcesFor(uri).firstOrNull { answered[it]?.let(::lines) == text } ?: return false
+ android.util.Log.i("LyricsLibrary", "kept lyrics for $uri named ${source.name}")
+ val named = current.copy(source = source.name)
+ cached(uri)?.takeIf { lines(it.lyrics) == text }?.let { keep(uri, named, it.chosen, query.title) }
+ withContext(Dispatchers.IO) {
+ runCatching {
+ val download = dev.lelonio.square.download.DownloadExtras
+ if (download.lyrics(uri) != null && keptForGood(named)) {
+ download.rememberLyrics(uri, json.encodeToString(Lyrics.serializer(), named))
+ }
+ }
+ }
+ _upgrades.tryEmit(uri to named)
+ return true
+ }
+
+ private fun same(name: String): String = name.trim().lowercase()
+
+ private fun lines(lyrics: Lyrics): List<String> =
+ lyrics.lines.map { it.text.trim().lowercase() }.filter { it.isNotEmpty() }
+
+ /** Whether the words are timed to the word, which nothing else here beats. */
+ fun isWordTimed(lyrics: Lyrics): Boolean = rank(lyrics) == 2
+
+ /** Whether these words may be kept beside a download, with no end date. */
+ fun keptForGood(lyrics: Lyrics): Boolean = lyrics.source != LyricsSource.SPICY_LYRICS.name
+
/** Only what is kept, asking nobody: for offline, where the network is not there. */
- suspend fun cachedLyrics(uri: String): Lyrics? = cached(uri)?.lyrics
+ suspend fun cachedLyrics(uri: String): Lyrics? =
+ cached(uri)?.takeIf { it.chosen || shows(uri, it.lyrics) }?.lyrics
- /** What every source has for the song, asked together, in the usual order. */
- suspend fun everySource(query: LyricsQuery): List<Pair<LyricsSource, Lyrics?>> = coroutineScope {
- sourcesFor(query.uri).map { source ->
- async { source to withTimeoutOrNull(ASK_TIMEOUT_MS) { fetch(source, query) } }
- }.awaitAll()
- }
+ /** What every source has for the song, from the song's one survey, in the usual order. */
+ suspend fun everySource(query: LyricsQuery): List<Pair<LyricsSource, Lyrics?>> =
+ survey(query).map { (source, answer) -> source to runCatching { answer.await() }.getOrNull() }
/**
* The listener's choice for this song, kept for good: here, and beside a
@@ -174,6 +342,8 @@ object LyricsLibrary {
*/
suspend fun choose(uri: String, lyrics: Lyrics) {
keep(uri, lyrics, chosen = true)
+ // Not beside a download, which keeps its words for good; see cached.
+ if (!keptForGood(lyrics)) return
withContext(Dispatchers.IO) {
runCatching {
dev.lelonio.square.download.DownloadExtras.rememberLyrics(uri, json.encodeToString(Lyrics.serializer(), lyrics))
@@ -182,22 +352,42 @@ object LyricsLibrary {
}
@Serializable
- private data class Entry(val savedAt: Long, val chosen: Boolean, val lyrics: Lyrics)
+ private data class Entry(
+ val savedAt: Long,
+ val chosen: Boolean,
+ val lyrics: Lyrics,
+ /** The title the song was asked by; null for entries kept before this was. */
+ val title: String? = null,
+ )
private val memory = android.util.LruCache<String, Entry>(64)
- private suspend fun cached(uri: String): Entry? {
- memory.get(uri)?.let { return it }
- val entry = withContext(Dispatchers.IO) {
+ /**
+ * What is kept for the song, if it is still to be believed.
+ *
+ * With [title], words the order picked are only taken when they were
+ * found under that title. A song once asked about under the title of the
+ * one before it kept that song's words as its own, for a month, and no
+ * later answer could replace them; such an entry, and one from before the
+ * title was written down, is asked again instead. A listener's choice is
+ * theirs, and kept whatever it was asked by.
+ */
+ private suspend fun cached(uri: String, title: String? = null): Entry? {
+ val entry = memory.get(uri) ?: withContext(Dispatchers.IO) {
runCatching { json.decodeFromString<Entry>(file(uri)?.readText() ?: return@withContext null) }.getOrNull()
} ?: return null
- if (!entry.chosen && System.currentTimeMillis() - entry.savedAt !in 0..MAX_AGE_MS) return null
+ if (title != null && !entry.chosen && (entry.title == null || same(entry.title) != same(title))) return null
+ // A month at most for anything picked by the order, and for Spicy
+ // Lyrics' answers even when chosen: its terms let a copy be kept for
+ // thirty days and no longer.
+ val expires = !entry.chosen || entry.lyrics.source == LyricsSource.SPICY_LYRICS.name
+ if (expires && System.currentTimeMillis() - entry.savedAt !in 0..MAX_AGE_MS) return null
memory.put(uri, entry)
return entry
}
- private suspend fun keep(uri: String, lyrics: Lyrics, chosen: Boolean) {
- val entry = Entry(System.currentTimeMillis(), chosen, lyrics)
+ private suspend fun keep(uri: String, lyrics: Lyrics, chosen: Boolean, title: String? = null) {
+ val entry = Entry(System.currentTimeMillis(), chosen, lyrics, title)
memory.put(uri, entry)
withContext(Dispatchers.IO) {
runCatching { file(uri)?.writeText(json.encodeToString(Entry.serializer(), entry)) }
@@ -210,6 +400,12 @@ object LyricsLibrary {
return File(dir, digest.joinToString("") { "%02x".format(it) } + ".json")
}
+ /** How long the choice waits for the sources further up the order. */
+ private const val DECIDE_MS = 4_000L
+
+ /** How often it looks at what has come in meanwhile. */
+ private const val POLL_MS = 100L
+
/** A source that has not answered by then is shown as having nothing. */
private const val ASK_TIMEOUT_MS = 12_000L
diff --git a/app/src/main/java/dev/lelonio/square/backend/lyrics/SpicyLyrics.kt b/app/src/main/java/dev/lelonio/square/backend/lyrics/SpicyLyrics.kt
new file mode 100644
index 0000000..977ff28
--- /dev/null
+++ b/app/src/main/java/dev/lelonio/square/backend/lyrics/SpicyLyrics.kt
@@ -0,0 +1,159 @@
+package dev.lelonio.square.backend.lyrics
+
+import dev.lelonio.square.data.LyricLine
+import dev.lelonio.square.data.LyricWord
+import dev.lelonio.square.data.Lyrics
+import dev.lelonio.square.data.LyricsCredit
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.withContext
+import okhttp3.OkHttpClient
+import okhttp3.Request
+import org.json.JSONArray
+import org.json.JSONObject
+
+/**
+ * Lyrics from Spicy Lyrics, for listeners who have a key of their own.
+ *
+ * Optional, and off until a key is entered in the settings: the API asks each
+ * person running an app to have their own key, which they get from Square's
+ * page in Spicy Lyrics' catalogue. Asked by the Spotify track id, which is the
+ * only thing it takes, so only for Spotify's tracks.
+ *
+ * What it answers is timed to the syllable more often than anything else here,
+ * and much of it is synced by its community; who did it is shown under the
+ * words, which the API makes a condition of using it. See [LyricsCredit].
+ */
+object SpicyLyrics {
+
+ private val http = OkHttpClient()
+
+ /** The listener's key, or blank when there is none; set by LyricsLibrary.attach. */
+ @Volatile
+ var key: () -> String = { "" }
+
+ /** Until when the API asked not to be asked, after a 429; see RateLimit-Reset. */
+ @Volatile
+ private var quietUntil = 0L
+
+ val enabled: Boolean get() = key().isNotBlank()
+
+ suspend fun lyrics(trackUri: String): Lyrics? = withContext(Dispatchers.IO) {
+ val secret = key().trim()
+ val id = trackUri.removePrefix("spotify:track:")
+ if (secret.isEmpty() || id == trackUri || System.currentTimeMillis() < quietUntil) return@withContext null
+ val request = Request.Builder()
+ .url("$API_URL/$id")
+ .header("Authorization", "Bearer $secret")
+ // The key handed out through Square's catalogue page allows this
+ // origin; a phone has none of its own to send.
+ .header("Origin", ORIGIN)
+ .header("Accept", "application/json")
+ .build()
+ val body = runCatching {
+ http.newCall(request).execute().use { response ->
+ when {
+ response.code == 429 -> {
+ val wait = response.header("RateLimit-Reset")?.toLongOrNull() ?: 60L
+ quietUntil = System.currentTimeMillis() + wait * 1000
+ android.util.Log.w(TAG, "rate limited for ${wait}s")
+ null
+ }
+ !response.isSuccessful -> {
+ if (response.code != 404) android.util.Log.w(TAG, "HTTP ${response.code} for $id")
+ null
+ }
+ else -> response.body?.string()
+ }
+ }
+ }.getOrNull() ?: return@withContext null
+ runCatching { parse(JSONObject(body)) }.getOrNull()
+ }
+
+ internal fun parse(json: JSONObject): Lyrics? {
+ val credit = credit(json)
+ val lines = when (json.optString("Type")) {
+ "Syllable" -> json.optJSONArray("Content").objects().mapNotNull { vocal ->
+ val lead = vocal.optJSONObject("Lead") ?: return@mapNotNull null
+ syllableLine(lead)
+ }
+ "Line" -> json.optJSONArray("Content").objects().mapNotNull { line ->
+ val text = line.optString("Text").trim()
+ if (text.isEmpty()) return@mapNotNull null
+ LyricLine(
+ startTimeMs = seconds(line, "StartTime"),
+ text = text,
+ translation = line.optString("TranslatedText").takeIf { it.isNotBlank() },
+ )
+ }
+ "Static" -> json.optJSONArray("Lines").objects().mapNotNull { line ->
+ val text = line.optString("Text").trim()
+ if (text.isEmpty()) null else LyricLine(startTimeMs = null, text = text)
+ }
+ else -> emptyList()
+ }
+ if (lines.isEmpty()) return null
+ return Lyrics(lines = lines, synced = json.optString("Type") != "Static", credit = credit)
+ }
+
+ /**
+ * A sung line from its syllables: the text with a space after each one that
+ * ends a word, and one timed piece per syllable, as TTML gives them.
+ */
+ private fun syllableLine(lead: JSONObject): LyricLine? {
+ val syllables = lead.optJSONArray("Syllables").objects()
+ if (syllables.isEmpty()) return null
+ val text = StringBuilder()
+ val words = syllables.mapNotNull { syllable ->
+ val piece = syllable.optString("Text")
+ text.append(piece)
+ if (!syllable.optBoolean("IsPartOfWord")) text.append(' ')
+ val start = seconds(syllable, "StartTime") ?: return@mapNotNull null
+ piece.trim().takeIf { it.isNotEmpty() }
+ ?.let { LyricWord(start, seconds(syllable, "EndTime") ?: start, it) }
+ }
+ val line = text.toString().replace(SPACES, " ").trim()
+ if (line.isEmpty()) return null
+ return LyricLine(
+ startTimeMs = seconds(lead, "StartTime") ?: words.firstOrNull()?.startMs,
+ text = line,
+ words = words,
+ translation = lead.optString("TranslatedText").takeIf { it.isNotBlank() },
+ )
+ }
+
+ /** Who to thank, as the API wants it said; see LyricsCredit. */
+ private fun credit(json: JSONObject): LyricsCredit {
+ val attribution = json.optJSONObject("UploadAttribution")
+ val uploader = attribution?.optJSONObject("Uploader")
+ val maker = attribution?.optJSONObject("Maker")
+ return LyricsCredit(
+ provider = PROVIDER,
+ uploader = uploader?.optString("username")?.takeIf { it.isNotBlank() },
+ uploaderUrl = uploader?.optString("url")?.takeIf { it.startsWith("http") },
+ maker = maker?.optString("username")?.takeIf { it.isNotBlank() },
+ makerUrl = maker?.optString("url")?.takeIf { it.startsWith("http") },
+ )
+ }
+
+ private fun seconds(json: JSONObject, key: String): Long? =
+ if (json.has(key)) (json.optDouble(key) * 1000).toLong() else null
+
+ private fun JSONArray?.objects(): List<JSONObject> =
+ if (this == null) emptyList() else (0 until length()).mapNotNull { optJSONObject(it) }
+
+ private val SPACES = Regex("\\s+")
+
+ private const val TAG = "SpicyLyrics"
+ private const val PROVIDER = "Spicy Lyrics"
+ private const val API_URL = "https://api.spicylyrics.org/v1/lyrics"
+
+ /**
+ * The origin the template allows; see the note on the request. An origin
+ * is a scheme and a host only, and this one is the developer's own
+ * GitHub Pages host rather than github.com, which everyone shares.
+ */
+ const val ORIGIN = "https://lelonio.github.io"
+
+ /** Where a listener gets a key: Square's page in the catalogue, once it has one. */
+ const val KEY_PAGE = "https://developers.spicylyrics.org/catalog"
+}
diff --git a/app/src/main/java/dev/lelonio/square/backend/lyrics/SpotifyLyrics.kt b/app/src/main/java/dev/lelonio/square/backend/lyrics/SpotifyLyrics.kt
index bc57a59..2332f37 100644
--- a/app/src/main/java/dev/lelonio/square/backend/lyrics/SpotifyLyrics.kt
+++ b/app/src/main/java/dev/lelonio/square/backend/lyrics/SpotifyLyrics.kt
@@ -39,11 +39,21 @@ object SpotifyLyrics {
): Lyrics? {
// Offline: the copy beside a download, or words this phone has shown
// before, which LyricsLibrary kept.
- if (!allowNetwork) return kept(uri) ?: LyricsLibrary.cachedLyrics(uri)
+ // Either only from the source the listener prefers, if they named one.
+ if (!allowNetwork) return kept(uri)?.takeIf { LyricsLibrary.shows(uri, it) } ?: LyricsLibrary.cachedLyrics(uri)
// Repeat views cost nothing: LyricsLibrary keeps its answers in memory
// as well as on disk, and a source picked by the listener with them.
- kept(uri)?.let { return it }
+ kept(uri)?.takeIf { LyricsLibrary.shows(uri, it) }?.let { downloaded ->
+ // A download's own copy first, at once; and if it is not timed to
+ // the word, the sources are asked whether one is now.
+ // Asked too when it does not say which source it is; see
+ // LyricsLibrary.name.
+ if (LyricsLibrary.worthAskingAgain(uri, downloaded)) {
+ LyricsLibrary.improveLater(LyricsQuery(uri, title, artist, durationMs), downloaded)
+ }
+ return downloaded
+ }
// The order, and every source in it, lives in LyricsLibrary, which
// also keeps what it found and the source the listener chose.
@@ -57,7 +67,9 @@ object SpotifyLyrics {
DownloadExtras.note("lyrics", uri)
return@withContext null
}
- runCatching { DownloadExtras.rememberLyrics(uri, json.encodeToString(found)) }
+ if (LyricsLibrary.keptForGood(found)) {
+ runCatching { DownloadExtras.rememberLyrics(uri, json.encodeToString(found)) }
+ }
found
}
}
diff --git a/app/src/main/java/dev/lelonio/square/backend/youtube/PcmMixer.kt b/app/src/main/java/dev/lelonio/square/backend/youtube/PcmMixer.kt
index 1ae808e..0a83145 100644
--- a/app/src/main/java/dev/lelonio/square/backend/youtube/PcmMixer.kt
+++ b/app/src/main/java/dev/lelonio/square/backend/youtube/PcmMixer.kt
@@ -95,6 +95,21 @@ class PcmMixer {
val audioSessionId: Int get() = track.audioSessionId
+ /**
+ * The room's send, on the one track every player is heard through; see
+ * PlayerReverb. Each player asks its own output for the room, and every
+ * output here is a channel into this track: ignored, as it was, the reverb
+ * slider did nothing to a YouTube song.
+ */
+ internal fun attachAuxEffect(effectId: Int) {
+ runCatching { track.attachAuxEffect(effectId) }
+ .onFailure { android.util.Log.w(TAG, "reverb not attached: ${it.message}") }
+ }
+
+ internal fun setAuxEffectSendLevel(level: Float) {
+ runCatching { track.setAuxEffectSendLevel(level) }
+ }
+
internal fun add(channel: MixerChannel) = synchronized(lock) {
channels += channel
lock.notifyAll()
@@ -495,7 +510,13 @@ class MixerChannel internal constructor(
lastStampUs = presentationTimeUs
while (stamps.size > MAX_STAMPS) stamps.removeFirst()
}
- val frames = min(available, capacity - queued)
+ // Only a held slot piles up the whole ring: it needs the pile to be
+ // lined up in (see handOver). A live one is kept a moment ahead,
+ // since everything it holds has already been through speed, pitch
+ // and karaoke: filled to two seconds, an effect was heard two
+ // seconds after it was set.
+ val room = (if (slot.held) capacity else LIVE_FRAMES) - queued
+ val frames = min(available, max(0, room))
val data = buffer.duplicate().order(ByteOrder.nativeOrder())
var write = (readIndex + queued) % capacity
for (f in 0 until frames) {
@@ -662,11 +683,14 @@ class MixerChannel internal constructor(
override fun setPlaybackParameters(playbackParams: PlaybackParameters) = Unit
override fun setOffloadDelayPadding(delayInFrames: Int, paddingInFrames: Int) = Unit
override fun setOffloadEndOfStream() = Unit
- override fun attachAuxEffect(effectId: Int) = Unit
- override fun setAuxEffectSendLevel(level: Float) = Unit
+ override fun attachAuxEffect(effectId: Int) = mixer.attachAuxEffect(effectId)
+ override fun setAuxEffectSendLevel(level: Float) = mixer.setAuxEffectSendLevel(level)
override fun setPreferredDevice(preferredDevice: AudioDeviceInfo?) = Unit
private companion object {
+ /** How far ahead a playing channel is filled: a quarter of a second. */
+ const val LIVE_FRAMES = PcmMixer.RATE / 4
+
/** About two seconds of blocks: far more than the track ever holds unplayed. */
const val MAX_BLOCKS = 200
diff --git a/app/src/main/java/dev/lelonio/square/backend/youtube/PlayerChallenges.kt b/app/src/main/java/dev/lelonio/square/backend/youtube/PlayerChallenges.kt
new file mode 100644
index 0000000..cf561bc
--- /dev/null
+++ b/app/src/main/java/dev/lelonio/square/backend/youtube/PlayerChallenges.kt
@@ -0,0 +1,174 @@
+package dev.lelonio.square.backend.youtube
+
+import android.content.Context
+import androidx.javascriptengine.IsolateStartupParameters
+import androidx.javascriptengine.JavaScriptIsolate
+import androidx.javascriptengine.JavaScriptSandbox
+import java.io.File
+import java.util.concurrent.TimeUnit
+import okhttp3.OkHttpClient
+import okhttp3.Request
+import org.json.JSONArray
+import org.json.JSONObject
+
+/**
+ * The two puzzles in a signed-in YouTube stream address, solved by YouTube's
+ * own player script.
+ *
+ * An address YouTube gives an account comes enciphered: its signature has to
+ * be run through a function in the website's player script, and so does the
+ * `n` parameter, without which the stream is throttled to a crawl. The
+ * function changes with every version of the script and is buried in three
+ * megabytes of obfuscated code, which is why NewPipe's patterns for finding it
+ * stopped matching. This runs yt-dlp's solver (ejs, public domain) over the
+ * script instead: it parses the script and lifts the two functions out of it,
+ * whatever they are called this week.
+ *
+ * In Android's isolated JavaScript engine, not a web page: the solver sets up
+ * the `location` and `document` the script expects, which in a page would
+ * navigate it away. The script is fetched once per version and kept on disk,
+ * and the solver's preparation of it is kept in the engine for as long as the
+ * engine lives.
+ */
+object PlayerChallenges {
+
+ /** A version of YouTube's player script, and the signature timestamp it was built for. */
+ class Script(val id: String, val code: String, val signatureTimestamp: Int)
+
+ private val http = OkHttpClient.Builder()
+ .connectTimeout(15, TimeUnit.SECONDS)
+ .readTimeout(30, TimeUnit.SECONDS)
+ .build()
+
+ private var sandbox: JavaScriptSandbox? = null
+ private var isolate: JavaScriptIsolate? = null
+
+ /** The player version the isolate has prepared; see [prepare]. */
+ private var prepared: String? = null
+
+ private var script: Script? = null
+ private var scriptCheckedAt = 0L
+
+ /** The current player script; its version looked up at most once an hour. */
+ @Synchronized
+ fun script(context: Context): Script {
+ val now = android.os.SystemClock.elapsedRealtime()
+ script?.takeIf { now - scriptCheckedAt < SCRIPT_TTL_MS }?.let { return it }
+ val id = currentPlayerId()
+ val kept = File(context.cacheDir, "yt-player/$id.js")
+ val code = kept.takeIf { it.exists() && it.length() > 0 }?.readText()
+ ?: get("https://www.youtube.com/s/player/$id/player_ias.vflset/en_US/base.js").also {
+ kept.parentFile?.mkdirs()
+ // One version kept: they are three megabytes each.
+ kept.parentFile?.listFiles()?.forEach { old -> if (old != kept) old.delete() }
+ kept.writeText(it)
+ }
+ val timestamp = TIMESTAMP.find(code)?.groupValues?.get(1)?.toInt()
+ ?: error("no signature timestamp in player $id")
+ return Script(id, code, timestamp).also {
+ script = it
+ scriptCheckedAt = now
+ }
+ }
+
+ /**
+ * Solves [n] and [sig] challenges with [script], blocking; the answers by
+ * challenge. Runs on the player's loading thread, never the main one.
+ */
+ @Synchronized
+ fun solve(context: Context, script: Script, n: List<String>, sig: List<String>): Pair<Map<String, String>, Map<String, String>> {
+ val engine = isolate(context)
+ prepare(engine, script)
+ val requests = JSONArray().apply {
+ if (n.isNotEmpty()) put(JSONObject().put("type", "n").put("challenges", JSONArray(n)))
+ if (sig.isNotEmpty()) put(JSONObject().put("type", "sig").put("challenges", JSONArray(sig)))
+ }
+ val answer = engine.evaluateJavaScriptAsync(
+ "JSON.stringify(jsc({type: 'preprocessed', preprocessed_player: globalThis.__player, requests: $requests}))",
+ ).get(SOLVE_TIMEOUT_S, TimeUnit.SECONDS)
+ val responses = JSONObject(answer).getJSONArray("responses")
+ var nIndex = -1
+ var sigIndex = -1
+ var at = 0
+ if (n.isNotEmpty()) nIndex = at++
+ if (sig.isNotEmpty()) sigIndex = at
+ fun results(index: Int): Map<String, String> {
+ if (index < 0) return emptyMap()
+ val response = responses.getJSONObject(index)
+ if (response.optString("type") != "result") error("challenge unsolved: ${response.optString("error")}")
+ val data = response.getJSONObject("data")
+ return data.keys().asSequence().associateWith { data.getString(it) }
+ }
+ return results(nIndex) to results(sigIndex)
+ }
+
+ /** The solver's parse of [script], made once per version and kept in the engine. */
+ private fun prepare(engine: JavaScriptIsolate, script: Script) {
+ if (prepared == script.id) return
+ val started = android.os.SystemClock.elapsedRealtime()
+ engine.evaluateJavaScriptAsync(
+ "globalThis.__player = jsc({type: 'player', player: ${JSONObject.quote(script.code)}, " +
+ "requests: [], output_preprocessed: true}).preprocessed_player; 'ok'",
+ ).get(PREPARE_TIMEOUT_S, TimeUnit.SECONDS)
+ prepared = script.id
+ android.util.Log.i(TAG, "player ${script.id} prepared in ${android.os.SystemClock.elapsedRealtime() - started} ms")
+ }
+
+ private fun isolate(context: Context): JavaScriptIsolate {
+ isolate?.let { return it }
+ if (!JavaScriptSandbox.isSupported()) error("this phone's WebView has no isolated JavaScript engine")
+ val box = sandbox ?: JavaScriptSandbox.createConnectedInstanceAsync(context.applicationContext)
+ .get(CONNECT_TIMEOUT_S, TimeUnit.SECONDS)
+ .also { sandbox = it }
+ if (!box.isFeatureSupported(JavaScriptSandbox.JS_FEATURE_EVALUATE_WITHOUT_TRANSACTION_LIMIT)) {
+ error("this phone's JavaScript engine cannot take a script the size of YouTube's player")
+ }
+ val parameters = IsolateStartupParameters().apply {
+ if (box.isFeatureSupported(JavaScriptSandbox.JS_FEATURE_ISOLATE_MAX_HEAP_SIZE)) {
+ maxHeapSizeBytes = MAX_HEAP_BYTES
+ }
+ }
+ val engine = box.createIsolate(parameters)
+ // The solver and the two libraries it is bundled with (meriyah, which
+ // parses the script, and astring, which writes the lifted functions
+ // back out). The core reads them as globals of those names.
+ val lib = context.assets.open("ejs/yt.solver.lib.min.js").bufferedReader().use { it.readText() }
+ val core = context.assets.open("ejs/yt.solver.core.min.js").bufferedReader().use { it.readText() }
+ engine.evaluateJavaScriptAsync(
+ "$lib\n;var meriyah = lib.meriyah, astring = lib.astring;\n$core\n;globalThis.jsc = jsc; 'ok'",
+ ).get(PREPARE_TIMEOUT_S, TimeUnit.SECONDS)
+ prepared = null
+ return engine.also { isolate = it }
+ }
+
+ /** Throws the engine away, so the next solve starts a fresh one; after a failure. */
+ @Synchronized
+ fun reset() {
+ runCatching { isolate?.close() }
+ isolate = null
+ prepared = null
+ }
+
+ private fun currentPlayerId(): String {
+ val page = get("https://www.youtube.com/iframe_api")
+ return PLAYER_ID.find(page)?.groupValues?.get(1) ?: error("no player version in the iframe API")
+ }
+
+ private fun get(url: String): String =
+ http.newCall(Request.Builder().url(url).header("User-Agent", USER_AGENT).build()).execute().use { response ->
+ if (!response.isSuccessful) error("HTTP ${response.code} for $url")
+ response.body?.string() ?: error("empty answer from $url")
+ }
+
+ private val PLAYER_ID = Regex("""player\\?/([0-9a-f]{8})""")
+ private val TIMESTAMP = Regex("""signatureTimestamp:(\d+)""")
+
+ private const val USER_AGENT =
+ "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36"
+ private const val SCRIPT_TTL_MS = 60 * 60 * 1000L
+ private const val CONNECT_TIMEOUT_S = 10L
+ private const val PREPARE_TIMEOUT_S = 30L
+ private const val SOLVE_TIMEOUT_S = 15L
+ private const val MAX_HEAP_BYTES = 256L * 1024 * 1024
+ private const val TAG = "SquareYTChallenges"
+}
diff --git a/app/src/main/java/dev/lelonio/square/backend/youtube/SignedInStreams.kt b/app/src/main/java/dev/lelonio/square/backend/youtube/SignedInStreams.kt
new file mode 100644
index 0000000..a946bce
--- /dev/null
+++ b/app/src/main/java/dev/lelonio/square/backend/youtube/SignedInStreams.kt
@@ -0,0 +1,332 @@
+package dev.lelonio.square.backend.youtube
+
+import com.metrolist.innertube.YouTube
+import com.metrolist.innertube.models.YouTubeClient
+import com.metrolist.innertube.models.response.PlayerResponse
+import java.net.URLDecoder
+import java.net.URLEncoder
+import java.util.concurrent.ConcurrentHashMap
+import kotlinx.coroutines.runBlocking
+import kotlinx.serialization.json.Json
+import okhttp3.MediaType.Companion.toMediaType
+import okhttp3.Request
+import okhttp3.RequestBody.Companion.toRequestBody
+import org.json.JSONObject
+import org.schabi.newpipe.extractor.exceptions.AgeRestrictedContentException
+import org.schabi.newpipe.extractor.exceptions.ContentNotAvailableException
+
+/**
+ * Streams for the songs YouTube will only play to someone signed in.
+ *
+ * Every stream is asked for without an account, which is what keeps the
+ * listener's account out of the playback requests; and for nearly every song
+ * that is all it takes. A few, explicit records above all, answer "please sign
+ * in" to any client that has no account, and played nothing: the player sat at
+ * --:-- with no word of why. Those are asked for again here as the signed-in
+ * account, through the client of YouTube's TV app, which takes the account's
+ * cookie and needs no proof-of-origin token.
+ *
+ * What it answers is enciphered as on the website: the signature, and the
+ * parameter YouTube throttles a stream by, are both undone by running the
+ * site's own player script; see PlayerChallenges.
+ */
+object SignedInStreams {
+
+ /** What to ask for: the sound, the picture alone, or both in one file. */
+ enum class Kind { AUDIO, VIDEO, MUXED }
+
+ /** Thrown when a song needs an account and none is signed in; see YouTubePlayerFactory. */
+ class SignInRequired(videoId: String) : java.io.IOException("$videoId plays only when signed in")
+
+ /**
+ * Thrown when a song needs an account, one is signed in, and its stream
+ * still could not be had: YouTube refused every client, or the address
+ * could not be deciphered. Said as such, rather than as a sign-in to do.
+ */
+ class Refused(videoId: String, cause: Throwable) :
+ java.io.IOException("$videoId could not be played signed in: ${cause.message}", cause)
+
+ private val urls = ConcurrentHashMap<String, Pair<Long, String>>()
+
+ /**
+ * Whether [error], from asking without an account, is YouTube asking for
+ * one: an age check, or a song it serves to accounts alone.
+ */
+ fun needsAccount(error: Throwable): Boolean =
+ generateSequence(error) { it.cause }.any {
+ it is AgeRestrictedContentException ||
+ (it is ContentNotAvailableException && it.message.orEmpty().contains("LOGIN_REQUIRED"))
+ }
+
+ val available: Boolean get() = YouTube.cookie != null
+
+ /**
+ * Forgets the addresses kept, after one failed to play: kept, it would be
+ * handed out again for the hour, and the song could not be tried afresh.
+ */
+ fun forget() = urls.clear()
+
+ /** The URL of [kind] for [videoId], as the signed-in account; blocking. */
+ fun url(context: android.content.Context, videoId: String, kind: Kind, lowRate: Boolean): String {
+ if (!available) throw SignInRequired(videoId)
+ val key = "$videoId|$kind|$lowRate"
+ val now = android.os.SystemClock.elapsedRealtime()
+ urls[key]?.takeIf { now - it.first < URL_TTL_MS }?.let { return it.second }
+ val script = PlayerChallenges.script(context)
+ val response = player(videoId, script.signatureTimestamp)
+ val issuedAt = android.os.SystemClock.elapsedRealtime()
+ val formats = response.streamingData
+ val chosen = when (kind) {
+ Kind.AUDIO -> formats?.adaptiveFormats.orEmpty()
+ .filter { it.isAudio && it.isOriginal }
+ // AAC before Opus, as for every other stream; see the resolver.
+ .sortedWith(
+ compareByDescending<PlayerResponse.StreamingData.Format> { it.mimeType.startsWith("audio/mp4") }
+ .thenBy { if (lowRate) it.bitrate else -it.bitrate },
+ )
+ .firstOrNull()
+ Kind.VIDEO -> formats?.adaptiveFormats.orEmpty()
+ .filter { !it.isAudio && (it.height ?: 0) in 1..MAX_VIDEO_HEIGHT }
+ .sortedWith(
+ compareByDescending<PlayerResponse.StreamingData.Format> { it.height ?: 0 }
+ .thenByDescending { it.mimeType.startsWith("video/mp4") },
+ )
+ .firstOrNull()
+ Kind.MUXED -> formats?.formats.orEmpty().maxByOrNull { it.height ?: 0 }
+ } ?: error("no ${kind.name.lowercase()} stream for $videoId signed in")
+ val url = try {
+ urlOf(context, script, chosen)
+ } catch (failure: Exception) {
+ // A fresh engine next time: one that failed may be in any state.
+ PlayerChallenges.reset()
+ throw failure
+ }
+ awaitReady(videoId, url, issuedAt)
+ urls[key] = now to url
+ if (urls.size > 64) urls.entries.minByOrNull { it.value.first }?.let { urls.remove(it.key) }
+ android.util.Log.i(
+ TAG,
+ "$videoId played signed in through $workingName (${kind.name.lowercase()}, itag ${chosen.itag})",
+ )
+ return url
+ }
+
+ /**
+ * The first signed-in client that will play it. The TV app's comes first,
+ * asked as YouTube's own TV app asks: of www.youtube.com, as a named TV. Its streams need no proof-of-origin token, which the website's
+ * clients do: their addresses answer 403 without one. Asked through
+ * music.youtube.com, or without a make and model, the TV client
+ * answers "the page needs to be reloaded" instead, which is why the
+ * library's own TV client is only a fallback. The rest are tried in turn
+ * after it.
+ */
+ private fun player(videoId: String, timestamp: Int): PlayerResponse {
+ val refusals = mutableListOf<String>()
+ val tv = runCatching { tvPlayer(videoId, timestamp) }
+ .onFailure { refusals += "TV: ${it.message}" }
+ .getOrNull()
+ val tvStatus = tv?.playabilityStatus
+ if (tv != null && tvStatus?.status == "OK" && tv.streamingData != null) {
+ workingName = "TVHTML5 (Samsung)"
+ return tv
+ }
+ if (tv != null) refusals += "TV: ${tvStatus?.status} ${tvStatus?.reason.orEmpty()}"
+ for (client in CLIENTS) {
+ val response = runBlocking {
+ YouTube.player(videoId, client = client, signatureTimestamp = timestamp)
+ }.getOrNull()
+ val status = response?.playabilityStatus
+ if (response != null && status?.status == "OK" && response.streamingData != null) {
+ workingName = client.clientName
+ if (refusals.isNotEmpty()) android.util.Log.i(TAG, "$videoId refused first: ${refusals.joinToString(" / ")}")
+ return response
+ }
+ refusals += "${client.clientName}: ${status?.status} ${status?.reason.orEmpty()}"
+ }
+ android.util.Log.w(TAG, "$videoId refused signed in: ${refusals.joinToString(" / ")}")
+ error("signed in, $videoId is unplayable: ${refusals.joinToString(" / ")}")
+ }
+
+ /**
+ * Waits for [url] to open. An address the TV client has just been given
+ * answers 403 for its first three or four seconds, then plays; handed to
+ * the player at once, it failed the song. Asked for its first two bytes
+ * until it answers otherwise, for as long as [READY_WAIT_MS] after it was
+ * issued; one that still refuses then is refused for good.
+ */
+ private fun awaitReady(videoId: String, url: String, issuedAt: Long) {
+ while (true) {
+ val code = runCatching {
+ val request = Request.Builder().url(url).header("Range", "bytes=0-1").build()
+ http.newCall(request).execute().use { it.code }
+ }.getOrElse { return }
+ if (code != 403) return
+ val waited = android.os.SystemClock.elapsedRealtime() - issuedAt
+ if (waited > READY_WAIT_MS) error("$videoId still refused after $waited ms")
+ Thread.sleep(READY_POLL_MS)
+ }
+ }
+
+ /** The player answer of YouTube's TV app, signed in; see [player]. */
+ private fun tvPlayer(videoId: String, timestamp: Int): PlayerResponse {
+ val locale = YouTube.locale
+ val body = JSONObject()
+ .put(
+ "context",
+ JSONObject().put(
+ "client",
+ JSONObject()
+ .put("clientName", "TVHTML5")
+ .put("clientVersion", TV_VERSION)
+ .put("userAgent", TV_USER_AGENT)
+ .put("deviceMake", "Samsung")
+ .put("deviceModel", "UKS9800")
+ .put("osName", "Tizen")
+ .put("osVersion", "2.4.0")
+ .put("hl", locale.hl)
+ .put("gl", locale.gl)
+ .apply { YouTube.visitorData?.let { put("visitorData", it) } },
+ ),
+ )
+ .put("videoId", videoId)
+ .put(
+ "playbackContext",
+ JSONObject().put(
+ "contentPlaybackContext",
+ JSONObject().put("signatureTimestamp", timestamp).put("html5Preference", "HTML5_PREF_WANTS"),
+ ),
+ )
+ .put("contentCheckOk", true)
+ .put("racyCheckOk", true)
+ val cookie = YouTube.cookie ?: throw SignInRequired(videoId)
+ val request = Request.Builder()
+ .url("$WWW/youtubei/v1/player?prettyPrint=false")
+ .post(body.toString().toRequestBody("application/json".toMediaType()))
+ .header("User-Agent", TV_USER_AGENT)
+ .header("Origin", WWW)
+ .header("X-Origin", WWW)
+ .header("X-Youtube-Client-Name", "7")
+ .header("X-Youtube-Client-Version", TV_VERSION)
+ .header("Cookie", cookie)
+ .header("X-Goog-AuthUser", "0")
+ .apply {
+ authorization(cookie)?.let { header("Authorization", it) }
+ YouTube.visitorData?.let { header("X-Goog-Visitor-Id", it) }
+ YouTube.pageId?.takeIf { it.isNotBlank() }?.let { header("X-Goog-PageId", it) }
+ }
+ .build()
+ val text = http.newCall(request).execute().use { response ->
+ if (!response.isSuccessful) error("HTTP ${response.code}")
+ response.body?.string() ?: error("empty answer")
+ }
+ return json.decodeFromString(PlayerResponse.serializer(), text)
+ }
+
+ /**
+ * The hashes that prove the cookie's holder made the request, as the
+ * website sends them: one for each of the account's three API cookies
+ * the cookie carries, each over the time, the cookie and the origin.
+ */
+ private fun authorization(cookie: String): String? {
+ val cookies = cookie.split(';').associate { it.trim().substringBefore('=') to it.trim().substringAfter('=', "") }
+ val now = System.currentTimeMillis() / 1000
+ fun hash(scheme: String, value: String?) = value?.takeIf { it.isNotEmpty() }?.let {
+ val digest = java.security.MessageDigest.getInstance("SHA-1")
+ .digest("$now $it $WWW".toByteArray())
+ .joinToString("") { byte -> "%02x".format(byte) }
+ "$scheme ${now}_$digest"
+ }
+ return listOfNotNull(
+ hash("SAPISIDHASH", cookies["SAPISID"] ?: cookies["__Secure-3PAPISID"]),
+ hash("SAPISID1PHASH", cookies["__Secure-1PAPISID"]),
+ hash("SAPISID3PHASH", cookies["__Secure-3PAPISID"]),
+ ).takeIf { it.isNotEmpty() }?.joinToString(" ")
+ }
+
+ /** The name of the client that last played something, for the log. */
+ @Volatile
+ private var workingName: String? = null
+
+ private val http = okhttp3.OkHttpClient.Builder()
+ .connectTimeout(15, java.util.concurrent.TimeUnit.SECONDS)
+ .readTimeout(20, java.util.concurrent.TimeUnit.SECONDS)
+ .build()
+
+ private val json = Json {
+ ignoreUnknownKeys = true
+ explicitNulls = false
+ }
+
+ private val CLIENTS = listOf(
+ YouTubeClient.TVHTML5,
+ YouTubeClient.MOBILE,
+ // The website's clients: their streams need a proof-of-origin token
+ // this does not make, save for Premium accounts. Last, for those.
+ YouTubeClient.WEB_CREATOR,
+ YouTubeClient.WEB_REMIX,
+ YouTubeClient.WEB_ACCOUNTS,
+ )
+
+ private const val WWW = "https://www.youtube.com"
+ // A Samsung TV's, as yt-dlp's tv_samsung client: since August 2026 a TV
+ // client that does not say what TV it is answers "the page needs to be
+ // reloaded" to an account.
+ private const val TV_VERSION = "5.20260707"
+ private const val TV_USER_AGENT =
+ "Mozilla/5.0 (SMART-TV; Linux; Tizen 2.4.0) AppleWebKit/538.1 (KHTML, like Gecko) Version/2.4.0 TV Safari/538.1"
+
+ /**
+ * A format's address with its signature and its throttling parameter
+ * undone, both by YouTube's own player script; see PlayerChallenges.
+ */
+ private fun urlOf(
+ context: android.content.Context,
+ script: PlayerChallenges.Script,
+ format: PlayerResponse.StreamingData.Format,
+ ): String {
+ var url: String
+ var signature: String? = null
+ var signatureParameter = "signature"
+ val cipher = format.signatureCipher ?: format.cipher
+ val direct = format.url
+ if (direct != null) {
+ url = direct
+ } else {
+ cipher ?: error("no address for itag ${format.itag}")
+ val params = cipher.split('&').associate { pair ->
+ pair.substringBefore('=') to URLDecoder.decode(pair.substringAfter('=', ""), "UTF-8")
+ }
+ url = params["url"] ?: error("no url in the cipher")
+ signature = params["s"]
+ params["sp"]?.let { signatureParameter = it }
+ }
+ val throttle = android.net.Uri.parse(url).getQueryParameter("n")
+ val (nAnswers, sigAnswers) = PlayerChallenges.solve(
+ context,
+ script,
+ listOfNotNull(throttle),
+ listOfNotNull(signature),
+ )
+ if (signature != null) {
+ val solved = sigAnswers[signature] ?: error("signature unsolved")
+ url += "&$signatureParameter=${URLEncoder.encode(solved, "UTF-8")}"
+ }
+ if (throttle != null) {
+ val solved = nAnswers[throttle] ?: error("throttling parameter unsolved")
+ url = url.replace(THROTTLE, "$1n=${URLEncoder.encode(solved, "UTF-8")}")
+ }
+ return url
+ }
+
+ private val THROTTLE = Regex("""([?&])n=[^&]*""")
+
+ /** As long as the anonymous answers are kept; the addresses last for hours. */
+ private const val URL_TTL_MS = 60 * 60 * 1000L
+
+ private const val MAX_VIDEO_HEIGHT = 1080
+
+ private const val READY_WAIT_MS = 10_000L
+ private const val READY_POLL_MS = 500L
+
+ private const val TAG = "SquareYTSignedIn"
+}
diff --git a/app/src/main/java/dev/lelonio/square/backend/youtube/SkipFadePlayer.kt b/app/src/main/java/dev/lelonio/square/backend/youtube/SkipFadePlayer.kt
index 6930b6f..b3ada12 100644
--- a/app/src/main/java/dev/lelonio/square/backend/youtube/SkipFadePlayer.kt
+++ b/app/src/main/java/dev/lelonio/square/backend/youtube/SkipFadePlayer.kt
@@ -30,16 +30,50 @@ class SkipFadePlayer(
override fun addMediaItem(mediaItem: MediaItem) = addMediaItems(mutableListOf(mediaItem))
override fun addMediaItems(mediaItems: MutableList<MediaItem>) {
- val at = if (mediaItems.isNotEmpty() && mediaItems.all(::isQueued)) queueEnd() else mediaItemCount
+ val queued = mediaItems.isNotEmpty() && mediaItems.all(::isQueued)
+ val at = if (queued) queueEnd() else mediaItemCount
super.addMediaItems(at, mediaItems)
+ if (queued) playNextInShuffle(at, mediaItems.size)
}
override fun addMediaItem(index: Int, mediaItem: MediaItem) = addMediaItems(index, mutableListOf(mediaItem))
override fun addMediaItems(index: Int, mediaItems: MutableList<MediaItem>) {
// The controller asks for the end; the queue knows better where that is.
- val at = if (mediaItems.isNotEmpty() && mediaItems.all(::isQueued)) queueEnd() else index
+ val queued = mediaItems.isNotEmpty() && mediaItems.all(::isQueued)
+ val at = if (queued) queueEnd() else index
super.addMediaItems(at, mediaItems)
+ if (queued) playNextInShuffle(at, mediaItems.size)
+ }
+
+ /**
+ * Shuffled, the songs just queued are played next too.
+ *
+ * Placing them after the song playing in the list is not enough with
+ * shuffle on: ExoPlayer plays its own shuffled order, and gave the new
+ * songs a random place in it, so "play next" played a random song next.
+ * The order is rewritten with them right after the song playing and after
+ * anything queued before them, and everything else as it was.
+ */
+ private fun playNextInShuffle(at: Int, count: Int) {
+ val exo = wrappedPlayer as? androidx.media3.exoplayer.ExoPlayer ?: return
+ if (!shuffleModeEnabled || count <= 0) return
+ val timeline = currentTimeline
+ if (timeline.isEmpty) return
+ val added = (at until at + count).toSet()
+ val order = mutableListOf<Int>()
+ var index = timeline.getFirstWindowIndex(true)
+ while (index != androidx.media3.common.C.INDEX_UNSET && order.size < timeline.windowCount) {
+ order += index
+ index = timeline.getNextWindowIndex(index, Player.REPEAT_MODE_OFF, true)
+ }
+ order.removeAll(added)
+ var place = order.indexOf(currentMediaItemIndex) + 1
+ while (place in order.indices && isQueued(getMediaItemAt(order[place]))) place++
+ order.addAll(place.coerceIn(0, order.size), (at until at + count).toList())
+ exo.setShuffleOrder(
+ androidx.media3.exoplayer.source.ShuffleOrder.DefaultShuffleOrder(order.toIntArray(), System.nanoTime()),
+ )
}
private fun isQueued(item: MediaItem) =
diff --git a/app/src/main/java/dev/lelonio/square/backend/youtube/YouTubeAccount.kt b/app/src/main/java/dev/lelonio/square/backend/youtube/YouTubeAccount.kt
index dde2e1f..00f3321 100644
--- a/app/src/main/java/dev/lelonio/square/backend/youtube/YouTubeAccount.kt
+++ b/app/src/main/java/dev/lelonio/square/backend/youtube/YouTubeAccount.kt
@@ -69,6 +69,12 @@ class YouTubeAccount(context: Context) {
// Which of the account's channels is answering. Null is the personal
// one, which is what the cookie alone reads as.
YouTube.pageId = prefs.getString(KEY_PAGE_ID, null)
+ // Browsing as the account too, not only the library. InnerTube sends
+ // the cookie with a browse only when told to, and nothing told it: the
+ // home page was the one anybody in the country gets, with none of the
+ // account's own shelves (what it played lately, the mixes and albums
+ // made for it) that YouTube Music shows the same account.
+ YouTube.useLoginForBrowse = YouTube.cookie != null
}
/**
diff --git a/app/src/main/java/dev/lelonio/square/backend/youtube/YouTubeBackend.kt b/app/src/main/java/dev/lelonio/square/backend/youtube/YouTubeBackend.kt
index 7a741e8..948c2a0 100644
--- a/app/src/main/java/dev/lelonio/square/backend/youtube/YouTubeBackend.kt
+++ b/app/src/main/java/dev/lelonio/square/backend/youtube/YouTubeBackend.kt
@@ -483,6 +483,9 @@ class YouTubeBackend(private val account: YouTubeAccount) : MusicBackend {
when {
uri.startsWith(TRACK_PREFIX) || uri.startsWith(VIDEO_PREFIX) -> emptyList()
+ // A song's radio, reopened: asked again, as there is no list to browse.
+ isStation(uri) -> radio("$TRACK_PREFIX${id.removePrefix(RADIO_LIST)}")
+
// Videos stay videos: no swapping them for their songs here, which
// is the whole reason somebody opened this list.
uri.startsWith(VIDEOS_PREFIX) -> YouTube.playlist(id).getOrThrow().songs.map(::toVideoTrack)
@@ -529,6 +532,27 @@ class YouTubeBackend(private val account: YouTubeAccount) : MusicBackend {
}
}
+ /**
+ * A station built from one song, as YouTube Music's own "Start radio" does.
+ *
+ * The radio is a watch queue rather than a playlist that can be browsed:
+ * YouTube assembles it from `RDAMVM` and the song's id when the song is
+ * played with that list, so this asks for the queue that playing would
+ * bring, and once more for the page after it. The song itself comes first.
+ */
+ suspend fun radio(trackUri: String): List<CatalogTrack> = withContext(Dispatchers.IO) {
+ val id = videoIdOfUri(trackUri)
+ val first = YouTube.next(
+ com.metrolist.innertube.models.WatchEndpoint(videoId = id, playlistId = "$RADIO_LIST$id"),
+ ).getOrThrow()
+ val more = first.continuation
+ ?.let { runCatching { YouTube.next(first.endpoint, it).getOrThrow().items }.getOrNull() }
+ .orEmpty()
+ (first.items + more)
+ .distinctBy { it.id }
+ .map(::toCatalogTrack)
+ }
+
/** Conversions run on past the list that asked for them; see [asSongs]. */
private val background = kotlinx.coroutines.CoroutineScope(kotlinx.coroutines.SupervisorJob() + Dispatchers.IO)
@@ -661,7 +685,20 @@ class YouTubeBackend(private val account: YouTubeAccount) : MusicBackend {
durationMs: Long,
): Lyrics? {
DownloadExtras.lyrics(uri)?.let { raw ->
- runCatching { lyricsJson.decodeFromString<Lyrics>(raw) }.getOrNull()?.let { return it }
+ runCatching { lyricsJson.decodeFromString<Lyrics>(raw) }.getOrNull()
+ ?.takeIf { dev.lelonio.square.backend.lyrics.LyricsLibrary.shows(uri, it) }
+ ?.let { downloaded ->
+ // As for Spotify's downloads: the sources asked whether one is
+ // timed to the word now, and which one this copy came from.
+ val library = dev.lelonio.square.backend.lyrics.LyricsLibrary
+ if (library.worthAskingAgain(uri, downloaded)) {
+ library.improveLater(
+ dev.lelonio.square.backend.lyrics.LyricsQuery(uri, title, artist, durationMs),
+ downloaded,
+ )
+ }
+ return downloaded
+ }
}
val found = dev.lelonio.square.backend.lyrics.LyricsLibrary.lyrics(
@@ -808,6 +845,14 @@ class YouTubeBackend(private val account: YouTubeAccount) : MusicBackend {
/** What the library puts in front of the artists it follows; see publicArtistId. */
private const val LIBRARY_ARTIST_PREFIX = "MPLA"
+ /** What a song's radio is named after: this, then the song's id. */
+ private const val RADIO_LIST = "RDAMVM"
+
+ /** A song's radio as an address, for the page that shows it. */
+ fun stationUri(trackUri: String): String = "$PLAYLIST_PREFIX$RADIO_LIST${videoIdOfUri(trackUri)}"
+
+ fun isStation(uri: String?): Boolean = uri?.startsWith("$PLAYLIST_PREFIX$RADIO_LIST") == true
+
/** YouTube Music's own id for the account's liked songs. */
private const val LIKED_MUSIC_ID = "LM"
diff --git a/app/src/main/java/dev/lelonio/square/backend/youtube/YouTubeFadeController.kt b/app/src/main/java/dev/lelonio/square/backend/youtube/YouTubeFadeController.kt
index f2f711f..70bce3b 100644
--- a/app/src/main/java/dev/lelonio/square/backend/youtube/YouTubeFadeController.kt
+++ b/app/src/main/java/dev/lelonio/square/backend/youtube/YouTubeFadeController.kt
@@ -124,6 +124,10 @@ class YouTubeFadeController(
private fun checkEnd() {
if (changing || !player.isPlaying) return
+ // No crossfade while a sleep timer waits for the end of this song: the
+ // fade moved to the next song seconds early, the timer took that for
+ // a skip, and the music never paused. The song now plays to its end.
+ if (dev.lelonio.square.playback.SleepTimer.atTrackEnd.value) return
val fadeMs = crossfadeStore?.durationMs() ?: 0
if (fadeMs <= 0) {
if (preparedItem != null) cancelOverlap()
diff --git a/app/src/main/java/dev/lelonio/square/backend/youtube/YouTubePlayerFactory.kt b/app/src/main/java/dev/lelonio/square/backend/youtube/YouTubePlayerFactory.kt
index 769917c..6f35073 100644
--- a/app/src/main/java/dev/lelonio/square/backend/youtube/YouTubePlayerFactory.kt
+++ b/app/src/main/java/dev/lelonio/square/backend/youtube/YouTubePlayerFactory.kt
@@ -77,6 +77,35 @@ object YouTubePlayerFactory {
return buildPlayer(true, mainSlot).let { exo ->
exo.addAnalyticsListener(Diagnostics)
+ // A song YouTube plays only to an account, with none signed in:
+ // said, and passed over, rather than left at --:-- with no word
+ // of why. See SignedInStreams.
+ exo.addListener(object : Player.Listener {
+ override fun onPlayerError(error: androidx.media3.common.PlaybackException) {
+ // A signed-in address that failed is not handed out again.
+ SignedInStreams.forget()
+ val causes = generateSequence<Throwable>(error) { it.cause }.toList()
+ val message = when {
+ causes.any { it is SignedInStreams.SignInRequired } ->
+ dev.lelonio.square.R.string.youtube_sign_in_required
+ causes.any { it is SignedInStreams.Refused } ->
+ dev.lelonio.square.R.string.youtube_signed_in_unplayable
+ else -> return
+ }
+ android.os.Handler(android.os.Looper.getMainLooper()).post {
+ android.widget.Toast.makeText(
+ host.context,
+ host.context.getString(message),
+ android.widget.Toast.LENGTH_LONG,
+ ).show()
+ }
+ if (exo.hasNextMediaItem()) {
+ exo.seekToNextMediaItem()
+ exo.prepare()
+ exo.play()
+ }
+ }
+ })
// Video for a video, sound for a song, as the queue moves.
exo.addListener(object : Player.Listener {
override fun onMediaItemTransition(mediaItem: androidx.media3.common.MediaItem?, reason: Int) {
@@ -172,6 +201,10 @@ object YouTubePlayerFactory {
parameters: androidx.media3.common.PlaybackParameters,
) {
android.util.Log.w(TAG, "params speed=${parameters.speed} pitch=${parameters.pitch}")
+ // Saved here as on the Spotify path (see LibrespotPlayer): never
+ // saved for a YouTube song, the effects button went on reading the
+ // speed of the last Spotify one, lit after "Original".
+ dev.lelonio.square.playback.AudioEffects.rememberSpeedAndPitch(parameters.speed, parameters.pitch)
}
override fun onLoadError(
@@ -286,7 +319,33 @@ private class YouTubeStreamResolver(
private val context: android.content.Context,
) : ResolvingDataSource.Resolver {
- override fun resolveDataSpec(dataSpec: DataSpec): DataSpec {
+ /**
+ * Asked without an account, and again as the account where YouTube will
+ * only play the song to one; see SignedInStreams.
+ */
+ override fun resolveDataSpec(dataSpec: DataSpec): DataSpec = try {
+ resolveAnonymously(dataSpec)
+ } catch (error: Exception) {
+ if (!SignedInStreams.needsAccount(error)) throw error
+ val base = dataSpec.uri.toString().substringBefore('#')
+ val kind = when (dataSpec.uri.fragment) {
+ PART_VIDEO -> SignedInStreams.Kind.VIDEO
+ PART_AUDIO -> SignedInStreams.Kind.AUDIO
+ else -> if (YouTubeVideoMode.wantsVideo(base)) SignedInStreams.Kind.MUXED else SignedInStreams.Kind.AUDIO
+ }
+ val id = YouTubeBackend.videoIdOfUri(base)
+ val url = try {
+ SignedInStreams.url(context, id, kind, wantsLowRate())
+ } catch (refused: SignedInStreams.SignInRequired) {
+ throw refused
+ } catch (refused: Exception) {
+ android.util.Log.w("SquareYTSignedIn", "$id refused: ${refused.message}")
+ throw SignedInStreams.Refused(id, refused)
+ }
+ dataSpec.withUri(android.net.Uri.parse(url))
+ }
+
+ private fun resolveAnonymously(dataSpec: DataSpec): DataSpec {
val uri = dataSpec.uri.toString()
if (!uri.startsWith(YouTubeBackend.TRACK_PREFIX) && !uri.startsWith(YouTubeBackend.VIDEO_PREFIX)) {
return dataSpec
diff --git a/app/src/main/java/dev/lelonio/square/data/Catalog.kt b/app/src/main/java/dev/lelonio/square/data/Catalog.kt
index 91d7588..d6077ca 100644
--- a/app/src/main/java/dev/lelonio/square/data/Catalog.kt
+++ b/app/src/main/java/dev/lelonio/square/data/Catalog.kt
@@ -111,6 +111,21 @@ data class Lyrics(
val synced: Boolean,
/** The LyricsSource it came from, by name; null for words kept before this was recorded. */
val source: String? = null,
+ /** Who to credit under the words, where the source requires it; see LyricsCredit. */
+ val credit: LyricsCredit? = null,
+)
+
+/**
+ * The credit a source asks to be shown wherever its words are: its name, and
+ * for community syncs the person who uploaded them and the one who made them.
+ */
+@Serializable
+data class LyricsCredit(
+ val provider: String,
+ val uploader: String? = null,
+ val uploaderUrl: String? = null,
+ val maker: String? = null,
+ val makerUrl: String? = null,
)
/**
diff --git a/app/src/main/java/dev/lelonio/square/data/LocalFileBindings.kt b/app/src/main/java/dev/lelonio/square/data/LocalFileBindings.kt
new file mode 100644
index 0000000..bfa35e9
--- /dev/null
+++ b/app/src/main/java/dev/lelonio/square/data/LocalFileBindings.kt
@@ -0,0 +1,49 @@
+package dev.lelonio.square.data
+
+import android.content.Context
+import java.io.File
+import java.util.concurrent.ConcurrentHashMap
+import org.json.JSONObject
+
+/**
+ * Which file on this phone each local entry of a Spotify playlist is, kept.
+ *
+ * A `spotify:local:` entry plays from a file only if the engine is told which
+ * one, and that used to be worked out when a playlist page opened and held in
+ * memory only. The queue survived a restart and this did not: a local song
+ * that was playing came back as an entry the engine could not find, silent
+ * until its playlist was opened again and the match made anew. Kept on disk
+ * and handed to the engine as it starts, the queue comes back whole.
+ */
+object LocalFileBindings {
+
+ private val bindings = ConcurrentHashMap<String, String>()
+ private var store: File? = null
+
+ fun attach(context: Context) {
+ store = File(context.applicationContext.filesDir, "local-file-bindings.json")
+ runCatching {
+ val json = JSONObject(store?.takeIf { it.exists() }?.readText() ?: return@runCatching)
+ json.keys().forEach { uri -> json.optString(uri).takeIf { it.isNotEmpty() }?.let { bindings[uri] = it } }
+ }
+ }
+
+ fun has(uri: String): Boolean = bindings.containsKey(uri)
+
+ /** New matches, kept and told to the engine. */
+ fun bind(entries: Map<String, String>) {
+ if (entries.isEmpty() || entries.all { (uri, path) -> bindings[uri] == path }) {
+ push()
+ return
+ }
+ bindings.putAll(entries)
+ runCatching { store?.writeText(JSONObject(bindings.toMap()).toString()) }
+ push()
+ }
+
+ /** Everything kept, to the engine: on every match, and when it starts. */
+ fun push() {
+ if (bindings.isEmpty()) return
+ runCatching { dev.lelonio.square.nativecore.NativeBridge.setLocalFiles(JSONObject(bindings.toMap()).toString()) }
+ }
+}
diff --git a/app/src/main/java/dev/lelonio/square/data/PreferencesStore.kt b/app/src/main/java/dev/lelonio/square/data/PreferencesStore.kt
index fb60792..145201b 100644
--- a/app/src/main/java/dev/lelonio/square/data/PreferencesStore.kt
+++ b/app/src/main/java/dev/lelonio/square/data/PreferencesStore.kt
@@ -104,6 +104,29 @@ class PreferencesStore(context: Context) {
prefs.edit().putBoolean(KEY_CANVAS, value).apply()
}
+ private val _spicyLyricsKey = MutableStateFlow(prefs.getString(KEY_SPICY_LYRICS, null).orEmpty())
+
+ /** The listener's own Spicy Lyrics key; blank leaves that source out. */
+ val spicyLyricsKey: StateFlow<String> = _spicyLyricsKey.asStateFlow()
+
+ fun setSpicyLyricsKey(value: String) {
+ _spicyLyricsKey.value = value.trim()
+ prefs.edit().putString(KEY_SPICY_LYRICS, value.trim()).apply()
+ }
+
+ private val _preferredLyricsSource = MutableStateFlow(prefs.getString(KEY_PREFERRED_LYRICS, null).orEmpty())
+
+ /**
+ * The lyrics source to show whenever it has words for the song, by its
+ * LyricsSource name; blank for the best of them, which is the default.
+ */
+ val preferredLyricsSource: StateFlow<String> = _preferredLyricsSource.asStateFlow()
+
+ fun setPreferredLyricsSource(value: String) {
+ _preferredLyricsSource.value = value
+ prefs.edit().putString(KEY_PREFERRED_LYRICS, value).apply()
+ }
+
/** How the lyrics are drawn: animated word by word, or as plain lines. */
enum class LyricsStyle { ANIMATED, CLASSIC }
@@ -349,6 +372,8 @@ class PreferencesStore(context: Context) {
const val KEY_SYSTEM_FONT = "system_font"
const val KEY_YOUTUBE_QUALITY = "youtube_quality"
const val KEY_LYRICS_STYLE = "lyrics_style"
+ const val KEY_SPICY_LYRICS = "spicy_lyrics_key"
+ const val KEY_PREFERRED_LYRICS = "preferred_lyrics_source"
const val KEY_KEEP_PLAYING = "keep_playing_on_close"
const val KEY_SPONSOR_BLOCK = "sponsor_block"
const val KEY_AUTOPLAY_INFINITE = "autoplay_infinite"
diff --git a/app/src/main/java/dev/lelonio/square/playback/MediaBrowseTree.kt b/app/src/main/java/dev/lelonio/square/playback/MediaBrowseTree.kt
index 51531f8..735b50e 100644
--- a/app/src/main/java/dev/lelonio/square/playback/MediaBrowseTree.kt
+++ b/app/src/main/java/dev/lelonio/square/playback/MediaBrowseTree.kt
@@ -354,18 +354,22 @@ class MediaBrowseTree(
/**
* A station from what is playing, without a screen to ask anything of.
*
- * The same list the player's own radio button builds: Spotify assembles it
+ * The same list the player's own radio button builds: the service assembles it
* and this asks for it. If it will not, the queue is left alone rather than
* replaced with something nobody chose.
*/
private fun startRadio(session: MediaSession) {
val player = session.player
val uri = player.currentMediaItem?.mediaId ?: return
- if (!uri.startsWith("spotify:track:")) return
+ val youtube = uri.startsWith(dev.lelonio.square.backend.youtube.YouTubeBackend.TRACK_PREFIX) ||
+ uri.startsWith(dev.lelonio.square.backend.youtube.YouTubeBackend.VIDEO_PREFIX)
+ if (!uri.startsWith("spotify:track:") && !youtube) return
scope.launch {
val station = "spotify:station:track:${uri.substringAfterLast(':')}"
- val tracks = runCatching { Catalog.tracks(Catalog.contextTrackUris(station)) }
+ val tracks = runCatching {
+ if (youtube) app.youtubeBackend.radio(uri) else Catalog.tracks(Catalog.contextTrackUris(station))
+ }
.onFailure { android.util.Log.w(TAG, "no station for $uri: $it") }
.getOrDefault(emptyList())
if (tracks.isEmpty()) return@launch
diff --git a/app/src/main/java/dev/lelonio/square/playback/NetworkWatch.kt b/app/src/main/java/dev/lelonio/square/playback/NetworkWatch.kt
index b1cfb0f..9af84e6 100644
--- a/app/src/main/java/dev/lelonio/square/playback/NetworkWatch.kt
+++ b/app/src/main/java/dev/lelonio/square/playback/NetworkWatch.kt
@@ -34,13 +34,35 @@ class NetworkWatch(context: Context, private val scope: CoroutineScope) {
/** A second look, because the first one races the system's own bookkeeping. */
private var settle: Job? = null
+ /**
+ * The default network as the callbacks name it, and what it can do.
+ *
+ * Not `activeNetwork`: that answers null to an app in the background
+ * whose network access the system is holding back (an app on standby, or
+ * one it has frozen), Wi-Fi up and working all the while. Read from there,
+ * leaving the app for a minute was the network going, and offline after
+ * it. The callbacks say which network is the default whatever the app is
+ * doing; it is gone when they say it is lost.
+ */
+ @Volatile
+ private var current: Pair<Network, NetworkCapabilities?>? = null
+
private val callback = object : ConnectivityManager.NetworkCallback() {
- override fun onAvailable(network: Network) = recheck()
- override fun onLost(network: Network) = recheck()
+ override fun onAvailable(network: Network) {
+ if (current?.first != network) current = network to connectivity?.getNetworkCapabilities(network)
+ recheck()
+ }
+ override fun onLost(network: Network) {
+ if (current?.first == network) current = null
+ recheck()
+ }
override fun onCapabilitiesChanged(
network: Network,
capabilities: NetworkCapabilities,
- ) = recheck()
+ ) {
+ current = network to capabilities
+ recheck()
+ }
}
fun start() {
@@ -93,7 +115,7 @@ class NetworkWatch(context: Context, private val scope: CoroutineScope) {
// ends offline once the engine itself has one. Declaring it back
// here was how the library stayed on the downloads after the
// signal returned.
- if (returned) SessionKeeper.networkReturned()
+ SessionKeeper.networkUp(returned)
OfflineMode.setSlow(false)
return
}
@@ -113,10 +135,13 @@ class NetworkWatch(context: Context, private val scope: CoroutineScope) {
* (Google 204 probe) frequently fails or is blocked on local/regional networks
* despite having working internet.
*/
+ /** The default network's capabilities: from the callbacks, or asked before the first one. */
+ private fun capabilities(): NetworkCapabilities? =
+ current?.let { (network, known) -> known ?: connectivity?.getNetworkCapabilities(network) }
+ ?: connectivity?.activeNetwork?.let { connectivity.getNetworkCapabilities(it) }
+
private fun describe(): String {
- val network = connectivity?.activeNetwork ?: return "no active network"
- val capabilities = connectivity.getNetworkCapabilities(network)
- ?: return "active network with no capabilities"
+ val capabilities = capabilities() ?: return "no default network"
val transports = listOfNotNull(
"wifi".takeIf { capabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI) },
"cellular".takeIf { capabilities.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR) },
@@ -131,8 +156,7 @@ class NetworkWatch(context: Context, private val scope: CoroutineScope) {
}
private fun connected(): Boolean {
- val network = connectivity?.activeNetwork ?: return false
- val capabilities = connectivity.getNetworkCapabilities(network) ?: return false
+ val capabilities = capabilities() ?: return false
val hasInternet = capabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
val isWifi = capabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI)
val isEthernet = capabilities.hasTransport(NetworkCapabilities.TRANSPORT_ETHERNET)
diff --git a/app/src/main/java/dev/lelonio/square/playback/PlaybackService.kt b/app/src/main/java/dev/lelonio/square/playback/PlaybackService.kt
index 6a0049b..fccb7ca 100644
--- a/app/src/main/java/dev/lelonio/square/playback/PlaybackService.kt
+++ b/app/src/main/java/dev/lelonio/square/playback/PlaybackService.kt
@@ -665,9 +665,18 @@ class PlaybackService : MediaLibraryService() {
}
}
+ /**
+ * The ExoPlayer behind [player], if there is one. The YouTube player is
+ * an ExoPlayer inside SkipFadePlayer: asked only for an ExoPlayer, its
+ * songs never got the room.
+ */
+ private fun exoOf(player: androidx.media3.common.Player?): androidx.media3.exoplayer.ExoPlayer? =
+ player as? androidx.media3.exoplayer.ExoPlayer
+ ?: (player as? androidx.media3.common.ForwardingPlayer)?.wrappedPlayer as? androidx.media3.exoplayer.ExoPlayer
+
/** Puts the room on the player in front, or takes it off the one leaving. */
private fun followReverb() {
- val exo = player as? androidx.media3.exoplayer.ExoPlayer ?: return
+ val exo = exoOf(player) ?: return
exoReverb.apply(exo, AudioEffects.reverb.value)
}
@@ -937,7 +946,7 @@ class PlaybackService : MediaLibraryService() {
// command answered "engine not started". Parked, it keeps the session
// alive behind the local player and is picked up again on the way back,
// already configured.
- (player as? androidx.media3.exoplayer.ExoPlayer)?.let(exoReverb::release)
+ exoOf(player)?.let(exoReverb::release)
// The video is the same case as a local file: the session plays
// something else for a while, and the engine has to be there when the
@@ -1463,6 +1472,15 @@ class PlaybackService : MediaLibraryService() {
val offline = runCatching { NativeBridge.isOffline }.getOrDefault(false)
dev.lelonio.square.playback.OfflineMode.setNoSession(offline)
android.util.Log.i(TAG, if (offline) "engine started offline" else "engine connected")
+ // Before the queue is handed over: a local song that was playing
+ // when the app closed is only playable once the engine knows its
+ // file; see LocalFileBindings. Entries of the saved queue never
+ // matched yet (saved by an older build, or never shown on a page
+ // since) are matched here, against the phone's own music, rather
+ // than left silent until their playlist is opened.
+ runCatching { bindSavedLocalEntries() }
+ .onFailure { android.util.Log.w(TAG, "local files not matched: $it") }
+ dev.lelonio.square.data.LocalFileBindings.push()
// Up with no session: try again for as long as there is a network.
if (offline) SessionKeeper.sessionMissing()
if (restoreQueue) restoreQueue()
@@ -1470,6 +1488,22 @@ class PlaybackService : MediaLibraryService() {
}
}
+ /** See the note where it is called, as the engine starts. */
+ private suspend fun bindSavedLocalEntries() {
+ val saved = playbackStore.load() ?: return
+ val unmatched = saved.tracks.filter {
+ dev.lelonio.square.data.LocalLibrary.isSpotifyLocal(it.uri) &&
+ !dev.lelonio.square.data.LocalFileBindings.has(it.uri)
+ }
+ if (unmatched.isEmpty()) return
+ val files = dev.lelonio.square.data.LocalLibrary.tracks(this)
+ val found = unmatched.mapNotNull { entry ->
+ dev.lelonio.square.data.LocalLibrary.match(entry, files)?.localFile?.let { entry.uri to it }
+ }.toMap()
+ android.util.Log.i(TAG, "matched ${found.size} of ${unmatched.size} local entries of the saved queue")
+ dev.lelonio.square.data.LocalFileBindings.bind(found)
+ }
+
/**
* Puts the last queue back, paused at the saved position.
*
diff --git a/app/src/main/java/dev/lelonio/square/playback/PlayerReverb.kt b/app/src/main/java/dev/lelonio/square/playback/PlayerReverb.kt
index f78c068..06cbe45 100644
--- a/app/src/main/java/dev/lelonio/square/playback/PlayerReverb.kt
+++ b/app/src/main/java/dev/lelonio/square/playback/PlayerReverb.kt
@@ -33,6 +33,21 @@ class PlayerReverb {
*/
private var watched: ExoPlayer? = null
private val level = object : androidx.media3.common.Player.Listener {
+ /**
+ * Off on pause and fresh on play, as on the Spotify path (see
+ * AudioOutput.setPlaybackActive). Left on through a pause, the room
+ * rang on for a moment, was cut off when the system stopped feeding
+ * it, and played the rest of that old tail over the next play.
+ */
+ override fun onPlayWhenReadyChanged(playWhenReady: Boolean, reason: Int) {
+ val player = watched ?: return
+ if (playWhenReady) {
+ if (amount > 0f && effect == null) apply(player, amount)
+ } else {
+ drop(player)
+ }
+ }
+
override fun onVolumeChanged(volume: Float) {
val player = watched ?: return
val room = amount
@@ -69,6 +84,9 @@ class PlayerReverb {
runCatching { player.addListener(this.level) }
}
+ // Built on play: a paused player gets its room when it starts.
+ if (!player.playWhenReady) return
+
val existing = effect
val reverb = existing ?: runCatching {
// Priority 0 and the output mix, as on the other path.
@@ -107,6 +125,14 @@ class PlayerReverb {
runCatching { player.removeListener(level) }
watched = null
}
+ drop(player)
+ }
+
+ /**
+ * Takes the room off [player] and throws it away, with whatever is still
+ * ringing inside it; released rather than disabled, see AudioOutput.
+ */
+ private fun drop(player: ExoPlayer) {
runCatching {
player.setAuxEffectInfo(AuxEffectInfo(AuxEffectInfo.NO_AUX_EFFECT_ID, 0f))
}
diff --git a/app/src/main/java/dev/lelonio/square/playback/SessionKeeper.kt b/app/src/main/java/dev/lelonio/square/playback/SessionKeeper.kt
index 370bf91..b52de0a 100644
--- a/app/src/main/java/dev/lelonio/square/playback/SessionKeeper.kt
+++ b/app/src/main/java/dev/lelonio/square/playback/SessionKeeper.kt
@@ -50,8 +50,22 @@ object SessionKeeper {
this.wanted = wanted
}
- /** The network came back after being gone. */
- fun networkReturned() = start("network returned")
+ /**
+ * A network is up: after being gone, or, with [returned] false, as it was.
+ *
+ * With no Spotify session wanted (YouTube Music the source, or nobody
+ * signed in) there is no session to wait for, and a network is all
+ * offline was about: it ends here. Left to the tries below, which stop at
+ * once when the engine is not wanted, it never ended at all, and the
+ * library stayed greyed out on a phone with working Wi-Fi.
+ */
+ fun networkUp(returned: Boolean) {
+ if (!wanted()) {
+ OfflineMode.setNoSession(false)
+ return
+ }
+ if (returned) start("network returned")
+ }
/** The network went; no point trying until it is back. */
fun networkGone() {
diff --git a/app/src/main/java/dev/lelonio/square/ui/MainViewModel.kt b/app/src/main/java/dev/lelonio/square/ui/MainViewModel.kt
index f0434dd..aa386cd 100644
--- a/app/src/main/java/dev/lelonio/square/ui/MainViewModel.kt
+++ b/app/src/main/java/dev/lelonio/square/ui/MainViewModel.kt
@@ -822,6 +822,7 @@ class MainViewModel(app: Application) : AndroidViewModel(app) {
private var devicesJob: Job? = null
init {
+ followKeptYouTube()
// A video in an open list, put right as its song is found; see
// YouTubeBackend.asSongs, which opens the list without waiting for all.
viewModelScope.launch {
@@ -1285,14 +1286,7 @@ class MainViewModel(app: Application) : AndroidViewModel(app) {
LocalLibrary.spotifyUri(file).also { uri ->
// Playable at once from the playlist, without waiting
// for its page to be matched again.
- file.localFile?.let { path ->
- engineLocalFiles[uri] = path
- runCatching {
- dev.lelonio.square.nativecore.NativeBridge.setLocalFiles(
- org.json.JSONObject(engineLocalFiles.toMap()).toString(),
- )
- }
- }
+ file.localFile?.let { path -> dev.lelonio.square.data.LocalFileBindings.bind(mapOf(uri to path)) }
}
}
withContext(Dispatchers.IO) {
@@ -2403,6 +2397,8 @@ class MainViewModel(app: Application) : AndroidViewModel(app) {
val snapshot = readLibrarySnapshot()
_state.value = snapshot ?: UiState.Connecting
if (!awaitEngine()) {
+ // No session, so Spotify's shelves are not coming from this load.
+ homeShelvesSettled.value = true
// A library with no session is not an empty library. Everything
// that was downloaded is still here and still playable, and the
// shelf for it is the one thing the listener came for.
@@ -2669,6 +2665,11 @@ class MainViewModel(app: Application) : AndroidViewModel(app) {
* playing something the listener did not choose.
*/
suspend fun radioFor(trackUri: String): List<CatalogTrack> {
+ if (isYouTubeSong(trackUri)) {
+ return runCatching { container.youtubeBackend.radio(trackUri) }
+ .onFailure { android.util.Log.w(TAG, "no radio for $trackUri: ${describe(it)}") }
+ .getOrDefault(emptyList())
+ }
val id = trackUri.substringAfterLast(':')
val station = "spotify:station:track:$id"
return runCatching { Catalog.tracks(Catalog.contextTrackUris(station)) }
@@ -2676,6 +2677,22 @@ class MainViewModel(app: Application) : AndroidViewModel(app) {
.getOrDefault(emptyList())
}
+ /** The address of the station [radioFor] builds from [trackUri]: Spotify's, or YouTube's. */
+ fun stationFor(trackUri: String): String =
+ if (isYouTubeSong(trackUri)) {
+ dev.lelonio.square.backend.youtube.YouTubeBackend.stationUri(trackUri)
+ } else {
+ "spotify:station:track:" + trackUri.substringAfterLast(':')
+ }
+
+ /** Whether a song has a radio at all: Spotify's tracks and YouTube's songs and videos. */
+ fun hasRadio(trackUri: String): Boolean =
+ trackUri.startsWith("spotify:track:") || isYouTubeSong(trackUri)
+
+ private fun isYouTubeSong(uri: String) =
+ uri.startsWith(dev.lelonio.square.backend.youtube.YouTubeBackend.TRACK_PREFIX) ||
+ uri.startsWith(dev.lelonio.square.backend.youtube.YouTubeBackend.VIDEO_PREFIX)
+
/** How the detail screen sorts its tracks; remembered between visits. */
val trackOrders get() = container.preferences.trackOrders
val defaultTrackOrder get() = container.preferences.defaultTrackOrder
@@ -3166,6 +3183,8 @@ class MainViewModel(app: Application) : AndroidViewModel(app) {
private fun loadHomeShelves() {
if (homeShelvesJob?.isActive == true) return
+ // On their way again, so their outline shows rather than the stand-in.
+ if (_homeShelves.value.isEmpty()) homeShelvesSettled.value = false
homeShelvesJob = viewModelScope.launch { loadHomeShelvesNow() }
}
@@ -3176,6 +3195,31 @@ class MainViewModel(app: Application) : AndroidViewModel(app) {
* coming up, used to be the end of Spotify's home for the session.
*/
private suspend fun loadHomeShelvesNow() {
+ try {
+ loadHomeShelvesTries()
+ } finally {
+ homeShelvesSettled.value = true
+ }
+ }
+
+ /**
+ * Whether Spotify's own shelves have been asked for and answered, either
+ * way. Until then the home page draws their outline rather than the app's
+ * own stand-in page, which used to show first and be swapped for Spotify's
+ * a few seconds later, all at once.
+ */
+ private val homeShelvesSettled = MutableStateFlow(false)
+
+ /** Spotify's shelves are on their way: online, on Spotify, not yet answered. */
+ val homeShelvesLoading: StateFlow<Boolean> = combine(
+ homeShelvesSettled,
+ dev.lelonio.square.playback.OfflineMode.active,
+ container.preferences.backend,
+ ) { settled, offline, backend ->
+ !settled && !offline && backend == BackendId.SPOTIFY && container.spotifySignedIn
+ }.stateIn(viewModelScope, SharingStarted.Eagerly, container.spotifySignedIn)
+
+ private suspend fun loadHomeShelvesTries() {
var shelves = emptyList<HomeShelf>()
for (wait in HOME_RETRY_MS) {
kotlinx.coroutines.delay(wait)
@@ -3625,6 +3669,56 @@ class MainViewModel(app: Application) : AndroidViewModel(app) {
}
}
+ /**
+ * A kept page brought in step with the page as it now reads.
+ *
+ * Downloading a playlist used to record its songs as they were that day
+ * and never look again: a song added afterwards, here or anywhere else,
+ * was in the list and not on the phone, and one taken out stayed on the
+ * phone. Every full read of a kept page now replaces what it wants, which
+ * fetches what is new and lets go of what is gone; the order is kept too,
+ * since it is the order the page shows offline.
+ *
+ * Only from a whole list read from the service: offline, or from a list
+ * that came back empty, there is nothing to say the playlist changed.
+ */
+ private fun followKept(uri: String, tracks: List<CatalogTrack>) {
+ val kept = container.downloads.owners.value[uri] ?: return
+ if (tracks.isEmpty() || dev.lelonio.square.playback.OfflineMode.active.value) return
+ val now = tracks.map { it.uri }
+ if (now == kept) return
+ viewModelScope.launch {
+ container.downloads.setOwner(uri, tracks, label = null)
+ val added = now.toSet() - kept.toSet()
+ val gone = kept.toSet() - now.toSet()
+ android.util.Log.i(TAG, "kept $uri followed: ${added.size} added, ${gone.size} gone")
+ if (gone.isNotEmpty()) sweepOrphans()
+ if (added.isNotEmpty()) DownloadService.start(getApplication())
+ }
+ }
+
+ /**
+ * Every kept list of YouTube Music's read again, once a run.
+ *
+ * A song added to a playlist from YouTube Music itself, or from another
+ * phone, would otherwise wait for the playlist to be opened here before
+ * it was downloaded. Spotify's are left to their next open: reading a
+ * long one in full is many requests, where YouTube answers in one.
+ */
+ private fun followKeptYouTube() = viewModelScope.launch {
+ delay(KEPT_SYNC_DELAY_MS)
+ container.downloads.ensureLoaded()
+ if (dev.lelonio.square.playback.OfflineMode.active.value) return@launch
+ val youtube = container.youtubeBackend
+ container.downloads.owners.value.keys
+ .filter { it.startsWith(dev.lelonio.square.backend.youtube.YouTubeBackend.PLAYLIST_PREFIX) }
+ .forEach { uri ->
+ runCatching { youtube.tracksOf(uri) }
+ .onSuccess { followKept(uri, it) }
+ .onFailure { android.util.Log.w(TAG, "kept $uri not read: ${describe(it)}") }
+ }
+ }
+
/**
* One track, kept on its own.
*
@@ -3810,22 +3904,17 @@ class MainViewModel(app: Application) : AndroidViewModel(app) {
artworkUrl = track.artworkUrl ?: file?.artworkUrl,
)
}
- // Told to the engine as they are found, and kept: a queue started on
- // one page plays on while another is open.
- matched.forEach { track ->
- val path = track.localFile ?: return@forEach
- if (LocalLibrary.isSpotifyLocal(track.uri)) engineLocalFiles[track.uri] = path
- }
- runCatching {
- dev.lelonio.square.nativecore.NativeBridge.setLocalFiles(
- org.json.JSONObject(engineLocalFiles.toMap()).toString(),
- )
- }
+ // Told to the engine as they are found, and kept, on disk too: a queue
+ // started on one page plays on while another is open, and after the
+ // app is closed and opened again; see LocalFileBindings.
+ dev.lelonio.square.data.LocalFileBindings.bind(
+ matched.mapNotNull { track ->
+ track.localFile?.takeIf { LocalLibrary.isSpotifyLocal(track.uri) }?.let { track.uri to it }
+ }.toMap(),
+ )
return matched
}
- /** Every local entry matched so far, as the engine is told them. */
- private val engineLocalFiles = java.util.concurrent.ConcurrentHashMap<String, String>()
fun openPlaylist(playlist: CatalogPlaylist) {
// Read again on every page: a file copied to the phone since the last
@@ -4080,6 +4169,7 @@ class MainViewModel(app: Application) : AndroidViewModel(app) {
return@launch
}
val tracks = container.activeBackend.tracksOf(playlist.uri)
+ followKept(playlist.uri, tracks)
if (isActive && _playlist.value.uri == playlist.uri) {
publishPlaylist(base.copy(tracks = tracks, loading = false))
}
@@ -4152,6 +4242,9 @@ class MainViewModel(app: Application) : AndroidViewModel(app) {
if (isActive && _playlist.value.uri == playlist.uri) {
publishPlaylist(base.copy(tracks = cached, loadingMore = false))
}
+ // The copy is the playlist as it is now, so a download
+ // of it that is behind can catch up from it.
+ followKept(playlist.uri, cached)
// A copy saved without a stamp is asked for one now, so
// the next open has a question to ask instead of a
// whole playlist to read.
@@ -4870,6 +4963,16 @@ class MainViewModel(app: Application) : AndroidViewModel(app) {
private fun invalidateContext(uri: String) {
contextCache.remove(uri)
viewModelScope.launch { container.contextCache.remove(uri) }
+ // A song just added to, or taken out of, a list that is kept: read
+ // again now rather than on the next open, so the download follows the
+ // change while the listener is still looking at it. Spotify's lists
+ // are read again on the next open, which the change above forces.
+ if (!uri.startsWith("spotify:") && container.downloads.owners.value.containsKey(uri)) {
+ viewModelScope.launch {
+ runCatching { container.activeBackend.tracksOf(uri) }
+ .onSuccess { followKept(uri, it) }
+ }
+ }
}
/**
@@ -4924,6 +5027,7 @@ class MainViewModel(app: Application) : AndroidViewModel(app) {
// Stamped with the version it was read from, so the next open can ask
// one question instead of reading it all again. Without a stamp the
// entry still saves — it just gets refreshed silently every time.
+ followKept(uri, tracks)
val snapshotId = snapshotOf(uri)
contextCache[uri] = ContextCacheStore.Entry(tracks, snapshotId)
rememberMembership(uri, tracks)
@@ -6068,6 +6172,9 @@ class MainViewModel(app: Application) : AndroidViewModel(app) {
const val TAG = "SquareUi"
+ /** After the start's own requests, which the listener is waiting on. */
+ const val KEPT_SYNC_DELAY_MS = 15_000L
+
/** Artists asked for new records on the home page; one request each. */
const val FRESH_ARTISTS = 14
diff --git a/app/src/main/java/dev/lelonio/square/ui/SquareApp.kt b/app/src/main/java/dev/lelonio/square/ui/SquareApp.kt
index 45958f6..5561365 100644
--- a/app/src/main/java/dev/lelonio/square/ui/SquareApp.kt
+++ b/app/src/main/java/dev/lelonio/square/ui/SquareApp.kt
@@ -462,6 +462,7 @@ fun SquareApp(
.collectAsStateWithLifecycle()
val inPlaylists by viewModel.inPlaylists.collectAsStateWithLifecycle()
val homeShelves by viewModel.homeShelves.collectAsStateWithLifecycle()
+ val homeShelvesLoading by viewModel.homeShelvesLoading.collectAsStateWithLifecycle()
val remote = elsewhere?.takeIf { elsewhereActive }
val showConnectedDevice by (context.applicationContext as dev.lelonio.square.SquareApplication)
.preferences.showConnectedDevice.collectAsStateWithLifecycle()
@@ -825,11 +826,17 @@ fun SquareApp(
// and the glass, which still reads it, always takes its dark film.
val playerInk = Color(0xFFF7F8FA)
+ // The cover's colour, except while a video plays: the picture on screen is
+ // the video, not the sleeve, and glass tinted after a record nobody is
+ // looking at clashes with it. The plain glass instead, until the video
+ // is put away.
+ val glassAccent = accent.takeUnless { videoOn || spotifyVideoOn }
+
// And the film on its glass: still dark, and now the record's own dark.
// The song's colour at the depth the grey film sat at, see playerFilmTint,
// eased from one song to the next rather than cut, like the field under it.
val playerFilm by animateColorAsState(
- targetValue = accent?.let { dev.lelonio.square.ui.player.playerFilmTint(it) }
+ targetValue = glassAccent?.let { dev.lelonio.square.ui.player.playerFilmTint(it) }
?: Color(0xFF23232A),
animationSpec = tween(PLAYER_FILM_FADE_MS),
label = "playerFilm",
@@ -1083,17 +1090,23 @@ fun SquareApp(
// Lyrics are lightweight text — fetch them immediately without delay.
// Wait until title and artist metadata have arrived to avoid fetching
// with empty strings and polluting the session cache with false nulls.
- val currentTitle = if (isRemote) playback.title else localState.value.title.ifBlank { playback.title }
- val currentArtist = if (isRemote) playback.artist else localState.value.artist.ifBlank { playback.artist }
+ // The player's own names only while they are this song's: read a
+ // moment after a skip they can still be the last song's, and asking
+ // under them found that song's words and kept them as this one's.
+ val own = localState.value.takeIf { !isRemote && it.mediaId == uri }
+ val currentTitle = own?.title?.ifBlank { null } ?: playback.title
+ val currentArtist = own?.artist?.ifBlank { null } ?: playback.artist
val currentDuration = if (isRemote && playback.durationMs > 0) {
playback.durationMs
} else {
- localState.value.durationMs.takeIf { it > 0 } ?: playback.durationMs
+ own?.durationMs?.takeIf { it > 0 } ?: playback.durationMs
}
if (currentTitle.isBlank()) return@LaunchedEffect
- if (lyricsFor != uri) {
+ // Asked again for the same song (its title or artist arrived late)
+ // with nothing to show yet: loading, not "no lyrics", until it answers.
+ if (lyricsFor != uri || lyrics == null) {
lyrics = null
lyricsFor = null
}
@@ -1169,7 +1182,7 @@ fun SquareApp(
// a tab bar and a player's worth of controls into a thumbnail, none of it
// legible and none of it reachable — the system owns the gestures there.
if (inPip) {
- SquareTheme(seed = accent) {
+ SquareTheme(seed = glassAccent) {
Box(
Modifier
.fillMaxSize()
@@ -1215,7 +1228,7 @@ fun SquareApp(
}
}
if (landscape && (videoOn || spotifyVideoOn) && player != null) {
- SquareTheme(seed = accent) {
+ SquareTheme(seed = glassAccent) {
dev.lelonio.square.ui.player.FullScreenVideo(
player = player,
attachKey = spotifyVideoGeneration,
@@ -1260,7 +1273,7 @@ fun SquareApp(
androidx.compose.runtime.CompositionLocalProvider(
dev.lelonio.square.ui.glass.LocalBackdropLuminance provides backdropLuminance,
) {
- SquareTheme(seed = accent) {
+ SquareTheme(seed = glassAccent) {
// Material's default content colour is black, and it used to arrive from
// the Surface that wrapped this tree. That Surface is gone — it painted
// an opaque page over the backdrop — so the colour has to be provided
@@ -1617,6 +1630,7 @@ fun SquareApp(
onRetryOnline = viewModel::retryOnline,
youtubeHome = youtubeHome,
shelves = homeShelves,
+ shelvesLoading = homeShelvesLoading,
onPlayTrending = { tracks, index ->
onPlay(tracks, index, null, false, trendingLabel, 0L)
},
@@ -1736,8 +1750,7 @@ fun SquareApp(
runCatching {
val tracks = viewModel.radioFor(seed.uri)
if (tracks.isEmpty()) return@launch
- val station = "spotify:station:track:" +
- seed.uri.substringAfterLast(':')
+ val station = viewModel.stationFor(seed.uri)
val name = radioOfTemplate.format(seed.artist)
// The station as a page and then as a
// queue, in that order: what the tab
@@ -3096,13 +3109,14 @@ fun SquareApp(
),
inLikedSongs = playback.mediaId != null &&
playback.mediaId in likedTracks,
- // Spotify's own radio, and only where Spotify
- // can answer: the station is a context on its
- // access point and means nothing anywhere else.
+ // The song's own radio, from the service it
+ // came from: Spotify's station or YouTube
+ // Music's, each meaningless to the other.
onRadio = playback.mediaId
?.takeIf {
- it.startsWith("spotify:track:") &&
- backend == dev.lelonio.square.backend.BackendId.SPOTIFY
+ (it.startsWith("spotify:track:") &&
+ backend == dev.lelonio.square.backend.BackendId.SPOTIFY) ||
+ (!it.startsWith("spotify:") && viewModel.hasRadio(it))
}
?.let { uri ->
{
@@ -3110,9 +3124,7 @@ fun SquareApp(
runCatching {
val tracks = viewModel.radioFor(uri)
if (tracks.isEmpty()) return@launch
- val station =
- "spotify:station:track:" +
- uri.substringAfterLast(':')
+ val station = viewModel.stationFor(uri)
val name = radioOf(playback.title)
viewModel.showStation(
uri = station,
@@ -3533,14 +3545,14 @@ fun SquareApp(
viewModel.toggleTrackDownload(menu.track)
}
}
- TrackSheetAction(stringResource(R.string.radio), PhosphorIcons.Regular.Broadcast) {
+ if (viewModel.hasRadio(menu.track.uri)) TrackSheetAction(stringResource(R.string.radio), PhosphorIcons.Regular.Broadcast) {
val track = menu.track
trackMenu = null
scope.launch {
runCatching {
val tracks = viewModel.radioFor(track.uri)
if (tracks.isEmpty()) return@launch
- val station = "spotify:station:track:" + track.uri.substringAfterLast(':')
+ val station = viewModel.stationFor(track.uri)
val name = radioOf(track.name)
viewModel.showStation(
uri = station,
diff --git a/app/src/main/java/dev/lelonio/square/ui/browse/Skeleton.kt b/app/src/main/java/dev/lelonio/square/ui/browse/Skeleton.kt
index d782277..9bafe7c 100644
--- a/app/src/main/java/dev/lelonio/square/ui/browse/Skeleton.kt
+++ b/app/src/main/java/dev/lelonio/square/ui/browse/Skeleton.kt
@@ -8,6 +8,7 @@ import androidx.compose.animation.core.tween
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
+import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.aspectRatio
@@ -93,6 +94,52 @@ fun SkeletonRow(
}
}
+/**
+ * The shape of a song that has not arrived: the cover's square and two lines,
+ * at the sizes a song row draws them, breathing like the rows above.
+ */
+@Composable
+fun SkeletonTrackRow(modifier: Modifier = Modifier) {
+ val breath = rememberInfiniteTransition(label = "skeletonTrack")
+ val alpha by breath.animateFloat(
+ initialValue = 0.5f,
+ targetValue = 1f,
+ animationSpec = infiniteRepeatable(animation = tween(BreathMs), repeatMode = RepeatMode.Reverse),
+ label = "skeletonTrackBreath",
+ )
+ Row(
+ modifier
+ .alpha(alpha)
+ .fillMaxWidth()
+ .padding(horizontal = 20.dp, vertical = 8.dp),
+ verticalAlignment = androidx.compose.ui.Alignment.CenterVertically,
+ ) {
+ Box(
+ Modifier
+ .size(48.dp)
+ .clip(RoundedCornerShape(8.dp))
+ .background(Bone),
+ )
+ Column(Modifier.padding(start = 14.dp).weight(1f)) {
+ Box(
+ Modifier
+ .fillMaxWidth(0.62f)
+ .height(13.dp)
+ .clip(RoundedCornerShape(4.dp))
+ .background(Bone),
+ )
+ Box(
+ Modifier
+ .padding(top = 8.dp)
+ .fillMaxWidth(0.36f)
+ .height(11.dp)
+ .clip(RoundedCornerShape(4.dp))
+ .background(Bone),
+ )
+ }
+ }
+}
+
/**
* Barely there on purpose: this is a placeholder for something, not a thing.
* At any more it reads as a row of blank tiles that failed to load.
diff --git a/app/src/main/java/dev/lelonio/square/ui/components/Artwork.kt b/app/src/main/java/dev/lelonio/square/ui/components/Artwork.kt
index 353c13c..a2ec416 100644
--- a/app/src/main/java/dev/lelonio/square/ui/components/Artwork.kt
+++ b/app/src/main/java/dev/lelonio/square/ui/components/Artwork.kt
@@ -9,6 +9,8 @@ import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.animation.core.tween
+import dev.lelonio.square.ui.theme.Ink
+import androidx.compose.animation.core.snap
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
@@ -59,14 +61,14 @@ fun Artwork(
*/
decodeSize: Dp = 0.dp,
/**
- * How long a new picture takes to replace the one before it.
+ * How long a picture takes to come up once it has loaded.
*
- * Zero in lists, and deliberately: a crossfade animates every row that
- * scrolls into view, which is exactly when frames are scarcest. Somewhere
- * that shows one picture the size of the screen, and sometimes replaces it
- * with a better copy of the same thing, wants the opposite.
+ * Only for a picture that had to be fetched or read from disk: one already
+ * in memory, a row scrolled back into view, is drawn at once, so scrolling
+ * animates nothing. Before this was zero in lists, which made every new
+ * page arrive as a grid of covers popping in one frame each.
*/
- crossfadeMs: Int = 0,
+ crossfadeMs: Int = ARTWORK_APPEAR_MS,
/**
* Whether a missing picture is worth drawing a stand-in for.
*
@@ -122,15 +124,22 @@ fun Artwork(
var arrived by remember(source) { mutableStateOf(false) }
var failed by remember(source) { mutableStateOf(false) }
+ // Drawn at once when it came out of memory; faded up otherwise.
+ var instant by remember(source) { mutableStateOf(false) }
val appear by animateFloatAsState(
targetValue = if (arrived || crossfadeMs <= 0) 1f else 0f,
- animationSpec = tween(crossfadeMs),
+ animationSpec = if (instant) snap() else tween(crossfadeMs),
label = "artwork",
)
if (fallback && failed) {
GeneratedCover(title, corner)
}
+ // A quiet tile of the same shape while it loads, so a row has its
+ // picture's place from the start rather than a hole that fills.
+ if (fallback && !arrived && !failed) {
+ Box(Modifier.fillMaxSize().background(Ink.copy(alpha = 0.07f)))
+ }
AsyncImage(
model = request,
@@ -139,6 +148,7 @@ fun Artwork(
onState = { state ->
when (state) {
is coil.compose.AsyncImagePainter.State.Success -> {
+ instant = state.result.dataSource == coil.decode.DataSource.MEMORY_CACHE
arrived = true
failed = false
}
@@ -184,6 +194,9 @@ fun Artwork(
* thumbnail to the top of a page, where a bitmap would either be soft or be
* three bitmaps. A folder because that is what it is.
*/
+/** How long a newly loaded picture takes to come up. */
+const val ARTWORK_APPEAR_MS = 220
+
@Composable
private fun LocalFilesCover() {
Box(
diff --git a/app/src/main/java/dev/lelonio/square/ui/home/HomeScreen.kt b/app/src/main/java/dev/lelonio/square/ui/home/HomeScreen.kt
index 0aa123a..d2f7412 100644
--- a/app/src/main/java/dev/lelonio/square/ui/home/HomeScreen.kt
+++ b/app/src/main/java/dev/lelonio/square/ui/home/HomeScreen.kt
@@ -177,6 +177,8 @@ fun HomeScreen(
* cannot be reconstructed from the account's playlists.
*/
shelves: List<dev.lelonio.square.data.HomeShelf> = emptyList(),
+ /** Spotify's shelves are on their way; their outline stands in until then. */
+ shelvesLoading: Boolean = false,
) {
if (youtubeMode) {
YouTubeHome(
@@ -341,7 +343,10 @@ fun HomeScreen(
// are a second, worse answer to the same question, printed
// underneath the first, so they stand in only while there is
// no real one; the chips are the real one's.
- val ownFeed = shelves.isEmpty()
+ // Not while Spotify's are on their way: shown first and then
+ // replaced, the stand-in page was a page that changed under
+ // the listener a few seconds after opening.
+ val ownFeed = shelves.isEmpty() && !shelvesLoading
val showOwn = current == Feed.ALL && ownFeed
val showReleases = showOwn
val showArtists = showOwn
@@ -404,11 +409,26 @@ fun HomeScreen(
run {
val visible = if (filter == Feed.ALL) shelves
else shelves.filter { dev.lelonio.square.data.TabContents.chipOf(it) == filter.chip }
+ // Their outline while they come, and a fade as they land
+ // rather than the rows appearing in one frame.
+ if (visible.isEmpty() && shelvesLoading && filter == Feed.ALL) {
+ items(SHELF_OUTLINES, key = { "shelf-outline-$it" }, contentType = { "skeleton" }) {
+ Box(Modifier.animateItem(fadeInSpec = null, placementSpec = null, fadeOutSpec = tween(200))) {
+ SkeletonSection(tileWidth = 152.dp, tileHeight = 152.dp)
+ }
+ }
+ }
visible.forEach { shelf ->
- item(contentType = "shelf") { Heading(shelf.title) }
- item(contentType = "shelf") {
- Carousel(shelf.items, key = { it.uri }) { entry ->
- PlaylistTile(entry) { onOpenPlaylist(entry) }
+ item(key = "shelf-heading-${shelf.title}", contentType = "shelf") {
+ Box(Modifier.animateItem(fadeInSpec = tween(320), placementSpec = null, fadeOutSpec = null)) {
+ Heading(shelf.title)
+ }
+ }
+ item(key = "shelf-${shelf.title}", contentType = "shelf") {
+ Box(Modifier.animateItem(fadeInSpec = tween(320), placementSpec = null, fadeOutSpec = null)) {
+ Carousel(shelf.items, key = { it.uri }) { entry ->
+ PlaylistTile(entry) { onOpenPlaylist(entry) }
+ }
}
}
}
@@ -1580,6 +1600,9 @@ private fun Centered(content: @Composable () -> Unit) {
}
}
+/** How many shelves' outlines stand in while Spotify's are on their way. */
+private const val SHELF_OUTLINES = 4
+
@StringRes
private fun greeting(): Int = when (Calendar.getInstance().get(Calendar.HOUR_OF_DAY)) {
in 5..12 -> R.string.good_morning
diff --git a/app/src/main/java/dev/lelonio/square/ui/library/PlaylistScreen.kt b/app/src/main/java/dev/lelonio/square/ui/library/PlaylistScreen.kt
index 0c6c73d..d7c6d5c 100644
--- a/app/src/main/java/dev/lelonio/square/ui/library/PlaylistScreen.kt
+++ b/app/src/main/java/dev/lelonio/square/ui/library/PlaylistScreen.kt
@@ -312,7 +312,8 @@ fun PlaylistScreen(
val audioPermissionNeeded = state.tracks.any {
dev.lelonio.square.data.LocalLibrary.isSpotifyLocal(it.uri)
} && !dev.lelonio.square.data.LocalLibrary.granted(LocalContext.current)
- val isStation = state.uri?.startsWith("spotify:station:") == true
+ val isStation = state.uri?.startsWith("spotify:station:") == true ||
+ dev.lelonio.square.backend.youtube.YouTubeBackend.isStation(state.uri)
var sort by remember(state.uri, storedSort, isStation) {
mutableStateOf(
if (isStation) {
@@ -858,8 +859,12 @@ fun PlaylistScreen(
}
when {
- state.loading -> item(contentType = "status") {
- StatusBox { CircularProgressIndicator(strokeWidth = 2.dp) }
+ // The songs' outline while they come, rather than a spinner
+ // and then the whole list in one frame.
+ state.loading -> items(TRACK_OUTLINES, key = { "track-outline-$it" }, contentType = { "skeleton" }) {
+ dev.lelonio.square.ui.browse.SkeletonTrackRow(
+ Modifier.animateItem(fadeInSpec = null, placementSpec = null, fadeOutSpec = tween(160)),
+ )
}
// The one empty list in the app that is a question rather than
@@ -924,6 +929,8 @@ fun PlaylistScreen(
key = { index, track -> "$index ${track.uri}" },
contentType = { _, _ -> "track" },
) { index, track ->
+ // Faded in as the list arrives; nothing moves after that.
+ Box(Modifier.animateItem(fadeInSpec = tween(260), placementSpec = null, fadeOutSpec = null)) {
SwipeToQueue(onQueue = { onEnqueue(track) }) {
TrackRow(
track = track,
@@ -963,6 +970,7 @@ fun PlaylistScreen(
dev.lelonio.square.data.DownloadState.Done,
)
}
+ }
}
}
@@ -2741,6 +2749,9 @@ private fun SectionHeader(
/** How many songs an artist page opens on; the heading holds the rest. */
private const val TOP_SONGS = 5
+/** How many song outlines stand in while a page's songs are loading. */
+private const val TRACK_OUTLINES = 8
+
/** What the hero shrinks to: a bar, under the status bar's own inset. */
private val COLLAPSED_BAR_HEIGHT = 56.dp
diff --git a/app/src/main/java/dev/lelonio/square/ui/player/ClassicLyricsView.kt b/app/src/main/java/dev/lelonio/square/ui/player/ClassicLyricsView.kt
index e7777aa..7a0f1ac 100644
--- a/app/src/main/java/dev/lelonio/square/ui/player/ClassicLyricsView.kt
+++ b/app/src/main/java/dev/lelonio/square/ui/player/ClassicLyricsView.kt
@@ -29,9 +29,14 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.CompositingStrategy
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.draw.drawWithContent
+import androidx.compose.ui.graphics.lerp
+import androidx.compose.ui.text.AnnotatedString
+import androidx.compose.ui.text.SpanStyle
+import androidx.compose.ui.text.buildAnnotatedString
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
+import dev.lelonio.square.data.LyricLine
import dev.lelonio.square.data.Lyrics
import kotlin.math.abs
@@ -40,9 +45,10 @@ import kotlin.math.abs
* quieter, and nothing else moving.
*
* The other style, [LyricsView], is the animated one ported from Spicy Lyrics,
- * with words lighting up as they are sung. This is for whoever prefers to read
- * them still, and for phones the animation is heavy on: a line changing colour
- * is all that is drawn when the song moves on.
+ * with words that glow and lift as they are sung. This is for whoever prefers
+ * to read them still, and for phones the animation is heavy on: the words of
+ * the line being sung take the ink in turn, where the source times them, and
+ * nothing else moves.
*/
@Composable
fun ClassicLyricsView(
@@ -110,14 +116,25 @@ fun ClassicLyricsView(
.clickable(enabled = line.startTimeMs != null) { line.startTimeMs?.let(onSeek) }
.padding(horizontal = 24.dp, vertical = 2.dp),
) {
+ // The line being sung, word by word where the source times
+ // its words: what has been sung in full ink, the word being
+ // sung brightening as it goes, the rest as quiet as the
+ // lines around it. Only this line reads the position, so
+ // only it redraws as the song moves.
+ val timed = lyrics.synced && index == activeLine && line.words.isNotEmpty()
+ val ranges = remember(line) { wordRanges(line) }
Text(
- line.text.ifBlank { "♪" },
+ if (timed) {
+ sungSoFar(line, ranges, positionMs.value, GlassInk, GlassInk.copy(alpha = 0.38f))
+ } else {
+ AnnotatedString(line.text.ifBlank { "♪" })
+ },
style = MaterialTheme.typography.headlineSmall.copy(
fontSize = 24.sp,
lineHeight = 31.sp,
fontWeight = FontWeight.Bold,
),
- color = ink,
+ color = if (timed) GlassInk.copy(alpha = 0.38f) else ink,
)
val translation = line.translation.takeIf { showTranslation && !it.isNullOrBlank() }
if (translation != null) {
@@ -132,3 +149,43 @@ fun ClassicLyricsView(
}
}
}
+
+/** Where each timed word sits in the line's text, found in order; null for one not found. */
+private fun wordRanges(line: LyricLine): List<IntRange?> {
+ var cursor = 0
+ return line.words.map { word ->
+ val at = line.text.indexOf(word.text, cursor)
+ if (at < 0) {
+ null
+ } else {
+ cursor = at + word.text.length
+ at until cursor
+ }
+ }
+}
+
+/** The line, coloured as far as it has been sung at [positionMs]. */
+private fun sungSoFar(
+ line: LyricLine,
+ ranges: List<IntRange?>,
+ positionMs: Long,
+ sung: Color,
+ quiet: Color,
+): AnnotatedString =
+ buildAnnotatedString {
+ append(line.text)
+ // Everything up to the end of the last word sung, the spaces too.
+ val sungEnd = line.words.indices
+ .lastOrNull { line.words[it].endMs <= positionMs && ranges[it] != null }
+ ?.let { ranges[it]!!.last + 1 } ?: 0
+ if (sungEnd > 0) addStyle(SpanStyle(color = sung), 0, sungEnd)
+ val singing = line.words.indices.firstOrNull {
+ val word = line.words[it]
+ positionMs in word.startMs until word.endMs && ranges[it] != null
+ } ?: return@buildAnnotatedString
+ val word = line.words[singing]
+ val range = ranges[singing]!!
+ val progress = ((positionMs - word.startMs).toFloat() / (word.endMs - word.startMs).coerceAtLeast(1))
+ .coerceIn(0f, 1f)
+ addStyle(SpanStyle(color = lerp(quiet, sung, progress)), range.first, range.last + 1)
+ }
diff --git a/app/src/main/java/dev/lelonio/square/ui/player/LyricsOptions.kt b/app/src/main/java/dev/lelonio/square/ui/player/LyricsOptions.kt
index c09c493..3510229 100644
--- a/app/src/main/java/dev/lelonio/square/ui/player/LyricsOptions.kt
+++ b/app/src/main/java/dev/lelonio/square/ui/player/LyricsOptions.kt
@@ -1,6 +1,13 @@
package dev.lelonio.square.ui.player
import androidx.activity.compose.BackHandler
+import androidx.compose.animation.AnimatedVisibility
+import androidx.compose.animation.core.animateFloatAsState
+import androidx.compose.animation.core.tween
+import androidx.compose.animation.expandVertically
+import androidx.compose.animation.fadeIn
+import androidx.compose.animation.fadeOut
+import androidx.compose.animation.shrinkVertically
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
@@ -20,15 +27,20 @@ import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.setValue
import androidx.compose.runtime.mutableStateMapOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
+import androidx.compose.ui.draw.rotate
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
+import androidx.compose.ui.text.withLink
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import com.adamglin.PhosphorIcons
@@ -50,7 +62,7 @@ import kotlinx.coroutines.launch
@Composable
fun LyricsSourceChip(source: String?, backdrop: Backdrop, onClick: () -> Unit, modifier: Modifier = Modifier) {
val label = LyricsSource.entries.firstOrNull { it.name == source }?.label
- ?: stringResource(R.string.lyrics_options)
+ ?: stringResource(R.string.lyrics_sources)
GlassSurface(
backdrop = backdrop,
shape = RoundedCornerShape(50),
@@ -90,15 +102,16 @@ fun LyricsOptionsPanel(
backdrop: Backdrop,
) {
BackHandler(onBack = onDismiss)
- val sources = remember(query.uri) { LyricsLibrary.sourcesFor(query.uri) }
+ val sources = remember(query.uri) { LyricsLibrary.survey(query).keys.toList() }
// Absent: still asking. Present and null: asked, and it has nothing.
val answers = remember(query) { mutableStateMapOf<LyricsSource, Lyrics?>() }
val asked = remember(query) { mutableStateMapOf<LyricsSource, Boolean>() }
+ // The song's own survey: what has answered already is there at once, and
+ // only what is still on its way is waited for.
LaunchedEffect(query) {
- sources.forEach { source ->
+ LyricsLibrary.survey(query).forEach { (source, answer) ->
launch {
- val found = kotlinx.coroutines.withTimeoutOrNull(12_000) { LyricsLibrary.fetch(source, query) }
- answers[source] = found
+ answers[source] = runCatching { answer.await() }.getOrNull()
asked[source] = true
}
}
@@ -138,7 +151,11 @@ fun LyricsOptionsPanel(
.padding(vertical = 10.dp),
) {
Heading(stringResource(R.string.lyrics_source_title))
- sources.forEach { source ->
+ // What has words for this song, in the order they are tried;
+ // the rest, still asking or with nothing, folded away under
+ // one row, so the choice is between real answers. A source
+ // that answers moves up as it does.
+ val row: @Composable (LyricsSource) -> Unit = { source ->
val done = asked[source] == true
val found = answers[source]
SourceRow(
@@ -161,6 +178,55 @@ fun LyricsOptionsPanel(
}
}
}
+ sources.forEach { source ->
+ AnimatedVisibility(
+ visible = answers[source] != null,
+ enter = fadeIn(tween(220)) + expandVertically(tween(220)),
+ exit = fadeOut(tween(160)) + shrinkVertically(tween(160)),
+ ) { row(source) }
+ }
+ val others = sources.filter { answers[it] == null }
+ if (others.isNotEmpty()) {
+ var expanded by remember(query.uri) { mutableStateOf(false) }
+ val turn by animateFloatAsState(if (expanded) 180f else 0f, tween(220), label = "caret")
+ Row(
+ Modifier
+ .fillMaxWidth()
+ .pressable({ expanded = !expanded })
+ .padding(horizontal = 22.dp, vertical = 8.dp),
+ verticalAlignment = Alignment.CenterVertically,
+ horizontalArrangement = Arrangement.spacedBy(12.dp),
+ ) {
+ Text(
+ stringResource(R.string.lyrics_more_sources),
+ style = MaterialTheme.typography.bodyLarge,
+ color = GlassInkDim,
+ modifier = Modifier.weight(1f),
+ )
+ // Said while any of them is still asking: one may yet
+ // move up into the list.
+ if (!expanded && others.any { asked[it] != true }) {
+ CircularProgressIndicator(
+ color = GlassInkDim,
+ strokeWidth = 2.dp,
+ modifier = Modifier.size(16.dp),
+ )
+ }
+ Icon(
+ PhosphorIcons.Regular.CaretDown,
+ contentDescription = null,
+ tint = GlassInkDim,
+ modifier = Modifier.size(18.dp).rotate(turn),
+ )
+ }
+ AnimatedVisibility(
+ visible = expanded,
+ enter = fadeIn(tween(220)) + expandVertically(tween(220)),
+ exit = fadeOut(tween(160)) + shrinkVertically(tween(160)),
+ ) {
+ Column { others.forEach { row(it) } }
+ }
+ }
Heading(stringResource(R.string.lyrics_style_title), top = 10.dp)
// Two side by side, on one line: a choice of two does not need
// two rows, and the panel has to fit the lyrics' own space.
@@ -241,3 +307,46 @@ private fun SourceRow(name: String, status: String?, selected: Boolean, enabled:
}
}
}
+
+/**
+ * "Lyrics from Spicy Lyrics · uploaded by …, made by …", each name a link to
+ * the person's page, as the source asks; the names only when it gives them.
+ */
+@Composable
+fun LyricsCreditLine(credit: dev.lelonio.square.data.LyricsCredit, modifier: Modifier = Modifier) {
+ val from = stringResource(R.string.lyrics_from, credit.provider)
+ val uploadedBy = stringResource(R.string.lyrics_uploaded_by)
+ val madeBy = stringResource(R.string.lyrics_made_by)
+ val text = androidx.compose.ui.text.buildAnnotatedString {
+ append(from)
+ fun person(label: String, name: String?, url: String?) {
+ if (name == null) return
+ append(" · ")
+ append(label)
+ append(" ")
+ if (url != null) {
+ withLink(
+ androidx.compose.ui.text.LinkAnnotation.Url(
+ url,
+ androidx.compose.ui.text.TextLinkStyles(
+ androidx.compose.ui.text.SpanStyle(fontWeight = FontWeight.SemiBold),
+ ),
+ ),
+ ) { append(name) }
+ } else {
+ append(name)
+ }
+ }
+ person(uploadedBy, credit.uploader, credit.uploaderUrl)
+ person(madeBy, credit.maker, credit.makerUrl)
+ }
+ Text(
+ text,
+ style = MaterialTheme.typography.bodySmall,
+ color = GlassInkDim,
+ maxLines = 2,
+ overflow = TextOverflow.Ellipsis,
+ textAlign = androidx.compose.ui.text.style.TextAlign.Center,
+ modifier = modifier,
+ )
+}
diff --git a/app/src/main/java/dev/lelonio/square/ui/player/LyricsView.kt b/app/src/main/java/dev/lelonio/square/ui/player/LyricsView.kt
index 2406ce8..04e2b25 100644
--- a/app/src/main/java/dev/lelonio/square/ui/player/LyricsView.kt
+++ b/app/src/main/java/dev/lelonio/square/ui/player/LyricsView.kt
@@ -570,14 +570,27 @@ fun KaraokeWordItem(
val jumpPadding = (12.dp * visualSettings.jumpStrength).coerceAtLeast(8.dp)
if (isLetterGroup) {
- KaraokeLetterGroup(
- word = word,
- charTimings = charTimings,
- progressProvider = progressProvider,
- jumpPadding = jumpPadding,
- isBackground = isBackground,
- modifier = modifier,
- )
+ // The space after the word, kept as the plain word keeps it: the
+ // letters are timed from the word without it, and a long word drawn
+ // letter by letter used to run straight into the next one.
+ val space = remember(piece) { piece.substring(piece.trimEnd().length) }
+ Row(modifier = modifier.wrapContentWidth()) {
+ KaraokeLetterGroup(
+ word = word,
+ charTimings = charTimings,
+ progressProvider = progressProvider,
+ jumpPadding = jumpPadding,
+ isBackground = isBackground,
+ )
+ if (space.isNotEmpty()) {
+ Text(
+ text = space,
+ color = Color.Transparent,
+ softWrap = false,
+ style = lyicTextStyle(isBackground = isBackground),
+ )
+ }
+ }
} else {
KaraokePlainWord(
word = word,
diff --git a/app/src/main/java/dev/lelonio/square/ui/player/PlayerScreen.kt b/app/src/main/java/dev/lelonio/square/ui/player/PlayerScreen.kt
index 4900ed3..76e20b3 100644
--- a/app/src/main/java/dev/lelonio/square/ui/player/PlayerScreen.kt
+++ b/app/src/main/java/dev/lelonio/square/ui/player/PlayerScreen.kt
@@ -2521,6 +2521,19 @@ private fun LyricsStage(
// to the other style: low on the left, across from the panel's other
// controls. Shown with no words as well, since another source may
// have what the usual order stopped short of.
+ // The credit a source asks for, on screen with its words: Spicy Lyrics
+ // makes it a condition of using it. Across the top, clear of the
+ // controls below.
+ val credit = lyrics?.credit
+ if (credit != null && !optionsOpen && !loading) {
+ LyricsCreditLine(
+ credit = credit,
+ modifier = Modifier
+ .align(Alignment.TopCenter)
+ .padding(horizontal = 24.dp, vertical = 4.dp),
+ )
+ }
+
if (query != null && !loading && !optionsOpen) {
LyricsSourceChip(
source = lyrics?.source,
diff --git a/app/src/main/java/dev/lelonio/square/ui/settings/SettingsScreen.kt b/app/src/main/java/dev/lelonio/square/ui/settings/SettingsScreen.kt
index 00e5b0e..1b7f063 100644
--- a/app/src/main/java/dev/lelonio/square/ui/settings/SettingsScreen.kt
+++ b/app/src/main/java/dev/lelonio/square/ui/settings/SettingsScreen.kt
@@ -14,6 +14,9 @@ import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.lazy.LazyColumn
+import androidx.compose.foundation.lazy.LazyListScope
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Icon
@@ -52,6 +55,12 @@ import com.adamglin.phosphoricons.regular.ArrowUpRight
import com.adamglin.phosphoricons.regular.CaretDown
import com.adamglin.phosphoricons.regular.CaretRight
import com.adamglin.phosphoricons.regular.CaretUp
+import com.adamglin.phosphoricons.regular.MicrophoneStage
+import com.adamglin.phosphoricons.regular.Lifebuoy
+import com.adamglin.phosphoricons.regular.ShieldCheck
+import com.adamglin.phosphoricons.regular.GearSix
+import com.adamglin.phosphoricons.regular.Palette
+import com.adamglin.phosphoricons.regular.Translate
import dev.lelonio.square.ui.glass.backdrop.Backdrop
import dev.lelonio.square.BuildConfig
import androidx.compose.ui.graphics.vector.ImageVector
@@ -284,6 +293,11 @@ fun SettingsScreen(
return@AnimatedContent
}
+ // Every group folded when a page opens: the headings are the page's
+ // contents, and only the group asked for opens.
+ var openGroups by remember(shown) { mutableStateOf(emptySet<String>()) }
+ val toggleGroup: (String) -> Unit = { id -> openGroups = if (id in openGroups) openGroups - id else openGroups + id }
+
LazyColumn(
Modifier.fillMaxSize(),
contentPadding = PaddingValues(
@@ -347,7 +361,9 @@ fun SettingsScreen(
}
}
- if (shown == SettingsPage.Account && showSpotify) item("webapi") {
+ if (shown == SettingsPage.Account && showSpotify) groupHeading(Group.SETUP, open = "setup" in openGroups) { toggleGroup("setup") }
+
+ if (shown == SettingsPage.Account && showSpotify && "setup" in openGroups) groupItem("webapi", Group.SETUP) {
Section(stringResource(R.string.web_api)) {
if (webApi.connected) {
InfoRow(stringResource(R.string.application), stringResource(R.string.connected))
@@ -367,7 +383,7 @@ fun SettingsScreen(
}
}
- if (shown == SettingsPage.Account && showSpotify) item("tutorial") {
+ if (shown == SettingsPage.Account && showSpotify && "setup" in openGroups) groupItem("tutorial", Group.SETUP) {
Section(stringResource(R.string.guide)) {
ActionRow(stringResource(R.string.see_setup_again), destructive = false) {
onShowTutorial()
@@ -375,9 +391,13 @@ fun SettingsScreen(
}
}
+ if (shown == SettingsPage.Account && showSpotify && "setup" in openGroups) groupEnd(Group.SETUP)
+
+ if (shown == SettingsPage.Playback) groupHeading(Group.SOUND, open = "sound" in openGroups) { toggleGroup("sound") }
+
if (shown == SettingsPage.Playback && showSpotify &&
(dev.lelonio.square.backend.spotify.SpotifyWebPlayback.needed(context) ||
- dev.lelonio.square.playback.websdk.WebSdkRecovery.isConfigured(context))) item("web-sdk-recovery") {
+ dev.lelonio.square.playback.websdk.WebSdkRecovery.isConfigured(context)) && "sound" in openGroups) groupItem("web-sdk-recovery", Group.SOUND) {
Section(stringResource(R.string.web_sdk_settings_title)) {
ActionRow(stringResource(R.string.web_sdk_settings_open), destructive = false) {
context.startActivity(android.content.Intent(
@@ -393,7 +413,7 @@ fun SettingsScreen(
}
}
- if (shown == SettingsPage.Playback) item("backend") {
+ if (shown == SettingsPage.Playback && "sound" in openGroups) groupItem("backend", Group.SOUND) {
BackendSection()
}
@@ -413,12 +433,14 @@ fun SettingsScreen(
StorageChart()
}
- if (shown == SettingsPage.Downloads && showSpotify && !sdkPlayback) item("downloads") {
+ if (shown == SettingsPage.Downloads && showSpotify && !sdkPlayback) groupHeading(Group.DOWNLOADS, open = "downloads" in openGroups) { toggleGroup("downloads") }
+
+ if (shown == SettingsPage.Downloads && showSpotify && !sdkPlayback && "downloads" in openGroups) groupItem("downloads", Group.DOWNLOADS) {
DownloadsSection(backdrop)
}
// The bitrate is librespot's; ExoPlayer takes what YouTube serves.
- if (shown == SettingsPage.Playback && showSpotify && !sdkPlayback) item("quality") {
+ if (shown == SettingsPage.Playback && showSpotify && !sdkPlayback && "sound" in openGroups) groupItem("quality", Group.SOUND) {
QualitySection()
}
@@ -426,11 +448,20 @@ fun SettingsScreen(
// What happens when the app is swiped away, which is a playback
// decision rather than an app one; asked for in #27.
// YouTube Music's own, in the place Spotify's quality has.
- if (shown == SettingsPage.Playback && !showSpotify) item("youtube-quality") {
+ if (shown == SettingsPage.Playback && !showSpotify && "sound" in openGroups) groupItem("youtube-quality", Group.SOUND) {
YouTubeQualitySection()
}
- if (shown == SettingsPage.Playback) item("keep-playing") {
+ // The effects run on our own output, so this one holds for both backends.
+ if (shown == SettingsPage.Playback && !sdkPlayback && "sound" in openGroups) groupItem("effect-quality", Group.SOUND) {
+ EffectQualitySection()
+ }
+
+ if (shown == SettingsPage.Playback && "sound" in openGroups) groupEnd(Group.SOUND)
+
+ if (shown == SettingsPage.Playback) groupHeading(Group.LISTENING, open = "listening" in openGroups) { toggleGroup("listening") }
+
+ if (shown == SettingsPage.Playback && "listening" in openGroups) groupItem("keep-playing", Group.LISTENING) {
val prefs = remember(context) {
(context.applicationContext as dev.lelonio.square.SquareApplication).preferences
}
@@ -470,23 +501,16 @@ fun SettingsScreen(
}
}
- if (shown == SettingsPage.Playback && !sdkPlayback) item("crossfade") {
+ if (shown == SettingsPage.Playback && !sdkPlayback && "listening" in openGroups) groupItem("crossfade", Group.LISTENING) {
CrossfadeSection(backdrop)
}
// Autoplay: automatically append similar tracks when queue reaches the end.
- if (shown == SettingsPage.Playback) item("autoplay") {
+ if (shown == SettingsPage.Playback && "listening" in openGroups) groupItem("autoplay", Group.LISTENING) {
AutoplaySection(backdrop)
}
- // Spotify's own, served by its access point: on another source there is
- // no clip to ask for and nothing this switch could turn off.
- // On either source: Apple's moving covers play over YouTube Music too.
- if (shown == SettingsPage.Playback) item("canvas") {
- CanvasSection(backdrop)
- }
-
- if (shown == SettingsPage.Playback && showSpotify) item("connected-device-label") {
+ if (shown == SettingsPage.Playback && showSpotify && "listening" in openGroups) groupItem("connected-device-label", Group.LISTENING) {
val enabled by app.preferences.showConnectedDevice.collectAsStateWithLifecycle()
Section(stringResource(R.string.connected_device_label)) {
DownloadSwitch(
@@ -498,15 +522,38 @@ fun SettingsScreen(
}
}
- // The effects run on our own output, so this one holds for both backends.
- if (shown == SettingsPage.Playback && !sdkPlayback) item("effect-quality") {
- EffectQualitySection()
+ if (shown == SettingsPage.Playback && "listening" in openGroups) groupEnd(Group.LISTENING)
+
+ if (shown == SettingsPage.Playback) groupHeading(Group.LYRICS, open = "lyrics" in openGroups) { toggleGroup("lyrics") }
+
+ if (shown == SettingsPage.Playback && "lyrics" in openGroups) groupItem("lyrics-source", Group.LYRICS) {
+ PreferredLyricsSection(showSpotify)
+ }
+
+ // Spicy Lyrics is asked by Spotify track id, so only on that source.
+ if (shown == SettingsPage.Playback && showSpotify && "lyrics" in openGroups) groupItem("spicy-lyrics", Group.LYRICS) {
+ SpicyLyricsSection()
+ }
+
+ if (shown == SettingsPage.Playback && "lyrics" in openGroups) groupEnd(Group.LYRICS)
+
+ if (shown == SettingsPage.Playback) groupHeading(Group.COVERS, open = "covers" in openGroups) { toggleGroup("covers") }
+
+ // On either source: Apple's moving covers play over YouTube Music too.
+ if (shown == SettingsPage.Playback && "covers" in openGroups) groupItem("canvas", Group.COVERS) {
+ CanvasSection(backdrop)
}
+ if (shown == SettingsPage.Playback && "covers" in openGroups) groupEnd(Group.COVERS)
+
+ if (shown == SettingsPage.Downloads && showSpotify && !sdkPlayback && "downloads" in openGroups) groupEnd(Group.DOWNLOADS)
+
+ if (shown == SettingsPage.Downloads) groupHeading(Group.CLEANUP, open = "cleanup" in openGroups) { toggleGroup("cleanup") }
+
// The cleaning up, under everything it cleans: the songs first, then
// the copies of playlists that make a long list open at once, then the
// app's own working files. Each says what goes and what stays.
- if (shown == SettingsPage.Downloads) item("cleanup") {
+ if (shown == SettingsPage.Downloads && "cleanup" in openGroups) groupItem("cleanup", Group.CLEANUP) {
var clearedLists by remember { mutableStateOf(false) }
var clearedCache by remember { mutableStateOf(false) }
Section(stringResource(R.string.storage_cleanup)) {
@@ -554,7 +601,11 @@ fun SettingsScreen(
if (clearedLists && clearedCache) Spacer(Modifier.height(0.dp))
}
- if (shown == SettingsPage.App) item("language") {
+ if (shown == SettingsPage.Downloads && "cleanup" in openGroups) groupEnd(Group.CLEANUP)
+
+ if (shown == SettingsPage.App) groupHeading(Group.LANGUAGE, open = "language" in openGroups) { toggleGroup("language") }
+
+ if (shown == SettingsPage.App && "language" in openGroups) groupItem("language", Group.LANGUAGE) {
Section(stringResource(R.string.language)) {
AppLanguages.forEachIndexed { index, (tag, name) ->
if (index > 0) RowDivider()
@@ -566,9 +617,13 @@ fun SettingsScreen(
}
}
+ if (shown == SettingsPage.App && "language" in openGroups) groupEnd(Group.LANGUAGE)
+
+ if (shown == SettingsPage.App) groupHeading(Group.APPEARANCE, open = "appearance" in openGroups) { toggleGroup("appearance") }
+
// What the bar does, which is behaviour rather than material: the glass
// page says what it is made of, this says how it acts.
- if (shown == SettingsPage.App) item("bar") {
+ if (shown == SettingsPage.App && "appearance" in openGroups) groupItem("bar", Group.APPEARANCE) {
val glass = remember(context) {
(context.applicationContext as dev.lelonio.square.SquareApplication).glass
}
@@ -588,7 +643,7 @@ fun SettingsScreen(
// two people are sent to when the music stops in the background or a
// notification never arrives.
// The face the app is set in: its own, or the phone's.
- if (shown == SettingsPage.App) item("font") {
+ if (shown == SettingsPage.App && "appearance" in openGroups) groupItem("font", Group.APPEARANCE) {
val store = remember(context) {
(context.applicationContext as dev.lelonio.square.SquareApplication).preferences
}
@@ -604,7 +659,11 @@ fun SettingsScreen(
}
}
- if (shown == SettingsPage.App) item("system") {
+ if (shown == SettingsPage.App && "appearance" in openGroups) groupEnd(Group.APPEARANCE)
+
+ if (shown == SettingsPage.App) groupHeading(Group.SYSTEM, open = "system" in openGroups) { toggleGroup("system") }
+
+ if (shown == SettingsPage.App && "system" in openGroups) groupItem("system", Group.SYSTEM) {
Section(stringResource(R.string.page_app_system)) {
ActionRow(
stringResource(R.string.app_system_settings),
@@ -635,8 +694,8 @@ fun SettingsScreen(
}
}
- if (shown == SettingsPage.App && android.os.Build.VERSION.SDK_INT >= 31) {
- item("links") {
+ if (shown == SettingsPage.App && android.os.Build.VERSION.SDK_INT >= 31 && "system" in openGroups) {
+ groupItem("links", Group.SYSTEM) {
Section(stringResource(R.string.spotify_links)) {
Text(
stringResource(R.string.spotify_links_note),
@@ -667,6 +726,8 @@ fun SettingsScreen(
}
}
+ if (shown == SettingsPage.App && "system" in openGroups) groupEnd(Group.SYSTEM)
+
if (shown == SettingsPage.About) item("author") {
Section(stringResource(R.string.developed_by)) {
val uriHandler = LocalUriHandler.current
@@ -760,20 +821,32 @@ fun SettingsScreen(
}
}
- if (shown == SettingsPage.About) item("about") {
- Section(stringResource(R.string.about)) {
+ // The update on its own, never folded away: the one thing on this
+ // page somebody comes to do rather than to read.
+ if (shown == SettingsPage.About) item("update") {
+ Section(null) {
UpdateRow(askToInstall)
- RowDivider()
+ }
+ }
+
+ if (shown == SettingsPage.About) groupHeading(Group.ABOUT, open = "about" in openGroups) { toggleGroup("about") }
+
+ if (shown == SettingsPage.About && "about" in openGroups) groupItem("about", Group.ABOUT) {
+ Section(stringResource(R.string.about)) {
Licences()
RowDivider()
ReportRows(name = ready?.displayName, onSave = askToSaveReport)
}
}
+ if (shown == SettingsPage.About && "about" in openGroups) groupEnd(Group.ABOUT)
+
+ if (shown == SettingsPage.About) groupHeading(Group.HELP, open = "help" in openGroups) { toggleGroup("help") }
+
// Where to take a question, an idea or a problem. Beside the report,
// which is what a problem needs attached: the whole errand on one
// page, rather than a web address to go and find.
- if (shown == SettingsPage.About) item("help") {
+ if (shown == SettingsPage.About && "help" in openGroups) groupItem("help", Group.HELP) {
val uriHandler = LocalUriHandler.current
Section(stringResource(R.string.help_feedback)) {
ActionRow(
@@ -796,9 +869,13 @@ fun SettingsScreen(
}
}
+ if (shown == SettingsPage.About && "help" in openGroups) groupEnd(Group.HELP)
+
+ if (shown == SettingsPage.About) groupHeading(Group.PERMISSIONS, open = "permissions" in openGroups) { toggleGroup("permissions") }
+
// Last, and tighter than the rest: a reference for whoever wants to
// check what the app asks Spotify for, not something anyone does.
- if (shown == SettingsPage.About) item("permissions") {
+ if (shown == SettingsPage.About && "permissions" in openGroups) groupItem("permissions", Group.PERMISSIONS) {
Section(stringResource(R.string.permissions_asked)) {
Text(
stringResource(R.string.permissions_note),
@@ -831,6 +908,8 @@ fun SettingsScreen(
}
}
+ if (shown == SettingsPage.About && "permissions" in openGroups) groupEnd(Group.PERMISSIONS)
+
// Spotify's sign-out, so only while Spotify is the source. On YouTube
// Music the account section above has its own, and this one signed the
// app out of Spotify from a page about a Google account.
@@ -1496,6 +1575,125 @@ private fun QualitySection() {
}
}
+/**
+ * The listener's own Spicy Lyrics key.
+ *
+ * Optional: without it the source is simply not asked. The key comes from
+ * Square's page in Spicy Lyrics' catalogue, which gives each person their own,
+ * as the API's terms ask of an app that runs on other people's phones.
+ */
+@Composable
+private fun SpicyLyricsSection() {
+ val context = LocalContext.current
+ val store = remember(context) {
+ (context.applicationContext as dev.lelonio.square.SquareApplication).preferences
+ }
+ val saved by store.spicyLyricsKey.collectAsStateWithLifecycle()
+ var draft by remember(saved) { mutableStateOf(saved) }
+ val uriHandler = LocalUriHandler.current
+ Section(stringResource(R.string.spicy_lyrics_title)) {
+ Column(Modifier.padding(horizontal = 18.dp, vertical = 12.dp)) {
+ Text(
+ stringResource(R.string.spicy_lyrics_note),
+ style = MaterialTheme.typography.bodySmall,
+ color = InkDim,
+ )
+ androidx.compose.material3.OutlinedTextField(
+ value = draft,
+ onValueChange = { draft = it },
+ label = { Text(stringResource(R.string.spicy_lyrics_key)) },
+ singleLine = true,
+ visualTransformation = androidx.compose.ui.text.input.PasswordVisualTransformation(),
+ shape = RoundedCornerShape(16.dp),
+ modifier = Modifier
+ .fillMaxWidth()
+ .padding(top = 12.dp),
+ )
+ }
+ RowDivider()
+ if (draft.trim() != saved) {
+ ActionRow(stringResource(R.string.save), destructive = false, icon = PhosphorIcons.Regular.Check) {
+ store.setSpicyLyricsKey(draft)
+ }
+ RowDivider()
+ }
+ if (saved.isNotEmpty()) {
+ ActionRow(stringResource(R.string.spicy_lyrics_remove), destructive = true) {
+ store.setSpicyLyricsKey("")
+ }
+ RowDivider()
+ }
+ ActionRow(stringResource(R.string.spicy_lyrics_get_key), destructive = false, icon = PhosphorIcons.Regular.ArrowUpRight) {
+ runCatching { uriHandler.openUri(dev.lelonio.square.backend.lyrics.SpicyLyrics.KEY_PAGE) }
+ }
+ }
+}
+
+/**
+ * The lyrics source to show first, or none and the best of them.
+ *
+ * Folded under one row showing the choice: the list is every source there
+ * is, and most people never open it. Only the sources the current service
+ * asks, so a YouTube Music listener is not offered Spotify's own words.
+ */
+@Composable
+private fun PreferredLyricsSection(showSpotify: Boolean) {
+ val context = LocalContext.current
+ val store = remember(context) {
+ (context.applicationContext as dev.lelonio.square.SquareApplication).preferences
+ }
+ val chosen by store.preferredLyricsSource.collectAsStateWithLifecycle()
+ // Read so that entering or removing a Spicy Lyrics key changes the list.
+ val spicyKey by store.spicyLyricsKey.collectAsStateWithLifecycle()
+ val sources = remember(showSpotify, spicyKey) {
+ dev.lelonio.square.backend.lyrics.LyricsLibrary.sourcesFor(
+ if (showSpotify) "spotify:track:" else dev.lelonio.square.backend.youtube.YouTubeBackend.TRACK_PREFIX,
+ )
+ }
+ val auto = stringResource(R.string.lyrics_preferred_auto)
+ val current = sources.firstOrNull { it.name == chosen }?.label ?: auto
+ var open by remember { mutableStateOf(false) }
+ Section(stringResource(R.string.lyrics_preferred_title)) {
+ Row(
+ Modifier
+ .fillMaxWidth()
+ .clickable { open = !open }
+ .padding(horizontal = 18.dp, vertical = 14.dp),
+ verticalAlignment = Alignment.CenterVertically,
+ horizontalArrangement = Arrangement.spacedBy(12.dp),
+ ) {
+ Text(current, style = MaterialTheme.typography.bodyLarge, modifier = Modifier.weight(1f))
+ Icon(
+ if (open) PhosphorIcons.Regular.CaretUp else PhosphorIcons.Regular.CaretDown,
+ contentDescription = null,
+ tint = InkDim,
+ modifier = Modifier.size(18.dp),
+ )
+ }
+ if (open) {
+ RowDivider()
+ ChoiceRow(label = auto, selected = sources.none { it.name == chosen }) {
+ store.setPreferredLyricsSource("")
+ open = false
+ }
+ sources.forEach { source ->
+ RowDivider()
+ ChoiceRow(label = source.label, selected = source.name == chosen) {
+ store.setPreferredLyricsSource(source.name)
+ open = false
+ }
+ }
+ }
+ RowDivider()
+ Text(
+ stringResource(R.string.lyrics_preferred_note),
+ style = MaterialTheme.typography.bodySmall,
+ color = InkDim,
+ modifier = Modifier.padding(horizontal = 18.dp, vertical = 14.dp),
+ )
+ }
+}
+
@Composable
private fun YouTubeQualitySection() {
val context = LocalContext.current
@@ -1837,8 +2035,10 @@ private fun DownloadSwitch(
@Composable
private fun Section(title: String?, content: @Composable () -> Unit) {
+ // Under a group of the same name, said once, by the group.
+ val group = LocalGroupTitle.current
Column(Modifier.padding(horizontal = 20.dp, vertical = 10.dp)) {
- if (title != null) {
+ if (title != null && !title.equals(group, ignoreCase = true)) {
Text(
title.uppercase(),
style = MaterialTheme.typography.labelLarge,
@@ -1856,6 +2056,155 @@ private fun Section(title: String?, content: @Composable () -> Unit) {
}
}
+/**
+ * The groups a settings page is folded into, each under a heading that opens
+ * it. A page used to be one long run of sections with nothing to say which of
+ * them belonged together; now it reads as a short list of what is on it.
+ */
+private enum class Group(@StringRes val title: Int, @StringRes val summary: Int, val icon: ImageVector) {
+ SOUND(R.string.settings_group_sound, R.string.settings_group_sound_summary, PhosphorIcons.Regular.Waveform),
+ LISTENING(R.string.settings_group_listening, R.string.settings_group_listening_summary, PhosphorIcons.Regular.Playlist),
+ LYRICS(R.string.settings_group_lyrics, R.string.settings_group_lyrics_summary, PhosphorIcons.Regular.MicrophoneStage),
+ COVERS(R.string.settings_group_covers, R.string.settings_group_covers_summary, PhosphorIcons.Regular.FilmStrip),
+ SETUP(R.string.settings_group_setup, R.string.settings_group_setup_summary, PhosphorIcons.Regular.Key),
+ DOWNLOADS(R.string.downloads, R.string.settings_group_downloads_summary, PhosphorIcons.Regular.DownloadSimple),
+ CLEANUP(R.string.storage_cleanup, R.string.settings_group_cleanup_summary, PhosphorIcons.Regular.Broom),
+ LANGUAGE(R.string.language, R.string.settings_group_language_summary, PhosphorIcons.Regular.Translate),
+ APPEARANCE(R.string.settings_group_appearance, R.string.settings_group_appearance_summary, PhosphorIcons.Regular.Palette),
+ SYSTEM(R.string.page_app_system, R.string.settings_group_system_summary, PhosphorIcons.Regular.GearSix),
+ ABOUT(R.string.about, R.string.settings_group_about_summary, PhosphorIcons.Regular.Info),
+ HELP(R.string.help_feedback, R.string.settings_group_help_summary, PhosphorIcons.Regular.Lifebuoy),
+ PERMISSIONS(R.string.permissions_asked, R.string.settings_group_permissions_summary, PhosphorIcons.Regular.ShieldCheck),
+}
+
+/** The group a section is drawn in, whose heading it then does not repeat; see Section. */
+private val LocalGroupTitle = androidx.compose.runtime.compositionLocalOf<String?> { null }
+
+/**
+ * A group's heading, and the panel its sections sit in when it is open.
+ *
+ * The panel is wider than the sections' own cards and quieter than them, so
+ * a group reads as the thing that holds settings and a setting as the thing
+ * inside: folded, the panel is only its heading; open, the heading is its
+ * top, the sections run down it on the same ground, and [groupEnd] closes it.
+ * The heading says what is inside, so a folded group still says what opening
+ * it will show.
+ */
+private fun LazyListScope.groupHeading(group: Group, open: Boolean, onToggle: () -> Unit) =
+ item("group-${group.name}") {
+ val turn by androidx.compose.animation.core.animateFloatAsState(
+ if (open) 180f else 0f,
+ tween(GROUP_MOTION_MS),
+ label = "groupCaret",
+ )
+ val lower by androidx.compose.animation.core.animateDpAsState(
+ if (open) 0.dp else GROUP_CORNER,
+ tween(GROUP_MOTION_MS),
+ label = "groupCorner",
+ )
+ val gap by androidx.compose.animation.core.animateDpAsState(
+ if (open) 0.dp else 6.dp,
+ tween(GROUP_MOTION_MS),
+ label = "groupGap",
+ )
+ Row(
+ Modifier
+ .animateItem(fadeInSpec = tween(GROUP_MOTION_MS), fadeOutSpec = tween(150))
+ .fillMaxWidth()
+ .padding(start = GROUP_MARGIN, end = GROUP_MARGIN, top = 6.dp, bottom = gap)
+ .clip(RoundedCornerShape(GROUP_CORNER, GROUP_CORNER, lower, lower))
+ .background(groupPanel())
+ .clickable(onClick = onToggle)
+ .padding(start = 18.dp, end = 20.dp, top = 16.dp, bottom = 16.dp),
+ verticalAlignment = Alignment.CenterVertically,
+ horizontalArrangement = Arrangement.spacedBy(14.dp),
+ ) {
+ GroupMark(group.icon)
+ Column(Modifier.weight(1f)) {
+ Text(
+ stringResource(group.title),
+ style = MaterialTheme.typography.titleMedium,
+ fontWeight = FontWeight.SemiBold,
+ maxLines = 1,
+ overflow = TextOverflow.Ellipsis,
+ )
+ Text(
+ stringResource(group.summary),
+ style = MaterialTheme.typography.bodySmall,
+ color = InkDim,
+ maxLines = 2,
+ overflow = TextOverflow.Ellipsis,
+ )
+ }
+ Icon(
+ PhosphorIcons.Regular.CaretDown,
+ contentDescription = null,
+ tint = InkDim,
+ modifier = Modifier
+ .size(18.dp)
+ .graphicsLayer { rotationZ = turn },
+ )
+ }
+ }
+
+/** The foot of an open group's panel, under its last section. */
+private fun LazyListScope.groupEnd(group: Group) =
+ item("group-end-${group.name}") {
+ Box(
+ Modifier
+ .animateItem(fadeInSpec = tween(GROUP_MOTION_MS), fadeOutSpec = tween(150))
+ .fillMaxWidth()
+ .padding(start = GROUP_MARGIN, end = GROUP_MARGIN, bottom = 6.dp)
+ .height(10.dp)
+ .clip(RoundedCornerShape(0.dp, 0.dp, GROUP_CORNER, GROUP_CORNER))
+ .background(groupPanel()),
+ )
+ }
+
+/**
+ * A group's mark: larger than a setting's and filled with the accent rather
+ * than tinted by it, the one place on the page the colour is spent.
+ */
+@Composable
+private fun GroupMark(icon: ImageVector) {
+ val accent = settingsAccent()
+ Box(
+ Modifier
+ .size(40.dp)
+ .clip(RoundedCornerShape(13.dp))
+ .background(accent.copy(alpha = 0.26f)),
+ contentAlignment = Alignment.Center,
+ ) {
+ Icon(icon, contentDescription = null, tint = accent, modifier = Modifier.size(22.dp))
+ }
+}
+
+/** The ground of a group's panel: under the sections' own cards, which stand out on it. */
+@Composable
+private fun groupPanel(): Color = Ink.copy(alpha = 0.045f)
+
+/** How far a group's panel sits from the edge: outside the sections' own cards. */
+private val GROUP_MARGIN = 10.dp
+private val GROUP_CORNER = 28.dp
+private const val GROUP_MOTION_MS = 220
+
+/** One of a group's sections, fading in as the group opens and out as it closes. */
+private fun LazyListScope.groupItem(key: String, group: Group, content: @Composable () -> Unit) =
+ item(key) {
+ val title = stringResource(group.title)
+ // A column, not a box: some items are more than one section (the
+ // covers' switch and, under it, where they come from), and a box
+ // drew them on top of each other.
+ Column(
+ Modifier
+ .animateItem(fadeInSpec = tween(GROUP_MOTION_MS), fadeOutSpec = tween(150))
+ .padding(horizontal = GROUP_MARGIN)
+ .background(groupPanel()),
+ ) {
+ androidx.compose.runtime.CompositionLocalProvider(LocalGroupTitle provides title) { content() }
+ }
+ }
+
@Composable
private fun InfoRow(label: String, value: String, icon: ImageVector? = null) {
Row(
@@ -2032,6 +2381,9 @@ private val LICENCES = listOf(
"Coil" to "Apache-2.0",
"Spicy Lyrics" to "AGPL-3.0",
"OkHttp / Retrofit" to "Apache-2.0",
+ "yt-dlp ejs" to "Unlicense",
+ "meriyah" to "ISC",
+ "astring" to "MIT",
)
private const val GITHUB_USER = "Lelonio"
diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml
index 411ca6b..0d632b4 100644
--- a/app/src/main/res/values-de/strings.xml
+++ b/app/src/main/res/values-de/strings.xml
@@ -309,6 +309,27 @@
<string name="page_app">App</string>
<string name="page_account_summary">Ihr Konto, die Web-API-Anwendung und das Abmelden</string>
<string name="page_playback_summary">Woher die Musik kommt, Qualität und Wiedergabe</string>
+ <string name="settings_group_sound">Klang</string>
+ <string name="settings_group_listening">Wiedergabe</string>
+ <string name="settings_group_lyrics">Songtexte</string>
+ <string name="settings_group_covers">Cover</string>
+ <string name="settings_group_setup">Einrichtung</string>
+ <string name="settings_group_appearance">Darstellung</string>
+ <string name="settings_group_sound_summary">Quelle, Qualität und Effekte</string>
+ <string name="settings_group_listening_summary">Crossfade, Autoplay und Schließen der App</string>
+ <string name="settings_group_lyrics_summary">Bevorzugte Quelle und Spicy Lyrics</string>
+ <string name="settings_group_covers_summary">Animierte Cover und ihre Herkunft</string>
+ <string name="settings_group_setup_summary">Web-API und Einrichtungsanleitung</string>
+ <string name="settings_group_downloads_summary">Wie Songs heruntergeladen werden</string>
+ <string name="settings_group_cleanup_summary">Gespeicherte Listen und temporäre Dateien löschen</string>
+ <string name="settings_group_language_summary">Die Sprache der App</string>
+ <string name="settings_group_appearance_summary">Leiste und Schrift</string>
+ <string name="settings_group_system_summary">Berechtigungen, Akku und Links</string>
+ <string name="settings_group_about_summary">Lizenzen und Berichte</string>
+ <string name="settings_group_help_summary">Community, Diskussionen und Probleme</string>
+ <string name="settings_group_permissions_summary">Was die App von Spotify anfordert</string>
+ <string name="youtube_sign_in_required">Dieser Song lässt sich nur mit Anmeldung bei YouTube Music abspielen</string>
+ <string name="youtube_signed_in_unplayable">YouTube gibt diesen Song nur angemeldeten Konten frei, und Square kann ihn noch nicht lesen</string>
<string name="page_app_summary">Sprache, Leiste, System und Links</string>
<string name="page_downloads">Downloads und Speicher</string>
<string name="storage_cleanup">Aufräumen</string>
@@ -562,4 +583,17 @@
<string name="lyrics_nothing">Kein Songtext</string>
<string name="connecting_slow">Dauert es lange? Hör inzwischen, was auf deinem Handy ist.</string>
<string name="go_offline">Zum Offlinemodus wechseln</string>
+ <string name="lyrics_from">Songtext von %1$s</string>
+ <string name="lyrics_uploaded_by">hochgeladen von</string>
+ <string name="lyrics_made_by">erstellt von</string>
+ <string name="spicy_lyrics_title">Spicy Lyrics</string>
+ <string name="spicy_lyrics_note">Optional. Mit deinem eigenen Schlüssel wird auch Spicy Lyrics nach Songtexten gefragt, oft silbengenau. Den Schlüssel bekommst du auf der Seite von Square bei Spicy Lyrics.</string>
+ <string name="spicy_lyrics_key">Spicy-Lyrics-Schlüssel</string>
+ <string name="spicy_lyrics_get_key">Schlüssel holen</string>
+ <string name="spicy_lyrics_remove">Schlüssel entfernen</string>
+ <string name="lyrics_more_sources">Weitere Quellen</string>
+ <string name="lyrics_sources">Quellen</string>
+ <string name="lyrics_preferred_title">Songtext-Quelle</string>
+ <string name="lyrics_preferred_auto">Automatisch (die beste)</string>
+ <string name="lyrics_preferred_note">Es werden nur Songtexte der gewählten Quelle angezeigt: Hat sie keinen für den Song, wird keiner angezeigt. Automatisch wählt die beste verfügbare.</string>
</resources>
diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml
index 8bb7720..e557f1a 100644
--- a/app/src/main/res/values-es/strings.xml
+++ b/app/src/main/res/values-es/strings.xml
@@ -309,6 +309,27 @@
<string name="page_app">Aplicación</string>
<string name="page_account_summary">Tu cuenta, la aplicación de la Web API y cerrar sesión</string>
<string name="page_playback_summary">De dónde viene la música, calidad y reproducción</string>
+ <string name="settings_group_sound">Sonido</string>
+ <string name="settings_group_listening">Escucha</string>
+ <string name="settings_group_lyrics">Letras</string>
+ <string name="settings_group_covers">Portadas</string>
+ <string name="settings_group_setup">Configuración</string>
+ <string name="settings_group_appearance">Apariencia</string>
+ <string name="settings_group_sound_summary">Fuente, calidad y efectos</string>
+ <string name="settings_group_listening_summary">Crossfade, reproducción automática y cierre de la app</string>
+ <string name="settings_group_lyrics_summary">Fuente preferida y Spicy Lyrics</string>
+ <string name="settings_group_covers_summary">Portadas animadas y su origen</string>
+ <string name="settings_group_setup_summary">API web y guía de configuración</string>
+ <string name="settings_group_downloads_summary">Cómo se descargan las canciones</string>
+ <string name="settings_group_cleanup_summary">Borrar listas guardadas y archivos temporales</string>
+ <string name="settings_group_language_summary">El idioma de la app</string>
+ <string name="settings_group_appearance_summary">Barra y fuente</string>
+ <string name="settings_group_system_summary">Permisos, batería y enlaces</string>
+ <string name="settings_group_about_summary">Licencias e informes</string>
+ <string name="settings_group_help_summary">Comunidad, debates y problemas</string>
+ <string name="settings_group_permissions_summary">Lo que la app pide a Spotify</string>
+ <string name="youtube_sign_in_required">Esta canción solo se puede escuchar con la sesión de YouTube Music iniciada</string>
+ <string name="youtube_signed_in_unplayable">YouTube solo ofrece esta canción con la sesión iniciada y Square todavía no puede leerla</string>
<string name="page_app_summary">Idioma, barra, sistema y enlaces</string>
<string name="page_downloads">Descargas y almacenamiento</string>
<string name="storage_cleanup">Limpieza</string>
@@ -568,4 +589,17 @@
<string name="lyrics_nothing">Sin letra</string>
<string name="connecting_slow">¿Tarda mucho? Mientras tanto, escucha lo que tienes en el teléfono.</string>
<string name="go_offline">Cambiar al modo sin conexión</string>
+ <string name="lyrics_from">Letra de %1$s</string>
+ <string name="lyrics_uploaded_by">subida por</string>
+ <string name="lyrics_made_by">creada por</string>
+ <string name="spicy_lyrics_title">Spicy Lyrics</string>
+ <string name="spicy_lyrics_note">Opcional. Con tu propia clave, también se consulta Spicy Lyrics, a menudo sincronizada por sílaba. Consigue la clave en la página de Square en Spicy Lyrics.</string>
+ <string name="spicy_lyrics_key">Clave de Spicy Lyrics</string>
+ <string name="spicy_lyrics_get_key">Obtener clave</string>
+ <string name="spicy_lyrics_remove">Quitar la clave</string>
+ <string name="lyrics_more_sources">Más fuentes</string>
+ <string name="lyrics_sources">Fuentes</string>
+ <string name="lyrics_preferred_title">Fuente de letras</string>
+ <string name="lyrics_preferred_auto">Automática (la mejor)</string>
+ <string name="lyrics_preferred_note">Solo se muestran letras de la fuente elegida: si no tiene la de la canción, no se muestra ninguna. Automática elige la mejor disponible.</string>
</resources>
diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml
index 34e153e..4d2b66f 100644
--- a/app/src/main/res/values-fr/strings.xml
+++ b/app/src/main/res/values-fr/strings.xml
@@ -309,6 +309,27 @@
<string name="page_app">Application</string>
<string name="page_account_summary">Votre compte, l’application Web API et la déconnexion</string>
<string name="page_playback_summary">D\'où vient la musique, qualité et lecture</string>
+ <string name="settings_group_sound">Son</string>
+ <string name="settings_group_listening">Écoute</string>
+ <string name="settings_group_lyrics">Paroles</string>
+ <string name="settings_group_covers">Pochettes</string>
+ <string name="settings_group_setup">Configuration</string>
+ <string name="settings_group_appearance">Apparence</string>
+ <string name="settings_group_sound_summary">Source, qualité et effets</string>
+ <string name="settings_group_listening_summary">Fondu enchaîné, lecture auto et fermeture de l’app</string>
+ <string name="settings_group_lyrics_summary">Source préférée et Spicy Lyrics</string>
+ <string name="settings_group_covers_summary">Pochettes animées et leur origine</string>
+ <string name="settings_group_setup_summary">API web et guide de configuration</string>
+ <string name="settings_group_downloads_summary">Comment les titres sont téléchargés</string>
+ <string name="settings_group_cleanup_summary">Vider les listes enregistrées et les fichiers temporaires</string>
+ <string name="settings_group_language_summary">La langue de l’app</string>
+ <string name="settings_group_appearance_summary">Barre et police</string>
+ <string name="settings_group_system_summary">Autorisations, batterie et liens</string>
+ <string name="settings_group_about_summary">Licences et rapports</string>
+ <string name="settings_group_help_summary">Communauté, discussions et problèmes</string>
+ <string name="settings_group_permissions_summary">Ce que l’app demande à Spotify</string>
+ <string name="youtube_sign_in_required">Ce titre ne peut être lu qu’en étant connecté à YouTube Music</string>
+ <string name="youtube_signed_in_unplayable">YouTube ne diffuse ce titre qu’aux comptes connectés, et Square ne peut pas encore le lire</string>
<string name="page_app_summary">Langue, barre, système et liens</string>
<string name="page_downloads">Téléchargements et stockage</string>
<string name="storage_cleanup">Nettoyage</string>
@@ -562,4 +583,17 @@
<string name="lyrics_nothing">Pas de paroles</string>
<string name="connecting_slow">Ça prend du temps ? Écoute en attendant ce qui est sur ton téléphone.</string>
<string name="go_offline">Passer en mode hors ligne</string>
+ <string name="lyrics_from">Paroles de %1$s</string>
+ <string name="lyrics_uploaded_by">envoyées par</string>
+ <string name="lyrics_made_by">réalisées par</string>
+ <string name="spicy_lyrics_title">Spicy Lyrics</string>
+ <string name="spicy_lyrics_note">Facultatif. Avec ta propre clé, Spicy Lyrics est aussi consulté, souvent synchronisé à la syllabe. Obtiens la clé sur la page de Square chez Spicy Lyrics.</string>
+ <string name="spicy_lyrics_key">Clé Spicy Lyrics</string>
+ <string name="spicy_lyrics_get_key">Obtenir une clé</string>
+ <string name="spicy_lyrics_remove">Supprimer la clé</string>
+ <string name="lyrics_more_sources">Autres sources</string>
+ <string name="lyrics_sources">Sources</string>
+ <string name="lyrics_preferred_title">Source des paroles</string>
+ <string name="lyrics_preferred_auto">Automatique (la meilleure)</string>
+ <string name="lyrics_preferred_note">Seules les paroles de la source choisie sont affichées : si elle n’en a pas pour le morceau, rien n’est affiché. Automatique choisit la meilleure disponible.</string>
</resources>
diff --git a/app/src/main/res/values-hi/strings.xml b/app/src/main/res/values-hi/strings.xml
index 90a8674..a9fbeb6 100644
--- a/app/src/main/res/values-hi/strings.xml
+++ b/app/src/main/res/values-hi/strings.xml
@@ -324,6 +324,27 @@
<string name="page_app">ऐप</string>
<string name="page_account_summary">आपका खाता, Web API ऐप्लिकेशन और साइन आउट</string>
<string name="page_playback_summary">संगीत कहाँ से आता है, गुणवत्ता और प्लेबैक</string>
+ <string name="settings_group_sound">ध्वनि</string>
+ <string name="settings_group_listening">सुनना</string>
+ <string name="settings_group_lyrics">बोल</string>
+ <string name="settings_group_covers">कवर</string>
+ <string name="settings_group_setup">सेटअप</string>
+ <string name="settings_group_appearance">रूप</string>
+ <string name="settings_group_sound_summary">स्रोत, गुणवत्ता और इफ़ेक्ट</string>
+ <string name="settings_group_listening_summary">क्रॉसफ़ेड, ऑटोप्ले और ऐप बंद करना</string>
+ <string name="settings_group_lyrics_summary">पसंदीदा स्रोत और Spicy Lyrics</string>
+ <string name="settings_group_covers_summary">एनिमेटेड कवर और उनका स्रोत</string>
+ <string name="settings_group_setup_summary">वेब API और सेटअप गाइड</string>
+ <string name="settings_group_downloads_summary">गाने कैसे डाउनलोड होते हैं</string>
+ <string name="settings_group_cleanup_summary">सहेजी सूचियाँ और अस्थायी फ़ाइलें साफ़ करें</string>
+ <string name="settings_group_language_summary">ऐप की भाषा</string>
+ <string name="settings_group_appearance_summary">बार और फ़ॉन्ट</string>
+ <string name="settings_group_system_summary">अनुमतियाँ, बैटरी और लिंक</string>
+ <string name="settings_group_about_summary">लाइसेंस और रिपोर्ट</string>
+ <string name="settings_group_help_summary">समुदाय, चर्चाएँ और समस्याएँ</string>
+ <string name="settings_group_permissions_summary">ऐप Spotify से क्या माँगता है</string>
+ <string name="youtube_sign_in_required">यह गाना सिर्फ़ YouTube Music में साइन इन करने पर चलता है</string>
+ <string name="youtube_signed_in_unplayable">YouTube यह गाना सिर्फ़ साइन इन किए खातों को देता है, और Square अभी इसे नहीं पढ़ पाता</string>
<string name="page_app_summary">भाषा, पट्टी, सिस्टम और लिंक</string>
<string name="page_downloads">डाउनलोड और स्टोरेज</string>
<string name="storage_cleanup">सफ़ाई</string>
@@ -577,4 +598,17 @@
<string name="lyrics_nothing">कोई बोल नहीं</string>
<string name="connecting_slow">ज़्यादा समय लग रहा है? तब तक फ़ोन पर मौजूद गाने सुनें।</string>
<string name="go_offline">ऑफ़लाइन मोड पर जाएँ</string>
+ <string name="lyrics_from">%1$s से बोल</string>
+ <string name="lyrics_uploaded_by">अपलोड किया</string>
+ <string name="lyrics_made_by">बनाया</string>
+ <string name="spicy_lyrics_title">Spicy Lyrics</string>
+ <string name="spicy_lyrics_note">वैकल्पिक। अपनी कुंजी से Spicy Lyrics से भी बोल लिए जाते हैं, अक्सर अक्षर-स्तर पर सिंक। कुंजी Spicy Lyrics पर Square के पेज से लें।</string>
+ <string name="spicy_lyrics_key">Spicy Lyrics कुंजी</string>
+ <string name="spicy_lyrics_get_key">कुंजी पाएँ</string>
+ <string name="spicy_lyrics_remove">कुंजी हटाएँ</string>
+ <string name="lyrics_more_sources">और स्रोत</string>
+ <string name="lyrics_sources">स्रोत</string>
+ <string name="lyrics_preferred_title">बोल का स्रोत</string>
+ <string name="lyrics_preferred_auto">स्वचालित (सबसे अच्छा)</string>
+ <string name="lyrics_preferred_note">सिर्फ़ चुने गए स्रोत के बोल दिखाए जाते हैं: अगर उसके पास गाने के बोल नहीं हैं, तो कुछ नहीं दिखेगा। स्वचालित सबसे अच्छा उपलब्ध स्रोत चुनता है।</string>
</resources>
diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml
index 69b4991..7acc2b3 100644
--- a/app/src/main/res/values-it/strings.xml
+++ b/app/src/main/res/values-it/strings.xml
@@ -310,6 +310,27 @@
<string name="page_app">App</string>
<string name="page_account_summary">Il tuo account, l’applicazione Web API e la disconnessione</string>
<string name="page_playback_summary">Da dove arriva la musica, qualità e riproduzione</string>
+ <string name="settings_group_sound">Audio</string>
+ <string name="settings_group_listening">Ascolto</string>
+ <string name="settings_group_lyrics">Testi</string>
+ <string name="settings_group_covers">Copertine</string>
+ <string name="settings_group_setup">Configurazione</string>
+ <string name="settings_group_appearance">Aspetto</string>
+ <string name="settings_group_sound_summary">Sorgente, qualità ed effetti</string>
+ <string name="settings_group_listening_summary">Crossfade, autoplay e chiusura dell\'app</string>
+ <string name="settings_group_lyrics_summary">Fonte preferita e Spicy Lyrics</string>
+ <string name="settings_group_covers_summary">Copertine animate e da dove arrivano</string>
+ <string name="settings_group_setup_summary">API web e guida alla configurazione</string>
+ <string name="settings_group_downloads_summary">Come vengono scaricati i brani</string>
+ <string name="settings_group_cleanup_summary">Svuota liste salvate e file temporanei</string>
+ <string name="settings_group_language_summary">La lingua dell\'app</string>
+ <string name="settings_group_appearance_summary">Barra e carattere</string>
+ <string name="settings_group_system_summary">Permessi, batteria e link</string>
+ <string name="settings_group_about_summary">Licenze e segnalazioni</string>
+ <string name="settings_group_help_summary">Community, discussioni e problemi</string>
+ <string name="settings_group_permissions_summary">Cosa chiede l\'app a Spotify</string>
+ <string name="youtube_sign_in_required">Questo brano si può ascoltare solo con l\'accesso a YouTube Music</string>
+ <string name="youtube_signed_in_unplayable">YouTube dà questo brano solo con l\'accesso e per ora Square non riesce a leggerlo</string>
<string name="page_app_summary">Lingua, barra, sistema e collegamenti</string>
<string name="page_downloads">Download e spazio</string>
<string name="storage_cleanup">Pulizia</string>
@@ -599,4 +620,17 @@
<string name="lyrics_nothing">Nessun testo</string>
<string name="connecting_slow">Ci vuole molto? Intanto ascolta quello che hai sul telefono.</string>
<string name="go_offline">Passa alla modalità offline</string>
+ <string name="lyrics_from">Testi da %1$s</string>
+ <string name="lyrics_uploaded_by">caricati da</string>
+ <string name="lyrics_made_by">creati da</string>
+ <string name="spicy_lyrics_title">Spicy Lyrics</string>
+ <string name="spicy_lyrics_note">Facoltativo. Con una chiave tua, anche Spicy Lyrics viene interrogato per i testi, spesso sincronizzati per sillaba. La chiave si ottiene dalla pagina di Square su Spicy Lyrics.</string>
+ <string name="spicy_lyrics_key">Chiave Spicy Lyrics</string>
+ <string name="spicy_lyrics_get_key">Ottieni la chiave</string>
+ <string name="spicy_lyrics_remove">Rimuovi la chiave</string>
+ <string name="lyrics_more_sources">Altre fonti</string>
+ <string name="lyrics_sources">Fonti</string>
+ <string name="lyrics_preferred_title">Fonte dei testi</string>
+ <string name="lyrics_preferred_auto">Automatica (la migliore)</string>
+ <string name="lyrics_preferred_note">Vengono mostrati solo i testi della fonte scelta: se non ha il testo del brano, non viene mostrato nulla. Automatica sceglie la migliore disponibile.</string>
</resources>
diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml
index 7edc1ad..e85ee59 100644
--- a/app/src/main/res/values-ja/strings.xml
+++ b/app/src/main/res/values-ja/strings.xml
@@ -325,6 +325,27 @@
<string name="page_app">アプリ</string>
<string name="page_account_summary">アカウント、Web API用の開発者アプリ、ログアウト</string>
<string name="page_playback_summary">再生サービス、音質、再生設定</string>
+ <string name="settings_group_sound">サウンド</string>
+ <string name="settings_group_listening">再生</string>
+ <string name="settings_group_lyrics">歌詞</string>
+ <string name="settings_group_covers">カバー</string>
+ <string name="settings_group_setup">セットアップ</string>
+ <string name="settings_group_appearance">外観</string>
+ <string name="settings_group_sound_summary">ソース、音質、エフェクト</string>
+ <string name="settings_group_listening_summary">クロスフェード、自動再生、アプリを閉じたとき</string>
+ <string name="settings_group_lyrics_summary">優先ソースと Spicy Lyrics</string>
+ <string name="settings_group_covers_summary">動くカバーとその提供元</string>
+ <string name="settings_group_setup_summary">Web API とセットアップガイド</string>
+ <string name="settings_group_downloads_summary">曲のダウンロード方法</string>
+ <string name="settings_group_cleanup_summary">保存したリストと一時ファイルを削除</string>
+ <string name="settings_group_language_summary">アプリの言語</string>
+ <string name="settings_group_appearance_summary">バーとフォント</string>
+ <string name="settings_group_system_summary">権限、バッテリー、リンク</string>
+ <string name="settings_group_about_summary">ライセンスとレポート</string>
+ <string name="settings_group_help_summary">コミュニティ、ディスカッション、問題</string>
+ <string name="settings_group_permissions_summary">アプリが Spotify に求めるもの</string>
+ <string name="youtube_sign_in_required">この曲は YouTube Music にログインしている場合のみ再生できます</string>
+ <string name="youtube_signed_in_unplayable">YouTube はこの曲をログイン中のアカウントにしか提供せず、Square はまだ読み込めません</string>
<string name="page_app_summary">言語、下部バー、システム、リンク</string>
<string name="page_downloads">ダウンロードとストレージ</string>
<string name="storage_cleanup">クリーンアップ</string>
@@ -618,5 +639,18 @@
<string name="lyrics_nothing">歌詞なし</string>
<string name="connecting_slow">時間がかかっていますか?その間、端末に保存した曲を聴けます。</string>
<string name="go_offline">オフラインモードに切り替え</string>
+ <string name="lyrics_from">歌詞提供:%1$s</string>
+ <string name="lyrics_uploaded_by">アップロード</string>
+ <string name="lyrics_made_by">作成</string>
+ <string name="spicy_lyrics_title">Spicy Lyrics</string>
+ <string name="spicy_lyrics_note">任意。自分のキーがあれば、Spicy Lyricsからも歌詞を取得します(音節単位で同期されていることが多いです)。キーはSpicy LyricsのSquareのページから取得できます。</string>
+ <string name="spicy_lyrics_key">Spicy Lyricsのキー</string>
+ <string name="spicy_lyrics_get_key">キーを取得</string>
+ <string name="spicy_lyrics_remove">キーを削除</string>
+ <string name="lyrics_more_sources">その他のソース</string>
+ <string name="lyrics_sources">ソース</string>
+ <string name="lyrics_preferred_title">歌詞のソース</string>
+ <string name="lyrics_preferred_auto">自動(最適なもの)</string>
+ <string name="lyrics_preferred_note">選んだソースの歌詞だけが表示されます。その曲の歌詞がなければ何も表示されません。自動では最適なソースが選ばれます。</string>
</resources>
diff --git a/app/src/main/res/values-ko/strings.xml b/app/src/main/res/values-ko/strings.xml
index 45014cf..4796543 100644
--- a/app/src/main/res/values-ko/strings.xml
+++ b/app/src/main/res/values-ko/strings.xml
@@ -300,6 +300,27 @@
<string name="page_app">앱</string>
<string name="page_account_summary">내 계정, Web API 애플리케이션, 로그아웃</string>
<string name="page_playback_summary">음악 소스, 음질, 재생</string>
+ <string name="settings_group_sound">사운드</string>
+ <string name="settings_group_listening">감상</string>
+ <string name="settings_group_lyrics">가사</string>
+ <string name="settings_group_covers">커버</string>
+ <string name="settings_group_setup">설정</string>
+ <string name="settings_group_appearance">모양</string>
+ <string name="settings_group_sound_summary">소스, 음질 및 효과</string>
+ <string name="settings_group_listening_summary">크로스페이드, 자동 재생 및 앱 닫기</string>
+ <string name="settings_group_lyrics_summary">선호 출처와 Spicy Lyrics</string>
+ <string name="settings_group_covers_summary">움직이는 커버와 그 출처</string>
+ <string name="settings_group_setup_summary">웹 API와 설정 가이드</string>
+ <string name="settings_group_downloads_summary">노래를 다운로드하는 방법</string>
+ <string name="settings_group_cleanup_summary">저장된 목록과 임시 파일 정리</string>
+ <string name="settings_group_language_summary">앱 언어</string>
+ <string name="settings_group_appearance_summary">바와 글꼴</string>
+ <string name="settings_group_system_summary">권한, 배터리 및 링크</string>
+ <string name="settings_group_about_summary">라이선스 및 보고서</string>
+ <string name="settings_group_help_summary">커뮤니티, 토론 및 문제</string>
+ <string name="settings_group_permissions_summary">앱이 Spotify에 요청하는 것</string>
+ <string name="youtube_sign_in_required">이 노래는 YouTube Music에 로그인해야 재생할 수 있습니다</string>
+ <string name="youtube_signed_in_unplayable">YouTube는 이 노래를 로그인한 계정에만 제공하며, Square는 아직 읽을 수 없습니다</string>
<string name="page_app_summary">언어, 바, 시스템, 링크</string>
<string name="page_downloads">다운로드 및 저장공간</string>
<string name="storage_cleanup">정리</string>
@@ -586,4 +607,17 @@
<string name="lyrics_nothing">가사 없음</string>
<string name="connecting_slow">오래 걸리나요? 그동안 휴대폰에 있는 음악을 들어보세요.</string>
<string name="go_offline">오프라인 모드로 전환</string>
+ <string name="lyrics_from">%1$s 제공 가사</string>
+ <string name="lyrics_uploaded_by">업로드</string>
+ <string name="lyrics_made_by">제작</string>
+ <string name="spicy_lyrics_title">Spicy Lyrics</string>
+ <string name="spicy_lyrics_note">선택 사항입니다. 내 키가 있으면 Spicy Lyrics에서도 가사를 가져오며, 음절 단위로 동기화된 경우가 많습니다. 키는 Spicy Lyrics의 Square 페이지에서 받을 수 있습니다.</string>
+ <string name="spicy_lyrics_key">Spicy Lyrics 키</string>
+ <string name="spicy_lyrics_get_key">키 받기</string>
+ <string name="spicy_lyrics_remove">키 삭제</string>
+ <string name="lyrics_more_sources">다른 출처</string>
+ <string name="lyrics_sources">출처</string>
+ <string name="lyrics_preferred_title">가사 출처</string>
+ <string name="lyrics_preferred_auto">자동 (가장 좋은 출처)</string>
+ <string name="lyrics_preferred_note">선택한 출처의 가사만 표시됩니다. 그 출처에 노래 가사가 없으면 아무것도 표시되지 않습니다. 자동은 가장 좋은 출처를 고릅니다.</string>
</resources>
diff --git a/app/src/main/res/values-pt/strings.xml b/app/src/main/res/values-pt/strings.xml
index d183e93..b8327bc 100644
--- a/app/src/main/res/values-pt/strings.xml
+++ b/app/src/main/res/values-pt/strings.xml
@@ -309,6 +309,27 @@
<string name="page_app">Aplicativo</string>
<string name="page_account_summary">Sua conta, o aplicativo da Web API e sair</string>
<string name="page_playback_summary">De onde vem a música, qualidade e reprodução</string>
+ <string name="settings_group_sound">Som</string>
+ <string name="settings_group_listening">Audição</string>
+ <string name="settings_group_lyrics">Letras</string>
+ <string name="settings_group_covers">Capas</string>
+ <string name="settings_group_setup">Configuração</string>
+ <string name="settings_group_appearance">Aparência</string>
+ <string name="settings_group_sound_summary">Fonte, qualidade e efeitos</string>
+ <string name="settings_group_listening_summary">Crossfade, reprodução automática e fechar o app</string>
+ <string name="settings_group_lyrics_summary">Fonte preferida e Spicy Lyrics</string>
+ <string name="settings_group_covers_summary">Capas animadas e de onde vêm</string>
+ <string name="settings_group_setup_summary">API web e guia de configuração</string>
+ <string name="settings_group_downloads_summary">Como as músicas são baixadas</string>
+ <string name="settings_group_cleanup_summary">Limpar listas salvas e arquivos temporários</string>
+ <string name="settings_group_language_summary">O idioma do app</string>
+ <string name="settings_group_appearance_summary">Barra e fonte</string>
+ <string name="settings_group_system_summary">Permissões, bateria e links</string>
+ <string name="settings_group_about_summary">Licenças e relatórios</string>
+ <string name="settings_group_help_summary">Comunidade, discussões e problemas</string>
+ <string name="settings_group_permissions_summary">O que o app pede ao Spotify</string>
+ <string name="youtube_sign_in_required">Esta música só toca com sessão iniciada no YouTube Music</string>
+ <string name="youtube_signed_in_unplayable">O YouTube só libera esta música com sessão iniciada, e o Square ainda não consegue lê-la</string>
<string name="page_app_summary">Idioma, barra, sistema e links</string>
<string name="page_downloads">Downloads e armazenamento</string>
<string name="storage_cleanup">Limpeza</string>
@@ -562,4 +583,17 @@
<string name="lyrics_nothing">Sem letra</string>
<string name="connecting_slow">Está demorando? Enquanto isso, ouça o que está no seu telefone.</string>
<string name="go_offline">Mudar para o modo offline</string>
+ <string name="lyrics_from">Letra de %1$s</string>
+ <string name="lyrics_uploaded_by">enviada por</string>
+ <string name="lyrics_made_by">feita por</string>
+ <string name="spicy_lyrics_title">Spicy Lyrics</string>
+ <string name="spicy_lyrics_note">Opcional. Com sua própria chave, o Spicy Lyrics também é consultado, muitas vezes sincronizado por sílaba. Pegue a chave na página do Square no Spicy Lyrics.</string>
+ <string name="spicy_lyrics_key">Chave do Spicy Lyrics</string>
+ <string name="spicy_lyrics_get_key">Obter chave</string>
+ <string name="spicy_lyrics_remove">Remover a chave</string>
+ <string name="lyrics_more_sources">Mais fontes</string>
+ <string name="lyrics_sources">Fontes</string>
+ <string name="lyrics_preferred_title">Fonte das letras</string>
+ <string name="lyrics_preferred_auto">Automática (a melhor)</string>
+ <string name="lyrics_preferred_note">Só são mostradas letras da fonte escolhida: se ela não tiver a da música, nenhuma é mostrada. Automática escolhe a melhor disponível.</string>
</resources>
diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml
index ccc3a6f..9e1db7c 100644
--- a/app/src/main/res/values-ru/strings.xml
+++ b/app/src/main/res/values-ru/strings.xml
@@ -326,6 +326,27 @@
<string name="page_app">Приложение</string>
<string name="page_account_summary">Ваш аккаунт, приложение Web API и выход</string>
<string name="page_playback_summary">Откуда музыка, качество и воспроизведение</string>
+ <string name="settings_group_sound">Звук</string>
+ <string name="settings_group_listening">Прослушивание</string>
+ <string name="settings_group_lyrics">Тексты</string>
+ <string name="settings_group_covers">Обложки</string>
+ <string name="settings_group_setup">Настройка</string>
+ <string name="settings_group_appearance">Внешний вид</string>
+ <string name="settings_group_sound_summary">Источник, качество и эффекты</string>
+ <string name="settings_group_listening_summary">Кроссфейд, автовоспроизведение и закрытие приложения</string>
+ <string name="settings_group_lyrics_summary">Предпочитаемый источник и Spicy Lyrics</string>
+ <string name="settings_group_covers_summary">Анимированные обложки и их источник</string>
+ <string name="settings_group_setup_summary">Веб-API и руководство по настройке</string>
+ <string name="settings_group_downloads_summary">Как скачиваются песни</string>
+ <string name="settings_group_cleanup_summary">Очистить сохранённые списки и временные файлы</string>
+ <string name="settings_group_language_summary">Язык приложения</string>
+ <string name="settings_group_appearance_summary">Панель и шрифт</string>
+ <string name="settings_group_system_summary">Разрешения, батарея и ссылки</string>
+ <string name="settings_group_about_summary">Лицензии и отчёты</string>
+ <string name="settings_group_help_summary">Сообщество, обсуждения и проблемы</string>
+ <string name="settings_group_permissions_summary">Что приложение запрашивает у Spotify</string>
+ <string name="youtube_sign_in_required">Эту песню можно слушать, только войдя в YouTube Music</string>
+ <string name="youtube_signed_in_unplayable">YouTube отдаёт эту песню только вошедшим в аккаунт, а Square пока не может её прочитать</string>
<string name="page_app_summary">Язык, панель, система и ссылки</string>
<string name="page_downloads">Загрузки и память</string>
<string name="storage_cleanup">Очистка</string>
@@ -591,4 +612,17 @@
<string name="lyrics_nothing">Нет текста</string>
<string name="connecting_slow">Долго? Пока слушайте то, что есть на телефоне.</string>
<string name="go_offline">Перейти в офлайн-режим</string>
+ <string name="lyrics_from">Текст из %1$s</string>
+ <string name="lyrics_uploaded_by">загрузил</string>
+ <string name="lyrics_made_by">создал</string>
+ <string name="spicy_lyrics_title">Spicy Lyrics</string>
+ <string name="spicy_lyrics_note">Необязательно. С вашим ключом тексты будут запрашиваться и у Spicy Lyrics, часто с синхронизацией по слогам. Ключ можно получить на странице Square в Spicy Lyrics.</string>
+ <string name="spicy_lyrics_key">Ключ Spicy Lyrics</string>
+ <string name="spicy_lyrics_get_key">Получить ключ</string>
+ <string name="spicy_lyrics_remove">Удалить ключ</string>
+ <string name="lyrics_more_sources">Другие источники</string>
+ <string name="lyrics_sources">Источники</string>
+ <string name="lyrics_preferred_title">Источник текстов</string>
+ <string name="lyrics_preferred_auto">Автоматически (лучший)</string>
+ <string name="lyrics_preferred_note">Показываются только тексты из выбранного источника: если у него нет текста песни, ничего не показывается. Автоматически выбирается лучший из доступных.</string>
</resources>
diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xml
index 83bec66..383c6f0 100644
--- a/app/src/main/res/values-tr/strings.xml
+++ b/app/src/main/res/values-tr/strings.xml
@@ -324,6 +324,27 @@
<string name="page_app">Uygulama</string>
<string name="page_account_summary">Hesabın, Web API uygulaması ve çıkış</string>
<string name="page_playback_summary">Müzik nereden geliyor, kalite ve çalma</string>
+ <string name="settings_group_sound">Ses</string>
+ <string name="settings_group_listening">Dinleme</string>
+ <string name="settings_group_lyrics">Sözler</string>
+ <string name="settings_group_covers">Kapaklar</string>
+ <string name="settings_group_setup">Kurulum</string>
+ <string name="settings_group_appearance">Görünüm</string>
+ <string name="settings_group_sound_summary">Kaynak, kalite ve efektler</string>
+ <string name="settings_group_listening_summary">Geçiş, otomatik oynatma ve uygulamayı kapatma</string>
+ <string name="settings_group_lyrics_summary">Tercih edilen kaynak ve Spicy Lyrics</string>
+ <string name="settings_group_covers_summary">Hareketli kapaklar ve kaynağı</string>
+ <string name="settings_group_setup_summary">Web API ve kurulum rehberi</string>
+ <string name="settings_group_downloads_summary">Şarkılar nasıl indirilir</string>
+ <string name="settings_group_cleanup_summary">Kayıtlı listeleri ve geçici dosyaları temizle</string>
+ <string name="settings_group_language_summary">Uygulamanın dili</string>
+ <string name="settings_group_appearance_summary">Çubuk ve yazı tipi</string>
+ <string name="settings_group_system_summary">İzinler, pil ve bağlantılar</string>
+ <string name="settings_group_about_summary">Lisanslar ve raporlar</string>
+ <string name="settings_group_help_summary">Topluluk, tartışmalar ve sorunlar</string>
+ <string name="settings_group_permissions_summary">Uygulamanın Spotify’dan istedikleri</string>
+ <string name="youtube_sign_in_required">Bu şarkı yalnızca YouTube Music’te oturum açıkken çalar</string>
+ <string name="youtube_signed_in_unplayable">YouTube bu şarkıyı yalnızca oturum açmış hesaplara veriyor ve Square henüz okuyamıyor</string>
<string name="page_app_summary">Dil, çubuk, sistem ve bağlantılar</string>
<string name="page_downloads">İndirmeler ve depolama</string>
<string name="storage_cleanup">Temizlik</string>
@@ -575,4 +596,17 @@
<string name="lyrics_nothing">Söz yok</string>
<string name="connecting_slow">Uzun mu sürüyor? Bu arada telefonundakileri dinle.</string>
<string name="go_offline">Çevrimdışı moda geç</string>
+ <string name="lyrics_from">Sözler: %1$s</string>
+ <string name="lyrics_uploaded_by">yükleyen</string>
+ <string name="lyrics_made_by">hazırlayan</string>
+ <string name="spicy_lyrics_title">Spicy Lyrics</string>
+ <string name="spicy_lyrics_note">İsteğe bağlı. Kendi anahtarınla Spicy Lyrics de sorgulanır, çoğu zaman hece hece senkronize. Anahtarı Spicy Lyrics üzerindeki Square sayfasından al.</string>
+ <string name="spicy_lyrics_key">Spicy Lyrics anahtarı</string>
+ <string name="spicy_lyrics_get_key">Anahtar al</string>
+ <string name="spicy_lyrics_remove">Anahtarı kaldır</string>
+ <string name="lyrics_more_sources">Diğer kaynaklar</string>
+ <string name="lyrics_sources">Kaynaklar</string>
+ <string name="lyrics_preferred_title">Şarkı sözü kaynağı</string>
+ <string name="lyrics_preferred_auto">Otomatik (en iyisi)</string>
+ <string name="lyrics_preferred_note">Yalnızca seçilen kaynağın sözleri gösterilir: şarkı için sözü yoksa hiçbir şey gösterilmez. Otomatik, mevcut en iyisini seçer.</string>
</resources>
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 7614220..cc2940b 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -330,6 +330,27 @@
<string name="page_app">App</string>
<string name="page_account_summary">Your account, the Web API application and signing out</string>
<string name="page_playback_summary">Where the music comes from, quality and playing</string>
+ <string name="settings_group_sound">Sound</string>
+ <string name="settings_group_listening">Listening</string>
+ <string name="settings_group_lyrics">Lyrics</string>
+ <string name="settings_group_covers">Covers</string>
+ <string name="settings_group_setup">Setup</string>
+ <string name="settings_group_appearance">Appearance</string>
+ <string name="settings_group_sound_summary">Source, quality and effects</string>
+ <string name="settings_group_listening_summary">Crossfade, autoplay and closing the app</string>
+ <string name="settings_group_lyrics_summary">Preferred source and Spicy Lyrics</string>
+ <string name="settings_group_covers_summary">Animated covers and where they come from</string>
+ <string name="settings_group_setup_summary">Web API and the setup guide</string>
+ <string name="settings_group_downloads_summary">How songs are downloaded</string>
+ <string name="settings_group_cleanup_summary">Clear saved lists and temporary files</string>
+ <string name="settings_group_language_summary">The language the app speaks</string>
+ <string name="settings_group_appearance_summary">Bar and font</string>
+ <string name="settings_group_system_summary">Permissions, battery and links</string>
+ <string name="settings_group_about_summary">Licences and reports</string>
+ <string name="settings_group_help_summary">Community, discussions and problems</string>
+ <string name="settings_group_permissions_summary">What the app asks Spotify for</string>
+ <string name="youtube_sign_in_required">This song plays only when signed in to YouTube Music</string>
+ <string name="youtube_signed_in_unplayable">YouTube plays this song only to signed-in accounts, and Square cannot read it yet</string>
<string name="page_app_summary">Language, bar, system and links</string>
<string name="page_downloads">Downloads and storage</string>
<string name="storage_cleanup">Cleaning up</string>
@@ -626,4 +647,17 @@
<string name="lyrics_nothing">No lyrics</string>
<string name="connecting_slow">Taking long? Play what is on your phone in the meantime.</string>
<string name="go_offline">Switch to offline mode</string>
+ <string name="lyrics_from">Lyrics from %1$s</string>
+ <string name="lyrics_uploaded_by">uploaded by</string>
+ <string name="lyrics_made_by">made by</string>
+ <string name="spicy_lyrics_title">Spicy Lyrics</string>
+ <string name="spicy_lyrics_note">Optional. With your own key, Spicy Lyrics is asked for lyrics too, often synced to the syllable. Get the key from Square\'s page on Spicy Lyrics.</string>
+ <string name="spicy_lyrics_key">Spicy Lyrics key</string>
+ <string name="spicy_lyrics_get_key">Get a key</string>
+ <string name="spicy_lyrics_remove">Remove the key</string>
+ <string name="lyrics_more_sources">More sources</string>
+ <string name="lyrics_sources">Sources</string>
+ <string name="lyrics_preferred_title">Lyrics source</string>
+ <string name="lyrics_preferred_auto">Automatic (best available)</string>
+ <string name="lyrics_preferred_note">Only lyrics from the chosen source are shown: if it has none for the song, no lyrics are shown. Automatic picks the best available.</string>
</resources>
diff --git a/app/src/test/java/dev/lelonio/square/backend/lyrics/LyricsWinnerTest.kt b/app/src/test/java/dev/lelonio/square/backend/lyrics/LyricsWinnerTest.kt
new file mode 100644
index 0000000..ded8a3b
--- /dev/null
+++ b/app/src/test/java/dev/lelonio/square/backend/lyrics/LyricsWinnerTest.kt
@@ -0,0 +1,46 @@
+package dev.lelonio.square.backend.lyrics
+
+import dev.lelonio.square.data.LyricLine
+import dev.lelonio.square.data.LyricWord
+import dev.lelonio.square.data.Lyrics
+import org.junit.Assert.*
+import org.junit.Test
+
+class LyricsWinnerTest {
+ private val order = listOf(LyricsSource.APPLE_MUSIC, LyricsSource.SPOTIFY, LyricsSource.LRCLIB, LyricsSource.KUGOU)
+ private fun word(source: LyricsSource) =
+ Lyrics(listOf(LyricLine(0, "a b", words = listOf(LyricWord(0, 1, "a")))), synced = true, source = source.name)
+ private fun line(source: LyricsSource) = Lyrics(listOf(LyricLine(0, "a b")), synced = true, source = source.name)
+ private fun plain(source: LyricsSource) = Lyrics(listOf(LyricLine(null, "a b")), synced = false, source = source.name)
+
+ @Test fun wordTimingFurtherDownBeatsALineTimedAnswerAbove() {
+ val all = mapOf(LyricsSource.APPLE_MUSIC to null, LyricsSource.SPOTIFY to line(LyricsSource.SPOTIFY),
+ LyricsSource.LRCLIB to line(LyricsSource.LRCLIB), LyricsSource.KUGOU to word(LyricsSource.KUGOU))
+ assertEquals("KUGOU", LyricsLibrary.winner(order, all, final = false)?.source)
+ }
+
+ @Test fun waitsWhileAnEarlierSourceCouldStillWin() {
+ val partial = mapOf(LyricsSource.SPOTIFY to word(LyricsSource.SPOTIFY))
+ assertNull(LyricsLibrary.winner(order, partial, final = false))
+ assertEquals("SPOTIFY", LyricsLibrary.winner(order, partial, final = true)?.source)
+ val earlierAnswered = mapOf(LyricsSource.APPLE_MUSIC to line(LyricsSource.APPLE_MUSIC), LyricsSource.SPOTIFY to word(LyricsSource.SPOTIFY))
+ assertEquals("SPOTIFY", LyricsLibrary.winner(order, earlierAnswered, final = false)?.source)
+ }
+
+ @Test fun withoutWordTimingTheFirstLineTimedWinsOnceAllAreIn() {
+ val all = mapOf(LyricsSource.APPLE_MUSIC to plain(LyricsSource.APPLE_MUSIC), LyricsSource.SPOTIFY to null,
+ LyricsSource.LRCLIB to line(LyricsSource.LRCLIB), LyricsSource.KUGOU to line(LyricsSource.KUGOU))
+ assertEquals("LRCLIB", LyricsLibrary.winner(order, all, final = false)?.source)
+ assertNull(LyricsLibrary.winner(order, all - LyricsSource.KUGOU, final = false))
+ assertNull(LyricsLibrary.winner(order, order.associateWith { null }, final = false))
+ }
+
+ @Test fun aPreferredSourceIsTheOnlyAnswer() {
+ val partial = mapOf(LyricsSource.APPLE_MUSIC to word(LyricsSource.APPLE_MUSIC))
+ assertNull(LyricsLibrary.winner(order, partial, final = false, preferred = LyricsSource.LRCLIB))
+ val all = partial + mapOf(LyricsSource.SPOTIFY to null, LyricsSource.LRCLIB to plain(LyricsSource.LRCLIB), LyricsSource.KUGOU to null)
+ assertEquals("LRCLIB", LyricsLibrary.winner(order, all, final = false, preferred = LyricsSource.LRCLIB)?.source)
+ val withoutIt = all + (LyricsSource.LRCLIB to null)
+ assertNull(LyricsLibrary.winner(order, withoutIt, final = true, preferred = LyricsSource.LRCLIB))
+ }
+}
diff --git a/app/src/test/java/dev/lelonio/square/backend/lyrics/SpicyLyricsTest.kt b/app/src/test/java/dev/lelonio/square/backend/lyrics/SpicyLyricsTest.kt
new file mode 100644
index 0000000..53905fb
--- /dev/null
+++ b/app/src/test/java/dev/lelonio/square/backend/lyrics/SpicyLyricsTest.kt
@@ -0,0 +1,47 @@
+package dev.lelonio.square.backend.lyrics
+
+import org.json.JSONObject
+import org.junit.Assert.*
+import org.junit.Test
+
+class SpicyLyricsTest {
+ @Test fun syllablesBecomeWordsAndTheCreditIsKept() {
+ val json = JSONObject(
+ """
+ {"Type":"Syllable","source":"spicy_lyrics",
+ "UploadAttribution":{"Uploader":{"username":"alice","url":"https://spicylyrics.org/u/alice"}},
+ "Content":[{"Type":"Vocal","OppositeAligned":false,"Lead":{
+ "StartTime":1.5,"EndTime":3.0,"TranslatedText":"Ciao bellissima",
+ "Syllables":[
+ {"Text":"Hel","StartTime":1.5,"EndTime":1.7,"IsPartOfWord":true},
+ {"Text":"lo","StartTime":1.7,"EndTime":2.0,"IsPartOfWord":false},
+ {"Text":"beau","StartTime":2.0,"EndTime":2.3,"IsPartOfWord":true},
+ {"Text":"ti","StartTime":2.3,"EndTime":2.5,"IsPartOfWord":true},
+ {"Text":"ful","StartTime":2.5,"EndTime":3.0,"IsPartOfWord":false}]}}]}
+ """.trimIndent(),
+ )
+ val lyrics = SpicyLyrics.parse(json)!!
+ val line = lyrics.lines.single()
+ assertEquals("Hello beautiful", line.text)
+ assertEquals(1500L, line.startTimeMs)
+ assertEquals(listOf("Hel", "lo", "beau", "ti", "ful"), line.words.map { it.text })
+ assertEquals(2300L, line.words[3].startMs)
+ assertEquals("Ciao bellissima", line.translation)
+ assertTrue(lyrics.synced)
+ assertEquals("Spicy Lyrics", lyrics.credit?.provider)
+ assertEquals("alice", lyrics.credit?.uploader)
+ assertNull(lyrics.credit?.maker)
+ }
+
+ @Test fun lineAndStaticLyrics() {
+ val line = SpicyLyrics.parse(
+ JSONObject("""{"Type":"Line","source":"apple_music","Content":[{"Type":"Vocal","Text":"A line","StartTime":4.25,"EndTime":6}]}"""),
+ )!!
+ assertEquals(4250L, line.lines.single().startTimeMs)
+ assertNull(line.credit?.uploader)
+
+ val static = SpicyLyrics.parse(JSONObject("""{"Type":"Static","Lines":[{"Text":"One"},{"Text":""},{"Text":"Two"}]}"""))!!
+ assertEquals(listOf("One", "Two"), static.lines.map { it.text })
+ assertFalse(static.synced)
+ }
+}
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index 14267dc..25d9ba2 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -15,6 +15,7 @@ androidx-profileinstaller = { module = "androidx.profileinstaller:profileinstall
androidx-core-ktx = { module = "androidx.core:core-ktx", version = "1.15.0" }
androidx-activity-compose = { module = "androidx.activity:activity-compose", version = "1.9.3" }
androidx-browser = { module = "androidx.browser:browser", version = "1.8.0" }
+androidx-javascriptengine = { module = "androidx.javascriptengine:javascriptengine", version = "1.1.1" }
reorderable = { module = "sh.calvin.reorderable:reorderable", version = "3.1.0" }
androidx-security-crypto = { module = "androidx.security:security-crypto", version = "1.1.0-alpha06" }
androidx-lifecycle-runtime-compose = { module = "androidx.lifecycle:lifecycle-runtime-compose", version.ref = "lifecycle" }