diff --git a/package.json b/package.json index d3377265..5aea0839 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "stylelint-bundle": "^8.0.0", "stylus-lang-bundle": "^0.54.5", "updates": "^4.2.1", - "usercss-meta": "^0.8.0" + "usercss-meta": "^0.8.1" }, "scripts": { "lint": "eslint **/*.js || true", diff --git a/tools/update-libraries.js b/tools/update-libraries.js index d4dc0090..8e490af1 100644 --- a/tools/update-libraries.js +++ b/tools/update-libraries.js @@ -38,7 +38,7 @@ async function updateReadme(lib) { const pkg = await fs.readJson(`${root}/node_modules/${lib}/package.json`); const file = `${root}/vendor/${lib}/README.md`; const txt = await fs.readFile(file, 'utf8'); - return fs.writeFile(file, txt.replace(/\bv[\d.]+[-\w]*\b/g, `v${pkg.version}`)); + return fs.writeFile(file, txt.replace(/\b([v@])[\d.]+[-\w]*\b/g, `$1${pkg.version}`)); } function isFolder(fileOrFolder) { diff --git a/vendor/usercss-meta/README.md b/vendor/usercss-meta/README.md index 3de6f474..b1eb9236 100644 --- a/vendor/usercss-meta/README.md +++ b/vendor/usercss-meta/README.md @@ -1,5 +1,5 @@ -## usercss-meta v0.8.0 +## usercss-meta v0.8.1 usercss-meta installed via npm - source repo: -https://unpkg.com/usercss-meta@0.8.0/dist/usercss-meta.min.js +https://unpkg.com/usercss-meta@0.8.1/dist/usercss-meta.min.js diff --git a/vendor/usercss-meta/usercss-meta.min.js b/vendor/usercss-meta/usercss-meta.min.js index e76b45ed..68c1c8fe 100644 --- a/vendor/usercss-meta/usercss-meta.min.js +++ b/vendor/usercss-meta/usercss-meta.min.js @@ -1,2 +1,2 @@ -var usercssMeta=function(e){"use strict";class n extends Error{constructor(e){super(e.message),delete e.message,this.name="ParseError",Object.assign(this,e)}}class t extends n{constructor(e,n){super({code:"missingChar",args:e,message:`Missing character: ${e.map(e=>`'${e}'`).join(", ")}`,index:n})}}class a extends n{constructor(e){super({code:"EOF",message:"Unexpected end of file",index:e})}}const s=/<<e[1]===n?n:JSON.parse(`"${e}"`))}function v(e){l.lastIndex=e.lastIndex,l.exec(e.text),e.lastIndex=l.lastIndex}function y(e){i.lastIndex=e.lastIndex,e.lastIndex+=i.exec(e.text)[0].length}function g(e){if(e.lastIndex>=e.text.length)throw new a(e.lastIndex);e.index=e.lastIndex,e.value=e.text[e.lastIndex],e.lastIndex++,y(e)}function m(e){const t=e.lastIndex;o.lastIndex=t;const a=o.exec(e.text);if(!a)throw new n({code:"invalidWord",message:"Invalid word",index:t});e.index=t,e.value=a[1],e.lastIndex+=a[0].length}function h(e){const a=e.lastIndex;try{!function e(a){const{text:s}=a;if("{"===s[a.lastIndex]){const n={};for(a.lastIndex++,y(a);"}"!==s[a.lastIndex];){b(a);const l=a.value;if(":"!==s[a.lastIndex])throw new t([":"],a.lastIndex);if(a.lastIndex++,y(a),e(a),n[l]=a.value,","===s[a.lastIndex])a.lastIndex++,y(a);else if("}"!==s[a.lastIndex])throw new t([",","}"],a.lastIndex)}a.lastIndex++,y(a),a.value=n}else if("["===s[a.lastIndex]){const n=[];for(a.lastIndex++,y(a);"]"!==s[a.lastIndex];)if(e(a),n.push(a.value),","===s[a.lastIndex])a.lastIndex++,y(a);else if("]"!==s[a.lastIndex])throw new t([",","]"],a.lastIndex);a.lastIndex++,y(a),a.value=n}else if('"'===s[a.lastIndex]||"'"===s[a.lastIndex]||"`"===s[a.lastIndex])b(a);else if(/[-\d.]/.test(s[a.lastIndex]))O(a);else{if(m(a),!(a.value in x))throw new n({code:"unknownJSONLiteral",args:[a.value],message:`Unknown literal '${a.value}'`,index:a.index});a.value=x[a.value]}}(e)}catch(e){throw e.message=`Invalid JSON: ${e.message}`,e}e.index=a}function I(e){const t=e.lastIndex;s.lastIndex=t;const a=e.text.match(s);if(!a)throw new n({code:"missingEOT",message:"Missing EOT",index:t});e.index=t,e.lastIndex+=a[0].length,e.value=f(a[1].trim()),y(e)}function w(e){c.lastIndex=e.lastIndex;const n=c.exec(e.text);e.index=e.lastIndex,e.lastIndex=c.lastIndex,e.value=n[0].trim().replace(/\s+/g,"-")}function b(e){const t=e.lastIndex,a="`"===e.text[t]?u:d;a.lastIndex=t;const s=a.exec(e.text);if(!s)throw new n({code:"invalidString",message:"Invalid string",index:t});e.index=t,e.lastIndex+=s[0].length,e.value=p(s[1])}function O(e){const t=e.lastIndex;r.lastIndex=t;const a=r.exec(e.text);if(!a)throw new n({code:"invalidNumber",message:"Invalid number",index:t});e.index=t,e.value=Number(a[0].trim()),e.lastIndex+=a[0].length}function $(e){l.lastIndex=e.lastIndex;const n=l.exec(e.text);e.index=e.lastIndex,e.value=p(n[0].trim()),e.lastIndex=l.lastIndex}var k={eatLine:v,eatWhitespace:y,parseChar:g,parseEOT:I,parseJSON:h,parseNumber:O,parseString:b,parseStringToEnd:$,parseStringUnquoted:w,parseWord:m,unquote:p};const S=self.URL,R={name:$,version:$,namespace:$,author:$,description:$,homepageURL:$,supportURL:$,updateURL:$,license:$,preprocessor:$},E={version:function(e){if(!/\bv?(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-[\da-z-]+(?:\.[\da-z-]+)*)?(?:\+[\da-z-]+(?:\.[\da-z-]+)*)?\b/gi.test(e.value))throw new n({code:"invalidVersion",args:[e.value],message:`Invalid version: ${e.value}`,index:e.valueIndex});var t;e.value="v"===(t=e.value)[0]||"="===t[0]?t.slice(1):t},homepageURL:V,supportURL:V,updateURL:V},j={text:$,color:$,checkbox:g,select:J,dropdown:{advanced:D},image:{var:J,advanced:D},number:M,range:M},U={checkbox:function(e){if("1"!==e.value&&"0"!==e.value)throw new n({code:"invalidCheckboxDefault",message:"value must be 0 or 1",index:e.valueIndex})},number:_,range:_},N=["name","namespace","version"],T=["default","min","max","step"];function M(e){h(e);const t={min:null,max:null,step:null,units:null};if("number"==typeof e.value)t.default=e.value;else{if(!Array.isArray(e.value))throw new n({code:"invalidRange",message:"the default value must be an array or a number",index:e.valueIndex});{let a=0;for(const s of e.value)if("string"==typeof s){if(null!=t.units)throw new n({code:"invalidRangeMultipleUnits",message:"units is alredy defined",index:e.valueIndex});t.units=s}else{if("number"!=typeof s&&null!==s)throw new n({code:"invalidRangeValue",message:"value must be number, string, or null",index:e.valueIndex});if(a>=T.length)throw new n({code:"invalidRangeTooManyValues",message:"the array contains too many values",index:e.valueIndex});t[T[a++]]=s}}}e.value=t.default,Object.assign(e.varResult,t)}function J(e){h(e);const t=Array.isArray(e.value)?e.value.map(e=>L(e)):Object.entries(e.value).map(([e,n])=>L(e,n));if(0===t.length)throw new n({code:"invalidSelectEmptyOptions",message:"Option list is empty",index:e.valueIndex});const a=t.filter(e=>e.isDefault);if(a.length>1)throw new n({code:"invalidSelectMultipleDefaults",message:"multiple default values",index:e.valueIndex});t.forEach(e=>{delete e.isDefault}),e.varResult.options=t,e.value=(a.length>0?a[0]:t[0]).name}function D(e){const a=e.lastIndex;if("{"!==e.text[e.lastIndex])throw new t(["{"],a);const s=[];for(e.lastIndex++;"}"!==e.text[e.lastIndex];){const n={};w(e),n.name=e.value,b(e),n.label=e.value,"dropdown"===e.type?I(e):b(e),n.value=e.value,s.push(n)}if(e.lastIndex++,y(e),0===s.length)throw new n({code:"invalidSelectEmptyOptions",message:"Option list is empty",index:a});"dropdown"===e.type&&(e.varResult.type="select",e.type="select"),e.varResult.options=s,e.value=s[0].name}function L(e,n){let t,a=!1;e.endsWith("*")&&(a=!0,e=e.slice(0,-1));const s=e.match(/^(\w+):(.*)/);return s&&([,t,e]=s),t||(t=e),n||(n=t),{name:t,label:e,value:n,isDefault:a}}function A(e,n){if(n)try{e()}catch(e){n.push(e)}else e()}function V(e){let t;try{t=new S(e.value)}catch(n){throw n.args=[e.value],n.index=e.valueIndex,n}if(!/^https?:/.test(t.protocol))throw new n({code:"invalidURLProtocol",args:[t.protocol],message:`Invalid protocol: ${t.protocol}`,index:e.valueIndex})}function _(e){const t=e.value;if("number"!=typeof t)throw new n({code:"invalidRangeDefault",message:`the default value of @var ${e.type} must be a number`,index:e.valueIndex,args:[e.type]});const a=e.varResult;if(null!=a.min&&ta.max)throw new n({code:"invalidRangeMax",message:"the value is larger than the maximum",index:e.valueIndex});if(null!=a.step){const s=a.step.toString().split(".")[1],l=s?10**s.length:0;if(t*l%(a.step*l))throw new n({code:"invalidRangeStep",message:"the value is not a multiple of the step",index:e.valueIndex})}}function K({unknownKey:e="ignore",mandatoryKeys:t=N,parseKey:a,parseVar:s,validateKey:l,validateVar:r,allowErrors:i=!1}={}){if(!["ignore","assign","throw"].includes(e))throw new TypeError("unknownKey must be 'ignore', 'assign', or 'throw'");const o=Object.assign({__proto__:null},R,a),u=Object.assign({},j,s),d=Object.assign({},E,l),c=Object.assign({},U,r);return{parse:function(e){if(e.includes("\r"))throw new TypeError("metadata includes invalid character: '\\r'");const a={},s=[],l=/@(\w+)[^\S\r\n]*/gm,r={index:0,lastIndex:0,text:e,usercssData:a,warn:e=>s.push(e)};let o;for(;o=l.exec(e);)r.index=o.index,r.lastIndex=l.lastIndex,r.key=o[1],r.shouldIgnore=!1,A(()=>{try{"var"===r.key||"advanced"===r.key?f(r):p(r)}catch(e){throw void 0===e.index&&(e.index=r.index),e}"var"===r.key||"advanced"===r.key||r.shouldIgnore||(a[r.key]=r.value)},i&&s),l.lastIndex=r.lastIndex;return r.maybeUSO&&!a.preprocessor&&(a.preprocessor="uso"),A(()=>{const e=t.filter(e=>!Object.prototype.hasOwnProperty.call(a,e));if(e.length>0)throw new n({code:"missingMandatory",args:e,message:`Missing metadata: ${e.map(e=>`@${e}`).join(", ")}`})},i&&s),{metadata:a,errors:s}},validateVar:function(e){x({key:"var",type:e.type,value:e.value,varResult:e})}};function x(e){const n="object"==typeof c[e.type]?c[e.type][e.key]:c[e.type];n&&n(e)}function f(e){const t={type:null,label:null,name:null,value:null,default:null,options:null};e.varResult=t,m(e),e.type=e.value,t.type=e.type;const a="object"==typeof u[e.type]?u[e.type][e.key]:u[e.type];if(!a)throw new n({code:"unknownVarType",message:`Unknown @${e.key} type: ${e.type}`,args:[e.key,e.type],index:e.index});m(e),t.name=e.value,b(e),t.label=e.value,e.valueIndex=e.lastIndex,a(e),x(e),t.default=e.value,e.usercssData.vars||(e.usercssData.vars={}),e.usercssData.vars[t.name]=t,"advanced"===e.key&&(e.maybeUSO=!0)}function p(t){let a=o[t.key];if(!a){if("assign"!==e){if(v(t),"ignore"===e)return void(t.shouldIgnore=!0);throw new n({code:"unknownMeta",args:[t.key],message:`Unknown metadata: @${t.key}`,index:t.index})}a=$}t.valueIndex=t.lastIndex,a(t),d[t.key]&&d[t.key](t)}}function P({alignKeys:e=!1,space:n=2,format:t="stylus",stringifyKey:a={},stringifyVar:s={}}={}){return{stringify:function(l){let r;if("stylus"===t)r="var";else{if("xstyle"!==t)throw new TypeError("options.format must be 'stylus' or 'xstyle'");r="advanced"}const i=[];for(const[e,o]of Object.entries(l))if(Object.prototype.hasOwnProperty.call(a,e)){const n=a[e](o);Array.isArray(n)?i.push(...n.map(n=>[e,n])):i.push([e,n])}else if("vars"===e)for(const e of Object.values(o))i.push([r,z(e,t,s,n)]);else if(Array.isArray(o))for(const n of o)i.push([e,W(n)]);else i.push([e,W(o)]);const o=e?Math.max(...i.map(e=>e[0].length)):0;return`/* ==UserStyle==\n${u=i.map(([e,n])=>`@${e.padEnd(o)} ${n}`).join("\n"),u.replace(/\*\//g,"*\\/")}\n==/UserStyle== */`;var u}}}function z(e,n,t,a){return`${"xstyle"===n&&"select"===e.type?"dropdown":e.type} ${e.name} ${JSON.stringify(e.label)} ${function(){if(Object.prototype.hasOwnProperty.call(t,e.type))return t[e.type](e,n,a);if(e.options)return"stylus"===n?JSON.stringify(e.options.reduce((n,t)=>{const a=t.name===e.default?"*":"";return n[`${t.name}:${t.label}${a}`]=t.value,n},{}),null,a):function(e,n=!1,t=0){const a="string"==typeof t?t:" ".repeat(t);return`{\n${e.map(e=>`${a}${e.name} ${JSON.stringify(e.label)} ${function(e){return n?JSON.stringify(e):`<<`'${e}'`).join(", ")}`,index:n})}}class a extends n{constructor(e){super({code:"EOF",message:"Unexpected end of file",index:e})}}const s=/<<e[1]===n?n:JSON.parse(`"${e}"`))}function v(e){l.lastIndex=e.lastIndex,l.exec(e.text),e.lastIndex=l.lastIndex}function y(e){i.lastIndex=e.lastIndex,e.lastIndex+=i.exec(e.text)[0].length}function g(e){if(e.lastIndex>=e.text.length)throw new a(e.lastIndex);e.index=e.lastIndex,e.value=e.text[e.lastIndex],e.lastIndex++,y(e)}function m(e){const t=e.lastIndex;o.lastIndex=t;const a=o.exec(e.text);if(!a)throw new n({code:"invalidWord",message:"Invalid word",index:t});e.index=t,e.value=a[1],e.lastIndex+=a[0].length}function h(e){const a=e.lastIndex;try{!function e(a){const{text:s}=a;if("{"===s[a.lastIndex]){const n={};for(a.lastIndex++,y(a);"}"!==s[a.lastIndex];){b(a);const l=a.value;if(":"!==s[a.lastIndex])throw new t([":"],a.lastIndex);if(a.lastIndex++,y(a),e(a),n[l]=a.value,","===s[a.lastIndex])a.lastIndex++,y(a);else if("}"!==s[a.lastIndex])throw new t([",","}"],a.lastIndex)}a.lastIndex++,y(a),a.value=n}else if("["===s[a.lastIndex]){const n=[];for(a.lastIndex++,y(a);"]"!==s[a.lastIndex];)if(e(a),n.push(a.value),","===s[a.lastIndex])a.lastIndex++,y(a);else if("]"!==s[a.lastIndex])throw new t([",","]"],a.lastIndex);a.lastIndex++,y(a),a.value=n}else if('"'===s[a.lastIndex]||"'"===s[a.lastIndex]||"`"===s[a.lastIndex])b(a);else if(/[-\d.]/.test(s[a.lastIndex]))O(a);else{if(m(a),!(a.value in x))throw new n({code:"unknownJSONLiteral",args:[a.value],message:`Unknown literal '${a.value}'`,index:a.index});a.value=x[a.value]}}(e)}catch(e){throw e.message=`Invalid JSON: ${e.message}`,e}e.index=a}function I(e){const t=e.lastIndex;s.lastIndex=t;const a=e.text.match(s);if(!a)throw new n({code:"missingEOT",message:"Missing EOT",index:t});e.index=t,e.lastIndex+=a[0].length,e.value=p(a[1].trim()),y(e)}function w(e){c.lastIndex=e.lastIndex;const n=c.exec(e.text);e.index=e.lastIndex,e.lastIndex=c.lastIndex,e.value=n[0].trim().replace(/\s+/g,"-")}function b(e){const t=e.lastIndex,a="`"===e.text[t]?u:d;a.lastIndex=t;const s=a.exec(e.text);if(!s)throw new n({code:"invalidString",message:"Invalid string",index:t});e.index=t,e.lastIndex+=s[0].length,e.value=f(s[1])}function O(e){const t=e.lastIndex;r.lastIndex=t;const a=r.exec(e.text);if(!a)throw new n({code:"invalidNumber",message:"Invalid number",index:t});e.index=t,e.value=Number(a[0].trim()),e.lastIndex+=a[0].length}function $(e){l.lastIndex=e.lastIndex;const n=l.exec(e.text);e.index=e.lastIndex,e.value=f(n[0].trim()),e.lastIndex=l.lastIndex}var k={eatLine:v,eatWhitespace:y,parseChar:g,parseEOT:I,parseJSON:h,parseNumber:O,parseString:b,parseStringToEnd:$,parseStringUnquoted:w,parseWord:m,unquote:f};const S=self.URL,R={name:$,version:$,namespace:$,author:$,description:$,homepageURL:$,supportURL:$,updateURL:$,license:$,preprocessor:$},E={version:function(e){if(!/\bv?(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-[\da-z-]+(?:\.[\da-z-]+)*)?(?:\+[\da-z-]+(?:\.[\da-z-]+)*)?\b/gi.test(e.value))throw new n({code:"invalidVersion",args:[e.value],message:`Invalid version: ${e.value}`,index:e.valueIndex});var t;e.value="v"===(t=e.value)[0]||"="===t[0]?t.slice(1):t},homepageURL:V,supportURL:V,updateURL:V},j={text:$,color:$,checkbox:g,select:J,dropdown:{advanced:D},image:{var:J,advanced:D},number:M,range:M},U={checkbox:function(e){if("1"!==e.value&&"0"!==e.value)throw new n({code:"invalidCheckboxDefault",message:"value must be 0 or 1",index:e.valueIndex})},number:_,range:_},N=["name","namespace","version"],T=["default","min","max","step"];function M(e){h(e);const t={min:null,max:null,step:null,units:null};if("number"==typeof e.value)t.default=e.value;else{if(!Array.isArray(e.value))throw new n({code:"invalidRange",message:"the default value must be an array or a number",index:e.valueIndex,args:[e.type]});{let a=0;for(const s of e.value)if("string"==typeof s){if(null!=t.units)throw new n({code:"invalidRangeMultipleUnits",message:"units is alredy defined",args:[e.type],index:e.valueIndex});t.units=s}else{if("number"!=typeof s&&null!==s)throw new n({code:"invalidRangeValue",message:"value must be number, string, or null",args:[e.type],index:e.valueIndex});if(a>=T.length)throw new n({code:"invalidRangeTooManyValues",message:"the array contains too many values",args:[e.type],index:e.valueIndex});t[T[a++]]=s}}}e.value=t.default,Object.assign(e.varResult,t)}function J(e){h(e);const t=Array.isArray(e.value)?e.value.map(e=>L(e)):Object.entries(e.value).map(([e,n])=>L(e,n));if(0===t.length)throw new n({code:"invalidSelectEmptyOptions",message:"Option list is empty",index:e.valueIndex});const a=t.filter(e=>e.isDefault);if(a.length>1)throw new n({code:"invalidSelectMultipleDefaults",message:"multiple default values",index:e.valueIndex});t.forEach(e=>{delete e.isDefault}),e.varResult.options=t,e.value=(a.length>0?a[0]:t[0]).name}function D(e){const a=e.lastIndex;if("{"!==e.text[e.lastIndex])throw new t(["{"],a);const s=[];for(e.lastIndex++;"}"!==e.text[e.lastIndex];){const n={};w(e),n.name=e.value,b(e),n.label=e.value,"dropdown"===e.type?I(e):b(e),n.value=e.value,s.push(n)}if(e.lastIndex++,y(e),0===s.length)throw new n({code:"invalidSelectEmptyOptions",message:"Option list is empty",index:a});"dropdown"===e.type&&(e.varResult.type="select",e.type="select"),e.varResult.options=s,e.value=s[0].name}function L(e,n){let t,a=!1;e.endsWith("*")&&(a=!0,e=e.slice(0,-1));const s=e.match(/^(\w+):(.*)/);return s&&([,t,e]=s),t||(t=e),n||(n=t),{name:t,label:e,value:n,isDefault:a}}function A(e,n){if(n)try{e()}catch(e){n.push(e)}else e()}function V(e){let t;try{t=new S(e.value)}catch(n){throw n.args=[e.value],n.index=e.valueIndex,n}if(!/^https?:/.test(t.protocol))throw new n({code:"invalidURLProtocol",args:[t.protocol],message:`Invalid protocol: ${t.protocol}`,index:e.valueIndex})}function _(e){const t=e.value;if("number"!=typeof t)throw new n({code:"invalidRangeDefault",message:`the default value of @var ${e.type} must be a number`,index:e.valueIndex,args:[e.type]});const a=e.varResult;if(null!=a.min&&ta.max)throw new n({code:"invalidRangeMax",message:"the value is larger than the maximum",index:e.valueIndex,args:[e.type]});if(null!=a.step){const s=a.step.toString().split(".")[1],l=s?10**s.length:0;if(t*l%(a.step*l))throw new n({code:"invalidRangeStep",message:"the value is not a multiple of the step",index:e.valueIndex,args:[e.type]})}}function K({unknownKey:e="ignore",mandatoryKeys:t=N,parseKey:a,parseVar:s,validateKey:l,validateVar:r,allowErrors:i=!1}={}){if(!["ignore","assign","throw"].includes(e))throw new TypeError("unknownKey must be 'ignore', 'assign', or 'throw'");const o=Object.assign({__proto__:null},R,a),u=Object.assign({},j,s),d=Object.assign({},E,l),c=Object.assign({},U,r);return{parse:function(e){if(e.includes("\r"))throw new TypeError("metadata includes invalid character: '\\r'");const a={},s=[],l=/@(\w+)[^\S\r\n]*/gm,r={index:0,lastIndex:0,text:e,usercssData:a,warn:e=>s.push(e)};let o;for(;o=l.exec(e);)r.index=o.index,r.lastIndex=l.lastIndex,r.key=o[1],r.shouldIgnore=!1,A(()=>{try{"var"===r.key||"advanced"===r.key?p(r):f(r)}catch(e){throw void 0===e.index&&(e.index=r.index),e}"var"===r.key||"advanced"===r.key||r.shouldIgnore||(a[r.key]=r.value)},i&&s),l.lastIndex=r.lastIndex;return r.maybeUSO&&!a.preprocessor&&(a.preprocessor="uso"),A(()=>{const e=t.filter(e=>!Object.prototype.hasOwnProperty.call(a,e));if(e.length>0)throw new n({code:"missingMandatory",args:e,message:`Missing metadata: ${e.map(e=>`@${e}`).join(", ")}`})},i&&s),{metadata:a,errors:s}},validateVar:function(e){x({key:"var",type:e.type,value:e.value,varResult:e})}};function x(e){const n="object"==typeof c[e.type]?c[e.type][e.key]:c[e.type];n&&n(e)}function p(e){const t={type:null,label:null,name:null,value:null,default:null,options:null};e.varResult=t,m(e),e.type=e.value,t.type=e.type;const a="object"==typeof u[e.type]?u[e.type][e.key]:u[e.type];if(!a)throw new n({code:"unknownVarType",message:`Unknown @${e.key} type: ${e.type}`,args:[e.key,e.type],index:e.index});m(e),t.name=e.value,b(e),t.label=e.value,e.valueIndex=e.lastIndex,a(e),x(e),t.default=e.value,e.usercssData.vars||(e.usercssData.vars={}),e.usercssData.vars[t.name]=t,"advanced"===e.key&&(e.maybeUSO=!0)}function f(t){let a=o[t.key];if(!a){if("assign"!==e){if(v(t),"ignore"===e)return void(t.shouldIgnore=!0);throw new n({code:"unknownMeta",args:[t.key],message:`Unknown metadata: @${t.key}`,index:t.index})}a=$}t.valueIndex=t.lastIndex,a(t),d[t.key]&&d[t.key](t)}}function P({alignKeys:e=!1,space:n=2,format:t="stylus",stringifyKey:a={},stringifyVar:s={}}={}){return{stringify:function(l){let r;if("stylus"===t)r="var";else{if("xstyle"!==t)throw new TypeError("options.format must be 'stylus' or 'xstyle'");r="advanced"}const i=[];for(const[e,o]of Object.entries(l))if(Object.prototype.hasOwnProperty.call(a,e)){const n=a[e](o);Array.isArray(n)?i.push(...n.map(n=>[e,n])):i.push([e,n])}else if("vars"===e)for(const e of Object.values(o))i.push([r,z(e,t,s,n)]);else if(Array.isArray(o))for(const n of o)i.push([e,W(n)]);else i.push([e,W(o)]);const o=e?Math.max(...i.map(e=>e[0].length)):0;return`/* ==UserStyle==\n${u=i.map(([e,n])=>`@${e.padEnd(o)} ${n}`).join("\n"),u.replace(/\*\//g,"*\\/")}\n==/UserStyle== */`;var u}}}function z(e,n,t,a){return`${"xstyle"===n&&"select"===e.type?"dropdown":e.type} ${e.name} ${JSON.stringify(e.label)} ${function(){if(Object.prototype.hasOwnProperty.call(t,e.type))return t[e.type](e,n,a);if(e.options)return"stylus"===n?JSON.stringify(e.options.reduce((n,t)=>{const a=t.name===e.default?"*":"";return n[`${t.name}:${t.label}${a}`]=t.value,n},{}),null,a):function(e,n=!1,t=0){const a="string"==typeof t?t:" ".repeat(t);return`{\n${e.map(e=>`${a}${e.name} ${JSON.stringify(e.label)} ${function(e){return n?JSON.stringify(e):`<<