@dsebastien/music-notation 0.21.2 → 0.22.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/cli.js +1 -1
- package/dist/index.js +47 -1
- package/dist/index.js.map +2 -2
- package/dist/music-notation.css +46 -0
- package/dist/music-notation.publish.min.js +47 -1
- package/dist/music-notation.tab.min.js +53 -7
- package/dist/tab/index.d.ts +8 -0
- package/dist/tab/index.js +148 -6
- package/dist/tab/index.js.map +5 -4
- package/dist/tab/tempo.d.ts +53 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -191,7 +191,7 @@ Add this to your site's `publish.js`. It loads the bundle only on pages that hav
|
|
|
191
191
|
|
|
192
192
|
```js
|
|
193
193
|
;(() => {
|
|
194
|
-
const VERSION = '0.
|
|
194
|
+
const VERSION = '0.22.0'
|
|
195
195
|
const CDN = `https://cdn.jsdelivr.net/npm/@dsebastien/music-notation@${VERSION}/dist`
|
|
196
196
|
const selector = (languages) => languages.map((l) => `pre > code.language-${l}`).join(', ')
|
|
197
197
|
const BLOCKS = selector([
|
package/dist/cli.js
CHANGED
|
@@ -30,7 +30,7 @@ ${indentedBody}
|
|
|
30
30
|
`),pos=0;while((pos=s.indexOf(`
|
|
31
31
|
`,pos))!==-1)starts.push(++pos)}return this.lineStarts=starts}getLineColumn(start){if(start<=0)return{line:1,column:1};let starts=this.getLineStarts(),low=0,high=starts.length-1;while(low<=high){let mid=low+high>>1;if(starts[mid]<=start)low=mid+1;else high=mid-1}let lineIdx=high>=0?high:0;return{line:lineIdx+1,column:start-starts[lineIdx]+1}}makeLocation(start,end,bodyStart,bodyEnd){let getLineCol=(offset)=>this.getLineColumn(offset);return{start,end,bodyStart,bodyEnd,get line(){return getLineCol(start).line},get column(){return getLineCol(start).column}}}createBlockLocation(start,block){let end=block.endIndex??block.associatedToken.startIndex??start,bodyStart=block.associatedToken.endIndex,bodyEnd=block.endIndex!==void 0?block.isClosed?block.endIndex-1:block.endIndex:void 0;return this.makeLocation(start,end,bodyStart,bodyEnd)}reportError(message,token){this.errors.push({message,token})}get nextToken(){return this.tokens.peek()}consumeToken(){return this.tokens.next()}discardToken(){this.tokens.next()}skipWhitespace(){while(this.nextToken.type==="whitespace")this.discardToken()}parseComponentValues(){let values=[];while(this.nextToken.type!=="EOF")values.push(this.consumeComponentValue());return values}parseCommaSeparatedListOfComponentValues(){return splitComponentValuesByComma(this.parseComponentValues())}parseStyleSheet(){let rules=this.consumeListOfRules(!0);return CSSStyleSheet.createInternal(rules,(text)=>this.parseRule(text))}parseRule(ruleString){let errors=[],tokens=tokenize(ruleString,!1,errors),parser=new Parser(tokens,this.options);parser.errors.push(...errors);let rule=parser.consumeRule();return parser.ensureEOF(),rule}parseStyleAttribute(){return new CSSStyleDeclaration2(this.consumeDeclarationsFromBlockContents(this.parseComponentValues()))}parseStyleSheetContents(){return this.consumeListOfRules(!0)}parseBlockContents(){return this.consumeBlockContents(new ArrayComponentValueStream(this.parseComponentValues()),!0,!1)}parseDeclaration(){if(this.skipWhitespace(),this.nextToken.type!=="ident")return null;let stream=new LazyComponentValueStream(()=>this.consumeComponentValue(),"EOF"),decl=this.consumeDeclarationFromStream(stream);if(!decl)return null;return this.skipWhitespace(),this.nextToken.type==="EOF"?decl:null}parseComponentValue(){if(this.skipWhitespace(),this.nextToken.type==="EOF")return null;let value=this.consumeComponentValue();return this.skipWhitespace(),this.nextToken.type==="EOF"?value:null}consumeListOfRules(topLevel){let rules=[];while(!0){let token=this.nextToken;if(token.type==="whitespace")this.discardToken();else if(token.type==="EOF")return rules;else if((token.type==="CDO"||token.type==="CDC")&&topLevel)this.discardToken();else{let rule=this.consumeRule();if(rule)rules.push(rule)}}}consumeRule(nested=!1){if(this.skipWhitespace(),this.nextToken.type==="EOF")return null;return this.nextToken.type==="at-keyword"?this.consumeAtRule(nested):this.consumeQualifiedRule(nested)}finalizeAtRule(rule,block,nested,location,isTopLevelTokenStream){if(!this.isSupportedAtRule(rule.name,nested))return null;let handler=this.getAtRuleHandler(rule.name);if(handler){let res=handler(this,rule,block,nested);if(res instanceof CSSRule&&!res.location)res._location=location;return res}if(nested)return null;if(block&&isTopLevelTokenStream&&this.options?.atRules?.[rule.name]){let type=this.options.atRules[rule.name];if(type==="declaration"){let decls=this.consumeDeclarationsFromBlockContents(block.value),atRule=new CSSAtRule(rule.name,rule.prelude,block,void 0,decls);return atRule._location=location,atRule}if(type==="rule"){let childRules=this.consumeNestedRules(block,!1),atRule=new CSSAtRule(rule.name,rule.prelude,block,childRules);return atRule._location=location,atRule}}let cssRules;if(block&&!isTopLevelTokenStream)rule.childRules=this.consumeBlockContents(new ArrayComponentValueStream(block.value),nested),cssRules=rule.childRules;let atRule=new CSSAtRule(rule.name,rule.prelude,block,cssRules);return atRule._location=location,atRule}consumeAtRule(nested=!1){let token=this.consumeToken();if(token.type!=="at-keyword")return null;let rule={type:"at-rule",name:token.value,prelude:[],childRules:[]},start=token.startIndex??0;while(!0){let next=this.nextToken;if(next.type==="semicolon"||next.type==="EOF"){let end=next.endIndex??next.startIndex??start;return this.discardToken(),this.finalizeAtRule(rule,void 0,nested,this.makeLocation(start,end),!0)}else if(next.type==="}"){if(nested)return null;this.consumeToken(),rule.prelude.push(next)}else if(next.type==="{"){let block=this.consumeBlock(this.consumeToken());return this.finalizeAtRule(rule,block,nested,this.createBlockLocation(start,block),!0)}else rule.prelude.push(this.consumeComponentValue())}}scopeContextDepth=0;consumeNestedRules(block,isNestedStyleRule){let allowRelative=!isNestedStyleRule&&this.scopeContextDepth>0;return this.consumeBlockContents(new ArrayComponentValueStream(block.value),isNestedStyleRule||allowRelative,isNestedStyleRule,allowRelative)}handleGroupingAtRule(rule,block,nested,ctor){if(!block)return null;let childRules=this.consumeNestedRules(block,nested);return new ctor(serialize(rule.prelude).trim(),childRules,parseRuleInBlock)}parseLayerNameFromTokens(tokens,forbidCssWide=!1){let trimmed=trimComponentValues(tokens,!0);if(trimmed.length===0||trimmed.length%2===0)return null;let parts=[];for(let i=0;i<trimmed.length;i++){let t=trimmed[i];if(i%2===0){if(t.type!=="ident"||forbidCssWide&&CSS_WIDE_KEYWORDS$1.has(t.value.toLowerCase()))return null;parts.push(t.value)}else{if(t.type!=="delim"||t.value!==".")return null;parts.push(".")}}return parts.join("")}handleLayerRule(rule,block,nested=!1){if(block){let trimmed=trimComponentValues(rule.prelude,!0),layerName="";if(trimmed.length>0){let parsed=this.parseLayerNameFromTokens(trimmed);if(parsed===null)return null;layerName=parsed}return new CSSLayerBlockRule(layerName,this.consumeNestedRules(block,nested),parseRuleInBlock)}let segments=splitComponentValuesByComma(rule.prelude),nameList=[];for(let seg of segments){let name=this.parseLayerNameFromTokens(seg);if(name===null)return null;nameList.push(name)}return nameList.length>0?new CSSLayerStatementRule(nameList):null}parseScopeSelectorBlock(block){try{new SelectorParser(block.value,{allowRelative:!0,forbidPseudo:!0,declaredNamespaces:this.declaredNamespaces}).parse();let text=serialize(block.value).trim();return text?`(${text})`:""}catch{return null}}handleScopeRule(rule,block,_nested=!1){if(!block)return null;this.scopeContextDepth++;let childRules;try{childRules=this.consumeBlockContents(new ArrayComponentValueStream(block.value),!0,!1,!0)}finally{this.scopeContextDepth--}let startSelector=null,endSelector=null,prelude=rule.prelude,i=0;while(i<prelude.length&&prelude[i].type==="whitespace")i++;if(i<prelude.length&&prelude[i].type==="simple-block"&&prelude[i].associatedToken.type==="("){if(startSelector=this.parseScopeSelectorBlock(prelude[i]),startSelector===null)return null;i++}while(i<prelude.length&&prelude[i].type==="whitespace")i++;if(i<prelude.length&&prelude[i].type==="ident"&&String(prelude[i].value).toLowerCase()==="to"){i++;while(i<prelude.length&&prelude[i].type==="whitespace")i++;if(i<prelude.length&&prelude[i].type==="simple-block"&&prelude[i].associatedToken.type==="("){if(endSelector=this.parseScopeSelectorBlock(prelude[i]),endSelector===null)return null;i++}else return null}while(i<prelude.length&&prelude[i].type==="whitespace")i++;if(i<prelude.length)return null;return new CSSScopeRule(startSelector,endSelector,childRules,parseRuleInScopeBlock)}handleViewTransitionRule(_rule,block){return new CSSViewTransitionRule(this.consumeDeclarationsFromBlockContents(block.value))}parseKeyframeSelector(prelude){let lists=splitComponentValuesByComma(prelude),normalizedParts=[];for(let list of lists){let trimmed=trimComponentValues(list);if(trimmed.length!==1)return null;let v=trimmed[0];if(v.type==="ident"){let valStr=v.value.toLowerCase();if(valStr==="from")normalizedParts.push("0%");else if(valStr==="to")normalizedParts.push("100%");else return null}else if(v.type==="percentage"){let val=v.value;if(val<0||val>100)return null;normalizedParts.push(`${val}%`)}else return null}return normalizedParts.length>0?normalizedParts.join(", "):null}handleKeyframesRule(rule,block){let preludeClean=rule.prelude.filter((v)=>v.type!=="whitespace"&&v.type!=="comment");if(preludeClean.length!==1)return null;let first=preludeClean[0],keyframesName="";if(first.type==="ident"){if(KEYFRAMES_DISALLOWED_NAMES.has(first.value.toLowerCase()))return null;keyframesName=first.value}else if(first.type==="string"&&first.value!=="")keyframesName=first.value;else return null;let keyframeRules=[],stream=new ArrayComponentValueStream(block.value);while(!0){let val=stream.peek();if(val.type==="whitespace"||val.type==="semicolon"){stream.next();continue}if(val.type==="EOF")break;let prelude=[],blockVal=null;while(!0){let next=stream.peek();if(next.type==="EOF")break;if(next.type==="simple-block"&&next.associatedToken.type==="{"){blockVal=stream.next();break}prelude.push(stream.next())}if(!blockVal)break;let selectorText=this.parseKeyframeSelector(prelude);if(selectorText){let keyframeRule=new CSSKeyframeRule(selectorText,this.consumeDeclarationsFromBlockContents(blockVal.value)),kfStart=getComponentValueStartIndex(prelude[0])??blockVal.associatedToken.startIndex??0;keyframeRule._location=this.createBlockLocation(kfStart,blockVal),keyframeRules.push(keyframeRule)}}return new CSSKeyframesRule(keyframesName,keyframeRules)}handleFontFaceRule(_rule,block){return new CSSFontFaceRule(this.consumeDeclarationsFromBlockContents(block.value))}handlePageRule(rule,block){let{declarations,nestedRules}=splitLeadingDeclarations(this.consumeBlockContents(new ArrayComponentValueStream(block.value),!0));return new CSSPageRule(serialize(rule.prelude).trim(),declarations,nestedRules,parseRule)}handleMarginRule(rule,block){return new CSSMarginRule(rule.name,this.consumeDeclarationsFromBlockContents(block.value),INTERNAL_RULE_TOKEN)}handleCounterStyleRule(rule,block){return new CSSCounterStyleRule(serialize(rule.prelude).trim(),this.consumeDeclarationsFromBlockContents(block.value))}handleFontFeatureValuesRule(rule,block){let fontFeatureRule=new CSSFontFeatureValuesRule(serialize(rule.prelude).trim()),stream=new ArrayComponentValueStream(block.value);while(stream.peek().type!=="EOF"){let token=stream.peek();if(token.type==="whitespace"||token.type==="comment"){stream.next();continue}if(token.type==="at-keyword"){let atToken=stream.next(),target=FONT_FEATURE_VALUE_BLOCKS[atToken.value.toLowerCase()];while(stream.peek().type==="whitespace"||stream.peek().type==="comment")stream.next();let next=stream.peek();if(next.type==="simple-block"&&next.associatedToken.type==="{"){let childBlock=stream.next();if(target)for(let d of this.consumeDeclarationsFromBlockContents(childBlock.value)){let values=d.value.filter((v)=>v.type==="number").map((v)=>v.value);fontFeatureRule[target].set(d.name,values)}}}else stream.next()}return fontFeatureRule}handlePropertyRule(rule,block){let nonWsPrelude=trimComponentValues(rule.prelude,!0);if(nonWsPrelude.length!==1||nonWsPrelude[0].type!=="ident")return null;let name=nonWsPrelude[0].value;if(!name.startsWith("--")||name==="--")return null;let declarations=this.consumeDeclarationsFromBlockContents(block.value),syntax=null,inherits=null,initialValue=null;for(let d of declarations){let val=serialize(d.value).trim(),descName=d.name.toLowerCase();if(descName==="syntax"){let nonWsTokens=trimComponentValues(d.value,!0);if(nonWsTokens.length===1&&nonWsTokens[0].type==="string")syntax=nonWsTokens[0].value}else if(descName==="inherits"){if(val==="true")inherits=!0;else if(val==="false")inherits=!1}else if(descName==="initial-value")initialValue=val}if(syntax===null||inherits===null)return null;if(ParseHooks.validatePropertyRuleDescriptor){if(!ParseHooks.validatePropertyRuleDescriptor({name,syntax,inherits,initialValue:initialValue??void 0}))return null}else if(!isValidDashedIdent(name)||typeof syntax!=="string"||syntax.length===0||typeof inherits!=="boolean")return null;return new CSSPropertyRule(name,syntax,inherits,initialValue)}handlePositionTryRule(rule,block){let nonWsPrelude=trimComponentValues(rule.prelude,!0);if(nonWsPrelude.length!==1||nonWsPrelude[0].type!=="ident")return null;let name=nonWsPrelude[0].value;if(!isValidDashedIdent(name))return null;return new CSSPositionTryRule(name,this.consumeDeclarationsFromBlockContents(block.value),INTERNAL_RULE_TOKEN)}parseImportScopeArgs(scopeArgs){let scopeStart=null,scopeEnd=null,k=0;while(k<scopeArgs.length&&scopeArgs[k].type==="whitespace")k++;if(k<scopeArgs.length&&scopeArgs[k].type==="simple-block"&&scopeArgs[k].associatedToken.type==="(")scopeStart=serialize(scopeArgs[k].value).trim(),k++;else{let startTokens=[];while(k<scopeArgs.length){let tok=scopeArgs[k];if(tok.type==="ident"&&String(tok.value).toLowerCase()==="to")break;startTokens.push(tok),k++}let s=serialize(startTokens).trim();if(s)scopeStart=s}while(k<scopeArgs.length&&scopeArgs[k].type==="whitespace")k++;if(k<scopeArgs.length&&scopeArgs[k].type==="ident"&&String(scopeArgs[k].value).toLowerCase()==="to"){k++;while(k<scopeArgs.length&&scopeArgs[k].type==="whitespace")k++;if(k<scopeArgs.length&&scopeArgs[k].type==="simple-block"&&scopeArgs[k].associatedToken.type==="(")scopeEnd=serialize(scopeArgs[k].value).trim();else{let e=serialize(scopeArgs.slice(k)).trim();if(e)scopeEnd=e}}if(scopeStart)scopeStart=scopeStart.replace(/^\(/,"").replace(/\)$/,"").trim();if(scopeEnd)scopeEnd=scopeEnd.replace(/^\(/,"").replace(/\)$/,"").trim();return{scopeStart,scopeEnd}}handleImportRule(rule){let href="",layerName=null,supportsText=null,isScoped=!1,scopeStart=null,scopeEnd=null,prelude=rule.prelude,i=0;while(i<prelude.length&&prelude[i].type==="whitespace")i++;if(i<prelude.length){let extracted=extractUriFromComponentValue(prelude[i]);if(extracted!==null)href=extracted,i++}while(i<prelude.length){while(i<prelude.length&&prelude[i].type==="whitespace")i++;if(i>=prelude.length)break;let val=prelude[i];if(layerName===null&&val.type==="ident"&&val.value.toLowerCase()==="layer")layerName="",i++;else if(layerName===null&&val.type==="function"&&val.name.toLowerCase()==="layer"){let fnTokens=val.value;if(fnTokens.some((t)=>t.type==="whitespace"))break;let parsed=this.parseLayerNameFromTokens(fnTokens,!0);if(parsed===null)break;layerName=parsed,i++}else if(supportsText===null&&val.type==="function"&&val.name.toLowerCase()==="supports")supportsText=serialize(val.value).trim(),i++;else if(!isScoped&&val.type==="ident"&&val.value.toLowerCase()==="scope")isScoped=!0,i++;else if(!isScoped&&val.type==="function"&&val.name.toLowerCase()==="scope")isScoped=!0,{scopeStart,scopeEnd}=this.parseImportScopeArgs(val.value),i++;else break}let mediaText=serialize(prelude.slice(i)).trim();return new CSSImportRule(href,mediaText,layerName,supportsText,scopeStart,scopeEnd,isScoped,INTERNAL_RULE_TOKEN)}handleNamespaceRule(rule){let tokens=rule.prelude.filter((t)=>t.type!=="whitespace"&&t.type!=="comment"&&t.type!=="EOF"),prefix="",namespaceURI="";if(tokens.length===1)namespaceURI=extractUriFromComponentValue(tokens[0])??"";else if(tokens.length>=2)if(tokens[0].type==="ident")prefix=tokens[0].value,namespaceURI=extractUriFromComponentValue(tokens[1])??"";else namespaceURI=extractUriFromComponentValue(tokens[0])??"";let nsRule=new CSSNamespaceRule(prefix,namespaceURI,INTERNAL_RULE_TOKEN);return this.declaredNamespaces.add(nsRule.prefix),nsRule}handleCustomMediaRule(rule){let prelude=rule.prelude,i=0;while(i<prelude.length&&prelude[i].type==="whitespace")i++;if(i>=prelude.length)return null;let nameToken=prelude[i];if(nameToken.type!=="ident"||!nameToken.value.startsWith("--"))return null;let name=nameToken.value;i++;let remainingTokens=prelude.slice(i).filter((v)=>v.type!=="whitespace"&&v.type!=="comment"),query;if(remainingTokens.length===0)query=new MediaList("");else if(remainingTokens.length===1&&remainingTokens[0].type==="ident"&&remainingTokens[0].value.toLowerCase()==="true")query=!0;else if(remainingTokens.length===1&&remainingTokens[0].type==="ident"&&remainingTokens[0].value.toLowerCase()==="false")query=!1;else{let mediaText=serialize(prelude.slice(i)).trim(),parsed=ParseHooks.parseMediaQueryList(mediaText);if(parsed.length===0||parsed.some((q)=>q.invalid))return null;query=new MediaList(mediaText)}return new CSSCustomMediaRule(name,query)}consumeQualifiedRule(nested=!1){let prelude=[];while(!0){let next=this.nextToken;if(next.type==="EOF")return this.reportError("Unexpected EOF in qualified rule",next),null;else if(next.type==="}"){if(this.reportError("Unexpected } in qualified rule",next),nested)return null;this.consumeToken(),prelude.push(next)}else if(next.type==="{"){if(isCustomPropertyDeclaration(prelude)){this.reportError("Qualified rule prelude looks like a custom property",next);let blockToken=this.consumeToken();return this.consumeBlock(blockToken),null}let blockToken=this.consumeToken(),start=getComponentValueStartIndex(prelude[0])??blockToken.startIndex??0,stream=new LazyComponentValueStream(()=>this.consumeComponentValue(),"}"),blockContents=this.consumeBlockContents(stream,!0),term=stream.terminator,end;if(term)end=term.endIndex??(term.startIndex!==void 0?term.startIndex+1:start);else{let eofPos=this.nextToken.startIndex??this.nextToken.endIndex;if(eofPos!==void 0)end=eofPos;else{let buffered=stream.slice(0,stream.position);end=(buffered.length>0?getComponentValueEndIndex(buffered[buffered.length-1]):void 0)??blockToken.endIndex??blockToken.startIndex??start}}let bodyStart=blockToken.endIndex,bodyEnd=term?term.startIndex??end:end,location=this.makeLocation(start,end,bodyStart,bodyEnd);return this.createStyleRule(prelude,blockContents,nested,nested,location)}else prelude.push(this.consumeComponentValue())}}consumeDeclarationsFromBlockContents(values){let stream=new ArrayComponentValueStream(values),decls=[];while(!0){let val=stream.peek();if(val.type==="whitespace"||val.type==="semicolon")stream.next();else if(val.type==="EOF"||val.type==="}")break;else if(val.type==="at-keyword")this.consumeAtRuleFromStream(stream);else{let decl=this.consumeDeclarationFromStream(stream);if(decl)decls.push(decl);else while(!0){let next=stream.peek();if(next.type==="EOF"||next.type==="semicolon"||next.type==="}")break;stream.next()}}}return decls}consumeBlockContents(stream,nested=!1,isNestedStyleRule=nested,allowRelative=!1){let rules=[],decls=[],flushDecls=()=>{if(decls.length>0){let nestedDecl=new CSSNestedDeclarations(decls),start=decls[0].startIndex??0,end=decls[decls.length-1].endIndex??start;nestedDecl._location=this.makeLocation(start,end,start,end),rules.push(nestedDecl),decls=[]}};while(!0){let val=stream.peek();if(val.type==="whitespace"||val.type==="semicolon")stream.next();else if(val.type==="EOF"||val.type==="}")break;else if(val.type==="at-keyword"){let atRule=this.consumeAtRuleFromStream(stream,isNestedStyleRule);if(atRule)flushDecls(),rules.push(atRule)}else{let pos=stream.position;if(nested&&this.isNestedDeclarationAhead(stream)){let decl=this.consumeDeclarationFromStream(stream);if(decl){if(stream.peek().type==="semicolon"){let semi=stream.next();if(semi.endIndex!==void 0)decl.endIndex=semi.endIndex}decls.push(decl)}}else{stream.position=pos;let rule=this.consumeNestedQualifiedRuleFromStream(stream,isNestedStyleRule,"semicolon",allowRelative);if(flushDecls(),rule)rules.push(rule)}}}return flushDecls(),rules}isNestedDeclarationAhead(stream){let first=stream.peek();if(first.type!=="ident"||first.value==="--")return!1;if(first.value.startsWith("--"))return!0;let lookaheadPos=stream.position;try{stream.next();while(stream.peek().type==="whitespace")stream.next();if(stream.peek().type!=="colon")return!1;stream.next();let lookaheadTokens=[first,{type:"colon",value:":"}];while(!0){let next=stream.peek();if(next.type==="EOF"||next.type==="}"||next.type==="semicolon")return!0;if(next.type==="simple-block"&&next.associatedToken?.type==="{"){let selectorCandidate=serialize(lookaheadTokens).trim();return Parser.parseSelectorAST(selectorCandidate,{allowVendorPseudos:Boolean(this.options.allowVendorPseudos),allowUnknownPseudos:Boolean(this.options.allowUnknownPseudos)})===null}lookaheadTokens.push(stream.next())}}finally{stream.position=lookaheadPos}}consumeDeclarationFromStream(stream){let firstValue=stream.peek();if(firstValue.type!=="ident")return null;let startIndex=getComponentValueStartIndex(firstValue)??firstValue.startIndex;stream.next();let name=firstValue.value;if(name==="--")return null;while(stream.peek().type==="whitespace")stream.next();if(stream.peek().type!=="colon")return null;stream.next();while(stream.peek().type==="whitespace")stream.next();let declValue=[];while(!0){let val=stream.peek();if(val.type==="EOF"||val.type==="semicolon")break;if(!name.startsWith("--")&&val.type==="simple-block"&&val.associatedToken?.type==="{"&&declValue.some((v)=>v.type!=="whitespace")){declValue.push(stream.next());break}declValue.push(stream.next())}let important=!1,lastNonWsIndex=(end)=>{let j=end;while(j>=0&&declValue[j].type==="whitespace")j--;return j},lastNonWs=declValue[lastNonWsIndex(declValue.length-1)],endIndex=(lastNonWs&&(getComponentValueEndIndex(lastNonWs)??lastNonWs.endIndex))??firstValue.endIndex,i1=lastNonWsIndex(declValue.length-1),t1=declValue[i1];if(i1>=0&&t1?.type==="ident"&&t1.value.toLowerCase()==="important"){let i2=lastNonWsIndex(i1-1),t2=declValue[i2];if(i2>=0&&t2?.type==="delim"&&t2.value==="!")important=!0,declValue.splice(i2)}while(declValue.length>0&&declValue[declValue.length-1].type==="whitespace")declValue.pop();if(name.startsWith("--")){if(!validateDeclarationValue(declValue,!0,!0))return null}else{if(declValue.some((v)=>v.type==="simple-block"&&v.associatedToken.type==="{")&&declValue.reduce((count,v)=>v.type!=="whitespace"?count+1:count,0)>1)return null;if(!validateDeclarationValue(declValue,!0,!1))return null}if(name.toLowerCase()==="unicode-range"){let text=getOriginalText(declValue),errors=[],reParser=new Parser(tokenize(text,!0,errors));reParser.errors.push(...errors);let reParsed=reParser.parseComponentValues();if(!isValidUnicodeRangeValue(reParsed))return null;this.errors.push(...reParser.errors),declValue.splice(0,declValue.length,...reParsed)}return{type:"declaration",name,value:declValue,important,raw:name.startsWith("--")?getOriginalText(declValue):void 0,startIndex,endIndex}}consumeNestedQualifiedRuleFromStream(stream,nested=!0,stopToken,allowRelative=nested){let prelude=[];while(!0){let val=stream.peek();if(val.type==="EOF"||val.type==="}"||stopToken&&val.type===stopToken)return null;if(val.type==="simple-block"&&val.associatedToken.type==="{"){if(stream.next(),isCustomPropertyDeclaration(prelude))return this.consumeRemnantsOfABadDeclaration(stream,nested),null;let block=val,blockContents=this.consumeBlockContents(new ArrayComponentValueStream(block.value),!0),start=getComponentValueStartIndex(prelude[0])??block.associatedToken.startIndex??0;return this.createStyleRule(prelude,blockContents,nested,allowRelative,this.createBlockLocation(start,block))}prelude.push(stream.next())}}consumeAtRuleFromStream(stream,nested=!1){let token=stream.next();if(token.type!=="at-keyword")return null;let rule={type:"at-rule",name:token.value,prelude:[],childRules:[]},start=token.startIndex??0;while(!0){let val=stream.peek();if(val.type==="semicolon"){let semiToken=stream.next(),end=semiToken.endIndex??semiToken.startIndex??start;return this.finalizeAtRule(rule,void 0,nested,this.makeLocation(start,end),!1)}else if(val.type==="EOF"||val.type==="}"){let end=val.startIndex??start;return this.finalizeAtRule(rule,void 0,nested,this.makeLocation(start,end),!1)}else if(val.type==="simple-block"&&val.associatedToken.type==="{"){let block=stream.next();return this.finalizeAtRule(rule,block,nested,this.createBlockLocation(start,block),!1)}else rule.prelude.push(stream.next())}}consumeRemnantsOfABadDeclaration(stream,nested=!1){while(!0){let val=stream.peek();if(val.type==="EOF"||val.type==="semicolon"){stream.next();break}else if(val.type==="}"&&nested)break;else stream.next()}}isValidSelector(prelude){let trimmed=trimComponentValues(prelude);if(trimmed.length===0)return!1;let lastToken=trimmed[trimmed.length-1];if(lastToken.type==="delim"&&(lastToken.value==="."||lastToken.value==="#")||lastToken.type==="colon")return!1;for(let i=0;i<trimmed.length;i++){let val=trimmed[i];if(val.type==="number"||val.type==="dimension")return!1;if(val.type==="delim"){if(val.value==="#")return!1;if(val.value==="."&&(i+1>=trimmed.length||trimmed[i+1].type!=="ident"))return!1}if(val.type==="colon"&&i+1<trimmed.length){let nextVal=trimmed[i+1];if(nextVal.type!=="ident"&&nextVal.type!=="function"&&nextVal.type!=="colon")return!1}}return!0}createStyleRule(prelude,blockContents,isNested=!1,allowRelative=isNested,location){let{declarations,nestedRules}=splitLeadingDeclarations(blockContents),selectorText="",selectorAST=null;if(isNested){if(selectorText=this.normalizeNestedSelector(prelude),selectorText==="")return null;if(selectorAST=Parser.parseSelectorAST(selectorText,{declaredNamespaces:this.declaredNamespaces,allowRelative:!0,allowVendorPseudos:Boolean(this.options.allowVendorPseudos),allowUnknownPseudos:Boolean(this.options.allowUnknownPseudos)}),selectorAST===null)return null}else{if(!this.isValidSelector(prelude))return null;try{selectorAST=new SelectorParser(prelude,{declaredNamespaces:this.declaredNamespaces,allowRelative,allowVendorPseudos:Boolean(this.options.allowVendorPseudos),allowUnknownPseudos:Boolean(this.options.allowUnknownPseudos)}).parse()}catch{return null}selectorText=serialize(prelude).trim()}let rule=new CSSStyleRule(selectorText,declarations,nestedRules,parseRuleInBlock,selectorAST);if(location)rule._location=location;return rule}static#consumeSelectorTokens(parser){let prelude=[];while(!0){let next=parser.nextToken;if(next.type==="EOF")break;if(next.type==="{"||next.type==="}"||next.type==="at-keyword")return null;prelude.push(parser.consumeComponentValue())}return prelude}static parseSelectorAST(text,declaredNamespacesOrOptions,allowRelative=!1,allowVendorPseudos=!1){let isOptionsObj=declaredNamespacesOrOptions&&!(declaredNamespacesOrOptions instanceof Set),declaredNamespaces=isOptionsObj?declaredNamespacesOrOptions.declaredNamespaces:declaredNamespacesOrOptions,isRelative=isOptionsObj?declaredNamespacesOrOptions.allowRelative??!1:allowRelative,vendorPseudos=isOptionsObj?declaredNamespacesOrOptions.allowVendorPseudos??!1:allowVendorPseudos,unknownPseudos=isOptionsObj?declaredNamespacesOrOptions.allowUnknownPseudos??!1:!1,parser=new Parser(tokenize(text),{allowVendorPseudos:vendorPseudos,allowUnknownPseudos:unknownPseudos}),prelude=Parser.#consumeSelectorTokens(parser);if(prelude===null)return null;try{return new SelectorParser(prelude,{allowRelative:isRelative,declaredNamespaces,allowVendorPseudos:vendorPseudos,allowUnknownPseudos:unknownPseudos}).parse()}catch{return null}}normalizeNestedSelector(prelude){let segments=splitComponentValuesByComma(prelude,!0);if(segments.length===1&&segments[0].length===0)return"";let hasAmpersand=(values)=>values.some((val)=>val.type==="delim"&&val.value==="&"||val.type==="simple-block"&&hasAmpersand(val.value)||val.type==="function"&&hasAmpersand(val.value)),normalizedSegments=[];for(let segment of segments){let trimmed=trimComponentValues(segment);if(trimmed.length===0)return"";let firstNode=trimmed[0],secondNode=trimmed[1],startsWithCombinator=firstNode.type==="delim"&&[">","+","~"].includes(firstNode.value)||firstNode.type==="delim"&&firstNode.value==="|"&&secondNode?.type==="delim"&&secondNode.value==="|",serialized=serialize(trimmed);normalizedSegments.push(startsWithCombinator||!hasAmpersand(trimmed)?`& ${serialized}`:serialized)}return normalizedSegments.join(", ")}consumeBlock(startToken){let block={type:"simple-block",associatedToken:startToken,value:[]},mirror=getMirrorToken(startToken.type);while(!0){let next=this.nextToken;if(next.type===mirror)return block.endIndex=next.endIndex??next.startIndex,block.isClosed=!0,this.discardToken(),block;else if(next.type==="EOF")return block.endIndex=next.startIndex,block.isClosed=!1,this.reportError("Unexpected EOF in block",next),block;else block.value.push(this.consumeComponentValue())}}consumeFunction(nameToken){let func={type:"function",name:nameToken.value,value:[]};while(!0){let next=this.nextToken;if(next.type===")")return this.discardToken(),func;else if(next.type==="EOF")return this.reportError("Unexpected EOF in function",next),func;else func.value.push(this.consumeComponentValue())}}consumeComponentValue(){let token=this.consumeToken();if(token.type==="{"||token.type==="["||token.type==="(")return this.consumeBlock(token);if(token.type==="function")return this.consumeFunction(token);return token}ensureEOF(){if(this.skipWhitespace(),this.nextToken.type!=="EOF")throw new DOMException("Syntax error","SyntaxError")}static parseSelector(text){let prelude=Parser.#consumeSelectorTokens(new Parser(tokenize(text)));if(prelude===null)return null;return serialize(prelude).trim()||null}static parseRuleText(text){let parser=new Parser(tokenize(text),{source:text}),rule=parser.consumeRule();if(!rule)throw new DOMException("Syntax error","SyntaxError");return parser.ensureEOF(),rule}static parseStyleSheetText(text){return new Parser(tokenize(text),{source:text}).consumeListOfRules(!0)}};function parseRuleInBlockText(text,nested=!0,inScope=!1){let parser=new Parser3(tokenize(`{ ${text} }`));if(inScope)parser.scopeContextDepth=1;let block=parser.consumeBlock(parser.consumeToken()),contents=parser.consumeBlockContents(new ArrayComponentValueStream(block.value),inScope?!0:nested,inScope?!1:nested,inScope);if(contents.length!==1)throw new DOMException("Syntax error","SyntaxError");return contents[0]}function parseRuleInScopeBlockText(text){return parseRuleInBlockText(text,!0,!0)}function isValidVarArg(func){if((func.name||("value"in func&&typeof func.value==="string"?func.value:"")).toLowerCase()!=="var"||!Array.isArray(func.value))return!0;let args=func.value,commaIndex=args.findIndex((t)=>t.type==="comma"),nameTokens=(commaIndex!==-1?args.slice(0,commaIndex):args).filter((t)=>t.type!=="whitespace"&&t.type!=="comment");if(nameTokens.length===0)return!1;if(nameTokens.length===1&&nameTokens[0].type==="simple-block"&&nameTokens[0].associatedToken?.type==="{")return nameTokens[0].value.some((t)=>t.type!=="whitespace"&&t.type!=="comment");return!nameTokens.some((t)=>t.type==="simple-block"&&t.associatedToken?.type==="{")}function validateDeclarationValue(values,isTopLevel=!0,isCustomProperty=!1){for(let v of values){if(v.type==="bad-string"||v.type==="bad-url"||v.type===")"||v.type==="]"||v.type==="}")return!1;if(isTopLevel&&(v.type==="semicolon"||v.type==="delim"&&v.value==="!"))return!1;if(v.type==="simple-block"){if(!validateDeclarationValue(v.value,!1,isCustomProperty))return!1}else if(v.type==="function"){let func=v;if(!isCustomProperty&&!isValidVarArg(func))return!1;if(Array.isArray(func.value)&&!validateDeclarationValue(func.value,!1,isCustomProperty))return!1}}return!0}function parseRule(text){return Parser3.parseRuleText(text)}function parseRuleInBlock(text,nested=!0){return parseRuleInBlockText(text,nested)}function parseRuleInScopeBlock(text){return parseRuleInScopeBlockText(text)}function assembleUnicodeRanges(values){let result=[],i=0;while(i<values.length&&(values[i].type==="whitespace"||values[i].type==="comment"))i++;if(i>=values.length)return null;while(i<values.length){let v=values[i];if(v.type==="unicode-range"){let tok=v,start=tok.unicodeRangeStart??parseInt(tok.value.slice(2).split("-")[0],16),end=tok.unicodeRangeEnd??(tok.value.includes("-")?parseInt(tok.value.split("-")[1],16):start);if(start>1114111||end>1114111||start>end)return null;result.push(v),i++}else if(v.type==="ident"&&(v.value.toLowerCase()==="u"||v.value.toLowerCase().startsWith("u+"))){let text="";if(v.value.toLowerCase()==="u"){i++;while(i<values.length&&values[i].type==="comment")i++;let hasPlus=!1;if(i<values.length&&values[i].type==="delim"&&values[i].value==="+"){hasPlus=!0,i++;while(i<values.length&&values[i].type==="comment")i++}else if(i<values.length&&(values[i].type==="number"||values[i].type==="dimension")&&values[i].sign==="+")hasPlus=!0;if(hasPlus){let hexPart="";while(i<values.length){let t=values[i];if(t.type==="dimension"){let signStr=t.sign==="-"?"-":"";hexPart+=signStr+Math.abs(t.value).toString(16)+(t.unit||""),i++}else if(t.type==="number"){let signStr=t.sign==="-"?"-":"";hexPart+=signStr+Math.abs(t.value).toString(16),i++}else if(t.type==="ident"||t.type==="delim"&&["?","-"].includes(String(t.value)))hexPart+=String(t.value),i++;else if(t.type==="comment")i++;else break}text=`u+${hexPart}`}else return null}else{text=v.value,i++;while(i<values.length&&values[i].type==="delim"&&values[i].value==="?")text+="?",i++}let match1=/^u\+([0-9a-f]{1,6})(-([0-9a-f]{1,6}))?$/i.exec(text);if(match1){let startHex=match1[1],endHex=match1[3],startNum=parseInt(startHex,16);if(startNum>1114111)return null;if(endHex!==void 0){let endNum=parseInt(endHex,16);if(endNum>1114111||endNum<startNum)return null;result.push({type:"unicode-range",value:`U+${startNum.toString(16).toUpperCase()}-${endNum.toString(16).toUpperCase()}`})}else result.push({type:"unicode-range",value:`U+${startNum.toString(16).toUpperCase()}`})}else{let match2=/^u\+([0-9a-f]{0,5})(\?{1,6})$/i.exec(text);if(match2&&match2[1].length+match2[2].length<=6){let prefix=match2[1],q=match2[2],startHex=prefix+"0".repeat(q.length),endHex=prefix+"F".repeat(q.length),startNum=parseInt(startHex,16),endNum=parseInt(endHex,16);if(startNum>1114111||endNum>1114111)return null;result.push({type:"unicode-range",value:`U+${startNum.toString(16).toUpperCase()}-${endNum.toString(16).toUpperCase()}`})}else return null}}else return null;while(i<values.length&&(values[i].type==="whitespace"||values[i].type==="comment"))i++;if(i>=values.length||values[i].type==="EOF")break;if(values[i].type==="comma"||values[i].type==="delim"&&values[i].value===","){result.push({type:"comma",value:","}),i++;while(i<values.length&&(values[i].type==="whitespace"||values[i].type==="comment"))i++;if(i>=values.length)return null}else return null}return result}function isValidUnicodeRangeValue(values){return assembleUnicodeRanges(values)!==null}function parseStyleAttribute(tokens){return new Parser3(tokens).parseStyleAttribute()}function consumeRule(tokens){return new Parser3(tokens).consumeRule()}function consumeListOfRules(tokens,topLevel,options){return new Parser3(tokens,options).consumeListOfRules(topLevel)}function parseComponentValues(tokens,errors){let p=new Parser3(tokens),res=p.parseComponentValues();if(errors)errors.push(...p.errors);return res}Parser3.parseSelector;var parseSelectorAST=Parser3.parseSelectorAST;function validateCustomPropertyValue(values){return validateDeclarationValue(values,!0,!0)}function parse3(css,options){return new Parser3(tokenize(css),{source:css,...options}).parseStyleSheet()}CSSGroupingRule._parser={parseRule,parseRuleInBlock,parseRuleInScopeBlock};var CSS_WIDE_KEYWORDS=new Set("inherit,initial,unset,revert,revert-layer".split(",")),LOGICAL_SHORTHANDS=new Set("margin,padding,inset,scroll-margin,scroll-padding,border-width,border-style,border-color".split(","));function createStyleProxy(target){return new Proxy(target,{get(t,prop){if(typeof prop==="string"){if(!isNaN(Number(prop))){let index=Number(prop),decl=t._declarations[index];return decl?decl.name:void 0}if(prop in t&&(typeof t[prop]<"u"||prop.startsWith("_")))return t[prop];if(prop.startsWith("--"))return t._allowCustomProperties?t.getPropertyValue(prop):void 0;let isCustomProp=prop.startsWith("--"),cssProp=prop;if(!isCustomProp)if(prop==="cssFloat")cssProp="float";else cssProp=camelToDashed(prop);if(t._isPropertySupported(cssProp))return t.getPropertyValue(cssProp)}return t[prop]},set(t,prop,value){if(typeof prop==="string"){if(!isNaN(Number(prop)))return!1;if(prop in t&&(typeof t[prop]<"u"||prop.startsWith("_")))return t[prop]=value,!0;if(prop.startsWith("--")){if(t._allowCustomProperties)t.setProperty(prop,value);return!0}let cssProp=prop;if(prop==="cssFloat")cssProp="float";else cssProp=camelToDashed(prop);if(t._isPropertySupported(cssProp))return t.setProperty(cssProp,value),!0}return t[prop]=value,!0},has(t,prop){if(typeof prop==="string"){if(!isNaN(Number(prop))){let index=Number(prop);return index>=0&&index<t._declarations.length}if(prop in t)return!0;if(prop.startsWith("--"))return!0;let dashed=camelToDashed(prop);if(t._isPropertySupported(dashed))return!0;if(prop in SHORTHANDS)return!0;for(let s of Object.values(SHORTHANDS))if(s.longhands.includes(prop))return!0}return Reflect.has(t,prop)},ownKeys(t){return Array.from({length:t.length},(_,i)=>String(i))},getOwnPropertyDescriptor(t,prop){let i=typeof prop==="string"?Number(prop):NaN;if(Number.isInteger(i)&&i>=0&&i<t.length&&String(i)===prop)return{value:t.item(i),writable:!1,enumerable:!0,configurable:!0};let desc=Reflect.getOwnPropertyDescriptor(t,prop);return desc?{...desc,enumerable:!1}:void 0}})}var CSSStyleDeclaration2=class extends CSSStyleProperties{_declarations;_rawDeclarations;_declMap;_readonly=!1;_parentRule=null;_onChange=null;get parentRule(){return this._parentRule}get onChange(){return this._onChange}set onChange(fn){this._onChange=fn??null}get _filterDeclarationsInConstructor(){return!1}get _allowCustomProperties(){return!0}get _allowImportant(){return!0}constructor(parentRuleOrDeclarations,onChangeOrReadonly){super();this._declarations=[],this._rawDeclarations=[],this._declMap=new Map;let declarations=[];if(Array.isArray(parentRuleOrDeclarations)){if(declarations=parentRuleOrDeclarations,this._readonly=typeof onChangeOrReadonly==="boolean"?onChangeOrReadonly:!1,typeof onChangeOrReadonly==="function")this._onChange=onChangeOrReadonly}else if(this._parentRule=parentRuleOrDeclarations??null,this._readonly=typeof onChangeOrReadonly==="boolean"?onChangeOrReadonly:!1,typeof onChangeOrReadonly==="function")this._onChange=onChangeOrReadonly;let addDeclarationRecursive=(decl,isTopLevel=!1)=>{if(decl.name==="--")return;if(decl.important&&!this._allowImportant)return;let normalizedName=decl.name.startsWith("--")?decl.name:decl.name.toLowerCase();if(normalizedName.startsWith("--")&&!this._allowCustomProperties)return;if(this._filterDeclarationsInConstructor&&!normalizedName.startsWith("--")&&!this._isPropertySupported(normalizedName))return;if(decl.name=normalizedName,isTopLevel)this._rawDeclarations.push(decl);let shorthand=SHORTHANDS[decl.name];if(shorthand){if(!(serialize(decl.value).includes("var(")||serialize(decl.value).includes("env("))){let expanded=shorthand.expand(decl.value);if(expanded){for(let[lh,val]of Object.entries(expanded))addDeclarationRecursive({type:"declaration",name:lh,value:val,important:decl.important,fromAll:decl.name==="all"||decl.fromAll});return}}}this._addDeclaration(decl)};for(let d of declarations)addDeclarationRecursive(d,!0);return createStyleProxy(this)}_addDeclaration(d){let shorthand=SHORTHANDS[d.name];if(shorthand){for(let lh of shorthand.longhands)if(this._declMap.has(lh)){let existing=this._declMap.get(lh);if(existing.important&&!d.important)continue;let index=this._declarations.indexOf(existing);if(index!==-1)this._declarations.splice(index,1);this._declMap.delete(lh)}}if(this._declMap.has(d.name)){let existing=this._declMap.get(d.name);if(existing.important&&!d.important)return;let index=this._declarations.indexOf(existing);if(index!==-1)this._declarations.splice(index,1);this._declarations.push(d),this._declMap.set(d.name,d)}else this._declarations.push(d),this._declMap.set(d.name,d)}get length(){return this._declarations.length}item(index){return this._declarations[index]?.name||""}_getLonghandForContraction(lh){let decl=this._getWinningDeclaration(lh);if(decl&&decl.value.length>0)return{value:decl.value,important:decl.important};return null}getPropertyValue(property){if(!property.startsWith("--"))property=property.toLowerCase();else if(!isValidDashedIdent(property))return"";let shorthandLonghands=SHORTHANDS[property]?.longhands||SHORTHANDS_DATA[property];if(shorthandLonghands&&shorthandLonghands.length>0){let allCssWide=null,allMatch=!0,firstPrio=null,allSamePriority=!0;for(let lh of shorthandLonghands){let val=this.getPropertyValue(lh);if(!val){allMatch=!1;break}let prio=this.getPropertyPriority(lh);if(firstPrio===null)firstPrio=prio;else if(firstPrio!==prio)allSamePriority=!1;let trimmed=val.trim().toLowerCase();if(["initial","inherit","unset","revert","revert-layer"].includes(trimmed)){if(allCssWide===null)allCssWide=trimmed;else if(allCssWide!==trimmed){allMatch=!1;break}}else{allMatch=!1;break}}if(allMatch&&allCssWide&&allSamePriority)return allCssWide}let shorthand=SHORTHANDS[property];if(shorthand){let longhandValues={},anySet=!1,important=null,consistentImportant=!0,allLonghandsToCheck=getShorthandAllLonghands(shorthand);for(let lh of allLonghandsToCheck){let item=this._getLonghandForContraction(lh);if(item&&item.value.length>0){anySet=!0,longhandValues[lh]=item.value;let isImp=item.important;if(important===null)important=isImp;else if(important!==isImp)consistentImportant=!1}}if(anySet&&consistentImportant){let wm=this.getPropertyValue("writing-mode")||"horizontal-tb",dir=this.getPropertyValue("direction")||"ltr",physicalToLogicalSet=new Map;for(let lh of Object.keys(longhandValues)){let physicalProp=resolveLogicalProperty(lh,wm,dir),decl=this._getWinningDeclaration(lh);if(physicalToLogicalSet.has(physicalProp)){let other=physicalToLogicalSet.get(physicalProp);if(!(decl?.name==="all"||decl?.fromAll||other.decl?.name==="all"||other.decl?.fromAll)){if(serialize(longhandValues[lh]).trim()!==serialize(longhandValues[other.lh]).trim())return""}}if(decl&&decl.name!=="all"&&!decl.fromAll)physicalToLogicalSet.set(physicalProp,{lh,decl});else if(!physicalToLogicalSet.has(physicalProp))physicalToLogicalSet.set(physicalProp,{lh,decl})}let valuesForContractor={},anyLogical=!1,allLonghands=shorthand.logicalLonghands?[...shorthand.longhands,...shorthand.logicalLonghands]:shorthand.longhands;for(let lh of allLonghands){let val=longhandValues[lh];if(val){if(valuesForContractor[lh]=val,resolveLogicalProperty(lh,wm,dir)!==lh)anyLogical=!0;if(shorthand.logicalLonghands?.includes(lh))anyLogical=!0}}let hasAllLonghands=shorthand.longhands.every((lh)=>valuesForContractor[lh]),hasAllLogicals=shorthand.logicalLonghands?.every((lh)=>valuesForContractor[lh]);if(hasAllLonghands){let res=shorthand.contract(valuesForContractor);if(res)return res}if(hasAllLogicals&&anyLogical){let res=shorthand.contract(valuesForContractor);if(res&&!res.startsWith("logical")&&LOGICAL_SHORTHANDS.has(property)&&!CSS_WIDE_KEYWORDS.has(res.trim().toLowerCase()))res="logical "+res;return res||""}}let directDecl=this._getWinningDeclaration(property);if(directDecl){let directIdx=this._declarations.indexOf(directDecl),allLonghands=getShorthandAllLonghands(shorthand);if(this._declarations.some((d,idx)=>{if(!allLonghands.includes(d.name))return!1;if(d.important&&!directDecl.important)return!0;if(d.important===directDecl.important&&idx>directIdx)return!0;return!1}))return"";return serialize(directDecl.value).trim()}return""}let winner=this._getWinningDeclaration(property);if(winner){if(winner.name==="all")return serialize(winner.value);let isCustom=winner.name.startsWith("--");if(isCustom){if(winner.raw!==void 0&&winner.raw.includes("/*"))return winner.raw.trim();let serialized=serialize(winner.value,isCustom).trim();if(serialized==="")return" ";return serialized}if(winner.name==="font-family")return serializeFontFamily(winner.value);if(winner.name==="flex-basis"&&serialize(winner.value).trim()==="0")return"0px";return serialize(winner.value,isCustom)}return""}_getExactWinningDeclaration(property){if(!property.startsWith("--"))property=property.toLowerCase();let isCoveredByAll=!property.startsWith("--")&&property!=="direction"&&property!=="unicode-bidi"&&property!=="all",winner=null;for(let i=this._declarations.length-1;i>=0;i--){let d=this._declarations[i],isMatch=d.name===property,isAll=d.name==="all"&&isCoveredByAll;if(isMatch||isAll){if(!winner||d.important&&!winner.important){if(winner=d,winner.important)break}}}return winner}_getWinningDeclaration(property){let exact=this._getExactWinningDeclaration(property),shorthands=LONGHAND_TO_SHORTHAND[property];if(shorthands)for(let sh of shorthands){let shDecl=this._getExactWinningDeclaration(sh);if(shDecl){if(shDecl.important&&(!exact||!exact.important))return null;if(exact&&!exact.important&&!shDecl.important){if(this._declarations.indexOf(shDecl)>this._declarations.indexOf(exact))return null}}}return exact}getPropertyPriority(property){if(!property.startsWith("--"))property=property.toLowerCase();let shorthand=SHORTHANDS[property];if(shorthand){if(this.getPropertyValue(property)==="")return"";let checkSet=(longhands)=>{let importantCount=0,values={};for(let lh of longhands){let item=this._getLonghandForContraction(lh);if(item&&item.value.length>0){if(values[lh]=item.value,item.important)importantCount++}}return{importantCount,values}},primaryResult=checkSet(shorthand.longhands);if(primaryResult.importantCount===shorthand.longhands.length&&shorthand.longhands.length>0){if(shorthand.contract(primaryResult.values))return"important"}if(shorthand.logicalLonghands){let logicalResult=checkSet(shorthand.logicalLonghands);if(logicalResult.importantCount===shorthand.logicalLonghands.length&&shorthand.logicalLonghands.length>0){if(shorthand.contract(logicalResult.values))return"important"}}if(shorthand.physicalLonghands){let physicalResult=checkSet(shorthand.physicalLonghands);if(physicalResult.importantCount===shorthand.physicalLonghands.length&&shorthand.physicalLonghands.length>0){if(shorthand.contract(physicalResult.values))return"important"}}let directDecl=this._getWinningDeclaration(property);if(directDecl&&directDecl.important)return"important";return""}let winner=this._getWinningDeclaration(property);return winner&&winner.important?"important":""}setProperty(property,value,priority=""){this._setPropertyInternal(property,value,priority,!0,!1)}_setPropertyInternal(property,value,priority="",notify=!0,fromAll=!1){if(this._readonly)throw new DOMException("Modification is disallowed","NoModificationAllowedError");if(property==="--")return;if(property.startsWith("--")&&!this._allowCustomProperties)return;if(!property.startsWith("--"))property=property.toLowerCase();if(!property.startsWith("--")&&!this._isPropertySupported(property))return;let normalizedPriority=(priority??"").trim().toLowerCase();if(normalizedPriority!==""&&normalizedPriority!=="important")return;let isImportant=normalizedPriority==="important";if(isImportant&&!this._allowImportant)return;if(value===null||value===""){this.removeProperty(property);return}if(value===void 0&&!property.startsWith("--")&&!CUSTOM_IDENT_PROPERTIES.has(property))return;let valueStr=typeof value==="string"?value:String(value);if(property.startsWith("--")){if(!isValidDashedIdent(property))return;let tokens=tokenize(valueStr);if(tokens.some((t)=>t.type==="bad-string"||t.type==="bad-url"))return;if(!validateCustomPropertyValue(parseComponentValues(tokens)))return}let tokens=tokenize(valueStr,property==="unicode-range");if(tokens.some((t)=>t.type==="bad-string"||t.type==="bad-url"))return;if(property==="all")this._declarations=this._declarations.filter((d)=>d.name!=="all"),this._declMap.delete("all");let compVals=parseComponentValues(tokens);if(!property.startsWith("--")){if(!validateDeclarationValue(compVals))return;if(ParseHooks.validatePropertyValue&&!ParseHooks.validatePropertyValue(property,valueStr,value))return}let shorthand=SHORTHANDS[property];if(shorthand){let hasVar=valueStr.includes("var(")||valueStr.includes("env(");if(!hasVar){let expanded=shorthand.expand(compVals);if(expanded){if(ParseHooks.validatePropertyValue){for(let[lh,val]of Object.entries(expanded))if(!ParseHooks.validatePropertyValue(lh,serialize(val),val))return}for(let[lh,val]of Object.entries(expanded))this._setPropertyInternal(lh,serialize(val),normalizedPriority,!1,property==="all"||fromAll);if(notify){let allLh=getShorthandAllLonghands(shorthand);this._rawDeclarations=this._rawDeclarations.filter((d)=>d.name!==property&&!allLh.includes(d.name)),this._rawDeclarations.push({type:"declaration",name:property,value:compVals,important:isImportant}),this._onChange?.()}return}}if(hasVar&&validateDeclarationValue(compVals))for(let lh of shorthand.longhands)this.removeProperty(lh);else if(!shorthand.stub)return}let existing=this._declMap.get(property),componentValues=parseComponentValues(tokens);if(property==="unicode-range"){let assembled=assembleUnicodeRanges(componentValues);if(!assembled)return;componentValues.splice(0,componentValues.length,...assembled)}if(existing){if(existing.value=componentValues,existing.important=isImportant,existing.fromAll=fromAll,property.startsWith("--"))existing.raw=valueStr??void 0;let idx=this._declarations.indexOf(existing);if(idx!==-1){let info=LOGICAL_PROPERTY_INFO[property];if(this._declarations.slice(idx+1).some((d)=>{if(d.name==="all")return!0;if(!info)return!1;let otherInfo=LOGICAL_PROPERTY_INFO[d.name];return otherInfo&&otherInfo.group===info.group&&otherInfo.logic!==info.logic}))this._declarations.splice(idx,1),this._declarations.push(existing)}}else{let decl={type:"declaration",name:property,value:componentValues,important:isImportant,fromAll:fromAll||void 0,raw:property.startsWith("--")?valueStr??void 0:void 0};this._declarations.push(decl),this._declMap.set(property,decl)}if(notify)this._rawDeclarations=this._rawDeclarations.filter((d)=>d.name!==property),this._rawDeclarations.push({type:"declaration",name:property,value:componentValues,important:isImportant,raw:property.startsWith("--")?valueStr??void 0:void 0}),this._onChange?.()}removeProperty(property){if(this._readonly)throw new DOMException("Modification is disallowed","NoModificationAllowedError");if(!property.startsWith("--"))property=property.toLowerCase();if(property==="all"){let value=this.getPropertyValue("all"),changed=!1;this._rawDeclarations=this._rawDeclarations.filter((d)=>d.name==="direction"||d.name==="unicode-bidi"||d.name.startsWith("--"));for(let i=this._declarations.length-1;i>=0;i--){let d=this._declarations[i];if(d.name!=="direction"&&d.name!=="unicode-bidi"&&!d.name.startsWith("--"))this._declarations.splice(i,1),this._declMap.delete(d.name),changed=!0}if(changed)this._onChange?.();return value}let shorthand=SHORTHANDS[property];if(shorthand){let value=this.getPropertyValue(property),allLh=shorthand.logicalLonghands?[...shorthand.longhands,...shorthand.logicalLonghands]:shorthand.longhands;this._rawDeclarations=this._rawDeclarations.filter((d)=>d.name!==property&&!allLh.includes(d.name));let changed=!1;for(let lh of allLh)if(this._declMap.has(lh)){let index=this._declarations.findIndex((d)=>d.name===lh);if(index!==-1)this._declarations.splice(index,1),this._declMap.delete(lh),changed=!0}let index=this._declarations.findIndex((d)=>d.name===property);if(index!==-1)this._declarations.splice(index,1),this._declMap.delete(property),changed=!0;if(changed)this._onChange?.();return value}let value=this.getPropertyValue(property);this._rawDeclarations=this._rawDeclarations.filter((d)=>d.name!==property);let index=this._declarations.findIndex((d)=>d.name===property);if(index!==-1)return this._declarations.splice(index,1),this._declMap.delete(property),this._onChange?.(),value;return""}get cssText(){if(this._declarations.length===0)return"";return serializeDeclarations(this._declarations)}_applyCssText(value){let tokens=tokenize(value),newStyle;try{newStyle=parseStyleAttribute(tokens)}catch{return!1}if(!newStyle)return!1;this._declarations.length=0,this._rawDeclarations=newStyle._rawDeclarations.filter((d)=>{if(d.important&&!this._allowImportant)return!1;if(d.name.startsWith("--"))return this._allowCustomProperties;return this._isPropertySupported(d.name.toLowerCase())}),this._declMap.clear();for(let d of newStyle._declarations){if(d.name==="--")continue;if(d.important&&!this._allowImportant)continue;let normalizedName=d.name.startsWith("--")?d.name:d.name.toLowerCase();if(normalizedName.startsWith("--")&&!this._allowCustomProperties)continue;if(!normalizedName.startsWith("--")&&!this._isPropertySupported(normalizedName))continue;d.name=normalizedName;let shorthand=SHORTHANDS[d.name];if(shorthand){if(!(serialize(d.value).includes("var(")||serialize(d.value).includes("env("))){let expanded=shorthand.expand(d.value);if(expanded){for(let[lh,val]of Object.entries(expanded))this._addDeclaration({type:"declaration",name:lh,value:val,important:d.important,fromAll:d.name==="all"||d.fromAll});continue}}}this._addDeclaration(d)}return!0}set cssText(value){if(this._readonly)throw new DOMException("Modification is disallowed","NoModificationAllowedError");if(this._applyCssText(value))this._onChange?.(!0)}_isPropertySupported(property){return SUPPORTED_PROPERTIES.has(property)}*[Symbol.iterator](){for(let i=0;i<this.length;i++)yield this.item(i)}};applyWebIDLInterface(CSSStyleDeclaration2);var CSSKeyframeStyleDeclaration=class extends CSSStyleDeclaration2{get _filterDeclarationsInConstructor(){return!0}_isPropertySupported(property){return property!=="animation-name"&&super._isPropertySupported(property)}},CSSFontFaceDescriptors=class extends CSSStyleDeclaration2{_isPropertySupported(property){return super._isPropertySupported(property)||FONT_FACE_DESCRIPTORS.has(property)}},PAGE_DESCRIPTORS_INTERNAL=Symbol("CSSPageDescriptors.internal"),CSSPageDescriptors=class extends CSSStyleDeclaration2{get _filterDeclarationsInConstructor(){return!0}constructor(declarations,internalToken){if(internalToken!==PAGE_DESCRIPTORS_INTERNAL)throw TypeError("Illegal constructor");super(declarations)}_isPropertySupported(property){return PAGE_ALLOWED_PROPERTIES.has(property)}};function defineDescriptorProperties(proto,dashedProps,skip){for(let cssProp of dashedProps){if(cssProp===skip)continue;let desc={get(){return this.getPropertyValue(cssProp)},set(val){this.setProperty(cssProp,val===null||val===void 0?"":String(val))},enumerable:!0,configurable:!0};if(Object.defineProperty(proto,cssProp,desc),cssProp.includes("-")){let camelProp=cssProp.replace(/-([a-z])/g,(_,c)=>c.toUpperCase());Object.defineProperty(proto,camelProp,desc)}}}defineDescriptorProperties(CSSPageDescriptors.prototype,PAGE_DESCRIPTOR_PROPERTIES);var CSSPositionTryDescriptors=class extends CSSStyleDeclaration2{get _filterDeclarationsInConstructor(){return!0}get _allowCustomProperties(){return!1}get _allowImportant(){return!1}constructor(declarations,internalToken){if(internalToken!==PAGE_DESCRIPTORS_INTERNAL)throw TypeError("Illegal constructor");super(declarations)}_isPropertySupported(property){return POSITION_TRY_ALLOWED_PROPERTIES.has(property)}};defineDescriptorProperties(CSSPositionTryDescriptors.prototype,POSITION_TRY_ALLOWED_PROPERTIES,"inset-area");var CSSMarginDescriptors=class extends CSSStyleDeclaration2{};applyWebIDLInterface(CSSFontFaceDescriptors);applyWebIDLInterface(CSSPageDescriptors);applyWebIDLInterface(CSSPositionTryDescriptors);applyWebIDLInterface(CSSMarginDescriptors);var tagName4="style";class HTMLStyleElement extends TextElement{constructor(ownerDocument,localName=tagName4){super(ownerDocument,localName);this[SHEET]=null}get sheet(){let sheet=this[SHEET];if(sheet!==null)return sheet;return this[SHEET]=parse3(this.textContent)}get innerHTML(){return super.innerHTML||""}set innerHTML(value){super.textContent=value,this[SHEET]=null}get innerText(){return super.innerText||""}set innerText(value){super.textContent=value,this[SHEET]=null}get textContent(){return super.textContent||""}set textContent(value){super.textContent=value,this[SHEET]=null}}registerHTMLClass(tagName4,HTMLStyleElement);class HTMLTimeElement extends HTMLElement{constructor(ownerDocument,localName="time"){super(ownerDocument,localName)}get dateTime(){return stringAttribute.get(this,"datetime")}set dateTime(value){stringAttribute.set(this,"datetime",value)}}registerHTMLClass("time",HTMLTimeElement);class HTMLFieldSetElement extends HTMLElement{constructor(ownerDocument,localName="fieldset"){super(ownerDocument,localName)}}class HTMLEmbedElement extends HTMLElement{constructor(ownerDocument,localName="embed"){super(ownerDocument,localName)}}class HTMLHRElement extends HTMLElement{constructor(ownerDocument,localName="hr"){super(ownerDocument,localName)}}class HTMLProgressElement extends HTMLElement{constructor(ownerDocument,localName="progress"){super(ownerDocument,localName)}}class HTMLParagraphElement extends HTMLElement{constructor(ownerDocument,localName="p"){super(ownerDocument,localName)}}class HTMLTableElement extends HTMLElement{constructor(ownerDocument,localName="table"){super(ownerDocument,localName)}}class HTMLFrameSetElement extends HTMLElement{constructor(ownerDocument,localName="frameset"){super(ownerDocument,localName)}}class HTMLLIElement extends HTMLElement{constructor(ownerDocument,localName="li"){super(ownerDocument,localName)}}class HTMLBaseElement extends HTMLElement{constructor(ownerDocument,localName="base"){super(ownerDocument,localName)}}class HTMLDataListElement extends HTMLElement{constructor(ownerDocument,localName="datalist"){super(ownerDocument,localName)}}var tagName5="input";class HTMLInputElement extends HTMLElement{constructor(ownerDocument,localName=tagName5){super(ownerDocument,localName)}get autofocus(){return booleanAttribute.get(this,"autofocus")||-1}set autofocus(value){booleanAttribute.set(this,"autofocus",value)}get disabled(){return booleanAttribute.get(this,"disabled")}set disabled(value){booleanAttribute.set(this,"disabled",value)}get name(){return this.getAttribute("name")}set name(value){this.setAttribute("name",value)}get placeholder(){return this.getAttribute("placeholder")}set placeholder(value){this.setAttribute("placeholder",value)}get type(){return this.getAttribute("type")}set type(value){this.setAttribute("type",value)}get value(){return stringAttribute.get(this,"value")}set value(value){stringAttribute.set(this,"value",value)}}registerHTMLClass(tagName5,HTMLInputElement);class HTMLParamElement extends HTMLElement{constructor(ownerDocument,localName="param"){super(ownerDocument,localName)}}class HTMLMediaElement extends HTMLElement{constructor(ownerDocument,localName="media"){super(ownerDocument,localName)}}class HTMLAudioElement extends HTMLElement{constructor(ownerDocument,localName="audio"){super(ownerDocument,localName)}}var tagName6="h1";class HTMLHeadingElement extends HTMLElement{constructor(ownerDocument,localName=tagName6){super(ownerDocument,localName)}}registerHTMLClass([tagName6,"h2","h3","h4","h5","h6"],HTMLHeadingElement);class HTMLDirectoryElement extends HTMLElement{constructor(ownerDocument,localName="dir"){super(ownerDocument,localName)}}class HTMLQuoteElement extends HTMLElement{constructor(ownerDocument,localName="quote"){super(ownerDocument,localName)}}var import_canvas=__toESM(require_canvas(),1);var{createCanvas}=import_canvas.default,tagName7="canvas";class HTMLCanvasElement extends HTMLElement{constructor(ownerDocument,localName=tagName7){super(ownerDocument,localName);this[IMAGE]=createCanvas(300,150)}get width(){return this[IMAGE].width}set width(value){numericAttribute.set(this,"width",value),this[IMAGE].width=value}get height(){return this[IMAGE].height}set height(value){numericAttribute.set(this,"height",value),this[IMAGE].height=value}getContext(type){return this[IMAGE].getContext(type)}toDataURL(...args){return this[IMAGE].toDataURL(...args)}}registerHTMLClass(tagName7,HTMLCanvasElement);class HTMLLegendElement extends HTMLElement{constructor(ownerDocument,localName="legend"){super(ownerDocument,localName)}}var tagName8="option";class HTMLOptionElement extends HTMLElement{constructor(ownerDocument,localName=tagName8){super(ownerDocument,localName)}get value(){return stringAttribute.get(this,"value")}set value(value){stringAttribute.set(this,"value",value)}get selected(){return booleanAttribute.get(this,"selected")}set selected(value){let option=this.parentElement?.querySelector("option[selected]");if(option&&option!==this)option.selected=!1;booleanAttribute.set(this,"selected",value)}}registerHTMLClass(tagName8,HTMLOptionElement);class HTMLSpanElement extends HTMLElement{constructor(ownerDocument,localName="span"){super(ownerDocument,localName)}}class HTMLMeterElement extends HTMLElement{constructor(ownerDocument,localName="meter"){super(ownerDocument,localName)}}class HTMLVideoElement extends HTMLElement{constructor(ownerDocument,localName="video"){super(ownerDocument,localName)}}class HTMLTableCellElement extends HTMLElement{constructor(ownerDocument,localName="td"){super(ownerDocument,localName)}}var tagName9="title";class HTMLTitleElement extends TextElement{constructor(ownerDocument,localName=tagName9){super(ownerDocument,localName)}}registerHTMLClass(tagName9,HTMLTitleElement);class HTMLOutputElement extends HTMLElement{constructor(ownerDocument,localName="output"){super(ownerDocument,localName)}}class HTMLTableRowElement extends HTMLElement{constructor(ownerDocument,localName="tr"){super(ownerDocument,localName)}}class HTMLDataElement extends HTMLElement{constructor(ownerDocument,localName="data"){super(ownerDocument,localName)}}class HTMLMenuElement extends HTMLElement{constructor(ownerDocument,localName="menu"){super(ownerDocument,localName)}}var tagName10="select";class HTMLSelectElement extends HTMLElement{constructor(ownerDocument,localName=tagName10){super(ownerDocument,localName)}get options(){let children=new NodeList,{firstElementChild}=this;while(firstElementChild){if(firstElementChild.tagName==="OPTGROUP")children.push(...firstElementChild.children);else children.push(firstElementChild);firstElementChild=firstElementChild.nextElementSibling}return children}get disabled(){return booleanAttribute.get(this,"disabled")}set disabled(value){booleanAttribute.set(this,"disabled",value)}get name(){return this.getAttribute("name")}set name(value){this.setAttribute("name",value)}get value(){return this.querySelector("option[selected]")?.value}}registerHTMLClass(tagName10,HTMLSelectElement);class HTMLBRElement extends HTMLElement{constructor(ownerDocument,localName="br"){super(ownerDocument,localName)}}var tagName11="button";class HTMLButtonElement extends HTMLElement{constructor(ownerDocument,localName=tagName11){super(ownerDocument,localName)}get disabled(){return booleanAttribute.get(this,"disabled")}set disabled(value){booleanAttribute.set(this,"disabled",value)}get name(){return this.getAttribute("name")}set name(value){this.setAttribute("name",value)}get type(){return this.getAttribute("type")}set type(value){this.setAttribute("type",value)}}registerHTMLClass(tagName11,HTMLButtonElement);class HTMLMapElement extends HTMLElement{constructor(ownerDocument,localName="map"){super(ownerDocument,localName)}}class HTMLOptGroupElement extends HTMLElement{constructor(ownerDocument,localName="optgroup"){super(ownerDocument,localName)}}class HTMLDListElement extends HTMLElement{constructor(ownerDocument,localName="dl"){super(ownerDocument,localName)}}var tagName12="textarea";class HTMLTextAreaElement extends TextElement{constructor(ownerDocument,localName=tagName12){super(ownerDocument,localName)}get disabled(){return booleanAttribute.get(this,"disabled")}set disabled(value){booleanAttribute.set(this,"disabled",value)}get name(){return this.getAttribute("name")}set name(value){this.setAttribute("name",value)}get placeholder(){return this.getAttribute("placeholder")}set placeholder(value){this.setAttribute("placeholder",value)}get type(){return this.getAttribute("type")}set type(value){this.setAttribute("type",value)}get value(){return this.textContent}set value(content){this.textContent=content}}registerHTMLClass(tagName12,HTMLTextAreaElement);class HTMLFontElement extends HTMLElement{constructor(ownerDocument,localName="font"){super(ownerDocument,localName)}}class HTMLDivElement extends HTMLElement{constructor(ownerDocument,localName="div"){super(ownerDocument,localName)}}var tagName13="link";class HTMLLinkElement extends HTMLElement{constructor(ownerDocument,localName=tagName13){super(ownerDocument,localName)}get disabled(){return booleanAttribute.get(this,"disabled")}set disabled(value){booleanAttribute.set(this,"disabled",value)}get href(){return stringAttribute.get(this,"href").trim()}set href(value){stringAttribute.set(this,"href",value)}get hreflang(){return stringAttribute.get(this,"hreflang")}set hreflang(value){stringAttribute.set(this,"hreflang",value)}get media(){return stringAttribute.get(this,"media")}set media(value){stringAttribute.set(this,"media",value)}get rel(){return stringAttribute.get(this,"rel")}set rel(value){stringAttribute.set(this,"rel",value)}get type(){return stringAttribute.get(this,"type")}set type(value){stringAttribute.set(this,"type",value)}}registerHTMLClass(tagName13,HTMLLinkElement);var tagName14="slot";class HTMLSlotElement extends HTMLElement{constructor(ownerDocument,localName=tagName14){super(ownerDocument,localName)}get name(){return this.getAttribute("name")}set name(value){this.setAttribute("name",value)}assign(){}assignedNodes(options){let isNamedSlot=!!this.name,hostChildNodes=this.getRootNode().host?.childNodes??[],slottables;if(isNamedSlot)slottables=[...hostChildNodes].filter((node)=>node.slot===this.name);else slottables=[...hostChildNodes].filter((node)=>!node.slot);if(options?.flatten){let result=[];for(let slottable of slottables)if(slottable.localName==="slot")result.push(...slottable.assignedNodes({flatten:!0}));else result.push(slottable);slottables=result}return slottables.length?slottables:[...this.childNodes]}assignedElements(options){let slottables=this.assignedNodes(options).filter((n)=>n.nodeType===1);return slottables.length?slottables:[...this.children]}}registerHTMLClass(tagName14,HTMLSlotElement);class HTMLFormElement extends HTMLElement{constructor(ownerDocument,localName="form"){super(ownerDocument,localName)}}var tagName15="img";class HTMLImageElement extends HTMLElement{constructor(ownerDocument,localName=tagName15){super(ownerDocument,localName)}get alt(){return stringAttribute.get(this,"alt")}set alt(value){stringAttribute.set(this,"alt",value)}get sizes(){return stringAttribute.get(this,"sizes")}set sizes(value){stringAttribute.set(this,"sizes",value)}get src(){return stringAttribute.get(this,"src")}set src(value){stringAttribute.set(this,"src",value)}get srcset(){return stringAttribute.get(this,"srcset")}set srcset(value){stringAttribute.set(this,"srcset",value)}get title(){return stringAttribute.get(this,"title")}set title(value){stringAttribute.set(this,"title",value)}get width(){return numericAttribute.get(this,"width")}set width(value){numericAttribute.set(this,"width",value)}get height(){return numericAttribute.get(this,"height")}set height(value){numericAttribute.set(this,"height",value)}}registerHTMLClass(tagName15,HTMLImageElement);class HTMLPreElement extends HTMLElement{constructor(ownerDocument,localName="pre"){super(ownerDocument,localName)}}class HTMLUListElement extends HTMLElement{constructor(ownerDocument,localName="ul"){super(ownerDocument,localName)}}var tagName16="meta";class HTMLMetaElement extends HTMLElement{constructor(ownerDocument,localName=tagName16){super(ownerDocument,localName)}get name(){return stringAttribute.get(this,"name")}set name(value){stringAttribute.set(this,"name",value)}get httpEquiv(){return stringAttribute.get(this,"http-equiv")}set httpEquiv(value){stringAttribute.set(this,"http-equiv",value)}get content(){return stringAttribute.get(this,"content")}set content(value){stringAttribute.set(this,"content",value)}get charset(){return stringAttribute.get(this,"charset")}set charset(value){stringAttribute.set(this,"charset",value)}get media(){return stringAttribute.get(this,"media")}set media(value){stringAttribute.set(this,"media",value)}}registerHTMLClass(tagName16,HTMLMetaElement);class HTMLPictureElement extends HTMLElement{constructor(ownerDocument,localName="picture"){super(ownerDocument,localName)}}class HTMLAreaElement extends HTMLElement{constructor(ownerDocument,localName="area"){super(ownerDocument,localName)}}class HTMLOListElement extends HTMLElement{constructor(ownerDocument,localName="ol"){super(ownerDocument,localName)}}class HTMLTableCaptionElement extends HTMLElement{constructor(ownerDocument,localName="caption"){super(ownerDocument,localName)}}var tagName17="a";class HTMLAnchorElement extends HTMLElement{constructor(ownerDocument,localName=tagName17){super(ownerDocument,localName)}get href(){return encodeURI(decodeURI(stringAttribute.get(this,"href"))).trim()}set href(value){stringAttribute.set(this,"href",decodeURI(value))}get download(){return encodeURI(decodeURI(stringAttribute.get(this,"download")))}set download(value){stringAttribute.set(this,"download",decodeURI(value))}get target(){return stringAttribute.get(this,"target")}set target(value){stringAttribute.set(this,"target",value)}get type(){return stringAttribute.get(this,"type")}set type(value){stringAttribute.set(this,"type",value)}get rel(){return stringAttribute.get(this,"rel")}set rel(value){stringAttribute.set(this,"rel",value)}}registerHTMLClass(tagName17,HTMLAnchorElement);class HTMLLabelElement extends HTMLElement{constructor(ownerDocument,localName="label"){super(ownerDocument,localName)}}class HTMLUnknownElement extends HTMLElement{constructor(ownerDocument,localName="unknown"){super(ownerDocument,localName)}}class HTMLModElement extends HTMLElement{constructor(ownerDocument,localName="mod"){super(ownerDocument,localName)}}class HTMLDetailsElement extends HTMLElement{constructor(ownerDocument,localName="details"){super(ownerDocument,localName)}}var tagName18="source";class HTMLSourceElement extends HTMLElement{constructor(ownerDocument,localName=tagName18){super(ownerDocument,localName)}get src(){return stringAttribute.get(this,"src")}set src(value){stringAttribute.set(this,"src",value)}get srcset(){return stringAttribute.get(this,"srcset")}set srcset(value){stringAttribute.set(this,"srcset",value)}get sizes(){return stringAttribute.get(this,"sizes")}set sizes(value){stringAttribute.set(this,"sizes",value)}get type(){return stringAttribute.get(this,"type")}set type(value){stringAttribute.set(this,"type",value)}}registerHTMLClass(tagName18,HTMLSourceElement);class HTMLTrackElement extends HTMLElement{constructor(ownerDocument,localName="track"){super(ownerDocument,localName)}}class HTMLMarqueeElement extends HTMLElement{constructor(ownerDocument,localName="marquee"){super(ownerDocument,localName)}}var HTMLClasses={HTMLElement,HTMLTemplateElement,HTMLHtmlElement,HTMLScriptElement,HTMLFrameElement,HTMLIFrameElement,HTMLObjectElement,HTMLHeadElement,HTMLBodyElement,HTMLStyleElement,HTMLTimeElement,HTMLFieldSetElement,HTMLEmbedElement,HTMLHRElement,HTMLProgressElement,HTMLParagraphElement,HTMLTableElement,HTMLFrameSetElement,HTMLLIElement,HTMLBaseElement,HTMLDataListElement,HTMLInputElement,HTMLParamElement,HTMLMediaElement,HTMLAudioElement,HTMLHeadingElement,HTMLDirectoryElement,HTMLQuoteElement,HTMLCanvasElement,HTMLLegendElement,HTMLOptionElement,HTMLSpanElement,HTMLMeterElement,HTMLVideoElement,HTMLTableCellElement,HTMLTitleElement,HTMLOutputElement,HTMLTableRowElement,HTMLDataElement,HTMLMenuElement,HTMLSelectElement,HTMLBRElement,HTMLButtonElement,HTMLMapElement,HTMLOptGroupElement,HTMLDListElement,HTMLTextAreaElement,HTMLFontElement,HTMLDivElement,HTMLLinkElement,HTMLSlotElement,HTMLFormElement,HTMLImageElement,HTMLPreElement,HTMLUListElement,HTMLMetaElement,HTMLPictureElement,HTMLAreaElement,HTMLOListElement,HTMLTableCaptionElement,HTMLAnchorElement,HTMLLabelElement,HTMLUnknownElement,HTMLModElement,HTMLDetailsElement,HTMLSourceElement,HTMLTrackElement,HTMLMarqueeElement};var voidElements3={test:()=>!0},Mime={"text/html":{docType:"<!DOCTYPE html>",ignoreCase:!0,voidElements:/^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i},"image/svg+xml":{docType:'<?xml version="1.0" encoding="utf-8"?>',ignoreCase:!1,voidElements:voidElements3},"text/xml":{docType:'<?xml version="1.0" encoding="utf-8"?>',ignoreCase:!1,voidElements:voidElements3},"application/xml":{docType:'<?xml version="1.0" encoding="utf-8"?>',ignoreCase:!1,voidElements:voidElements3},"application/xhtml+xml":{docType:'<?xml version="1.0" encoding="utf-8"?>',ignoreCase:!1,voidElements:voidElements3}};class CustomEvent extends GlobalEvent{constructor(type,eventInitDict={}){super(type,eventInitDict);this.detail=eventInitDict.detail}}class InputEvent extends GlobalEvent{constructor(type,inputEventInit={}){super(type,inputEventInit);this.inputType=inputEventInit.inputType,this.data=inputEventInit.data,this.dataTransfer=inputEventInit.dataTransfer,this.isComposing=inputEventInit.isComposing||!1,this.ranges=inputEventInit.ranges}}var ImageClass=(ownerDocument)=>class extends HTMLImageElement{constructor(width,height){super(ownerDocument);switch(arguments.length){case 1:this.height=width,this.width=width;break;case 2:this.height=height,this.width=width;break}}};var deleteContents=({[START]:start,[END]:end},fragment=null)=>{setAdjacent(start[PREV],end[NEXT]);do{let after=getEnd(start),next=after===end?after:after[NEXT];if(fragment)fragment.insertBefore(start,fragment[END]);else start.remove();start=next}while(start!==end)};class Range{constructor(){this[START]=null,this[END]=null,this.commonAncestorContainer=null}insertNode(newNode){this[END].parentNode.insertBefore(newNode,this[START])}selectNode(node){this[START]=node,this[END]=getEnd(node)}selectNodeContents(node){this.selectNode(node),this.commonAncestorContainer=node}surroundContents(parentNode){parentNode.replaceChildren(this.extractContents())}setStartBefore(node){this[START]=node}setStartAfter(node){this[START]=node.nextSibling}setEndBefore(node){this[END]=getEnd(node.previousSibling)}setEndAfter(node){this[END]=getEnd(node)}cloneContents(){let{[START]:start,[END]:end}=this,fragment=start.ownerDocument.createDocumentFragment();while(start!==end)if(fragment.insertBefore(start.cloneNode(!0),fragment[END]),start=getEnd(start),start!==end)start=start[NEXT];return fragment}deleteContents(){deleteContents(this)}extractContents(){let fragment=this[START].ownerDocument.createDocumentFragment();return deleteContents(this,fragment),fragment}createContextualFragment(html){let{commonAncestorContainer:doc}=this,isSVG="ownerSVGElement"in doc,document=isSVG?doc.ownerDocument:doc,content=htmlToFragment(document,html);if(isSVG){let childNodes=[...content.childNodes];content=document.createDocumentFragment(),Object.setPrototypeOf(content,SVGElement.prototype),content.ownerSVGElement=document;for(let child of childNodes)Object.setPrototypeOf(child,SVGElement.prototype),child.ownerSVGElement=document,content.appendChild(child)}else this.selectNode(content);return content}cloneRange(){let range=new Range;return range[START]=this[START],range[END]=this[END],range}}var isOK=({nodeType},mask)=>{switch(nodeType){case ELEMENT_NODE:return mask&SHOW_ELEMENT;case TEXT_NODE:return mask&SHOW_TEXT;case COMMENT_NODE:return mask&SHOW_COMMENT;case CDATA_SECTION_NODE:return mask&SHOW_CDATA_SECTION}return 0};class TreeWalker{constructor(root,whatToShow=SHOW_ALL){this.root=root,this.currentNode=root,this.whatToShow=whatToShow;let{[NEXT]:next,[END]:end}=root;if(root.nodeType===DOCUMENT_NODE){let{documentElement}=root;next=documentElement,end=documentElement[END]}let nodes=[];while(next&&next!==end){if(isOK(next,whatToShow))nodes.push(next);next=next[NEXT]}this[PRIVATE]={i:0,nodes}}nextNode(){let $=this[PRIVATE];return this.currentNode=$.i<$.nodes.length?$.nodes[$.i++]:null,this.currentNode}}var query=(method,ownerDocument,selectors)=>{let{[NEXT]:next,[END]:end}=ownerDocument;return method.call({ownerDocument,[NEXT]:next,[END]:end},selectors)},globalExports=assign({},Facades,HTMLClasses,{CustomEvent,Event:GlobalEvent,EventTarget:DOMEventTarget,InputEvent,NamedNodeMap,NodeList}),window=new WeakMap;class Document2 extends NonElementParentNode{constructor(type){super(null,"#document",DOCUMENT_NODE);this[CUSTOM_ELEMENTS]={active:!1,registry:null},this[MUTATION_OBSERVER]={active:!1,class:null},this[MIME]=Mime[type],this[DOCTYPE]=null,this[DOM_PARSER]=null,this[GLOBALS]=null,this[IMAGE]=null,this[UPGRADE]=null}get defaultView(){if(!window.has(this))window.set(this,new Proxy(globalThis,{set:(target,name,value)=>{switch(name){case"addEventListener":case"removeEventListener":case"dispatchEvent":this[EVENT_TARGET][name]=value;break;default:target[name]=value;break}return!0},get:(globalThis2,name)=>{switch(name){case"addEventListener":case"removeEventListener":case"dispatchEvent":if(!this[EVENT_TARGET]){let et=this[EVENT_TARGET]=new DOMEventTarget;et.dispatchEvent=et.dispatchEvent.bind(et),et.addEventListener=et.addEventListener.bind(et),et.removeEventListener=et.removeEventListener.bind(et)}return this[EVENT_TARGET][name];case"document":return this;case"navigator":return{userAgent:"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36"};case"window":return window.get(this);case"customElements":if(!this[CUSTOM_ELEMENTS].registry)this[CUSTOM_ELEMENTS]=new CustomElementRegistry(this);return this[CUSTOM_ELEMENTS];case"performance":return globalThis2.performance;case"DOMParser":return this[DOM_PARSER];case"Image":if(!this[IMAGE])this[IMAGE]=ImageClass(this);return this[IMAGE];case"MutationObserver":if(!this[MUTATION_OBSERVER].class)this[MUTATION_OBSERVER]=new MutationObserverClass(this);return this[MUTATION_OBSERVER].class}return this[GLOBALS]&&this[GLOBALS][name]||globalExports[name]||globalThis2[name]}}));return window.get(this)}get doctype(){let docType=this[DOCTYPE];if(docType)return docType;let{firstChild}=this;if(firstChild&&firstChild.nodeType===DOCUMENT_TYPE_NODE)return this[DOCTYPE]=firstChild;return null}set doctype(value){if(/^([a-z:]+)(\s+system|\s+public(\s+"([^"]+)")?)?(\s+"([^"]+)")?/i.test(value)){let{$1:name,$4:publicId,$6:systemId}=RegExp;this[DOCTYPE]=new DocumentType(this,name,publicId,systemId),knownSiblings(this,this[DOCTYPE],this[NEXT])}}get documentElement(){return this.firstElementChild}get isConnected(){return!0}_getParent(){return this[EVENT_TARGET]}createAttribute(name){return new Attr(this,name)}createCDATASection(data){return new CDATASection(this,data)}createComment(textContent){return new Comment3(this,textContent)}createDocumentFragment(){return new DocumentFragment(this)}createDocumentType(name,publicId,systemId){return new DocumentType(this,name,publicId,systemId)}createElement(localName){return new Element2(this,localName)}createRange(){let range=new Range;return range.commonAncestorContainer=this,range}createTextNode(textContent){return new Text6(this,textContent)}createTreeWalker(root,whatToShow=-1){return new TreeWalker(root,whatToShow)}createNodeIterator(root,whatToShow=-1){return this.createTreeWalker(root,whatToShow)}createEvent(name){let event=create(name==="Event"?new GlobalEvent(""):new CustomEvent(""));return event.initEvent=event.initCustomEvent=(type,canBubble=!1,cancelable=!1,detail)=>{event.bubbles=!!canBubble,defineProperties(event,{type:{value:type},canBubble:{value:canBubble},cancelable:{value:cancelable},detail:{value:detail}})},event}cloneNode(deep=!1){let{constructor,[CUSTOM_ELEMENTS]:customElements,[DOCTYPE]:doctype}=this,document=new constructor;if(document[CUSTOM_ELEMENTS]=customElements,deep){let end=document[END],{childNodes}=this;for(let{length}=childNodes,i=0;i<length;i++)document.insertBefore(childNodes[i].cloneNode(!0),end);if(doctype)document[DOCTYPE]=childNodes[0]}return document}importNode(externalNode){let deep=1<arguments.length&&!!arguments[1],node=externalNode.cloneNode(deep),{[CUSTOM_ELEMENTS]:customElements}=this,{active}=customElements,upgrade=(element)=>{let{ownerDocument,nodeType}=element;if(element.ownerDocument=this,active&&ownerDocument!==this&&nodeType===ELEMENT_NODE)customElements.upgrade(element)};if(upgrade(node),deep)switch(node.nodeType){case ELEMENT_NODE:case DOCUMENT_FRAGMENT_NODE:{let{[NEXT]:next,[END]:end}=node;while(next!==end){if(next.nodeType===ELEMENT_NODE)upgrade(next);next=next[NEXT]}break}}return node}toString(){return this.childNodes.join("")}querySelector(selectors){return query(super.querySelector,this,selectors)}querySelectorAll(selectors){return query(super.querySelectorAll,this,selectors)}getElementsByTagNameNS(_,name){return this.getElementsByTagName(name)}createAttributeNS(_,name){return this.createAttribute(name)}createElementNS(nsp,localName,options){return nsp===SVG_NAMESPACE?new SVGElement(this,localName,null):this.createElement(localName,options)}}setPrototypeOf(globalExports.Document=function(){illegalConstructor()},Document2).prototype=Document2.prototype;var createHTMLElement=(ownerDocument,builtin,localName,options)=>{if(!builtin&&htmlClasses.has(localName))return new(htmlClasses.get(localName))(ownerDocument,localName);let{[CUSTOM_ELEMENTS]:{active,registry}}=ownerDocument;if(active){let ce=builtin?options.is:localName;if(registry.has(ce)){let{Class}=registry.get(ce),element=new Class(ownerDocument,localName);return customElements.set(element,{connected:!1}),element}}return new HTMLElement(ownerDocument,localName)};class HTMLDocument extends Document2{constructor(){super("text/html")}get all(){let nodeList=new NodeList,{[NEXT]:next,[END]:end}=this;while(next!==end){switch(next.nodeType){case ELEMENT_NODE:nodeList.push(next);break}next=next[NEXT]}return nodeList}get head(){let{documentElement}=this,{firstElementChild}=documentElement;if(!firstElementChild||firstElementChild.tagName!=="HEAD")firstElementChild=this.createElement("head"),documentElement.prepend(firstElementChild);return firstElementChild}get body(){let{head}=this,{nextElementSibling}=head;if(!nextElementSibling||nextElementSibling.tagName!=="BODY")nextElementSibling=this.createElement("body"),head.after(nextElementSibling);return nextElementSibling}get title(){let{head}=this;return head.getElementsByTagName("title").at(0)?.textContent||""}set title(textContent){let{head}=this,title=head.getElementsByTagName("title").at(0);if(title)title.textContent=textContent;else head.insertBefore(this.createElement("title"),head.firstChild).textContent=textContent}createElement(localName,options){let builtin=!!(options&&options.is),element=createHTMLElement(this,builtin,localName,options);if(builtin)element.setAttribute("is",options.is);return element}}class SVGDocument extends Document2{constructor(){super("image/svg+xml")}toString(){return this[MIME].docType+super.toString()}}class XMLDocument extends Document2{constructor(){super("text/xml")}toString(){return this[MIME].docType+super.toString()}}class DOMParser{parseFromString(markupLanguage,mimeType,globals=null){let isHTML=!1,document;if(mimeType==="text/html")isHTML=!0,document=new HTMLDocument;else if(mimeType==="image/svg+xml")document=new SVGDocument;else document=new XMLDocument;if(document[DOM_PARSER]=DOMParser,globals)document[GLOBALS]=globals;if(isHTML&&markupLanguage==="...")markupLanguage="<!doctype html><html><head></head><body></body></html>";return markupLanguage?parseFromString(document,isHTML,markupLanguage):document}}var{parse:parse4}=JSON;var parseHTML=(html,globals=null)=>new DOMParser().parseFromString(html,"text/html",globals).defaultView;function Document3(){illegalConstructor()}setPrototypeOf(Document3,Document2).prototype=Document2.prototype;import{readdir,readFile,stat}from"node:fs/promises";import{join,relative,resolve}from"node:path";import{isNotationLanguage,renderBlock}from"./index.js";import{parseTabSource}from"./tab/index.js";import{lookupGuitarVoicing}from"./voicings/index.js";var QUOTE2=/^[ \t]{0,3}>[ \t]?/,OPENING=/^(`{3,}|~{3,})(.*)$/,LIST_MARKER=/^(?:[-*+]|\d{1,9}[.)])[ \t]+/;function unquote(line,depth){let rest=line;for(let i=0;i<depth;i++){let m=QUOTE2.exec(rest);if(!m)return null;rest=rest.slice(m[0].length)}return rest}var dedent=(line,indent)=>{let i=0;while(i<indent&&(line[i]===" "||line[i]==="\t"))i++;return line.slice(i)},columns=(lead)=>[...lead].reduce((n,c)=>n+(c==="\t"?4-n%4:1),0);function opensComment(line){if((line.split("%%").length-1)%2===1)return!0;let html=line.lastIndexOf("<!--");return html>=0&&!line.includes("-->",html+4)}var commentEnd=(line)=>(line.split("%%").length-1)%2===1?"%%":"-->";function parseMarkdown(text){let lines=text.replace(/^\uFEFF/,"").split(/\r\n|\r|\n/),i=0,frontMatter=null;if(lines[0]?.trimEnd()==="---"){let end=lines.findIndex((l,n)=>n>0&&/^(?:---|\.\.\.)\s*$/.test(l));if(end>0)frontMatter=lines.slice(1,end).join(`
|
|
32
32
|
`),i=end+1}let blocks=[],comment=null,inList=!1;for(;i<lines.length;i++){let line=lines[i];if(comment){let end=line.indexOf(comment);if(end<0)continue;if(comment=null,opensComment(line.slice(end+2)))comment=commentEnd(line.slice(end+2));continue}let rest=line,depth=0;for(let m=QUOTE2.exec(rest);m;m=QUOTE2.exec(rest))rest=rest.slice(m[0].length),depth++;let spaces=/^[ \t]*/.exec(rest)[0].length,marker=LIST_MARKER.exec(rest.slice(spaces))?.[0].length??0,indent=spaces+marker;if(marker)inList=!0;else if(rest.trim()&&columns(rest.slice(0,spaces))===0)inList=!1;let open=OPENING.exec(rest.slice(indent));if(!open){if(opensComment(rest))comment=commentEnd(rest);continue}if(!marker&&!inList&&columns(rest.slice(0,spaces))>3)continue;let fence=open[1],info=open[2];if(fence[0]==="`"&&info.includes("`"))continue;let body=[],start=i;for(i++;i<lines.length;i++){let inner=unquote(lines[i],depth);if(inner===null){i--;break}let close=/^[ \t]*(`{3,}|~{3,})[ \t]*$/.exec(inner);if(close&&close[1][0]===fence[0]&&close[1].length>=fence.length)break;body.push(dedent(inner,indent))}blocks.push({language:info.trim().split(/\s+/)[0]??"",line:start+1,source:body.join(`
|
|
33
|
-
`)})}return{frontMatter,blocks}}import{chordNoteSet,midiOf,nameOf,noteOf}from"./index.js";var classes=(el)=>(el.getAttribute("class")??"").split(/\s+/),has=(el,cls)=>classes(el).includes(cls),text=(el)=>el?.textContent?.trim()||null,int=(value)=>value===null?null:Number(value),marksOf=(el)=>classes(el).flatMap((c)=>c==="mn-char"?["characteristic"]:c==="mn-diff"?["different"]:c==="mn-tone"?["chord tone"]:c==="mn-passing"?["passing"]:[]);function spelled(name,midi){let octave=Math.floor(midi/12)-1;for(let o of[octave,octave-1,octave+1])if(midiOf(`${name}${o}`)===midi)return`${name}${o}`;return noteOf(midi)}var labelAfter=(el,cls)=>{let next=el.nextElementSibling;return next&&has(next,cls)?text(next):null};function capoOf(svg){let capo=int(svg.getAttribute("data-mn-capo"));if(!capo)return{};return{capo,fretsFrom:svg.getAttribute("data-mn-frets-from")==="nut"?"nut":"capo"}}function guitarChord(svg){let chord=svg.getAttribute("data-mn-chord"),sounds=svg.getAttribute("data-mn-sounds"),set=sounds?chordNoteSet(sounds):chord?chordNoteSet(chord):null,strings=[...svg.querySelectorAll("[data-mn-string]")].map((el)=>{let fret=int(el.getAttribute("data-mn-fret")),midi=int(el.getAttribute("data-midi")),name=midi===null?null:set?.members.find((m)=>m.chroma===midi%12)?.name??nameOf(midi,set?.preferFlats);return{string:Number(el.getAttribute("data-mn-string")),fret,note:name!==null&&midi!==null?spelled(name,midi):null,label:fret?labelAfter(el,"mn-dot-text"):null,root:has(el,"mn-root"),mark:has(el,"mn-anchor")?"anchor":has(el,"mn-guide")?"guide":null}}),base=parseInt(text(svg.querySelector(".mn-base-fret"))??"1",10),rows=svg.querySelectorAll("line.mn-fret, line.mn-nut").length-1,frets=strings.map((s)=>s.fret===null?"x":String(s.fret)),barres=[...svg.querySelectorAll(".mn-barre")].map((el)=>({finger:el.getAttribute("data-mn-finger")??"",fret:Number(el.getAttribute("data-mn-fret")),from:Number(el.getAttribute("data-mn-from")),to:Number(el.getAttribute("data-mn-to"))}));return{type:"guitar-chord",title:text(svg.querySelector(".mn-title")),chord,frets:frets.join(frets.some((f)=>f.length>1)?"-":""),fretRange:[base,base+rows-1],strings,...capoOf(svg),...sounds?{sounds}:{},...barres.length?{barres}:{}}}function fretboard(svg){let range=(svg.getAttribute("data-mn-frets")??"0-0").split("-").map(Number),tuning=[...svg.querySelectorAll(".mn-string-name")].map((el)=>text(el)??"?"),dots=[...svg.querySelectorAll(".mn-dot[data-mn-string]")].map((el)=>({string:Number(el.getAttribute("data-mn-string")),fret:Number(el.getAttribute("data-mn-fret")),note:spelled(el.getAttribute("data-mn-note")??"",Number(el.getAttribute("data-midi"))),label:labelAfter(el,"mn-dot-text"),root:has(el,"mn-root"),marks:marksOf(el)})).sort((a,b)=>b.string-a.string||a.fret-b.fret),ghosts=[...svg.querySelectorAll("circle[data-mn-ghost-string]")].map((el)=>({string:Number(el.getAttribute("data-mn-ghost-string")),fret:Number(el.getAttribute("data-mn-fret")),note:spelled(el.getAttribute("data-mn-note")??"",Number(el.getAttribute("data-mn-pitch")))})).sort((a,b)=>b.string-a.string||a.fret-b.fret);return{type:"fretboard",title:text(svg.querySelector(".mn-title")),notes:svg.getAttribute("data-mn-set"),fretRange:[range[0]??0,range[1]??0],tuning:tuning.reverse(),dots,ghosts,...capoOf(svg)}}function keyboard(svg){let all=[...svg.querySelectorAll("rect[data-midi]")],midis=all.map((el)=>Number(el.getAttribute("data-midi"))),fingers=new Map([...svg.querySelectorAll(".mn-key-finger")].map((el)=>[Number(el.getAttribute("data-mn-key")),text(el)])),keys=all.filter((el)=>has(el,"mn-on")).map((el)=>{let midi=Number(el.getAttribute("data-midi"));return{midi,note:spelled(el.getAttribute("data-mn-note")??"",midi),label:labelAfter(el,"mn-key-label"),finger:fingers.get(midi)??null,root:has(el,"mn-root"),marks:marksOf(el),...has(el,"mn-hand-left")?{hand:"left"}:has(el,"mn-hand-right")?{hand:"right"}:{}}}).sort((a,b)=>a.midi-b.midi).map(({midi:_,...key})=>key);return{type:"keyboard",title:text(svg.querySelector(".mn-title")),chord:svg.getAttribute("data-mn-chord"),notes:svg.getAttribute("data-mn-set"),keyRange:[noteOf(Math.min(...midis)),noteOf(Math.max(...midis))],keys,ghosts:all.filter((el)=>has(el,"mn-ghost")).map((el)=>{let midi=Number(el.getAttribute("data-midi"));return spelled(el.getAttribute("data-mn-note")??"",midi)})}}function chart(el){let chords=[];for(let c of el.querySelectorAll(".mn-chord")){let name=text(c);if(name&&!chords.includes(name))chords.push(name)}return{type:"chart",title:text(el.querySelector(".mn-chart-title")),chords,sections:[...el.querySelectorAll(".mn-section-label")].map((s)=>text(s)??"")}}function strum(svg){let tempo=svg.getAttribute("data-mn-tempo"),swing=svg.getAttribute("data-mn-swing");return{type:"strum",title:text(svg.querySelector(".mn-title")),pattern:svg.getAttribute("data-mn-strum")??"",time:svg.getAttribute("data-mn-time")??"",subdivision:svg.getAttribute("data-mn-subdivision")??"",tempo:tempo===null?null:Number(tempo),...swing===null?{}:{swing:Number(swing)},chords:[...svg.querySelectorAll("[data-mn-beat][data-mn-chord]")].map((el)=>({beat:Number(el.getAttribute("data-mn-beat")),chord:el.getAttribute("data-mn-chord")??""}))}}function picking(svg){let tempo=svg.getAttribute("data-mn-tempo"),swing=svg.getAttribute("data-mn-swing"),slots=[...svg.querySelectorAll("[data-mn-beat]")],count=Number(svg.getAttribute("data-mn-strings"))||6;return{type:"picking",title:text(svg.querySelector(".mn-title")),pattern:svg.getAttribute("data-mn-picking")??"",time:svg.getAttribute("data-mn-time")??"",subdivision:svg.getAttribute("data-mn-subdivision")??"",tempo:tempo===null?null:Number(tempo),...swing===null?{}:{swing:Number(swing)},chords:slots.filter((el)=>el.hasAttribute("data-mn-chord")).map((el)=>({bar:Number(el.getAttribute("data-mn-bar")),chord:el.getAttribute("data-mn-chord")??""})),notes:slots.map((el)=>{let notes=(el.getAttribute("data-mn-notes")??"").split(" ").filter(Boolean);return notes.length?notes.map((n)=>{let[string,fret]=n.split(":");return`${count-Number(string)}:${fret}`}).join("+"):"-"})}}function describeBlock(el){return[...el.querySelectorAll("svg.mn-svg, .mn-chart, .mn-cell.mn-error, .mn-exercise, .mn-exercise-tab")].map((d)=>{if(has(d,"mn-exercise")||has(d,"mn-exercise-tab"))return{type:"exercise",direction:d.getAttribute("data-mn-exercise")??"",rhythm:d.getAttribute("data-mn-rhythm")??"",tempo:Number(d.getAttribute("data-mn-tempo")),...d.hasAttribute("data-mn-capo")?{capo:Number(d.getAttribute("data-mn-capo"))}:{},notes:(d.getAttribute("data-mn-notes")??"").split(" ").filter(Boolean)};if(has(d,"mn-error"))return{type:"error",message:(text(d.querySelector(".mn-error-message"))??"").replace(/^[a-z]+, /,"")};if(has(d,"mn-chart"))return chart(d);if(has(d,"mn-circle"))return{type:"circle",key:d.getAttribute("data-mn-set"),chords:[...d.querySelectorAll(".mn-circle-chip")].map((c)=>`${text(c.querySelector("title"))?.replace(": "," ")??""}`)};if(has(d,"mn-fretboard"))return fretboard(d);if(has(d,"mn-keyboard"))return withWords(d,keyboard(d));if(has(d,"mn-strum"))return strum(d);if(has(d,"mn-picking"))return picking(d);return withWords(d,guitarChord(d))})}function withWords(svg,diagram){let words=text(svg.closest("figure.mn-captioned")?.querySelector(".mn-fingering")??null);return words?{...diagram,words}:diagram}var quoted=(s)=>s?`"${s}"`:null,listed=(parts)=>parts.filter(Boolean).join(", "),extra=(label,root,more=[])=>[label!==null?`"${label}"`:null,root?"root":null,...more].filter(Boolean).join(" "),capoText=(capo,from)=>`capo ${capo}${from==="nut"?", frets from the nut":""}`;function formatDiagram(d,n){let lines=formatLines(d,n);if((d.type==="guitar-chord"||d.type==="keyboard")&&d.words)lines.push(`${" ".repeat(`${n}. `.length)}words: ${d.words}`);return lines}function formatLines(d,n){let head=`${n}. `,pad=" ".repeat(head.length);switch(d.type){case"error":return[`${head}error: ${d.message}`];case"exercise":return[`${head}${listed(["exercise",d.direction,d.rhythm,`tempo ${d.tempo}`,...d.capo?[`capo ${d.capo}`]:[],`${d.notes.length} notes`])}`,`${pad}${d.notes.join(" ")}`];case"circle":return[`${head}${listed(["circle of fifths",d.key,`chords ${d.chords.join(", ")}`])}`];case"strum":return[`${head}${listed(["strumming pattern",quoted(d.title),d.time,d.subdivision,d.swing!==void 0&&(Math.abs(d.swing-0.6666666666666666)<0.001?"swing":`swing ${Math.round(d.swing*100)}%`),d.tempo!==null&&`tempo ${d.tempo}`])}`,`${pad}${d.pattern}`];case"picking":return[`${head}${listed(["picking pattern",quoted(d.title),d.time,d.subdivision,d.swing!==void 0&&`swing ${Math.round(d.swing*100)}%`,d.tempo!==null&&`tempo ${d.tempo}`,d.chords.length>0&&`chords ${d.chords.map((c)=>`${c.chord} (bar ${c.bar+1})`).join(" ")}`])}`,`${pad}${d.pattern}`,`${pad}notes (string:fret) ${d.notes.join(" ")}`];case"chart":return[`${head}${listed(["chart",quoted(d.title),d.sections.length>0&&`sections ${d.sections.join(", ")}`,`chords ${d.chords.join(" ")||"none"}`])}`];case"guitar-chord":{let strings=d.strings.map((s)=>`${s.string} ${s.fret===null?"x":[s.fret,s.note,extra(s.label,s.root,s.mark?[s.mark]:[])].filter((p)=>p!==null&&p!=="").join(" ")}`);return[`${head}${listed(["chord diagram",quoted(d.title),d.chord&&`chord ${d.chord}`,d.capo!==void 0&&capoText(d.capo,d.fretsFrom),d.sounds!==void 0&&`sounds ${d.sounds}`,`frets ${d.fretRange[0]}-${d.fretRange[1]}`,d.frets,...(d.barres??[]).map((b)=>`barre ${b.finger} at fret ${b.fret}, strings ${b.from} to ${b.to}`)])}`,`${pad}strings: ${strings.join(" | ")}`]}case"fretboard":{let lines=[`${head}${listed(["fretboard",quoted(d.title),d.notes,d.capo!==void 0&&capoText(d.capo,d.fretsFrom),`frets ${d.fretRange[0]}-${d.fretRange[1]}`,`tuning ${d.tuning.join(" ")}`])}`],count=d.tuning.length;for(let string=count;string>=1;string--){let dots=d.dots.filter((dot)=>dot.string===string);if(!dots.length)continue;let name=d.tuning[count-string]??"?";lines.push(`${pad}string ${string} (${name}): ${dots.map((dot)=>[dot.fret,dot.note,extra(dot.label,dot.root,dot.marks)].filter((p)=>p!=="").join(" ")).join(", ")}`)}if(d.ghosts.length)lines.push(`${pad}ghosts (compared scale): ${d.ghosts.map((g)=>`string ${g.string} fret ${g.fret} ${g.note}`).join(", ")}`);return lines}case"keyboard":return[`${head}${listed(["keyboard",quoted(d.title),d.chord&&`chord ${d.chord}`,d.notes,`keys ${d.keyRange[0]}-${d.keyRange[1]}`])}`,`${pad}keys: ${d.keys.map((k)=>[k.note,extra(k.label,k.root,[...k.finger?[`finger ${k.finger}`]:[],...k.hand?[`${k.hand} hand`]:[],...k.marks])].filter(Boolean).join(" ")).join(", ")||"none"}`,...d.ghosts.length?[`${pad}ghosts (compared scale): ${d.ghosts.join(", ")}`]:[]]}}var DIAGRAM_LANGUAGES=["chord","keyboard","fretboard"],oneLine=(s)=>s.split(/[\r\n]+/).map((line)=>line.trim()).filter(Boolean).join(" ");function checkNote(file,text,doc){let note=parseMarkdown(text),reports=[];for(let block of note.blocks){let{language,line,source}=block,report=(status,message,diagrams=[])=>reports.push({file,line,language,status,message,diagrams}),isTab=language==="tab"||language==="score";if((isTab||isNotationLanguage(language))&&!source.trim()){if(note.frontMatter!==null&&DIAGRAM_LANGUAGES.includes(language))report("skipped","empty block: draws from the note's properties, not checked");else report("empty","empty block: draws nothing");continue}if(isTab){try{parseTabSource(language,source),report("skipped","alphaTex is not checked (it needs alphaTab)")}catch(e){report("error",oneLine(e instanceof Error?e.message:String(e)))}continue}if(!isNotationLanguage(language))continue;let host=doc.createElement("div"),result=renderBlock(language,source,host,{voicings:lookupGuitarVoicing}),diagrams=describeBlock(result.el);if(result.ok)report("ok",null,diagrams);else report("error",oneLine(result.error??"error"),diagrams);result.destroy()}return reports}function summarize(files,reports){let count=(status)=>reports.filter((r)=>r.status===status).length;return{files,blocks:reports.length,ok:count("ok"),errors:count("error"),skipped:count("skipped"),empty:count("empty")}}var formatError=(r)=>`${r.file}:${r.line}: ${r.language}: ${r.message}`;function formatReport(r){let where=`${r.file}:${r.line}: ${r.language}`;return r.status==="ok"?`${where}: ok`:`${where}: ${r.status}: ${r.message??""}`}function formatDescription(r){return[formatReport(r),...r.diagrams.flatMap((d,i)=>formatDiagram(d,i+1)).map((l)=>` ${l}`)]}var GLOB=/[*?[{]/;function globToRegExp(pattern){let out="";for(let i=0;i<pattern.length;i++){let c=pattern[i];if(c==="*"&&pattern[i+1]==="*"){let slash=pattern[i+2]==="/";out+=slash?"(?:.*/)?":".*",i+=slash?2:1}else if(c==="*")out+="[^/]*";else if(c==="?")out+="[^/]";else if(c==="{"){let end=pattern.indexOf("}",i);if(end<0)out+="\\{";else out+=`(?:${pattern.slice(i+1,end).split(",").map((p)=>p.replace(/[.+^$()|\\]/g,"\\$&").replace(/\*/g,"[^/]*")).join("|")})`,i=end}else if(c==="["){let end=pattern.indexOf("]",i+1);if(end<0)out+="\\[";else out+=`[${pattern.slice(i+1,end).replace(/^!/,"^").replace(/\\/g,"\\\\")}]`,i=end}else out+=c.replace(/[.+^$()|\\\]}]/g,"\\$&")}return new RegExp(`^${out}$`)}async function walk(dir){let entries=await readdir(dir,{withFileTypes:!0}),files=[];for(let entry of entries.sort((a,b)=>a.name.localeCompare(b.name))){let path=join(dir,entry.name);if(entry.isDirectory()){if(!entry.name.startsWith(".")&&entry.name!=="node_modules")files.push(...await walk(path))}else if(entry.isFile())files.push(path)}return files}var isMarkdown=(path)=>/\.(md|markdown)$/i.test(path);async function expand(arg,cwd){let pattern=arg.replace(/\\/g,"/"),path=resolve(cwd,arg),info=await stat(path).catch(()=>null);if(info)return info.isDirectory()?(await walk(path)).filter(isMarkdown):[path];if(!GLOB.test(pattern))throw Error(`${arg}: no such file or folder`);let segments=pattern.split("/"),first=segments.findIndex((s)=>GLOB.test(s)),base=resolve(cwd,segments.slice(0,first).join("/")||"."),matcher=globToRegExp(segments.slice(first).join("/"));if(!(await stat(base).catch(()=>null))?.isDirectory())return[];return(await walk(base)).filter((f)=>matcher.test(relative(base,f).replace(/\\/g,"/")))}var USAGE=`Usage: music-notation check [options] <files, folders or globs...>
|
|
33
|
+
`)})}return{frontMatter,blocks}}import{chordNoteSet,midiOf,nameOf,noteOf}from"./index.js";var classes=(el)=>(el.getAttribute("class")??"").split(/\s+/),has=(el,cls)=>classes(el).includes(cls),text=(el)=>el?.textContent?.trim()||null,int=(value)=>value===null?null:Number(value),marksOf=(el)=>classes(el).flatMap((c)=>c==="mn-char"?["characteristic"]:c==="mn-diff"?["different"]:c==="mn-tone"?["chord tone"]:c==="mn-passing"?["passing"]:[]);function spelled(name,midi){let octave=Math.floor(midi/12)-1;for(let o of[octave,octave-1,octave+1])if(midiOf(`${name}${o}`)===midi)return`${name}${o}`;return noteOf(midi)}var labelAfter=(el,cls)=>{let next=el.nextElementSibling;return next&&has(next,cls)?text(next):null};function capoOf(svg){let capo=int(svg.getAttribute("data-mn-capo"));if(!capo)return{};return{capo,fretsFrom:svg.getAttribute("data-mn-frets-from")==="nut"?"nut":"capo"}}function guitarChord(svg){let chord=svg.getAttribute("data-mn-chord"),sounds=svg.getAttribute("data-mn-sounds"),set=sounds?chordNoteSet(sounds):chord?chordNoteSet(chord):null,strings=[...svg.querySelectorAll("[data-mn-string]")].map((el)=>{let fret=int(el.getAttribute("data-mn-fret")),midi=int(el.getAttribute("data-midi")),name=midi===null?null:set?.members.find((m)=>m.chroma===midi%12)?.name??nameOf(midi,set?.preferFlats);return{string:Number(el.getAttribute("data-mn-string")),fret,note:name!==null&&midi!==null?spelled(name,midi):null,label:fret?labelAfter(el,"mn-dot-text"):null,root:has(el,"mn-root"),mark:has(el,"mn-anchor")?"anchor":has(el,"mn-guide")?"guide":null}}),base=parseInt(text(svg.querySelector(".mn-base-fret"))??"1",10),rows=svg.querySelectorAll("line.mn-fret, line.mn-nut").length-1,frets=strings.map((s)=>s.fret===null?"x":String(s.fret)),barres=[...svg.querySelectorAll(".mn-barre")].map((el)=>({finger:el.getAttribute("data-mn-finger")??"",fret:Number(el.getAttribute("data-mn-fret")),from:Number(el.getAttribute("data-mn-from")),to:Number(el.getAttribute("data-mn-to"))}));return{type:"guitar-chord",title:text(svg.querySelector(".mn-title")),chord,frets:frets.join(frets.some((f)=>f.length>1)?"-":""),fretRange:[base,base+rows-1],strings,...capoOf(svg),...sounds?{sounds}:{},...barres.length?{barres}:{}}}function fretboard(svg){let range=(svg.getAttribute("data-mn-frets")??"0-0").split("-").map(Number),tuning=[...svg.querySelectorAll(".mn-string-name")].map((el)=>text(el)??"?"),dots=[...svg.querySelectorAll(".mn-dot[data-mn-string]")].map((el)=>({string:Number(el.getAttribute("data-mn-string")),fret:Number(el.getAttribute("data-mn-fret")),note:spelled(el.getAttribute("data-mn-note")??"",Number(el.getAttribute("data-midi"))),label:labelAfter(el,"mn-dot-text"),root:has(el,"mn-root"),marks:marksOf(el)})).sort((a,b)=>b.string-a.string||a.fret-b.fret),ghosts=[...svg.querySelectorAll("circle[data-mn-ghost-string]")].map((el)=>({string:Number(el.getAttribute("data-mn-ghost-string")),fret:Number(el.getAttribute("data-mn-fret")),note:spelled(el.getAttribute("data-mn-note")??"",Number(el.getAttribute("data-mn-pitch")))})).sort((a,b)=>b.string-a.string||a.fret-b.fret);return{type:"fretboard",title:text(svg.querySelector(".mn-title")),notes:svg.getAttribute("data-mn-set"),fretRange:[range[0]??0,range[1]??0],tuning:tuning.reverse(),dots,ghosts,...capoOf(svg)}}function keyboard(svg){let all=[...svg.querySelectorAll("rect[data-midi]")],midis=all.map((el)=>Number(el.getAttribute("data-midi"))),fingers=new Map([...svg.querySelectorAll(".mn-key-finger")].map((el)=>[Number(el.getAttribute("data-mn-key")),text(el)])),keys=all.filter((el)=>has(el,"mn-on")).map((el)=>{let midi=Number(el.getAttribute("data-midi"));return{midi,note:spelled(el.getAttribute("data-mn-note")??"",midi),label:labelAfter(el,"mn-key-label"),finger:fingers.get(midi)??null,root:has(el,"mn-root"),marks:marksOf(el),...has(el,"mn-hand-left")?{hand:"left"}:has(el,"mn-hand-right")?{hand:"right"}:{}}}).sort((a,b)=>a.midi-b.midi).map(({midi:_,...key})=>key);return{type:"keyboard",title:text(svg.querySelector(".mn-title")),chord:svg.getAttribute("data-mn-chord"),notes:svg.getAttribute("data-mn-set"),keyRange:[noteOf(Math.min(...midis)),noteOf(Math.max(...midis))],keys,ghosts:all.filter((el)=>has(el,"mn-ghost")).map((el)=>{let midi=Number(el.getAttribute("data-midi"));return spelled(el.getAttribute("data-mn-note")??"",midi)})}}function chart(el){let chords=[];for(let c of el.querySelectorAll(".mn-chord")){let name=text(c);if(name&&!chords.includes(name))chords.push(name)}return{type:"chart",title:text(el.querySelector(".mn-chart-title")),chords,sections:[...el.querySelectorAll(".mn-section-label")].map((s)=>text(s)??"")}}function strum(svg){let tempo=svg.getAttribute("data-mn-tempo"),swing=svg.getAttribute("data-mn-swing");return{type:"strum",title:text(svg.querySelector(".mn-title")),pattern:svg.getAttribute("data-mn-strum")??"",time:svg.getAttribute("data-mn-time")??"",subdivision:svg.getAttribute("data-mn-subdivision")??"",tempo:tempo===null?null:Number(tempo),...swing===null?{}:{swing:Number(swing)},chords:[...svg.querySelectorAll("[data-mn-beat][data-mn-chord]")].map((el)=>({beat:Number(el.getAttribute("data-mn-beat")),chord:el.getAttribute("data-mn-chord")??""}))}}function picking(svg){let tempo=svg.getAttribute("data-mn-tempo"),swing=svg.getAttribute("data-mn-swing"),slots=[...svg.querySelectorAll("[data-mn-beat]")],count=Number(svg.getAttribute("data-mn-strings"))||6;return{type:"picking",title:text(svg.querySelector(".mn-title")),pattern:svg.getAttribute("data-mn-picking")??"",time:svg.getAttribute("data-mn-time")??"",subdivision:svg.getAttribute("data-mn-subdivision")??"",tempo:tempo===null?null:Number(tempo),...swing===null?{}:{swing:Number(swing)},chords:slots.filter((el)=>el.hasAttribute("data-mn-chord")).map((el)=>({bar:Number(el.getAttribute("data-mn-bar")),chord:el.getAttribute("data-mn-chord")??""})),notes:slots.map((el)=>{let notes=(el.getAttribute("data-mn-notes")??"").split(" ").filter(Boolean);return notes.length?notes.map((n)=>{let[string,fret]=n.split(":");return`${count-Number(string)}:${fret}`}).join("+"):"-"})}}function describeBlock(el){return[...el.querySelectorAll("svg.mn-svg, .mn-chart, .mn-cell.mn-error, .mn-exercise, .mn-exercise-tab")].map((d)=>{if(has(d,"mn-exercise")||has(d,"mn-exercise-tab"))return{type:"exercise",direction:d.getAttribute("data-mn-exercise")??"",rhythm:d.getAttribute("data-mn-rhythm")??"",tempo:Number(d.getAttribute("data-mn-tempo")),...d.hasAttribute("data-mn-capo")?{capo:Number(d.getAttribute("data-mn-capo"))}:{},notes:(d.getAttribute("data-mn-notes")??"").split(" ").filter(Boolean)};if(has(d,"mn-error"))return{type:"error",message:(text(d.querySelector(".mn-error-message"))??"").replace(/^[a-z]+, /,"")};if(has(d,"mn-chart"))return chart(d);if(has(d,"mn-circle"))return{type:"circle",key:d.getAttribute("data-mn-set"),chords:[...d.querySelectorAll(".mn-circle-chip")].map((c)=>`${text(c.querySelector("title"))?.replace(": "," ")??""}`)};if(has(d,"mn-fretboard"))return fretboard(d);if(has(d,"mn-keyboard"))return withWords(d,keyboard(d));if(has(d,"mn-strum"))return strum(d);if(has(d,"mn-picking"))return picking(d);return withWords(d,guitarChord(d))})}function withWords(svg,diagram){let words=text(svg.closest("figure.mn-captioned")?.querySelector(".mn-fingering")??null);return words?{...diagram,words}:diagram}var quoted=(s)=>s?`"${s}"`:null,listed=(parts)=>parts.filter(Boolean).join(", "),extra=(label,root,more=[])=>[label!==null?`"${label}"`:null,root?"root":null,...more].filter(Boolean).join(" "),capoText=(capo,from)=>`capo ${capo}${from==="nut"?", frets from the nut":""}`;function formatDiagram(d,n){let lines=formatLines(d,n);if((d.type==="guitar-chord"||d.type==="keyboard")&&d.words)lines.push(`${" ".repeat(`${n}. `.length)}words: ${d.words}`);return lines}function formatLines(d,n){let head=`${n}. `,pad=" ".repeat(head.length);switch(d.type){case"error":return[`${head}error: ${d.message}`];case"exercise":return[`${head}${listed(["exercise",d.direction,d.rhythm,`tempo ${d.tempo}`,...d.capo?[`capo ${d.capo}`]:[],`${d.notes.length} notes`])}`,`${pad}${d.notes.join(" ")}`];case"circle":return[`${head}${listed(["circle of fifths",d.key,`chords ${d.chords.join(", ")}`])}`];case"strum":return[`${head}${listed(["strumming pattern",quoted(d.title),d.time,d.subdivision,d.swing!==void 0&&(Math.abs(d.swing-0.6666666666666666)<0.001?"swing":`swing ${Math.round(d.swing*100)}%`),d.tempo!==null&&`tempo ${d.tempo}`])}`,`${pad}${d.pattern}`];case"picking":return[`${head}${listed(["picking pattern",quoted(d.title),d.time,d.subdivision,d.swing!==void 0&&`swing ${Math.round(d.swing*100)}%`,d.tempo!==null&&`tempo ${d.tempo}`,d.chords.length>0&&`chords ${d.chords.map((c)=>`${c.chord} (bar ${c.bar+1})`).join(" ")}`])}`,`${pad}${d.pattern}`,`${pad}notes (string:fret) ${d.notes.join(" ")}`];case"chart":return[`${head}${listed(["chart",quoted(d.title),d.sections.length>0&&`sections ${d.sections.join(", ")}`,`chords ${d.chords.join(" ")||"none"}`])}`];case"guitar-chord":{let strings=d.strings.map((s)=>`${s.string} ${s.fret===null?"x":[s.fret,s.note,extra(s.label,s.root,s.mark?[s.mark]:[])].filter((p)=>p!==null&&p!=="").join(" ")}`);return[`${head}${listed(["chord diagram",quoted(d.title),d.chord&&`chord ${d.chord}`,d.capo!==void 0&&capoText(d.capo,d.fretsFrom),d.sounds!==void 0&&`sounds ${d.sounds}`,`frets ${d.fretRange[0]}-${d.fretRange[1]}`,d.frets,...(d.barres??[]).map((b)=>`barre ${b.finger} at fret ${b.fret}, strings ${b.from} to ${b.to}`)])}`,`${pad}strings: ${strings.join(" | ")}`]}case"fretboard":{let lines=[`${head}${listed(["fretboard",quoted(d.title),d.notes,d.capo!==void 0&&capoText(d.capo,d.fretsFrom),`frets ${d.fretRange[0]}-${d.fretRange[1]}`,`tuning ${d.tuning.join(" ")}`])}`],count=d.tuning.length;for(let string=count;string>=1;string--){let dots=d.dots.filter((dot)=>dot.string===string);if(!dots.length)continue;let name=d.tuning[count-string]??"?";lines.push(`${pad}string ${string} (${name}): ${dots.map((dot)=>[dot.fret,dot.note,extra(dot.label,dot.root,dot.marks)].filter((p)=>p!=="").join(" ")).join(", ")}`)}if(d.ghosts.length)lines.push(`${pad}ghosts (compared scale): ${d.ghosts.map((g)=>`string ${g.string} fret ${g.fret} ${g.note}`).join(", ")}`);return lines}case"keyboard":return[`${head}${listed(["keyboard",quoted(d.title),d.chord&&`chord ${d.chord}`,d.notes,`keys ${d.keyRange[0]}-${d.keyRange[1]}`])}`,`${pad}keys: ${d.keys.map((k)=>[k.note,extra(k.label,k.root,[...k.finger?[`finger ${k.finger}`]:[],...k.hand?[`${k.hand} hand`]:[],...k.marks])].filter(Boolean).join(" ")).join(", ")||"none"}`,...d.ghosts.length?[`${pad}ghosts (compared scale): ${d.ghosts.join(", ")}`]:[]]}}var DIAGRAM_LANGUAGES=["chord","keyboard","fretboard"],oneLine=(s)=>s.split(/[\r\n]+/).map((line)=>line.trim()).filter(Boolean).join(" ");function checkNote(file,text,doc){let note=parseMarkdown(text),reports=[];for(let block of note.blocks){let{language,line,source}=block,report=(status,message,diagrams=[])=>reports.push({file,line,language,status,message,diagrams}),isTab=language==="tab"||language==="score";if((isTab||isNotationLanguage(language))&&!source.trim()){if(note.frontMatter!==null&&DIAGRAM_LANGUAGES.includes(language))report("skipped","empty block: draws from the note's properties, not checked");else report("empty","empty block: draws nothing");continue}if(isTab){try{parseTabSource(language,source),report("skipped","alphaTex is not checked (it needs alphaTab)")}catch(e){report("error",oneLine(e instanceof Error?e.message:String(e)))}continue}if(!isNotationLanguage(language))continue;let host=doc.createElement("div"),result=renderBlock(language,source,host,{voicings:lookupGuitarVoicing}),diagrams=describeBlock(result.el);if(result.ok)report("ok",null,diagrams);else report("error",oneLine(result.error??"error"),diagrams);result.destroy()}return reports}function summarize(files,reports){let count=(status)=>reports.filter((r)=>r.status===status).length;return{files,blocks:reports.length,ok:count("ok"),errors:count("error"),skipped:count("skipped"),empty:count("empty")}}var formatError=(r)=>`${r.file}:${r.line}: ${r.language}: ${r.message}`;function formatReport(r){let where=`${r.file}:${r.line}: ${r.language}`;return r.status==="ok"?`${where}: ok`:`${where}: ${r.status}: ${r.message??""}`}function formatDescription(r){return[formatReport(r),...r.diagrams.flatMap((d,i)=>formatDiagram(d,i+1)).map((l)=>` ${l}`)]}var GLOB=/[*?[{]/;function globToRegExp(pattern){let out="";for(let i=0;i<pattern.length;i++){let c=pattern[i];if(c==="*"&&pattern[i+1]==="*"){let slash=pattern[i+2]==="/";out+=slash?"(?:.*/)?":".*",i+=slash?2:1}else if(c==="*")out+="[^/]*";else if(c==="?")out+="[^/]";else if(c==="{"){let end=pattern.indexOf("}",i);if(end<0)out+="\\{";else out+=`(?:${pattern.slice(i+1,end).split(",").map((p)=>p.replace(/[.+^$()|\\]/g,"\\$&").replace(/\*/g,"[^/]*")).join("|")})`,i=end}else if(c==="["){let end=pattern.indexOf("]",i+1);if(end<0)out+="\\[";else out+=`[${pattern.slice(i+1,end).replace(/^!/,"^").replace(/\\/g,"\\\\")}]`,i=end}else out+=c.replace(/[.+^$()|\\\]}]/g,"\\$&")}return new RegExp(`^${out}$`)}async function walk(dir){let entries=await readdir(dir,{withFileTypes:!0}),files=[];for(let entry of entries.sort((a,b)=>a.name.localeCompare(b.name))){let path=join(dir,entry.name);if(entry.isDirectory()){if(!entry.name.startsWith(".")&&entry.name!=="node_modules")files.push(...await walk(path))}else if(entry.isFile())files.push(path)}return files}var isMarkdown=(path)=>/\.(md|markdown)$/i.test(path),slashed=(path)=>path.replace(/\\/g,"/");async function expand(arg,cwd){let pattern=slashed(arg),path=resolve(cwd,arg),info=await stat(path).catch(()=>null);if(info)return(info.isDirectory()?(await walk(path)).filter(isMarkdown):[path]).map(slashed);if(!GLOB.test(pattern))throw Error(`${arg}: no such file or folder`);let segments=pattern.split("/"),first=segments.findIndex((s)=>GLOB.test(s)),base=resolve(cwd,segments.slice(0,first).join("/")||"."),matcher=globToRegExp(segments.slice(first).join("/"));if(!(await stat(base).catch(()=>null))?.isDirectory())return[];return(await walk(base)).filter((f)=>matcher.test(slashed(relative(base,f)))).map(slashed)}var USAGE=`Usage: music-notation check [options] <files, folders or globs...>
|
|
34
34
|
|
|
35
35
|
Renders every chord, chords, keyboard, fretboard, strum, picking, progression and circle block
|
|
36
36
|
of Markdown files and reports each mistake as file:line: language: message.
|
package/dist/index.js
CHANGED
|
@@ -13790,6 +13790,52 @@ var styles_default = `/* Music notation. Colors follow Obsidian's theme variable
|
|
|
13790
13790
|
opacity: 0.85;
|
|
13791
13791
|
}
|
|
13792
13792
|
|
|
13793
|
+
/* The tab and score bar's tempo (#114): − 60 BPM + · 70 %. The value is a small field to type in;
|
|
13794
|
+
the unit switches BPM and percent; the other unit, dim, goes back to 100 % on a click. */
|
|
13795
|
+
.mn-tempo {
|
|
13796
|
+
display: inline-flex;
|
|
13797
|
+
align-items: center;
|
|
13798
|
+
gap: 2px;
|
|
13799
|
+
white-space: nowrap;
|
|
13800
|
+
}
|
|
13801
|
+
|
|
13802
|
+
.mn-play .mn-tempo button {
|
|
13803
|
+
min-width: 0;
|
|
13804
|
+
padding: 0 4px;
|
|
13805
|
+
font: inherit;
|
|
13806
|
+
line-height: 1.4;
|
|
13807
|
+
}
|
|
13808
|
+
|
|
13809
|
+
.mn-play .mn-tempo-value {
|
|
13810
|
+
/* Obsidian gives every input border-box and a 30 px height: 3.5ch then held the
|
|
13811
|
+
padding and border too, and "100" was cut. */
|
|
13812
|
+
box-sizing: content-box;
|
|
13813
|
+
width: 3.5ch;
|
|
13814
|
+
height: auto;
|
|
13815
|
+
padding: 0 2px;
|
|
13816
|
+
border: 1px solid var(--mn-faint);
|
|
13817
|
+
border-radius: 4px;
|
|
13818
|
+
background: transparent;
|
|
13819
|
+
color: inherit;
|
|
13820
|
+
font: inherit;
|
|
13821
|
+
font-variant-numeric: tabular-nums;
|
|
13822
|
+
text-align: right;
|
|
13823
|
+
}
|
|
13824
|
+
|
|
13825
|
+
.mn-play .mn-tempo-unit {
|
|
13826
|
+
font-size: 0.9em;
|
|
13827
|
+
}
|
|
13828
|
+
|
|
13829
|
+
.mn-play .mn-tempo-other {
|
|
13830
|
+
opacity: 0.7;
|
|
13831
|
+
font-variant-numeric: tabular-nums;
|
|
13832
|
+
}
|
|
13833
|
+
|
|
13834
|
+
.mn-play .mn-tempo-other:disabled {
|
|
13835
|
+
cursor: default;
|
|
13836
|
+
opacity: 0.55;
|
|
13837
|
+
}
|
|
13838
|
+
|
|
13793
13839
|
/* What Copy as image says (#11): "Copied", or what to do when the browser refuses. */
|
|
13794
13840
|
.mn-play-said {
|
|
13795
13841
|
font-size: 0.85em;
|
|
@@ -16444,5 +16490,5 @@ export {
|
|
|
16444
16490
|
withTonicizations
|
|
16445
16491
|
};
|
|
16446
16492
|
|
|
16447
|
-
//# debugId=
|
|
16493
|
+
//# debugId=790252566EAFD4BC64756E2164756E21
|
|
16448
16494
|
//# sourceMappingURL=index.js.map
|