jpfun 0.7.0 → 0.9.0
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/Bravura-LICENSE.txt +93 -0
- package/README.md +49 -146
- package/dist/Bravura-LICENSE.txt +93 -0
- package/dist/converter/midi/convert.d.ts +0 -10
- package/dist/converter/midi/convert.js +19 -56
- package/dist/converter/musicxml/features.d.ts +16 -8
- package/dist/converter/musicxml/features.js +88 -19
- package/dist/converter/musicxml/index.js +88 -50
- package/dist/converter/musicxml/model.d.ts +9 -0
- package/dist/converter/source.d.ts +4 -7
- package/dist/converter/source.js +11 -9
- package/dist/core.d.ts +1 -0
- package/dist/core.js +1 -0
- package/dist/diagnostic.d.ts +7 -1
- package/dist/diagnostic.js +40 -88
- package/dist/fraction.js +3 -2
- package/dist/functions/ASTtypes.d.ts +3 -32
- package/dist/functions/ASTtypes.js +5 -52
- package/dist/functions/adjust/index.js +45 -33
- package/dist/functions/arpeggio/index.js +50 -55
- package/dist/functions/arpeggio/shape.d.ts +2 -3
- package/dist/functions/arpeggio/shape.js +20 -50
- package/dist/functions/bar/index.d.ts +8 -0
- package/dist/functions/bar/index.js +105 -8
- package/dist/functions/beam/auto.d.ts +1 -2
- package/dist/functions/beam/auto.js +80 -135
- package/dist/functions/beam/index.js +6 -12
- package/dist/functions/beam/layout.d.ts +1 -1
- package/dist/functions/beam/layout.js +1 -1
- package/dist/functions/box/index.js +0 -6
- package/dist/functions/br/index.d.ts +34 -2
- package/dist/functions/br/index.js +5 -4
- package/dist/functions/dash/index.js +9 -10
- package/dist/functions/default.js +2 -1
- package/dist/functions/div/index.d.ts +3 -4
- package/dist/functions/div/index.js +18 -14
- package/dist/functions/dot/index.js +5 -11
- package/dist/functions/dyn/index.js +55 -57
- package/dist/functions/gliss/index.js +131 -103
- package/dist/functions/grace/index.d.ts +3 -12
- package/dist/functions/grace/index.js +52 -102
- package/dist/functions/head/index.js +10 -7
- package/dist/functions/key/index.js +13 -15
- package/dist/functions/meter/index.d.ts +56 -1
- package/dist/functions/meter/index.js +15 -10
- package/dist/functions/note/index.js +6 -6
- package/dist/functions/note/noteName.d.ts +16 -0
- package/dist/functions/note/noteName.js +88 -0
- package/dist/functions/note/source-transform.js +8 -10
- package/dist/functions/ottava/index.js +35 -40
- package/dist/functions/page/index.d.ts +1 -0
- package/dist/functions/page/index.js +27 -21
- package/dist/functions/pagebreak/index.js +2 -2
- package/dist/functions/rest/index.js +5 -5
- package/dist/functions/set/index.js +4 -4
- package/dist/functions/slide/index.js +0 -1
- package/dist/functions/stack/index.js +8 -57
- package/dist/functions/symbol/index.d.ts +21 -2
- package/dist/functions/symbol/index.js +69 -24
- package/dist/functions/symbol/ornament.d.ts +1 -2
- package/dist/functions/symbol/shape.d.ts +6 -0
- package/dist/functions/symbol/shape.js +16 -3
- package/dist/functions/symbol/symbols/coda.d.ts +4 -0
- package/dist/functions/symbol/symbols/coda.js +56 -0
- package/dist/functions/symbol/symbols/dynamics.d.ts +1 -1
- package/dist/functions/symbol/symbols/dynamics.js +18 -8
- package/dist/functions/symbol/symbols/harmonic.d.ts +2 -0
- package/dist/functions/symbol/symbols/harmonic.js +11 -0
- package/dist/functions/symbol/symbols/marcato.d.ts +2 -0
- package/dist/functions/symbol/symbols/marcato.js +22 -0
- package/dist/functions/symbol/symbols/staccato.d.ts +2 -0
- package/dist/functions/symbol/symbols/staccato.js +24 -0
- package/dist/functions/symbol/symbols/tenuto.d.ts +2 -0
- package/dist/functions/symbol/symbols/tenuto.js +11 -0
- package/dist/functions/symbol/symbols/tocoda.d.ts +2 -0
- package/dist/functions/symbol/symbols/tocoda.js +16 -0
- package/dist/functions/symbol/symbols/turn.d.ts +3 -0
- package/dist/functions/symbol/symbols/turn.js +50 -0
- package/dist/functions/symbol/symbols/wheel.d.ts +2 -0
- package/dist/functions/symbol/symbols/wheel.js +36 -0
- package/dist/functions/temporal.d.ts +3 -2
- package/dist/functions/temporal.js +8 -0
- package/dist/functions/text/index.js +38 -35
- package/dist/functions/tie/index.js +44 -43
- package/dist/functions/tremolo/index.d.ts +2 -0
- package/dist/functions/tremolo/index.js +318 -0
- package/dist/functions/tuplet/index.js +4 -14
- package/dist/functions/up/index.js +81 -85
- package/dist/functions/voice/connections.d.ts +2 -1
- package/dist/functions/voice/connections.js +48 -10
- package/dist/functions/voice/index.d.ts +2 -3
- package/dist/functions/voice/index.js +2 -963
- package/dist/functions/voice/lyrics.d.ts +30 -0
- package/dist/functions/voice/lyrics.js +289 -0
- package/dist/functions/voice/voice.d.ts +63 -0
- package/dist/functions/voice/voice.js +373 -0
- package/dist/functions/voice/voices.d.ts +106 -0
- package/dist/functions/voice/voices.js +423 -0
- package/dist/functions/volta/index.js +5 -23
- package/dist/jpfun.core.min.js +76 -59
- package/dist/jpfun.from-midi.min.js +5 -5
- package/dist/jpfun.from-musicxml.min.js +8 -8
- package/dist/jpfun.min.js +81 -64
- package/dist/layout/default.d.ts +0 -1
- package/dist/layout/default.js +0 -1
- package/dist/layout/engine.js +30 -18
- package/dist/layout/model.d.ts +0 -1
- package/dist/layout/model.js +1 -4
- package/dist/layout/page.d.ts +2 -1
- package/dist/layout/page.js +14 -14
- package/dist/layout/range.d.ts +7 -6
- package/dist/layout/range.js +23 -14
- package/dist/layout/types.d.ts +9 -28
- package/dist/lowering/loweringContext.d.ts +18 -23
- package/dist/lowering/loweringContext.js +33 -46
- package/dist/lowering/track.d.ts +8 -1
- package/dist/lowering/types.d.ts +13 -11
- package/dist/parser/parse-utils/call-utils.d.ts +1 -2
- package/dist/parser/parse-utils/call-utils.js +6 -34
- package/dist/parser/parse-utils/note-utils.d.ts +3 -3
- package/dist/parser/parse-utils/note-utils.js +21 -33
- package/dist/parser/parse-utils/string-utils.d.ts +3 -2
- package/dist/parser/parse-utils/string-utils.js +20 -5
- package/dist/parser/parserContext.d.ts +9 -9
- package/dist/parser/parserContext.js +62 -11
- package/dist/pipeline.js +2 -3
- package/dist/playback/compile.js +131 -82
- package/dist/playback/event.d.ts +6 -6
- package/dist/playback/event.js +13 -49
- package/dist/playback/time.js +42 -31
- package/dist/playback/types.d.ts +3 -1
- package/dist/render/canvas.js +4 -22
- package/dist/render/recording.js +1 -4
- package/dist/render/svg.d.ts +0 -1
- package/dist/render/svg.js +33 -31
- package/dist/render/text.d.ts +36 -1
- package/dist/render/text.js +134 -0
- package/dist/render/translate.d.ts +0 -1
- package/dist/render/translate.js +6 -23
- package/dist/render/types.d.ts +0 -2
- package/grammar.md +39 -30
- package/package.json +3 -3
- package/dist/functions/note/noteNameFSM.d.ts +0 -8
- package/dist/functions/note/noteNameFSM.js +0 -181
- package/dist/iife/core.d.ts +0 -1
- package/dist/iife/core.js +0 -3
- package/dist/iife/from-midi.d.ts +0 -1
- package/dist/iife/from-midi.js +0 -15
- package/dist/iife/from-musicxml.d.ts +0 -1
- package/dist/iife/from-musicxml.js +0 -3
- package/dist/iife/full.d.ts +0 -1
- package/dist/iife/full.js +0 -3
package/dist/jpfun.min.js
CHANGED
|
@@ -1,128 +1,145 @@
|
|
|
1
1
|
/*! jpfun | Apache-2.0 | github.com/madderscientist/jpFun */
|
|
2
|
-
"use strict";(()=>{var tc=Object.defineProperty;var ec=(s,t)=>{for(var e in t)tc(s,e,{get:t[e],enumerable:!0})};var ui={};ec(ui,{ANCHOR_KEY:()=>mt,ASTBraceNode:()=>dt,ASTFunctionNode:()=>$,ASTLabelNode:()=>Ht,ASTNodeBase:()=>Tt,ASTTextNode:()=>xt,CanvasPainter:()=>Jn,CanvasTextMeasurer:()=>Wo,DEFAULT_BPM:()=>Jt,DEFAULT_FONT_SIZE:()=>xr,DEFAULT_KEY:()=>Dt,DEFAULT_OCTAVE:()=>Wc,DEFAULT_PAGE_CONFIG:()=>Ct,DEFAULT_PROGRAM:()=>gn,DEFAULT_TEXT_FONT:()=>Oe,DEFAULT_TONALITY:()=>Ue,DEFAULT_VELOCITY:()=>Le,DefaultTextMeasurer:()=>Ln,Diagnostic:()=>H,ErrorDiagnostic:()=>k,Fraction:()=>F,JIANPU_NUMBER_FONT:()=>Go,LoweringContext:()=>cn,PageLayoutError:()=>Me,ParserContext:()=>_t,RecordingPainter:()=>Zs,SvgPainter:()=>Qn,TemporalNodeBase:()=>tt,Track:()=>pe,WarningDiagnostic:()=>q,analyzeScoreSyntax:()=>Dl,canvasFont:()=>Cn,compilePlayback:()=>Hl,compileScore:()=>Ks,completeSpringConfig:()=>wn,createLayoutPrepareContext:()=>Gs,defaultFunctions:()=>qn,defaultTextMeasurer:()=>Vo,functionAddonKey:()=>ce,getLayoutBounds:()=>wt,isLayoutAttachment:()=>Wt,isPlaybackRelation:()=>Ys,isVisualTemporalNode:()=>X,layoutDocument:()=>bo,layoutElement:()=>Sn,layoutHorizontal:()=>fo,layoutHorizontalRegion:()=>ve,layoutLocalSequence:()=>ke,layoutPageBounds:()=>ge,midiJsonToJpFun:()=>hf,musicXmlToJpFun:()=>Mf,normalizePageConfig:()=>je,paginateLayoutLines:()=>po,paintLayout:()=>qs,paintLayoutPages:()=>ze,performanceTimeToScoreTime:()=>ga,performanceTimeToSeconds:()=>Zn,prepareHorizontalLine:()=>wo,prepareLayoutHost:()=>Xe,preprocessSource:()=>Pe,primaryName:()=>Ve,renderLayoutPagesToCanvas:()=>jl,renderLayoutPagesToSvg:()=>Vl,resolveArgDef:()=>Ei,resolveArgType:()=>Te,scoreTimeToPerformanceTime:()=>ba,scoreTimeToSeconds:()=>Fl,secondsToPerformanceTime:()=>ya,secondsToScoreTime:()=>Bl,skipSpaces:()=>Yt,skipSpacesBack:()=>en,transferFunctionAddons:()=>le,transformNotes:()=>Rr,unionLayoutBoxes:()=>Ne});var H=class s{code;message;span;constructor(t,e,n){this.code=t,this.message=e,this.span=n}toLineCol(t){let e=s.offsetToLineCol(this.span.start,t),n=s.offsetToLineCol(this.span.end,t);return{startLine:e.line,startColumn:e.column,endLine:n.line,endColumn:n.column}}static offsetToLineCol(t,e){let n=e.length;if(n===0)return{line:1,column:Math.max(0,t)+1};let o=t;o<0&&(o=0);let i=0,r=n-1;for(;i<=r;){let l=i+r>>1;e[l]<=o?i=l+1:r=l-1}let a=Math.max(0,r),c=e[a]??0;return{line:a+1,column:o-c+1}}static error;static warning},k=class extends H{},q=class extends H{};H.error={Bug:(s,t)=>new k("E_BUG",`\u89E3\u6790\u5668\u9519\u8BEF: ${s}\uFF0C\u8BF7\u8054\u7CFB\u5F00\u53D1\u8005\u4FEE\u590D\u8FD9\u4E2A\u95EE\u9898`,t),MissingArg:(s,t,e)=>{let n=typeof t=="number"?`[${t}]`:`"${t}"`;return new k("E_MISSING_REQUIRED_ARG",`\u51FD\u6570@${s} \u7F3A\u5C11\u5FC5\u9700\u7684\u53C2\u6570 ${n}`,e)},InvalidArgType:(s,t,e,n,o)=>{let i=typeof t=="number"?`[${t}]`:`"${t}"`;return new k("E_WRONG_ARG_TYPE",`\u51FD\u6570 @${s} \u7684\u53C2\u6570 ${i} \u7C7B\u578B\u9519\u8BEF: \u5F97\u5230\u4E86 ${n}\uFF0C\u4F46\u671F\u671B ${e}`,o)},PosAfterNamedArg:(s,t)=>new k("E_POSARG_AFTER_KWARG",`\u51FD\u6570 @${s} \u7684\u4F4D\u7F6E\u53C2\u6570\u51FA\u73B0\u5728\u547D\u540D\u53C2\u6570\u4E4B\u540E\uFF0C\u8FD9\u662F\u4E0D\u5141\u8BB8\u7684`,t),EmptyContent:(s,t,e)=>{let n=typeof t=="number"?`[${t}]`:`"${t}"`;return new k("E_EMPTY_CONTENT",`\u51FD\u6570 @${s} \u7684\u53C2\u6570 ${n} \u5185\u5BB9\u4E3A\u7A7A(\u6216\u65E0\u53EF\u7528\u5185\u5BB9)\uFF1B\u8BF7\u63D0\u4F9B\u6709\u6548\u5185\u5BB9`,e)},UnterminatedCall:(s,t)=>new k("E_UNTERMINATED_CALL",`\u51FD\u6570\u8C03\u7528\u672A\u95ED\u5408: @${s}(...)`,t),UnterminatedString:s=>new k("E_UNTERMINATED_String","\u5F15\u53F7\u672A\u95ED\u5408",s),UnknownFunction:(s,t)=>new k("E_UNKNOWN_FUNCTION",`\u672A\u77E5\u51FD\u6570: @${s}\uFF0C\u8BF7\u68C0\u67E5\u62FC\u5199`,t),UnknownLabel:(s,t)=>new k("E_UNKNOWN_LABEL",`\u672A\u77E5\u6807\u7B7E: "${s}"`,t),InvalidTonality:(s,t)=>new k("E_INVALID_TONALITY",`\u65E0\u6548\u7684\u8C03\u6027: "${s}"\uFF0C\u8BF7\u63D0\u4F9B\u6709\u6548\u7684\u8C03\u6027\u540D\u79F0\uFF0C\u5FC5\u987B [\u4E00\u4E2A\u5927\u5199\u5B57\u6BCD][\u53D8\u97F3\u8BB0\u53F7#bn\u53EA\u80FD\u4E00\u4E2A][\u7EDD\u5BF9\u516B\u5EA6\u6570\u5B57]\uFF0C\u540E\u4E8C\u8005\u53EF\u9009`,t),BreakInsideEvent:s=>new k("E_BREAK_INSIDE_EVENT","\u6362\u884C\u6216\u6362\u9875\u5207\u65AD\u4E86\u4E00\u4E2A\u4ECD\u5728\u6301\u7EED\u7684\u4E8B\u4EF6\uFF1B\u8BF7\u628A\u957F\u97F3\u5199\u6210\u591A\u4E2A\u4E8B\u4EF6\uFF0C\u6216\u8C03\u6574\u6362\u884C\u3001\u6362\u9875\u7684\u4F4D\u7F6E",s),InvalidPageConfig:(s,t)=>new k("E_INVALID_PAGE_CONFIG",s,t),PageOverflow:(s,t,e)=>new k("E_PAGE_OVERFLOW",`\u8C31\u9762\u884C\u9700\u8981 ${s}px \u9AD8\u5EA6\uFF0C\u4F46\u9875\u9762\u5185\u5BB9\u533A\u53EA\u6709 ${t}px`,e)};H.warning={UnknownFunction:(s,t)=>new q("W_UNKNOWN_FUNCTION",`\u672A\u77E5\u51FD\u6570: @${s}\uFF0C\u5C06\u88AB\u5F53\u4F5C\u666E\u901A\u6587\u672C\u5904\u7406`,t),UnknownNamedArg:(s,t,e)=>new q("W_UNKNOWN_NAMED_ARG",`\u51FD\u6570 @${s} \u6536\u5230\u672A\u77E5\u7684\u547D\u540D\u53C2\u6570 "${t}"`,e),TooManyPosArgs:(s,t,e,n)=>new q("W_TOO_MANY_POS_ARGS",`\u51FD\u6570 @${s} \u63A5\u6536\u4E86\u8FC7\u591A\u7684\u4F4D\u7F6E\u53C2\u6570\uFF0C\u671F\u671B ${t} \u4E2A\u4F46\u5F97\u5230\u4E86 ${e} \u4E2A`,n),InvalidNumber:(s,t)=>new q("W_INVALID_NUMBER",`\u65E0\u6548\u7684\u6570\u5B57: "${s}"\uFF1B\u5C06\u4F7F\u7528\u9ED8\u8BA4\u503C(\u82E5\u5B58\u5728)`,t),InvalidBoolean:(s,t)=>new q("W_INVALID_BOOL",`\u65E0\u6548\u7684\u5E03\u5C14\u503C: "${s}": \u5E94\u4E3A 'true' \u6216 'false'\uFF1B\u5C06\u4F7F\u7528\u9ED8\u8BA4\u503C(\u82E5\u5B58\u5728)`,t),InvalidLength:(s,t)=>new q("W_INVALID_LENGTH",`\u65E0\u6548\u7684\u957F\u5EA6\u503C: "${s}"\uFF1B\u8BF7\u63D0\u4F9B\u6709\u6548\u7684\u957F\u5EA6\u503C\uFF0C\u4F8B\u5982 "10px" \u6216 "2em"\uFF1B\u5C06\u4F7F\u7528\u9ED8\u8BA4\u503C(\u82E5\u5B58\u5728)`,t),InvalidLengthUnit:(s,t)=>new q("W_INVALID_LENGTH_UNIT",`\u65E0\u6548\u7684\u957F\u5EA6\u5355\u4F4D: "${s}"\uFF1B\u4EC5\u652F\u6301 "px" \u548C "em"\uFF1B\u8BF7\u68C0\u67E5\u51FD\u6570\u53C2\u6570\u6216\u53D8\u91CF\u5B9A\u4E49\uFF1B\u5C06\u4F7F\u7528\u9ED8\u8BA4\u503C(\u82E5\u5B58\u5728)`,t),InvalidContent:s=>new q("W_INVALID_CONTENT","\u5185\u5BB9\u89E3\u6790\u5931\u8D25\uFF0C\u9519\u8BEF\u539F\u56E0\u89C1\u4E0A\uFF1B\u5C06\u4F7F\u7528\u9ED8\u8BA4\u503C(\u4F46\u5F80\u5F80\u4E0D\u5B58\u5728\uFF0C\u6781\u6709\u53EF\u80FD\u5BFC\u81F4\u9519\u8BEF)",s),EmptyContent:(s,t,e)=>new q("W_EMPTY_CONTENT",`\u51FD\u6570 @${s} \u7684\u53C2\u6570 "${t}" \u5185\u5BB9\u4E3A\u7A7A(\u6216\u65E0\u53EF\u7528\u5185\u5BB9)`,e),UnmatchedBrace:s=>new q("W_UNMATCHED_BRACE","\u672A\u5339\u914D\u7684\u5927\u62EC\u53F7: \u7F3A\u5C11\u53F3\u5927\u62EC\u53F7'}'\uFF1B\u5C06\u5C1D\u8BD5\u81EA\u52A8\u4FEE\u590D",s),LabelWithoutTarget:(s,t)=>new q("W_LABEL_WITHOUT_TARGET",`\u6807\u7B7E "${s}" \u6CA1\u6709\u53EF\u7ED1\u5B9A\u7684\u76EE\u6807\uFF1B\u6807\u7B7E\u5C06\u88AB\u5FFD\u7565`,t),TargetAlreadyLabeled:(s,t,e)=>new q("W_TARGET_ALREADY_LABELED",`\u76EE\u6807\u5DF2\u6807\u6CE8\u4E3A "${t}"\uFF0C"${s}" \u5C06\u88AB\u5FFD\u7565`,e),UnresolvedEndpoint:(s,t)=>new q("W_UNRESOLVED_ENDPOINT",`@${s} \u6709\u7AEF\u70B9\u627E\u4E0D\u5230\u5BF9\u5E94\u7684\u8C31\u9762\u5BF9\u8C61\uFF1B\u8BE5\u5173\u7CFB\u5C06\u88AB\u5FFD\u7565`,t),ZeroTimeTrack:(s,t)=>new q("W_ZERO_TIME_TRACK",`\u7B2C${t}\u4E2A\u5B50\u8F68\u9053\u7684\u65F6\u957F\u4E3A0`,s)};function ce(s){return`@${s}`}var Tt=class{sourceSpan;parent;get children(){return null}constructor(t,e=null){this.sourceSpan=t,this.parent=e}loweringEnter(t,e){return[]}timeFlowModel(t){return null}loweringExit(t,e,n){return[]}toString(t){return t.slice(this.sourceSpan.start,this.sourceSpan.end)}},xt=class extends Tt{},Ht=class extends Tt{label;target;constructor(t,e,n,o=null){super(t,o),this.label=e,this.target=n}toString(t){return`@${this.label} `}},dt=class s extends Tt{content;get children(){return this.content}constructor(t,e,n=null){super(t,n),this.content=e,this.content.forEach(o=>o.parent=this)}innerSpan(){return s.getContentSpan(this.content)}static getContentSpan(t){if(Array.isArray(t)){if(t.length===0)return{start:0,end:0};let e=s.getContentSpan(t[0]),n=s.getContentSpan(t[t.length-1]);return{start:e.start,end:n.end}}else return{start:t.sourceSpan.start,end:t.sourceSpan.end}}timeFlowModel(){return{children:this.content,mode:"sequence"}}toString(t){return`{${this.content.map(e=>e.toString(t)).join("")}}`}};function Ei(s,t,e){if(t){let n=t.toLowerCase();return s.args.find(o=>o.name?.toLowerCase()===n)}for(let n of s.args)if(!n.namedOnly&&e--===0)return n}function Te(s,t,e){return Ei(s,t,e)?.type??(!t&&s.allowExtraArgs?s.extraArgType:void 0)}function Ve(s){return Array.isArray(s.name)?s.name[0]:s.name}var $=class s extends Tt{label;static def;get def(){return this.constructor.def}get callName(){return this.def?Ve(this.def):""}static deSugarAtom=()=>null;get deSugarAtom(){return this.constructor.deSugarAtom}static deSugarRelation=()=>null;get deSugarRelation(){return this.constructor.deSugarRelation}getArgValue(t,e){let n=this.def;if(!n)return[];let o=Ve(n),i=0;return n.args.map((r,a)=>{let c=r.namedOnly?void 0:i++,l=r.name?.toLowerCase(),p=(l?t.get(l):void 0)??(c===void 0?void 0:t.get(c))??(l?e.variables[`${o}.${l}`.toLowerCase()]:void 0)??r.default;if(p===null)throw H.error.MissingArg(o,r.name||(c??a),this.sourceSpan);return p})}toString(t){let e=this.callName;return e?`@${e} `:super.toString(t)}static loweringAugment;static loweringFinalize;static layoutDecorationHandler;static findLabelable(t){let e=t;if(e.labelable)return e.labelable();for(let n of t.children??[]){let o=s.findLabelable(n);if(o)return o}return null}static findLastFuncContentIndex(t,e){for(;e>=0;e--)if(t[e]instanceof s||t[e]instanceof dt)return e;return-1}};function nc(s,t){for(;t!==0;){let e=s%t;s=t,t=e}return s}var F=class s{_numerator=0;_denominator=1;constructor(t=0,e=1){this.set(t,e)}get numerator(){return this._numerator}get denominator(){return this._denominator}set(t,e=1){if(!Number.isFinite(t)||!Number.isFinite(e))throw new RangeError("Fraction numerator and denominator must be finite");if(e===0)throw new RangeError("Denominator must not be zero");e<0&&(t=-t,e=-e);let n=nc(Math.abs(t),e);return this._numerator=t/n,this._denominator=e/n,this}copyFrom(t){return this._numerator=t._numerator,this._denominator=t._denominator,this}clone(){return new s(this._numerator,this._denominator)}add(t,e=1){let n;return typeof t=="number"?n=t:(n=t._numerator,e=t._denominator),this.set(this._numerator*e+n*this._denominator,this._denominator*e)}sub(t,e=1){let n;return typeof t=="number"?n=t:(n=t._numerator,e=t._denominator),this.set(this._numerator*e-n*this._denominator,this._denominator*e)}mul(t,e=1){let n;return typeof t=="number"?n=t:(n=t._numerator,e=t._denominator),this.set(this._numerator*n,this._denominator*e)}div(t,e=1){let n;if(typeof t=="number"?n=t:(n=t._numerator,e=t._denominator),n===0)throw new RangeError("Cannot divide by zero");return this.set(this._numerator*e,this._denominator*n)}divPow2(t=1){if(this._numerator===0)return this;for(;t>0&&this._numerator%2===0;)this._numerator/=2,t--;let e=this._denominator*2**t;if(!Number.isFinite(e))throw new RangeError("Fraction denominator overflow");return this._denominator=e,this}compare(t,e=1){let n;typeof t=="number"?n=t:(n=t._numerator,e=t._denominator);let o=this._numerator*e-n*this._denominator;return o<0?-1:o>0?1:0}equals(t,e=1){return t instanceof s?this._numerator===t._numerator&&this._denominator===t._denominator:this._numerator*e===t*this._denominator}isZero(){return this._numerator===0}toNumber(){return this._numerator/this._denominator}toString(){return this._denominator===1?String(this._numerator):`${this._numerator}/${this._denominator}`}};var Jt=120,Le=80,Ue="C4",gn=0,mt=-1/0,Dt=1/0,tt=class{t=new F;T=new F;track;ast;order;addon;mergeKey;foldedInto;layoutLine=0;box;springConfig;ports;decorations;initLayoutBox(){return this.box={x:0,y:0,w:0,h:0,anchor:0,visualAxis:0}}playbackState;prepareLayout(t){}paint(t){}};function le(s,t){let e=s.addon;if(e){for(let n of Object.keys(e).filter(o=>o.startsWith("@")))(t.addon??={})[n]=e[n],delete e[n];Object.keys(e).length||(s.addon=void 0)}}function X(s){return s.box!==void 0}function Wt(s){return typeof s.createGeometry=="function"}var Ce=class{target;dx;dy;constructor(t,e,n){this.target=t,this.dx=e,this.dy=n}drawText(t,e,n,o){this.target.drawText(t,e+this.dx,n+this.dy,o)}drawLine(t,e,n,o,i){this.target.drawLine(t+this.dx,e+this.dy,n+this.dx,o+this.dy,i)}drawRect(t,e,n,o,i){this.target.drawRect(t+this.dx,e+this.dy,n,o,i)}drawCircle(t,e,n,o){this.target.drawCircle(t+this.dx,e+this.dy,n,o)}drawPath(t,e,n){if(n){let o={...n,x:n.x+this.dx,y:n.y+this.dy};this.target.drawPath(t,e,o);return}this.target.drawPath(t.map(o=>this.translateCommand(o)),e)}translateCommand(t){switch(t.op){case"Z":return t;case"Q":return{op:"Q",cx:t.cx+this.dx,cy:t.cy+this.dy,x:t.x+this.dx,y:t.y+this.dy};case"C":return{op:"C",cx1:t.cx1+this.dx,cy1:t.cy1+this.dy,cx2:t.cx2+this.dx,cy2:t.cy2+this.dy,x:t.x+this.dx,y:t.y+this.dy};default:return{op:t.op,x:t.x+this.dx,y:t.y+this.dy}}}};var co=class extends ${static def={name:["adjust","adj"],description:"\u5FAE\u8C03\u76EE\u6807\u7684\u7ED8\u5236\u4F4D\u7F6E\u4E0E\u6392\u7248\u5360\u4F4D",details:`~~~jpfun
|
|
2
|
+
"use strict";(()=>{var Yc=Object.defineProperty;var qc=(r,t)=>{for(var e in t)Yc(r,e,{get:t[e],enumerable:!0})};var Ds={};qc(Ds,{ANCHOR_KEY:()=>gt,ASTBraceNode:()=>Nt,ASTFunctionNode:()=>B,ASTLabelNode:()=>Ee,ASTNodeBase:()=>Ht,ASTTextNode:()=>kt,CanvasPainter:()=>yo,CanvasTextMeasurer:()=>cr,DEFAULT_BPM:()=>Zt,DEFAULT_FONT_SIZE:()=>Xi,DEFAULT_KEY:()=>zt,DEFAULT_PAGE_CONFIG:()=>Lt,DEFAULT_PROGRAM:()=>kn,DEFAULT_TEXT_FONT:()=>De,DEFAULT_TONALITY:()=>Qe,DEFAULT_VELOCITY:()=>Me,DefaultTextMeasurer:()=>zn,Diagnostic:()=>Y,ErrorDiagnostic:()=>k,Fraction:()=>G,JIANPU_NUMBER_FONT:()=>Ve,LoweringContext:()=>xn,PageLayoutError:()=>Fe,ParserContext:()=>_t,RecordingPainter:()=>Cs,SvgPainter:()=>fo,TemporalNodeBase:()=>tt,Track:()=>ge,WarningDiagnostic:()=>K,analyzeScoreSyntax:()=>Ru,appendRun:()=>ne,canvasFont:()=>$n,compilePlayback:()=>Iu,compileScore:()=>Ss,completeSpringConfig:()=>Pn,createLayoutPrepareContext:()=>hs,defaultFunctions:()=>po,defaultTextMeasurer:()=>ur,functionAddonKey:()=>fe,getLayoutBounds:()=>St,isLayoutAttachment:()=>Xt,isPlaybackRelation:()=>ws,isVisualTemporalNode:()=>W,layoutDocument:()=>Oo,layoutElement:()=>Mn,layoutHorizontal:()=>Eo,layoutHorizontalRegion:()=>_e,layoutLocalSequence:()=>Ie,layoutPageBounds:()=>Ae,markdownToggles:()=>Gn,midiJsonToJpFun:()=>ap,musicXmlToJpFun:()=>Ap,normalizePageConfig:()=>Je,paginateLayoutLines:()=>Po,paintLayout:()=>As,paintLayoutPages:()=>Ue,paintRichLine:()=>oe,parseRichText:()=>lr,performanceTimeToScoreTime:()=>fc,performanceTimeToSeconds:()=>mo,prepareHorizontalLine:()=>Io,prepareLayoutHost:()=>nn,prepareRichLine:()=>Yt,preprocessSource:()=>ze,primaryName:()=>Ze,renderLayoutPagesToCanvas:()=>Gu,renderLayoutPagesToSvg:()=>Hu,resolveArgDef:()=>Ks,resolveArgType:()=>Pe,scanMarkdown:()=>cn,scoreTimeToPerformanceTime:()=>yc,scoreTimeToSeconds:()=>Fu,secondsToPerformanceTime:()=>dc,secondsToScoreTime:()=>_u,skipSpaces:()=>re,skipSpacesBack:()=>pn,symbols:()=>Xe,transferFunctionAddons:()=>ye,transformNotes:()=>ua,unionLayoutBoxes:()=>Oe});var Zc=/\{(\w+)\}/g,Y=class r{code;message;span;params;static format(t,e,n){return n?e.replace(Zc,(o,s)=>Object.hasOwn(n,s)?n[s]:o):e}constructor(t,e,n,o){if(this.code=t,this.span=n,o){let s={};for(let i of Object.keys(o))s[i]=String(o[i]);this.params=s}this.message=r.format(t,e,this.params)}toLineCol(t){let e=r.offsetToLineCol(this.span.start,t),n=r.offsetToLineCol(this.span.end,t);return{startLine:e.line,startColumn:e.column,endLine:n.line,endColumn:n.column}}static offsetToLineCol(t,e){let n=e.length;if(n===0)return{line:1,column:Math.max(0,t)+1};let o=t;o<0&&(o=0);let s=0,i=n-1;for(;s<=i;){let l=s+i>>1;e[l]<=o?s=l+1:i=l-1}let a=Math.max(0,i),c=e[a]??0;return{line:a+1,column:o-c+1}}static error;static warning},Us=r=>typeof r=="number"?`[${r}]`:`"${r}"`,k=class extends Y{},K=class extends Y{};Y.error={Bug:(r,t)=>new k("E_BUG","\u89E3\u6790\u5668\u9519\u8BEF: {message}\uFF0C\u8BF7\u8054\u7CFB\u5F00\u53D1\u8005\u4FEE\u590D\u8FD9\u4E2A\u95EE\u9898",t,{message:r}),MissingArg:(r,t,e)=>new k("E_MISSING_REQUIRED_ARG","\u51FD\u6570@{fn} \u7F3A\u5C11\u5FC5\u9700\u7684\u53C2\u6570 {arg}",e,{fn:r,arg:Us(t)}),PosAfterNamedArg:(r,t)=>new k("E_POSARG_AFTER_KWARG","\u51FD\u6570 @{fn} \u7684\u4F4D\u7F6E\u53C2\u6570\u51FA\u73B0\u5728\u547D\u540D\u53C2\u6570\u4E4B\u540E\uFF0C\u8FD9\u662F\u4E0D\u5141\u8BB8\u7684",t,{fn:r}),EmptyContent:(r,t,e)=>new k("E_EMPTY_CONTENT","\u51FD\u6570 @{fn} \u7684\u53C2\u6570 {arg} \u5185\u5BB9\u4E3A\u7A7A(\u6216\u65E0\u53EF\u7528\u5185\u5BB9)\uFF1B\u8BF7\u63D0\u4F9B\u6709\u6548\u5185\u5BB9",e,{fn:r,arg:Us(t)}),UnterminatedCall:(r,t)=>new k("E_UNTERMINATED_CALL","\u51FD\u6570\u8C03\u7528\u672A\u95ED\u5408: @{fn}(...)",t,{fn:r}),UnknownFunction:(r,t)=>new k("E_UNKNOWN_FUNCTION","\u672A\u77E5\u51FD\u6570: @{fn}\uFF0C\u8BF7\u68C0\u67E5\u62FC\u5199",t,{fn:r}),UnknownLabel:(r,t)=>new k("E_UNKNOWN_LABEL",'\u672A\u77E5\u6807\u7B7E: "{label}"',t,{label:r}),BreakInsideEvent:r=>new k("E_BREAK_INSIDE_EVENT","\u6362\u884C\u6216\u6362\u9875\u5207\u65AD\u4E86\u4E00\u4E2A\u4ECD\u5728\u6301\u7EED\u7684\u4E8B\u4EF6\uFF1B\u8BF7\u628A\u957F\u97F3\u5199\u6210\u591A\u4E2A\u4E8B\u4EF6\uFF0C\u6216\u8C03\u6574\u6362\u884C\u3001\u6362\u9875\u7684\u4F4D\u7F6E",r),PageOverflow:(r,t,e)=>new k("E_PAGE_OVERFLOW","\u8C31\u9762\u884C\u9700\u8981 {required}px \u9AD8\u5EA6\uFF0C\u4F46\u9875\u9762\u5185\u5BB9\u533A\u53EA\u6709 {available}px",e,{required:r,available:t})};Y.warning={InvalidUnicodeEscape:r=>new K("W_STRING_INVALID_UNICODE_ESCAPE","\u65E0\u6548\u7684 Unicode \u8F6C\u4E49\uFF1A\u8BF7\u4F7F\u7528 \\uXXXX\uFF08\u56DB\u4F4D\u5341\u516D\u8FDB\u5236\u6570\u5B57\uFF09\uFF1B\u5C06\u4FDD\u7559\u8BE5\u5B57\u7B26\u4E32\u539F\u6587",r),UnknownFunction:(r,t)=>new K("W_UNKNOWN_FUNCTION","\u672A\u77E5\u51FD\u6570: @{fn}\uFF0C\u5C06\u88AB\u5F53\u4F5C\u666E\u901A\u6587\u672C\u5904\u7406",t,{fn:r}),TooManyPosArgs:(r,t,e,n)=>new K("W_TOO_MANY_POS_ARGS","\u51FD\u6570 @{fn} \u63A5\u6536\u4E86\u8FC7\u591A\u7684\u4F4D\u7F6E\u53C2\u6570\uFF0C\u671F\u671B {expected} \u4E2A\u4F46\u5F97\u5230\u4E86 {actual} \u4E2A",n,{fn:r,expected:t,actual:e}),InvalidNumber:(r,t)=>new K("W_INVALID_NUMBER",'\u65E0\u6548\u7684\u6570\u5B57: "{value}"\uFF1B\u5C06\u4F7F\u7528\u9ED8\u8BA4\u503C(\u82E5\u5B58\u5728)',t,{value:r}),InvalidBoolean:(r,t)=>new K("W_INVALID_BOOL",`\u65E0\u6548\u7684\u5E03\u5C14\u503C: "{value}": \u5E94\u4E3A 'true' \u6216 'false'\uFF1B\u5C06\u4F7F\u7528\u9ED8\u8BA4\u503C(\u82E5\u5B58\u5728)`,t,{value:r}),InvalidLength:(r,t)=>new K("W_INVALID_LENGTH",'\u65E0\u6548\u7684\u957F\u5EA6\u503C: "{value}"\uFF1B\u8BF7\u63D0\u4F9B\u6709\u6548\u7684\u957F\u5EA6\u503C\uFF0C\u4F8B\u5982 "10px" \u6216 "2em"\uFF1B\u5C06\u4F7F\u7528\u9ED8\u8BA4\u503C(\u82E5\u5B58\u5728)',t,{value:r}),InvalidLengthUnit:(r,t)=>new K("W_INVALID_LENGTH_UNIT",'\u65E0\u6548\u7684\u957F\u5EA6\u5355\u4F4D: "{unit}"\uFF1B\u4EC5\u652F\u6301 "px" \u548C "em"\uFF1B\u8BF7\u68C0\u67E5\u51FD\u6570\u53C2\u6570\u6216\u53D8\u91CF\u5B9A\u4E49\uFF1B\u5C06\u4F7F\u7528\u9ED8\u8BA4\u503C(\u82E5\u5B58\u5728)',t,{unit:r}),InvalidContent:r=>new K("W_INVALID_CONTENT","\u5185\u5BB9\u89E3\u6790\u5931\u8D25\uFF0C\u9519\u8BEF\u539F\u56E0\u89C1\u4E0A\uFF1B\u5C06\u4F7F\u7528\u9ED8\u8BA4\u503C(\u4F46\u5F80\u5F80\u4E0D\u5B58\u5728\uFF0C\u6781\u6709\u53EF\u80FD\u5BFC\u81F4\u9519\u8BEF)",r),UnmatchedBrace:r=>new K("W_UNMATCHED_BRACE","\u672A\u5339\u914D\u7684\u5927\u62EC\u53F7: \u7F3A\u5C11\u53F3\u5927\u62EC\u53F7'}'\uFF1B\u5C06\u5C1D\u8BD5\u81EA\u52A8\u4FEE\u590D",r),LabelWithoutTarget:(r,t)=>new K("W_LABEL_WITHOUT_TARGET",'\u6807\u7B7E "{label}" \u6CA1\u6709\u53EF\u7ED1\u5B9A\u7684\u76EE\u6807\uFF1B\u6807\u7B7E\u5C06\u88AB\u5FFD\u7565',t,{label:r}),TargetAlreadyLabeled:(r,t,e)=>new K("W_TARGET_ALREADY_LABELED",'\u76EE\u6807\u5DF2\u6807\u6CE8\u4E3A "{oldLabel}"\uFF0C"{newLabel}" \u5C06\u88AB\u5FFD\u7565',e,{oldLabel:t,newLabel:r}),UnresolvedEndpoint:(r,t)=>new K("W_UNRESOLVED_ENDPOINT","@{fn} \u6709\u7AEF\u70B9\u627E\u4E0D\u5230\u5BF9\u5E94\u7684\u8C31\u9762\u5BF9\u8C61\uFF1B\u8BE5\u5173\u7CFB\u5C06\u88AB\u5FFD\u7565",t,{fn:r}),ZeroTimeTrack:(r,t)=>new K("W_ZERO_TIME_TRACK","\u7B2C{track}\u4E2A\u5B50\u8F68\u9053\u7684\u65F6\u957F\u4E3A0",r,{track:t})};function fe(r){return`@${r}`}var Ht=class{constructor(t,e=null){this.sourceSpan=t;this.parent=e}sourceSpan;parent;get children(){return null}loweringEnter(t,e){return[]}timeFlowModel(t){let e=this.children;return e?{mode:"sequence",children:e}:null}loweringExit(t,e,n){return[]}toString(t){return t.slice(this.sourceSpan.start,this.sourceSpan.end)}},kt=class extends Ht{},Ee=class extends Ht{label;target;constructor(t,e,n,o=null){super(t,o),this.label=e,this.target=n}toString(t){return`@${this.label} `}},Nt=class extends Ht{content;get children(){return this.content}constructor(t,e,n=null){super(t,n),this.content=e,this.content.forEach(o=>o.parent=this)}toString(t){return`{${this.content.map(e=>e.toString(t)).join("")}}`}};function Ks(r,t,e){if(t){let n=t.toLowerCase();return r.args.find(o=>o.name?.toLowerCase()===n)}for(let n of r.args)if(!n.namedOnly&&e--===0)return n}function Pe(r,t,e){return Ks(r,t,e)?.type??(!t&&r.allowExtraArgs?r.extraArgType:void 0)}function Ze(r){return Array.isArray(r.name)?r.name[0]:r.name}var B=class r extends Ht{label;static def;get def(){return this.constructor.def}get callName(){return this.def?Ze(this.def):""}static deSugarAtom=()=>null;static deSugarRelation=()=>null;getArgValue(t,e){let n=this.def;if(!n)return[];let o=Ze(n),s=0;return n.args.map((i,a)=>{let c=i.namedOnly?void 0:s++,l=i.name?.toLowerCase(),u=(l?t.get(l):void 0)??(c===void 0?void 0:t.get(c))??(l?e.variables[`${o}.${l}`.toLowerCase()]:void 0)??i.default;if(u===null)throw Y.error.MissingArg(o,i.name||(c??a),this.sourceSpan);return u})}toString(t){let e=this.callName;return e?`@${e} `:super.toString(t)}static layoutDecorationHandler;static findLabelable(t){let e=t;if(e.labelable)return e.labelable();for(let n of t.children??[]){let o=r.findLabelable(n);if(o)return o}return null}};function Qc(r,t){for(;t!==0;){let e=r%t;r=t,t=e}return r}var G=class r{_numerator=0;_denominator=1;constructor(t=0,e=1){(t!==0||e!==1)&&this.set(t,e)}get numerator(){return this._numerator}get denominator(){return this._denominator}set(t,e=1){if(!Number.isFinite(t)||!Number.isFinite(e))throw new RangeError("Fraction numerator and denominator must be finite");if(e===0)throw new RangeError("Denominator must not be zero");e<0&&(t=-t,e=-e);let n=Qc(Math.abs(t),e);return this._numerator=t/n,this._denominator=e/n,this}copyFrom(t){return this._numerator=t._numerator,this._denominator=t._denominator,this}clone(){return new r().copyFrom(this)}add(t,e=1){let n;return typeof t=="number"?n=t:(n=t._numerator,e=t._denominator),this.set(this._numerator*e+n*this._denominator,this._denominator*e)}sub(t,e=1){let n;return typeof t=="number"?n=t:(n=t._numerator,e=t._denominator),this.set(this._numerator*e-n*this._denominator,this._denominator*e)}mul(t,e=1){let n;return typeof t=="number"?n=t:(n=t._numerator,e=t._denominator),this.set(this._numerator*n,this._denominator*e)}div(t,e=1){let n;if(typeof t=="number"?n=t:(n=t._numerator,e=t._denominator),n===0)throw new RangeError("Cannot divide by zero");return this.set(this._numerator*e,this._denominator*n)}divPow2(t=1){if(this._numerator===0)return this;for(;t>0&&this._numerator%2===0;)this._numerator/=2,t--;let e=this._denominator*2**t;if(!Number.isFinite(e))throw new RangeError("Fraction denominator overflow");return this._denominator=e,this}compare(t,e=1){let n;typeof t=="number"?n=t:(n=t._numerator,e=t._denominator);let o=this._numerator*e-n*this._denominator;return o<0?-1:o>0?1:0}equals(t,e=1){return t instanceof r?this._numerator===t._numerator&&this._denominator===t._denominator:this._numerator*e===t*this._denominator}isZero(){return this._numerator===0}toNumber(){return this._numerator/this._denominator}toString(){return this._denominator===1?String(this._numerator):`${this._numerator}/${this._denominator}`}};var Zt=120,Me=80,Qe="C4",kn=0,gt=-1/0,zt=1/0,tt=class{t=new G;T=new G;track;ast;order;addon;mergeKey;foldedInto;get rootHost(){let t=this;for(;t.foldedInto;)t=t.foldedInto;return t}layoutLine=0;box;springConfig;ports;decorations;initLayoutBox(){return this.box={x:0,y:0,w:0,h:0,anchor:0,visualAxis:0}}playbackState;prepareLayout(t){}paint(t){}};function ye(r,t){let e=r.addon;if(e){for(let n of Object.keys(e).filter(o=>o.startsWith("@")))(t.addon??={})[n]=e[n],delete e[n];Object.keys(e).length||(r.addon=void 0)}}function W(r){return r.box!==void 0}function Xt(r){return typeof r.createGeometry=="function"}var Re=class{constructor(t,e,n){this.target=t;this.dx=e;this.dy=n}target;dx;dy;drawText(t,e,n,o){this.target.drawText(t,e+this.dx,n+this.dy,o)}drawLine(t,e,n,o,s){this.target.drawLine(t+this.dx,e+this.dy,n+this.dx,o+this.dy,s)}drawRect(t,e,n,o,s){this.target.drawRect(t+this.dx,e+this.dy,n,o,s)}drawCircle(t,e,n,o){this.target.drawCircle(t+this.dx,e+this.dy,n,o)}drawPath(t,e,n){this.target.drawPath(t,e,{x:(n?.x??0)+this.dx,y:(n?.y??0)+this.dy,scaleX:n?.scaleX??1,scaleY:n?.scaleY??1})}};var vo=class extends B{static def={name:["adjust","adj"],description:"\u5FAE\u8C03\u76EE\u6807\u7684\u7ED8\u5236\u4F4D\u7F6E\u4E0E\u6392\u7248\u5360\u4F4D",details:`~~~jpfun
|
|
3
3
|
@adjust(1, dx=2px, dy=-1px, dw=0.2em, dh=0px)
|
|
4
4
|
~~~
|
|
5
5
|
|
|
6
|
-
\u4F4D\u7F6E\u504F\u79FB\u5728\u6392\u7248\u540E\u5E94\u7528\uFF0C\u76F8\u90BB\u5BF9\u8C61\u4FDD\u6301\u539F\u4F4D\uFF1B\u5360\u4F4D\u8C03\u6574\u5728\u6392\u7248\u524D\u5E94\u7528\u3002\u53EA\u5305\u88F9\u5173\u7CFB\u5BF9\u8C61\u65F6\uFF0C\u5E73\u79FB\u4F5C\u7528\u4E8E\u8BE5\u5173\u7CFB\u5BF9\u8C61\u672C\u8EAB\u3002`,allowExtraArgs:!1,args:[{type:"content",description:"\u8981\u5FAE\u8C03\u7684\u5185\u5BB9\u6216\u5173\u7CFB\u5BF9\u8C61",default:null},{name:"dx",description:"\u6392\u7248\u540E\u7684\u6C34\u5E73\u504F\u79FB\uFF0C\u6B63\u503C\u5411\u53F3\uFF0C\u4E0D\u6539\u53D8\u5360\u4F4D",type:"length",default:{value:0,unit:"px"}},{name:"dy",description:"\u6392\u7248\u540E\u7684\u5782\u76F4\u504F\u79FB\uFF0C\u6B63\u503C\u5411\u4E0B\uFF0C\u4E0D\u6539\u53D8\u5360\u4F4D",type:"length",default:{value:0,unit:"px"}},{name:"dw",description:"\u589E\u51CF\u6C34\u5E73\u5360\u4F4D\uFF0C\u6309\u539F\u5DE6\u53F3\u6BD4\u4F8B\u5206\u914D\uFF0C\u6700\u7EC8\u5BBD\u5EA6\u4E0D\u5C0F\u4E8E 0",type:"length",default:{value:0,unit:"px"}},{name:"dh",description:"\u589E\u51CF\u4E0B\u65B9\u5360\u4F4D\uFF0C\u6700\u7EC8\u9AD8\u5EA6\u4E0D\u5C0F\u4E8E 0",type:"length",default:{value:0,unit:"px"}}]};target;dx;dy;dw;dh;get children(){return[this.target]}timeFlowModel(){return{children:[this.target],mode:"sequence"}}loweringEnter(t){let e={temporal:0,attachment:0},n={targets:e,onTemporal:o=>{X(o)&&(e.temporal++,oc(o,this))},onAttachment:o=>{Wt(o)&&(e.attachment++,sc(o,e,this.dx,this.dy))}};return t.beginLoweringGroup(this,n),[]}loweringExit(t){let e=t.endLoweringGroup(this);return e.targets.temporal===0&&e.targets.attachment===0&&t.diagnostics.push(new q("W_ADJUST_NO_TARGET","@adjust \u6CA1\u6709\u627E\u5230\u53EF\u8C03\u6574\u7684\u5BF9\u8C61",this.sourceSpan)),[]}constructor(t,e,n,o=null){super(t,o);let[i,r,a,c,l]=this.getArgValue(e,n);i.parent=this,this.target=i,this.dx=n.length2px(r),this.dy=n.length2px(a),this.dw=n.length2px(c),this.dh=n.length2px(l)}toString(t){return`@adjust(${this.target.toString(t)}, dx=${this.dx}px, dy=${this.dy}px, dw=${this.dw}px, dh=${this.dh}px)`}},Ti=co;function oc(s,t){let{dx:e,dy:n,dw:o,dh:i}=t;if(e===0&&n===0&&o===0&&i===0)return;(e!==0||n!==0)&&(s.placementOffset={x:(s.placementOffset?.x??0)+e,y:(s.placementOffset?.y??0)+n});let r,a,c=s.finalizeLayout,l=s.onPlaced;s.finalizeLayout=p=>{c?.call(s,p);let f=Math.max(0,s.box.w+o);s.box.anchor=s.box.w>0?s.box.anchor*f/s.box.w:0,s.box.w=f,s.box.h=Math.max(0,s.box.h+i)},s.onPlaced=()=>{s.box.x!==r&&(s.box.x+=e),s.box.y!==a&&(s.box.y+=n),l?.call(s),r=s.box.x,a=s.box.y}}function sc(s,t,e,n){if(t.temporal>0||e===0&&n===0)return;s.placementOffset={x:(s.placementOffset?.x??0)+e,y:(s.placementOffset?.y??0)+n};let o=s.createGeometry;s.createGeometry=i=>{let r=o.call(s,i);if(t.temporal>0||i.layoutOnly)return r;let a=c=>c.line===void 0?{x:c.x+e,y:c.y+n,w:c.w,h:c.h}:{x:c.x+e,y:c.y+n,w:c.w,h:c.h,line:c.line,track:c.track};return{regions:r.regions.map(a),occupancy:r.occupancy?.map(a),paint(c){r.paint(new Ce(c,e,n))}}}}var bn=1,ic=6,rc=16,lo=32,Li=1e-6,ac=.01;function wn(s,t=bn){let e=s.alpha_L??s.alpha_R??ic;s.alpha_L??=e,s.alpha_R??=e;let n=s.mu_L??s.mu_R??rc;s.mu_L??=n,s.mu_R??=n,s.beta_L??=t/Math.max(s.alpha_L,Li),s.beta_R??=t/Math.max(s.alpha_R,Li)}function Sn(s,t,e,n=bn){wn(s,n);let o=Math.pow(Math.max(e.T.toNumber(),ac),.5);return{config:s,box:t,time:e,duration_L:o,duration_R:o,WL:t.anchor,WR:t.w-t.anchor,margin_L:o*s.alpha_L,margin_R:o*s.alpha_R}}function cc(s,t=bn){let e=new Map,n=0;for(let i of s)for(let r of i)e.has(r.time.track)||e.set(r.time.track,n++);let o=[];for(let i of s){if(i.length===0)continue;let r=Array(i.length);o.push(r);let a=0,c=0,l=n;for(let f of i){f.WL>a&&(a=f.WL),f.WR>c&&(c=f.WR);let u=e.get(f.time.track);if(r[u]){let h=r[u];f.time.T.compare(h.time.T)>0?(r[u]=f,r[l++]=h):r[l++]=f}else r[u]=f}let p=i[0].time.t;for(let f of e){let u=f[1];if(!r[u]){let h=Sn({alpha_L:a,alpha_R:c},{x:0,w:0,anchor:0},{t:p,T:new F(1),track:f[0]},t);h.fake=!0,r[u]=h}}}return{mat:o,rows:n}}function lc(s,t,e,n){let o=n-e-s.WR-t.WL,i=s.margin_R+t.margin_L;if(o>=i)return{force:0,stiffness:0};let r=s.config.beta_R/s.duration_R,a=t.config.beta_L/t.duration_L,c=r*a/(r+a),l,p;if(o<0){let f=s.config.mu_R*t.config.mu_L/(s.config.mu_R+t.config.mu_L);l=c*i-f*o,p=f}else{let f=i-o;l=c*f,p=c}return{force:l,stiffness:p}}function fc(s,t,e=lo){let n=t-s.WL,o=s.margin_L;if(n>=o)return{force:0,stiffness:0};let i=s.config.beta_L/s.duration_L;if(n>=0)return{force:i*(o-n),stiffness:i};let r=s.config.mu_L*e;return{force:s.config.alpha_L*s.config.beta_L-r*n,stiffness:r}}function pc(s,t,e,n=lo){let o=e-(t+s.WR),i=s.margin_R;if(o>=i)return{force:0,stiffness:0};let r=s.config.beta_R/s.duration_R;if(o>=0)return{force:r*(i-o),stiffness:r};let a=s.config.mu_R*n;return{force:s.config.alpha_R*s.config.beta_R-a*o,stiffness:a}}function uc(s){return{damping:s.damping??.6,maxIter:s.maxIter??100,eps:s.eps??.01,crossPunish:s.crossPunish??lo,globalC:s.globalC??bn}}function hc(s,t,e,n,o){let{damping:i,maxIter:r,eps:a,crossPunish:c}=o,l=s.length,p=new Float64Array(t);for(let A=0;A<l;A++){let E=0,S=s[A];for(let v=0;v<t;v++){let L=p[v]+S[v].WL+S[v].margin_L;L>E&&(E=L)}for(let v=0;v<t;v++)p[v]=E+S[v].WR+S[v].margin_R;e[A]=E}let f=p.reduce((A,E)=>Math.max(A,E),0);if(f<=n)return!0;f=n/f;for(let A=0;A<l;A++)e[A]*=f;let u=new Float64Array(l),h=new Float64Array(l+1);function d(A){u.fill(0),h.fill(0);for(let E=0;E<t;E++){let S=s[0][E],v=fc(S,A[0],c);u[0]+=v.force,h[0]+=v.stiffness;for(let w=1;w<l;w++){let M=s[w-1][E],C=s[w][E],_=lc(M,C,A[w-1],A[w]);u[w-1]-=_.force,u[w]+=_.force,h[w]+=_.stiffness}let L=s[l-1][E],I=pc(L,A[l-1],n,c);u[l-1]-=I.force,h[l]+=I.stiffness}return u}let y=new Float64Array(l),m=new Float64Array(l);function g(){for(let E=0;E<l;E++){let S=E===0?0:h[E]/y[E-1],v=h[E]+h[E+1]+1e-4-S*h[E];if(!(v>0)||!Number.isFinite(v))throw new Error("Horizontal spring stiffness must produce a finite positive definite system");y[E]=v,m[E]=u[E]+(E===0?0:S*m[E-1])}m[l-1]/=y[l-1];for(let E=l-2;E>=0;E--)m[E]=(m[E]+h[E+1]*m[E+1])/y[E];return m}let x=0,b=0;for(;x<r;x++){let A=d(e);b=0;for(let S=0;S<A.length;S++){let v=Math.abs(A[S]);v>b&&(b=v)}if(b<a)break;let E=g();for(let S=0;S<l;S++)e[S]+=i*E[S]}return!1}function ve(s,t,e,n,o,i,r){if(e.length!==s.length||n.length!==Math.max(0,e.length-1))throw new Error("Horizontal region state does not match its columns");if(e.length===0||t===0)return;let a=n.some(h=>h!==0),c,l,p=s,f=e;if(a){c=new Uint32Array(e.length),l=new Float64Array(e.length),p=[];for(let h=0;h<e.length;){let d=h;for(;d<n.length&&n[d];)d++;let y=p.length;for(let m=h;m<=d;m++)c[m]=y,l[m]=e[m]-e[h];if(h===d)p.push(s[h]);else{let m=e[d]-e[h];p.push(Array.from({length:t},(g,x)=>{let b=s[h][x],A=s[d][x];return{config:{alpha_L:b.config.alpha_L,alpha_R:A.config.alpha_R,mu_L:b.config.mu_L,mu_R:A.config.mu_R,beta_L:b.config.beta_L,beta_R:A.config.beta_R},box:b.box,time:b.time,duration_L:b.duration_L,duration_R:A.duration_R,WL:b.WL,WR:m+A.WR,margin_L:b.margin_L,margin_R:A.margin_R,fake:b.fake&&A.fake}}))}h=d+1}f=new Float64Array(p.length)}let u=hc(p,t,f,o,i);if(n.fill(1),r!==void 0){let h=0,d=0;for(let m=0;m<t;m++)h=Math.max(h,p[0][m].WL),d=Math.max(d,p[p.length-1][m].WR);let y=f[f.length-1]+d-f[0]+h;if(!u||y>=o*r){let m=h-f[0],g=o-y;for(let x=0;x<f.length;x++)f[x]+=m+(f.length>1?g*x/(f.length-1):0)}}if(a)for(let h=0;h<e.length;h++)e[h]=f[c[h]]+l[h]}function fo(s,t,e={},n=[],o){let i=uc(e),{mat:r,rows:a}=cc(s,i.globalC),c=new Float64Array(r.length),l=new Uint8Array(Math.max(0,r.length-1)),p=n.length>1?[...n].sort((f,u)=>f.end-f.start-(u.end-u.start)):n;for(let{start:f,end:u,hook:h}of p){if(f<0||u<f||u>=r.length)throw new Error("Horizontal layout registration references invalid columns");h({columns:r,rows:a,start:f,end:u,X:c,fixed:l,options:i})}ve(r,a,c,l,t,i,o);for(let f=0;f<r.length;f++)for(let u of r[f])u.box.x=c[f]-u.box.anchor;return r}var Me=class extends Error{line;requiredHeight;availableHeight;constructor(t,e,n){super(`Page cannot fit layout line ${t}: requires ${e}px, available ${n}px`),this.line=t,this.requiredHeight=e,this.availableHeight=n,this.name="PageLayoutError"}},Ct={width:794,height:1/0,marginTop:45,marginBottom:48,marginLeft:40,marginRight:40,lineGap:22,fillRatio:.5};function je(s={}){let t=s.height??Ct.height,e={width:s.width??Ct.width,height:t<=0?1/0:t,marginTop:Math.max(0,s.marginTop??Ct.marginTop),marginBottom:Math.max(0,s.marginBottom??Ct.marginBottom),marginLeft:Math.max(0,s.marginLeft??Ct.marginLeft),marginRight:Math.max(0,s.marginRight??Ct.marginRight),lineGap:Math.max(0,s.lineGap??Ct.lineGap),fillRatio:s.fillRatio??Ct.fillRatio};if(!Number.isFinite(e.width)||e.width<=0)throw new Error(`Page width must be a positive finite number, got ${e.width}`);if(e.height!==1/0&&(!Number.isFinite(e.height)||e.height<=0))throw new Error(`Page height must be positive or Infinity, got ${e.height}`);if([e.marginTop,e.marginBottom,e.marginLeft,e.marginRight,e.lineGap].some(r=>!Number.isFinite(r)||r<0))throw new Error("Page margins and line gap must be finite non-negative numbers");let o=e.width-e.marginLeft-e.marginRight;if(o<=0)throw new Error(`Page horizontal margins leave no content width: ${o}px`);let i=e.height-e.marginTop-e.marginBottom;if(Number.isFinite(e.height)&&i<=0)throw new Error(`Page vertical margins leave no content height: ${i}px`);return e}function po(s,t,e=[]){let n=t.height-t.marginTop-t.marginBottom,o=[],i=new Array(s.length).fill(0),r=0,a=0,c=0,l=0,p=(f,u)=>{let h=f-a,d=u?Math.max(0,n-l-t.lineGap*(h-1)):0,y=t.lineGap+d/h,m=r+t.marginTop;for(let x=a;x<f;x++)i[x]=m,m+=s[x]+(x+1<f?y:0);let g=Number.isFinite(t.height)?t.height:m-r+t.marginBottom;o.push({bounds:{x:0,y:r,w:t.width,h:g},lineStart:a,lineEnd:f}),r+=g,a=f,c=0,l=0};for(let f=0;f<s.length;f++){let u=s[f];if(Number.isFinite(t.height)&&u>n+1e-6)throw new Me(f,u,n);f>a&&(e[f]!==void 0||Number.isFinite(t.height)&&c+t.lineGap+u>n+1e-6)&&p(f,Number.isFinite(t.height)&&(e[f]??!0)),c+=(f>a?t.lineGap:0)+u,l+=u}return s.length>a&&p(s.length,!1),{pages:o,lineTops:i}}var Ci={start:0,end:-1,wholeLine:!1};function uo(s){let t=new Set,e=n=>{t.add(n);for(let o of n.groups)for(let i of o.members)e(i)};return e(s),n=>{for(let o=n;o;o=o.parent)if(t.has(o))return o;return n}}function vi(s,t){for(let e=t;e;){let n=s.columnOf(e);if(n>=0)return n;let o=e instanceof tt?e.foldedInto:void 0;e=o&&X(o)?o:void 0}return-1}function ho(s,t,e,n){if(!t)return{start:0,end:s.columns.length-1,wholeLine:!0};if(typeof t[0]=="number")return{start:Math.max(0,t[0]),end:Math.min(s.columns.length-1,t[1]),wholeLine:!1};let[o,i]=t;if(o.layoutLine>i.layoutLine&&([o,i]=[i,o]),s.index<o.layoutLine||s.index>i.layoutLine)return Ci;let r=e&&n(e);if(r&&(n(o.track)!==r||n(i.track)!==r))throw new Error("Range endpoints must belong to the selected track");let a=o.layoutLine<s.index?0:vi(s,o),c=i.layoutLine>s.index?s.columns.length-1:vi(s,i);return a<0||c<0?Ci:{start:Math.min(a,c),end:Math.max(a,c),wholeLine:!1}}function mo(s,t,e,n){if(!s)return[];let{start:o,end:i}=ho(s,t,e,n),r=s.columns.slice(o,i+1);if(!e)return r;let a=n(e),c=l=>l.track===a;return r.every(l=>l.every(c))?r:r.map(l=>l.filter(c))}var Ni=.75,Ye=new WeakMap;function wt(s,t=!1){let{box:e}=s,n=Ye.get(s);if(!n)return e;let o=t?n.contentTop:n.top,i=t?0:n.bottom;return{x:e.x,y:e.y+o,w:e.w,h:e.h-o+i}}function Ne(s,t){let e=1/0,n=1/0,o=-1/0,i=-1/0;for(let r of t)e=Math.min(e,r.x),n=Math.min(n,r.y),o=Math.max(o,r.x+r.w),i=Math.max(i,r.y+r.h);return Number.isFinite(e)?(s.x=e,s.y=n,s.w=o-e,s.h=i-n,!0):(s.x=s.y=s.w=s.h=0,!1)}function Xe(s,t){if(s.springConfig??={},s.decorations&&Ye.delete(s),s.decorations=[],s.ports={},s.box.x=s.box.y=0,s.prepareLayout(t),s.addon)for(let[e,n]of Object.entries(s.addon)){let o=t.decorationHandlers.get(e);if(!o)continue;let i=o(s,n,t);i&&s.decorations.push(i)}dc(s),s.finalizeLayout?.(t)}function bo(s,t,e={}){let n=s.attachments.filter(Wt),o=je(s.page),i=o.width-o.marginLeft-o.marginRight,r=o.marginLeft,a=uo(s.rootTrack),c=new Map(n.map((C,_)=>[C,_])),l=yc(n),p=[];if(n.length){for(let C of s.astToTemporal.values())if(C.some(_=>_.placementOffset?.x||_.placementOffset?.y)){p=[...new Set([...s.astToTemporal.values()].flat().filter(X))];break}}let f=new Map,u=(C,_=!1)=>{let P=f.get(C);return P&&Mi(P,_)};t={...t,layoutSubdomain(C,_,P,W){let Z=ki(_,t),Q=new Set(_.flat()),K=O=>{for(let j=O;j&&j!==C;j=j.foldedInto)if(Q.has(j))return!0;return!1},N=W.filter(Wt).filter(O=>!O.endPoints?.length);for(let O of l.get(C)??[])!f.has(O)&&O.endPoints.every(K)&&N.push(O);N.sort((O,j)=>c.get(O)-c.get(j));let R=xc(_,Z,P,N,t,u,p.length?p.filter(K):p,C);return N.forEach((O,j)=>f.set(O,R.items[j])),{width:Z.width,height:R.height,positions:R.positions}}};let{lines:h,pageBreaks:d}=mc(s),y=[];for(let C of h)for(let _ of C.columns)for(let P of _)y.push(P),Xe(P,t);let m=n.filter(C=>!f.has(C)),g=h.map((C,_)=>wo(C.columns,_,e)),x=g.map(C=>C.view);for(let C of m)C.prepareHorizontal?.(x,t);for(let C of g){C.layout(i,o.fillRatio);for(let _ of C.view.columns)for(let P of _)P.box.x+=r}if(e.horizontalOnly)return{diagnostics:s.diagnostics,objects:y,attachments:[],bounds:{x:0,y:0,w:0,h:0},lineCount:h.length,pages:[]};for(let C of y){let _=h[C.layoutLine];Ii(_.hostExtents,C)}let b=bc(h.length,y,e.rowGap),A=()=>{let C=[],_=h.map((K,N)=>{let R=Ri(K,s.rootTrack,b[N]);return C.push(R.height),R.axes}),P,W;try{({pages:P,lineTops:W}=po(C,o,d))}catch(K){if(!(K instanceof Me))throw K;let N=h[K.line],R=1/0,O=-1/0;for(let j of N?.columns??[])for(let B of j)R=Math.min(R,B.ast.sourceSpan.start),O=Math.max(O,B.ast.sourceSpan.end);throw Number.isFinite(R)?H.error.PageOverflow(K.requiredHeight,K.availableHeight,{start:R,end:O}):K}let Z=(K,N)=>(W[K]??0)+(_[K]?.get(N)??0);for(let K of y)K.box.y=Z(K.layoutLine,K.track)-K.box.visualAxis,K.onPlaced?.();let Q={...t,width:i,originX:r,pages:P.map(K=>K.bounds),lines:x,getVisualAxis:(K,N)=>Z(K,a(N)),getHostExtent:(K,N)=>h[K]?.hostExtents.get(a(N)),getRangeColumns:(K,N,R)=>mo(x[K],N,R,a)};return{pages:P,attachmentContext:Q}},E=A(),S=go(m,E.attachmentContext,h,a,u,p);S.needsRelayout&&(E=A(),S=go(m,E.attachmentContext,h,a,u,p));let v=E.pages,L=0,I=n.map(C=>{let _=f.get(C),{geometry:P,box:W}=_?Mi(_):S.items[L++];return{box:W,regions:P.regions,layer:C.layer,sourceSpan:C.sourceSpan,paint(Z){P.paint(Z)}}}),w={x:0,y:0,w:0,h:0};function*M(){for(let C of v)yield C.bounds;for(let C of y)yield wt(C);for(let C of I)yield C.box}return Ne(w,M()),{diagnostics:s.diagnostics,objects:y,attachments:I,bounds:w,lineCount:h.length,pages:v}}function dc(s){if(s.decorations.length===0)return;let t=0,e=-1/0,n=0,o=-1/0;for(let r of["above","below"]){let a=r==="above",c=s.decorations.length===1?s.decorations:s.decorations.filter(u=>u[r]);c.length>1&&c.sort((u,h)=>u[r].order-h[r].order);let l=a?0:s.ports["decoration.below"]?.y??s.box.h,p=a?-1/0:s.box.h,f=p;for(let u of c){let h=u[r];if(!h)continue;let d=Math.max(0,h.height??0);!a&&!u.paint&&(l=Math.max(l,f));let y=a?l-(h.gap??0)-d:l+(h.gap??0);h.place?.(y),l=a?y:y+d,n=Math.min(n,y),p=a?Math.max(p,y+d):l,u.paint&&(t=Math.min(t,y),f=a?Math.max(f,y+d):l)}o=Math.max(o,p),e=Math.max(e,f)}s.box.h=e;let i=Math.max(0,o-e);(n!==0||i!==0)&&Ye.set(s,{top:n,bottom:i,contentTop:t})}function mc(s){let t=()=>({columns:[],hostExtents:new Map,attachmentExtents:new Map}),e=[],n=[],o=t();for(let i of s.columns){let r=[];for(;e.length<i[0].layoutLine;)e.push(o),o=t();for(let a of i){let c=a.addon?.pageBreakBefore;c!==void 0&&(n[e.length]=(n[e.length]??!0)&&c),X(a)&&r.push(a)}r.length&&o.columns.push(r)}return(o.columns.length>0||n[e.length]!==void 0||e.length===0)&&e.push(o),{lines:e,pageBreaks:n}}function Ke(s,t,e){s.top=Math.min(s.top,t),s.bottom=Math.max(s.bottom,e)}function yo(s,t,e,n){let o=s.get(t);o?Ke(o,e,n):s.set(t,{top:e,bottom:n})}function wo(s,t,e={},n=!1){let o=[],i=new Map,r=new Map,a;for(let l=0;l<s.length;l++)for(let p of s[l]){i.set(p,l),wn(p.springConfig,e.globalC);let f=r.get(p.track);f?f.push(p):r.set(p.track,[p])}let c={index:t,columns:s,trackRuns:r,columnOf:l=>i.get(l)??-1,trackIndexOf(l){if(!a){a=new Map;for(let p of r.values())for(let f=0;f<p.length;f++)a.set(p[f],f)}return a.get(l)??-1},registerHorizontalLayoutHook(l,p,f){let u=i.get(l),h=i.get(p);u===void 0||h===void 0||o.push({start:Math.min(u,h),end:Math.max(u,h),hook:f})}};for(let l of s)for(let p of l)p.prepareHorizontal?.(c);return{view:c,layout(l,p){let f=s.map(u=>u.map(h=>{let d=Sn(h.springConfig,h.box,h,e.globalC);return n&&(d.margin_L=d.margin_R=0),d}));return fo(f,l,e,o,p),f}}}function ke(s,t){return s.length===0?0:ki(s.map(e=>[e]),t).width}function ki(s,t){for(let i of s)for(let r of i)Xe(r,t);let e=wo(s,s[0][0].layoutLine,{},!0),n=1/0,o=-1/0;for(let i of e.layout(1/0))for(let r of i){let a=r.box.x+r.box.anchor;n=Math.min(n,a-r.WL),o=Math.max(o,a+r.WR)}for(let i of s)for(let r of i)r.box.x-=n;return{width:o-n,view:e.view}}function xc(s,{width:t,view:e},n,o,i,r,a,c){let l=s.flat(),p={hostExtents:new Map,attachmentExtents:new Map},f=0;for(let I of l)Ii(p.hostExtents,I),f=Math.max(f,I.ast.size*Ni);let u=l.map(I=>({x:I.box.x,y:0})),h=()=>{let I=Ri(p,n,f);return l.forEach((w,M)=>{w.box.y=u[M].y=I.axes.get(w.track)-w.box.visualAxis,w.onPlaced?.()}),I},d=h();if(o.length===0)return{height:d.height,positions:u,items:[]};let y=uo(n),m=[],g=[];m[e.index]=p,g[e.index]=e;let x=()=>go(o,{...i,width:t,originX:0,pages:[],lines:g,getVisualAxis:(I,w)=>d.axes.get(y(w))??0,getHostExtent:(I,w)=>m[I]?.hostExtents.get(y(w)),getRangeColumns:(I,w,M)=>mo(g[I],w,M,y)},m,y,r,a,c),b=x();b.needsRelayout&&(d=h(),b=x());let A=l[0],E={x:A.box.x,y:A.box.y},S=b.layoutItems&&_i(A,c),v=S&&(S.x!==0||S.y!==0)?{x:E.x-S.x,y:E.y-S.y}:E,L=b.items.map((I,w)=>({...I,reference:A,position:E,...b.layoutItems&&{layout:{...b.layoutItems[w],position:v}}}));return{height:d.height,positions:u,items:L}}function yc(s){let t=new Map;for(let e of s){let[n,...o]=e.endPoints??[];for(let i=n?.foldedInto;i;i=i.foldedInto){let r=i;if(!o.every(c=>gc(r,c)))continue;let a=t.get(i);a?a.push(e):t.set(i,[e])}}return t}function gc(s,t){for(let e=t.foldedInto;e;e=e.foldedInto)if(e===s)return!0;return!1}function Mi(s,t=!1){let e=t?s.layout??s:s,{position:n,geometry:o,box:i}=e,r=s.reference.box.x-n.x,a=s.reference.box.y-n.y;if(r===0&&a===0)return e;let c=l=>({...l,x:l.x+r,y:l.y+a});return{box:c(i),geometry:{regions:o.regions.map(c),occupancy:o.occupancy?.map(c),paint:l=>o.paint(new Ce(l,r,a))}}}function bc(s,t,e){if(e!==void 0)return new Array(s).fill(e);let n=new Array(s).fill(0),o=0;for(let i of t){let r=i.ast.size*Ni;r>n[i.layoutLine]&&(n[i.layoutLine]=r),r>o&&(o=r)}for(let i=0;i<s;i++)n[i]||=o;return n}function _i(s,t){let e=0,n=0;for(let o=s;o&&o!==t;o=o.foldedInto)e+=o.placementOffset?.x??0,n+=o.placementOffset?.y??0;return{x:e,y:n}}function go(s,t,e,n,o,i,r){if(s.length===0)return{items:[],needsRelayout:!1};let a=[];for(let f of i){let{x:u,y:h}=_i(f,r);(u!==0||h!==0)&&a.push({node:f,x:u,y:h,boxX:f.box.x,boxY:f.box.y})}let c=a.length>0||s.some(f=>f.placementOffset?.x||f.placementOffset?.y),l;if(c){for(let{node:f,x:u,y:h}of a)f.box.x-=u,f.box.y-=h;try{l=xo(s,{...t,layoutOnly:!0},e,n,o,!0)}finally{for(let{node:f,boxX:u,boxY:h}of a)f.box.x=u,f.box.y=h}}else l=xo(s,t,e,n,o,!0);if(!c)return l;let p;return{needsRelayout:l.needsRelayout,layoutItems:l.items,get items(){return p??=xo(s,t,e,n,o,!1).items}}}function xo(s,t,e,n,o,i){let r=new Map,a=[],c=!1;function l(h){let d=r.get(h);return d||(d=o(h,t.layoutOnly),d&&r.set(h,d)),d}function p(h,d,y){let m=t.lines[h],g=y===void 0?new Map:void 0,x,b=d&&"left"in d?d:void 0;if(!m||b&&b.left>=b.right)return g;let A=(M,C,_)=>{g?yo(g,M,C,_):x?Ke(x,C,_):x={top:C,bottom:_}},{start:E,end:S,wholeLine:v}=ho(m,d&&!("left"in d)?d:void 0,y,n),L=y&&n(y),I=b?.left??(v?t.originX:1/0),w=b?.right??(v?t.originX+t.width:-1/0);for(let M=E;M<=S;M++)for(let C of m.columns[M]){if(L&&C.track!==L||b&&(C.box.x+C.box.w<=I||C.box.x>=w))continue;v||(C.box.x<I&&(I=C.box.x),C.box.x+C.box.w>w&&(w=C.box.x+C.box.w));let _=Ye.get(C),P=_?.top??0,W=C.box.y+P-t.getVisualAxis(h,C.track);A(C.track,W,W+(C.box.h-P+(_?.bottom??0)))}for(let M of a[h]??[])L&&M.track!==L||M.right<=I||M.left>=w||A(M.track,M.top,M.bottom);return g??x}let f={...t,getRangeExtents:p,getHorizontalExtents:(h,d,y)=>p(h,{left:d,right:y}),getAttachmentOccupancy(h){let d=l(h)?.geometry;return d&&(d.occupancy??d.regions)},getAttachmentBox(h){let d=l(h);if(!d)throw new Error("Layout attachment dependency has not been measured");return d.box},getContentBounds(h){let d=[];for(let m of h.nodes)X(m)&&(m.box.w>0||m.box.h>0)&&d.push(wt(m,!0));for(let m of h.attachments){if(!Wt(m))continue;let g=l(m);if(!g&&!s.includes(m))continue;let x=g?.box??f.getAttachmentBox(m);(x.w>0||x.h>0)&&d.push(x)}let y={x:0,y:0,w:0,h:0};return Ne(y,d)?y:void 0}};return{items:s.map(h=>{let d=h.createGeometry(f),y={x:0,y:0,w:0,h:0};Ne(y,d.regions);let m={geometry:d,box:y};r.set(h,m);for(let g of d.occupancy??d.regions){if(g.line===void 0)continue;let x=e[g.line],b=n(g.track),A=g.y-t.getVisualAxis(g.line,b),E=A+g.h,S=x.hostExtents.get(b),v=x.attachmentExtents.get(b);i&&(A<Math.min(S?.top??1/0,v?.top??1/0)||E>Math.max(S?.bottom??-1/0,v?.bottom??-1/0))&&(c=!0),i&&yo(x.attachmentExtents,b,A,E),(a[g.line]??=[]).push({track:b,left:g.x,right:g.x+g.w,top:A,bottom:E})}return m}),needsRelayout:c}}function Ii(s,t){let e=Ye.get(t),n=e?.top??0,o=t.box.h-n+(e?.bottom??0),i=n-t.box.visualAxis;yo(s,t.track,i,i+o)}function Ri(s,t,e){let n=new Map,o=c=>{let l=s.hostExtents.get(c),p=s.attachmentExtents.get(c),f=l?{top:l.top,bottom:l.bottom}:null;p&&(f?Ke(f,p.top,p.bottom):f={top:p.top,bottom:p.bottom});let u=[];for(let d of c.groups){let y=d.members.map(o);if(y.every(x=>x===null))continue;let m=d.measure(y,e),g=null;for(let x of m){if(!x)continue;let b=x.offset+x.extent.top,A=x.offset+x.extent.bottom;g?Ke(g,b,A):g={top:b,bottom:A}}g&&u.push({group:d,placements:m,extent:g})}let h=(d,y)=>{f??={top:0,bottom:0};for(let m=0;m<d.group.members.length;m++){let g=d.placements[m];g&&n.set(d.group.members[m],y+g.offset)}Ke(f,y+d.extent.top,y+d.extent.bottom)};for(let d of u)d.group.place||h(d,0);for(let d of u){let y=d.group.place;if(!y)continue;h(d,y(f??{top:0,bottom:0},d.extent,e))}return f},i=o(t),r=new Map;if(!i)return{axes:r,height:0};let a=(c,l)=>{r.set(c,l);for(let p of c.groups)for(let f of p.members){let u=n.get(f);u!==void 0&&a(f,l+u)}};return a(t,-i.top),{axes:r,height:i.bottom-i.top}}var An=class{min=1/0;max=-1/0;add(t){t<this.min&&(this.min=t),t>this.max&&(this.max=t)}};function So(s,t,e,n,o,i){if(!(s>0&&s<1))return;let r=1-s;i.add(r*r*r*t+3*r*r*s*e+3*r*s*s*n+s*s*s*o)}function Oi(s,t,e,n,o){o.add(s),o.add(n);let i=-s+3*t-3*e+n,r=2*(s-2*t+e),a=t-s;if(Math.abs(i)<1e-12){Math.abs(r)>1e-12&&So(-a/r,s,t,e,n,o);return}let c=r*r-4*i*a;if(c<0)return;let l=Math.sqrt(c);So((-r+l)/(2*i),s,t,e,n,o),So((-r-l)/(2*i),s,t,e,n,o)}function $i(s,t,e,n){n.add(s),n.add(e);let o=s-2*t+e;if(Math.abs(o)<1e-12)return;let i=(s-t)/o;if(!(i>0&&i<1))return;let r=1-i;n.add(r*r*s+2*r*i*t+i*i*e)}function Bt(s){let t=new An,e=new An,n=0,o=0,i=0,r=0;for(let a of s){if(a.op==="Z"){n=i,o=r;continue}a.op==="C"?(Oi(n,a.cx1,a.cx2,a.x,t),Oi(o,a.cy1,a.cy2,a.y,e)):a.op==="Q"?($i(n,a.cx,a.x,t),$i(o,a.cy,a.y,e)):(t.add(a.x),e.add(a.y),a.op==="M"&&(i=a.x,r=a.y)),n=a.x,o=a.y}return Number.isFinite(t.min)?{x:t.min,y:e.min,w:t.max-t.min,h:e.max-e.min}:{x:0,y:0,w:0,h:0}}var wc=54.2813,Di=87.37505,En=72.8125,Sc=93.6719,Ac=-27.4688,Bi=-7.9375,Ec=Bi+Sc,Tc=[{op:"M",x:28.1406,y:86.06255},{op:"C",cx1:28.1406,cy1:86.06255,cx2:30.4531,cy2:84.07815,x:32.7656,y:81.42185},{op:"C",cx1:33.7656,cy1:80.43755,cx2:34.0938,cy2:79.10935,x:34.0938,y:78.10935},{op:"C",cx1:34.0938,cy1:77.12505,cx2:33.7656,cy2:76.45315,x:33.0938,y:75.79685},{op:"L",x:29.4531,y:72.15625},{op:"C",cx1:28.7969,cy1:71.50005,cx2:28.4688,cy2:70.82815,x:28.4688,y:70.17185},{op:"C",cx1:28.4688,cy1:68.84375,cx2:29.4531,cy2:68.18755,x:29.4531,y:68.18755},{op:"C",cx1:29.4531,cy1:68.18755,cx2:47.6563,cy2:47.00005,x:50.6406,y:43.68755},{op:"C",cx1:53.2969,cy1:40.04685,cx2:54.2813,cy2:36.40625,x:54.2813,y:33.09375},{op:"C",cx1:54.2813,cy1:26.14065,cx2:50.3125,cy2:19.85935,x:47.3281,y:17.21875},{op:"L",x:31.4375,y:1.32812},{op:"C",cx1:30.4531,cy1:.32812,cx2:29.7969,cy2:0,x:28.7969,y:0},{op:"C",cx1:27.1406,cy1:0,cx2:25.8125,cy2:1.32812,x:25.8125,y:1.32812},{op:"C",cx1:25.8125,cy1:1.32812,cx2:23.5,cy2:3.3125,x:21.1875,y:5.95312},{op:"C",cx1:20.1875,cy1:6.95313,cx2:19.8594,cy2:7.9375,x:19.8594,y:8.9375},{op:"C",cx1:19.8594,cy1:9.92188,cx2:20.1875,cy2:10.59375,x:20.8594,y:11.25},{op:"L",x:24.5,y:14.89063},{op:"C",cx1:25.1563,cy1:15.5625,cx2:25.4844,cy2:16.21875,x:25.4844,y:16.875},{op:"C",cx1:25.4844,cy1:18.20315,cx2:24.5,cy2:19.20315,x:24.5,y:19.20315},{op:"C",cx1:24.5,cy1:19.20315,cx2:6.625,cy2:40.37505,x:3.64063,y:43.68755},{op:"C",cx1:1,cy1:47.32815,cx2:0,cy2:50.96875,x:0,y:54.28125},{op:"C",cx1:0,cy1:61.23435,cx2:3.96875,cy2:67.51565,x:6.95313,y:70.17185},{op:"L",x:22.8438,y:86.06255},{op:"C",cx1:23.8281,cy1:87.04685,cx2:24.8281,cy2:87.37505,x:25.4844,y:87.37505},{op:"C",cx1:27.1406,cy1:87.37505,cx2:28.1406,cy2:86.06255,x:28.1406,y:86.06255}],Lc=[{op:"M",x:111.8751,y:21.5156},{op:"C",cx1:112.5313,cy1:20.1875,cx2:113.5313,cy2:18.2031,x:113.5313,y:16.875},{op:"C",cx1:113.5313,cy1:12.23438,cx2:109.8907,cy2:8.9375,x:105.2501,y:8.9375},{op:"C",cx1:103.9219,cy1:8.9375,cx2:101.6094,cy2:9.26563,x:100.2813,y:10.25},{op:"L",x:72.1563,y:31.7656},{op:"L",x:72.1563,y:28.4531},{op:"C",cx1:72.1563,cy1:16.54688,cx2:66.8594,cy2:8.26563,x:58.2501,y:.98437},{op:"C",cx1:57.2657,cy1:.32812,cx2:55.9376,cy2:0,x:55.2657,y:0},{op:"C",cx1:53.6251,cy1:0,cx2:52.9532,cy2:.98437,x:52.9532,y:.98437},{op:"C",cx1:51.6251,cy1:2.3125,cx2:49.3126,cy2:4.29687,x:48.3282,y:5.625},{op:"C",cx1:47.3282,cy1:6.9375,cx2:47.0001,cy2:7.9375,x:47.0001,y:8.9375},{op:"C",cx1:47.0001,cy1:9.92188,cx2:47.3282,cy2:10.57813,x:47.6563,y:11.25},{op:"C",cx1:49.9688,cy1:13.5625,cx2:50.9688,cy2:16.21875,x:50.9688,y:18.8594},{op:"C",cx1:50.9688,cy1:24.8125,cx2:46.3282,cy2:30.1094,x:41.0469,y:30.1094},{op:"C",cx1:39.3907,cy1:30.1094,cx2:37.7344,cy2:29.4531,x:36.4063,y:28.4531},{op:"L",x:12.9063,y:10.57813},{op:"C",cx1:11.5782,cy1:9.59375,cx2:9.5938,cy2:8.9375,x:7.9375,y:8.9375},{op:"C",cx1:3.6407,cy1:8.9375,cx2:0,cy2:12.57813,x:0,y:16.875},{op:"C",cx1:0,cy1:18.2031,cx2:.6563,cy2:20.1875,x:1.3125,y:21.5156},{op:"L",x:49.9688,y:90.3594},{op:"C",cx1:51.2969,cy1:92.3438,cx2:54.2813,cy2:93.6719,x:56.5938,y:93.6719},{op:"C",cx1:58.9063,cy1:93.6719,cx2:61.8907,cy2:92.3438,x:63.2188,y:90.3594},{op:"L",x:111.8751,y:21.5156}];function Pi(s,t,e,n,o,i){let r=c=>e+(i?wc-c:c)*o,a=c=>n+(i?Di-c:c)*o;for(let c of t)c.op==="Z"?s.push(c):c.op==="C"?s.push({op:"C",cx1:r(c.cx1),cy1:a(c.cy1),cx2:r(c.cx2),cy2:a(c.cy2),x:r(c.x),y:a(c.y)}):c.op==="Q"?s.push({op:"Q",cx:r(c.cx),cy:a(c.cy),x:r(c.x),y:a(c.y)}):s.push({op:c.op,x:r(c.x),y:a(c.y)})}function Fi(s,t,e){let n=e==="up"||e==="down",o=Math.max(1,Math.round(s/(t*.3))),i=n?Math.max(0,o-1):o,r=n?Ec+En*i:Di+En*(i-1),a=s/r,c=[];for(let u=0;u<i;u++)Pi(c,Tc,0,u*En*a,a,e==="");n&&Pi(c,Lc,Ac*a,(i*En+Bi)*a,a,!1);let l=Bt(c);if(e!=="up")return{commands:c,bounds:l};let p=l.x+l.w,f=u=>p-(u-l.x);for(let u of c)u.op!=="Z"&&(u.op==="C"?(u.cx1=f(u.cx1),u.cy1=s-u.cy1,u.cx2=f(u.cx2),u.cy2=s-u.cy2):u.op==="Q"&&(u.cx=f(u.cx),u.cy=s-u.cy),u.x=f(u.x),u.y=s-u.y);return{commands:c,bounds:{x:l.x,y:s-l.y-l.h,w:l.w,h:l.h}}}function Cc(s){let t=s,e=s.ast;return(e.callName==="up"||e.callName==="down")&&Array.isArray(t.members)&&Array.isArray(e.contents)?t:null}var Ao=class extends ${static def={name:["arp","arpeggio"],description:"\u7436\u97F3",details:`~~~jpfun
|
|
6
|
+
\u4F4D\u7F6E\u504F\u79FB\u5728\u6392\u7248\u540E\u5E94\u7528\uFF0C\u76F8\u90BB\u5BF9\u8C61\u4FDD\u6301\u539F\u4F4D\uFF1B\u5360\u4F4D\u8C03\u6574\u5728\u6392\u7248\u524D\u5E94\u7528\u3002\u53EA\u5305\u88F9\u5173\u7CFB\u5BF9\u8C61\u65F6\uFF0C\u5E73\u79FB\u4F5C\u7528\u4E8E\u8BE5\u5173\u7CFB\u5BF9\u8C61\u672C\u8EAB\u3002`,allowExtraArgs:!1,args:[{type:"content",description:"\u8981\u5FAE\u8C03\u7684\u5185\u5BB9\u6216\u5173\u7CFB\u5BF9\u8C61",default:null},{name:"dx",description:"\u6392\u7248\u540E\u7684\u6C34\u5E73\u504F\u79FB\uFF0C\u6B63\u503C\u5411\u53F3\uFF0C\u4E0D\u6539\u53D8\u5360\u4F4D",type:"length",default:{value:0,unit:"px"}},{name:"dy",description:"\u6392\u7248\u540E\u7684\u5782\u76F4\u504F\u79FB\uFF0C\u6B63\u503C\u5411\u4E0B\uFF0C\u4E0D\u6539\u53D8\u5360\u4F4D",type:"length",default:{value:0,unit:"px"}},{name:"dw",description:"\u589E\u51CF\u6C34\u5E73\u5360\u4F4D\uFF0C\u6309\u539F\u5DE6\u53F3\u6BD4\u4F8B\u5206\u914D\uFF0C\u6700\u7EC8\u5BBD\u5EA6\u4E0D\u5C0F\u4E8E 0",type:"length",default:{value:0,unit:"px"}},{name:"dh",description:"\u589E\u51CF\u4E0B\u65B9\u5360\u4F4D\uFF0C\u6700\u7EC8\u9AD8\u5EA6\u4E0D\u5C0F\u4E8E 0",type:"length",default:{value:0,unit:"px"}}]};target;dx;dy;dw;dh;get children(){return[this.target]}loweringEnter(t){let e={temporals:0,attachments:[],onTemporal:n=>{W(n)&&(e.temporals++,Jc(n,this))},onAttachment:n=>{Xt(n)&&e.attachments.push(n)}};return t.beginLoweringGroup(this,e),[]}loweringExit(t){let{temporals:e,attachments:n}=t.endLoweringGroup(this);if(e===0&&n.length===0)t.diagnostics.push(new K("W_ADJUST_NO_TARGET","@adjust \u6CA1\u6709\u627E\u5230\u53EF\u8C03\u6574\u7684\u5BF9\u8C61",this.sourceSpan));else if(e===0&&(this.dx!==0||this.dy!==0))for(let o of n)tl(o,this.dx,this.dy);return[]}constructor(t,e,n,o=null){super(t,o);let[s,i,a,c,l]=this.getArgValue(e,n);s.parent=this,this.target=s,this.dx=n.length2px(i),this.dy=n.length2px(a),this.dw=n.length2px(c),this.dh=n.length2px(l)}toString(t){return`@adjust(${this.target.toString(t)}, dx=${this.dx}px, dy=${this.dy}px, dw=${this.dw}px, dh=${this.dh}px)`}},Ys=vo;function Jc(r,{dx:t,dy:e,dw:n,dh:o}){if(t===0&&e===0&&n===0&&o===0)return;let s=!r.placementOffset&&(t!==0||e!==0);(t!==0||e!==0)&&(r.placementOffset={x:(r.placementOffset?.x??0)+t,y:(r.placementOffset?.y??0)+e});let i,a,c=r.finalizeLayout;if(r.finalizeLayout=m=>{c?.call(r,m),i=a=void 0;let d=Math.max(0,r.box.w+n);r.box.anchor=r.box.w>0?r.box.anchor*d/r.box.w:0,r.box.w=d,r.box.h=Math.max(0,r.box.h+o)},!s)return;let{x:l,y:u}=r.box;Object.defineProperties(r.box,{x:{get:()=>l,set(m){m===i&&l===i&&(i=void 0),l=m}},y:{get:()=>u,set(m){m===a&&u===a&&(a=void 0),u=m}}});let p=r.onPlaced;r.onPlaced=()=>{l!==i&&(l+=r.placementOffset.x),u!==a&&(u+=r.placementOffset.y),p?.call(r),i=l,a=u}}function tl(r,t,e){let n=!r.placementOffset;if(r.placementOffset={x:(r.placementOffset?.x??0)+t,y:(r.placementOffset?.y??0)+e},!n)return;let o=r.createGeometry;r.createGeometry=s=>{let i=o.call(r,s);if(s.layoutOnly)return i;let{x:a,y:c}=r.placementOffset,l=u=>({...u,x:u.x+a,y:u.y+c});return{regions:i.regions.map(l),occupancy:i.occupancy?.map(l),paint(u){i.paint(new Re(u,a,c))}}}}var En=1,el=6,nl=16,ko=32,qs=1e-6,ol=.01;function Pn(r,t=En){let e=r.alpha_L??r.alpha_R??el;r.alpha_L??=e,r.alpha_R??=e;let n=r.mu_L??r.mu_R??nl;r.mu_L??=n,r.mu_R??=n,r.beta_L??=t/Math.max(r.alpha_L,qs),r.beta_R??=t/Math.max(r.alpha_R,qs)}function Mn(r,t,e,n=En){Pn(r,n);let o=Math.pow(Math.max(e.T.toNumber(),ol),.5);return{config:r,box:t,time:e,duration_L:o,duration_R:o,WL:t.anchor,WR:t.w-t.anchor,margin_L:o*r.alpha_L,margin_R:o*r.alpha_R}}function rl(r,t=En){let e=new Map,n=0;for(let s of r)for(let i of s)e.has(i.time.track)||e.set(i.time.track,n++);let o=[];for(let s of r){if(s.length===0)continue;let i=Array(s.length);o.push(i);let a=0,c=0,l=n;for(let p of s){p.WL>a&&(a=p.WL),p.WR>c&&(c=p.WR);let m=e.get(p.time.track);if(i[m]){let d=i[m];p.time.T.compare(d.time.T)>0?(i[m]=p,i[l++]=d):i[l++]=p}else i[m]=p}let u=s[0].time.t;for(let p of e){let m=p[1];i[m]||(i[m]=Mn({alpha_L:a,alpha_R:c},{x:0,w:0,anchor:0},{t:u,T:new G(1),track:p[0]},t))}}return{mat:o,rows:n}}function sl(r,t,e,n){let o=n-e-r.WR-t.WL,s=r.margin_R+t.margin_L;if(o>=s)return{force:0,stiffness:0};let i=r.config.beta_R/r.duration_R,a=t.config.beta_L/t.duration_L,c=i*a/(i+a),l,u;if(o<0){let p=r.config.mu_R*t.config.mu_L/(r.config.mu_R+t.config.mu_L);l=c*s-p*o,u=p}else{let p=s-o;l=c*p,u=c}return{force:l,stiffness:u}}function il(r,t,e=ko){let n=t-r.WL,o=r.margin_L;if(n>=o)return{force:0,stiffness:0};let s=r.config.beta_L/r.duration_L;if(n>=0)return{force:s*(o-n),stiffness:s};let i=r.config.mu_L*e;return{force:r.config.alpha_L*r.config.beta_L-i*n,stiffness:i}}function al(r,t,e,n=ko){let o=e-(t+r.WR),s=r.margin_R;if(o>=s)return{force:0,stiffness:0};let i=r.config.beta_R/r.duration_R;if(o>=0)return{force:i*(s-o),stiffness:i};let a=r.config.mu_R*n;return{force:r.config.alpha_R*r.config.beta_R-a*o,stiffness:a}}function cl(r){return{damping:r.damping??.6,maxIter:r.maxIter??100,eps:r.eps??.01,crossPunish:r.crossPunish??ko,globalC:r.globalC??En}}function ll(r,t,e,n,o){let{damping:s,maxIter:i,eps:a,crossPunish:c}=o,l=r.length,u=new Float64Array(t);for(let T=0;T<l;T++){let L=0,w=r[T];for(let A=0;A<t;A++){let C=u[A]+w[A].WL+w[A].margin_L;C>L&&(L=C)}for(let A=0;A<t;A++)u[A]=L+w[A].WR+w[A].margin_R;e[T]=L}let p=u.reduce((T,L)=>Math.max(T,L),0);if(p<=n)return!0;p=n/p;for(let T=0;T<l;T++)e[T]*=p;let m=new Float64Array(l),d=new Float64Array(l+1);function f(T){m.fill(0),d.fill(0);for(let L=0;L<t;L++){let w=r[0][L],A=il(w,T[0],c);m[0]+=A.force,d[0]+=A.stiffness;for(let E=1;E<l;E++){let v=r[E-1][L],S=r[E][L],M=sl(v,S,T[E-1],T[E]);m[E-1]-=M.force,m[E]+=M.force,d[E]+=M.stiffness}let C=r[l-1][L],_=al(C,T[l-1],n,c);m[l-1]-=_.force,d[l]+=_.stiffness}return m}let x=new Float64Array(l),y=new Float64Array(l);function h(){for(let L=0;L<l;L++){let w=L===0?0:d[L]/x[L-1],A=d[L]+d[L+1]+1e-4-w*d[L];if(!(A>0)||!Number.isFinite(A))throw new Error("Horizontal spring stiffness must produce a finite positive definite system");x[L]=A,y[L]=m[L]+(L===0?0:w*y[L-1])}y[l-1]/=x[l-1];for(let L=l-2;L>=0;L--)y[L]=(y[L]+d[L+1]*y[L+1])/x[L];return y}let g=0,b=0;for(;g<i;g++){let T=f(e);b=0;for(let w=0;w<T.length;w++){let A=Math.abs(T[w]);A>b&&(b=A)}if(b<a)break;let L=h();for(let w=0;w<l;w++)e[w]+=s*L[w]}return!1}function _e(r,t,e,n,o,s,i){if(e.length!==r.length||n.length!==Math.max(0,e.length-1))throw new Error("Horizontal region state does not match its columns");if(e.length===0||t===0)return;let a=n.some(d=>d!==0),c,l,u=r,p=e;if(a){c=new Uint32Array(e.length),l=new Float64Array(e.length),u=[];for(let d=0;d<e.length;){let f=d;for(;f<n.length&&n[f];)f++;let x=u.length;for(let y=d;y<=f;y++)c[y]=x,l[y]=e[y]-e[d];if(d===f)u.push(r[d]);else{let y=e[f]-e[d];u.push(Array.from({length:t},(h,g)=>{let b=r[d][g],T=r[f][g];return{config:{alpha_L:b.config.alpha_L,alpha_R:T.config.alpha_R,mu_L:b.config.mu_L,mu_R:T.config.mu_R,beta_L:b.config.beta_L,beta_R:T.config.beta_R},box:b.box,time:b.time,duration_L:b.duration_L,duration_R:T.duration_R,WL:b.WL,WR:y+T.WR,margin_L:b.margin_L,margin_R:T.margin_R}}))}d=f+1}p=new Float64Array(u.length)}let m=ll(u,t,p,o,s);if(n.fill(1),i!==void 0){let d=0,f=0;for(let y=0;y<t;y++)d=Math.max(d,u[0][y].WL),f=Math.max(f,u[u.length-1][y].WR);let x=p[p.length-1]+f-p[0]+d;if(!m||x>=o*i){let y=d-p[0],h=o-x;for(let g=0;g<p.length;g++)p[g]+=y+(p.length>1?h*g/(p.length-1):0)}}if(a)for(let d=0;d<e.length;d++)e[d]=p[c[d]]+l[d]}function Eo(r,t,e={},n=[],o){let s=cl(e),{mat:i,rows:a}=rl(r,s.globalC),c=new Float64Array(i.length),l=new Uint8Array(Math.max(0,i.length-1)),u=n.length>1?[...n].sort((p,m)=>p.end-p.start-(m.end-m.start)):n;for(let{start:p,end:m,hook:d}of u){if(p<0||m<p||m>=i.length)throw new Error("Horizontal layout registration references invalid columns");d({columns:i,rows:a,start:p,end:m,X:c,fixed:l,options:s})}_e(i,a,c,l,t,s,o);for(let p=0;p<i.length;p++)for(let m of i[p])m.box.x=c[p]-m.box.anchor;return i}var Fe=class extends Error{constructor(e,n,o){super(`Page cannot fit layout line ${e}: requires ${n}px, available ${o}px`);this.line=e;this.requiredHeight=n;this.availableHeight=o;this.name="PageLayoutError"}line;requiredHeight;availableHeight},Lt={width:794,height:1/0,marginTop:45,marginBottom:48,marginLeft:40,marginRight:40,lineGap:22,minLineGap:11,fillRatio:.5};function Je(r={}){let t=r.height??Lt.height,e={width:r.width??Lt.width,height:t<=0?1/0:t,marginTop:Math.max(0,r.marginTop??Lt.marginTop),marginBottom:Math.max(0,r.marginBottom??Lt.marginBottom),marginLeft:Math.max(0,r.marginLeft??Lt.marginLeft),marginRight:Math.max(0,r.marginRight??Lt.marginRight),lineGap:Math.max(0,r.lineGap??Lt.lineGap),minLineGap:Math.max(0,r.minLineGap??Lt.minLineGap),fillRatio:r.fillRatio??Lt.fillRatio};if(!Number.isFinite(e.width)||e.width<=0)throw new Error(`Page width must be a positive finite number, got ${e.width}`);if(e.height!==1/0&&(!Number.isFinite(e.height)||e.height<=0))throw new Error(`Page height must be positive or Infinity, got ${e.height}`);if([e.marginTop,e.marginBottom,e.marginLeft,e.marginRight,e.lineGap,e.minLineGap].some(i=>!Number.isFinite(i)))throw new Error("Page margins and line gap must be finite non-negative numbers");let o=e.width-e.marginLeft-e.marginRight;if(o<=0)throw new Error(`Page horizontal margins leave no content width: ${o}px`);let s=e.height-e.marginTop-e.marginBottom;if(Number.isFinite(e.height)&&s<=0)throw new Error(`Page vertical margins leave no content height: ${s}px`);return e}function Po(r,t,e=[],n=[]){let o=t.height-t.marginTop-t.marginBottom,s=Math.min(t.lineGap,t.minLineGap),i=d=>Math.max(t.lineGap-Math.max(0,n[d]??0),s),a=[],c=new Array(r.length).fill(0),l=0,u=0,p=0,m=(d,f)=>{let x=d-u,y=f?Math.max(0,o-p)/x:0,h=l+t.marginTop;for(let b=u;b<d;b++)c[b]=h,h+=r[b]+(b+1<d?i(b+1)+y:0);let g=Number.isFinite(t.height)?t.height:h-l+t.marginBottom;a.push({bounds:{x:0,y:l,w:t.width,h:g},lineStart:u,lineEnd:d}),l+=g,u=d,p=0};for(let d=0;d<r.length;d++){let f=r[d];if(Number.isFinite(t.height)&&f>o+1e-6)throw new Fe(d,f,o);d>u&&(e[d]!==void 0||Number.isFinite(t.height)&&p+i(d)+f>o+1e-6)&&m(d,Number.isFinite(t.height)&&(e[d]??!0)),p+=(d>u?i(d):0)+f}return r.length>u&&m(r.length,!1),{pages:a,lineTops:c}}var Zs={start:0,end:-1};function Mo(r){let t=new Set,e=n=>{t.add(n);for(let o of n.groups)for(let s of o.members)e(s)};return e(r),n=>{for(let o=n;o;o=o.parent)if(t.has(o))return o;return n}}function Qs(r,t){for(let e=t;e;){let n=r.columnOf(e);if(n>=0)return n;let o=e instanceof tt?e.foldedInto:void 0;e=o&&W(o)?o:void 0}return-1}function Ro(r,t){if(!t)return{start:0,end:r.columns.length-1};let[e,n]=t;if(e.layoutLine>n.layoutLine&&([e,n]=[n,e]),r.index<e.layoutLine||r.index>n.layoutLine)return Zs;let o=e.layoutLine<r.index?0:Qs(r,e),s=n.layoutLine>r.index?r.columns.length-1:Qs(r,n);return o<0||s<0?Zs:{start:Math.min(o,s),end:Math.max(o,s)}}function _o(r,t,e,n){if(!r)return[];let{start:o,end:s}=Ro(r,t),i=r.columns.slice(o,s+1);if(!e)return i;let a=n(e),c=l=>l.track===a;return i.every(l=>l.every(c))?i:i.map(l=>l.filter(c))}function Ut(r,t,e,n=r.originX){return r.lines[t]?.trackRuns.get(e)?.find(s=>!s.T.isZero())?.box.x??n}function Kt(r,t){let e=r.lines[t]?.trackRuns;if(!e||e.size===0)return r.originX+r.width;let n=r.originX;for(let o of e.values())for(let s of o)n=Math.max(n,s.box.x+s.box.w);return n}var ti=.75,en=new WeakMap;function St(r,t=!1){let{box:e}=r,n=en.get(r);if(!n)return e;let o=t?n.contentTop:n.top,s=t?0:n.bottom;return{x:e.x,y:e.y+o,w:e.w,h:e.h-o+s}}function Oe(r,t){let e=1/0,n=1/0,o=-1/0,s=-1/0;for(let i of t)e=Math.min(e,i.x),n=Math.min(n,i.y),o=Math.max(o,i.x+i.w),s=Math.max(s,i.y+i.h);return Number.isFinite(e)?(r.x=e,r.y=n,r.w=o-e,r.h=s-n,!0):(r.x=r.y=r.w=r.h=0,!1)}function nn(r,t){if(r.springConfig={},r.decorations&&en.delete(r),r.decorations=[],r.ports={},r.box.x=r.box.y=0,r.prepareLayout(t),r.addon)for(let[e,n]of Object.entries(r.addon)){let o=t.decorationHandlers.get(e);if(!o)continue;let s=o(r,n,t);s&&r.decorations.push(s)}ul(r),r.finalizeLayout?.(t)}function Oo(r,t,e={}){let n=r.attachments.filter(Xt),o=Je(r.page),s=o.width-o.marginLeft-o.marginRight,i=o.marginLeft,a=Mo(r.rootTrack),c=new Map(n.map((S,M)=>[S,M])),l=dl(n),u=[];if(n.length){for(let S of r.astToTemporal.values())if(S.some(M=>M.placementOffset?.x||M.placementOffset?.y)){u=[...new Set([...r.astToTemporal.values()].flat().filter(W))];break}}let p=new Map,m=(S,M=!1)=>{let I=p.get(S);return I&&Js(I,M)};t={...t,layoutSubdomain(S,M,I,z){let j=ei(M,t),q=new Set(M.flat()),et=R=>{for(let D=R;D&&D!==S;D=D.foldedInto)if(q.has(D))return!0;return!1},N=z.filter(Xt).filter(R=>!R.endPoints?.length);for(let R of l.get(S)??[])!p.has(R)&&R.endPoints.every(et)&&N.push(R);N.sort((R,D)=>c.get(R)-c.get(D));let O=ml(M,j,I,N,t,m,u.length?u.filter(et):u,S);return N.forEach((R,D)=>p.set(R,O.items[D])),{width:j.width,height:O.height,positions:O.positions}}};let{lines:d,pageBreaks:f}=pl(r),x=[];for(let S of d)for(let M of S.columns)for(let I of M)x.push(I),nn(I,t);let y=n.filter(S=>!p.has(S)),h=d.map((S,M)=>Io(S.columns,M,e)),g=h.map(S=>S.view);for(let S of y)S.prepareHorizontal?.(g,t);for(let S of h){S.layout(s,o.fillRatio);for(let M of S.view.columns)for(let I of M)I.box.x+=i}if(e.horizontalOnly)return{diagnostics:r.diagnostics,objects:x,attachments:[],bounds:{x:0,y:0,w:0,h:0},lineCount:d.length,pages:[]};for(let S of x){let M=d[S.layoutLine];ri(M.hostExtents,S)}let b=yl(d.length,x,e.rowGap),T=()=>{let S=[],M=[],I=d.map((N,O)=>{let R=si(N,r.rootTrack,b[O]);S.push(R.height);let D=1/0;for(let U of N.columns)for(let Q of U)D=Math.min(D,(R.axes.get(Q.track)??0)-Q.ast.size/2);return M.push(D<1/0?D:0),R.axes}),z,j;try{({pages:z,lineTops:j}=Po(S,o,f,M))}catch(N){if(!(N instanceof Fe))throw N;let O=d[N.line],R=1/0,D=-1/0;for(let U of O?.columns??[])for(let Q of U)R=Math.min(R,Q.ast.sourceSpan.start),D=Math.max(D,Q.ast.sourceSpan.end);throw Number.isFinite(R)?Y.error.PageOverflow(N.requiredHeight,N.availableHeight,{start:R,end:D}):N}let q=(N,O)=>(j[N]??0)+(I[N]?.get(O)??0);for(let N of x)N.box.y=q(N.layoutLine,N.track)-N.box.visualAxis,N.onPlaced?.();let et={...t,width:s,originX:i,pages:z.map(N=>N.bounds),lines:g,getVisualAxis:(N,O)=>q(N,a(O)),getHostExtent:(N,O)=>d[N]?.hostExtents.get(a(O)),getRangeColumns:(N,O,R)=>_o(g[N],O,R,a)};return{pages:z,attachmentContext:et}},L=T(),w=oi(y,L.attachmentContext,d,a,m,u);w.needsRelayout&&(L=T(),w=Rn(y,L.attachmentContext,d,a,m,!1));let A=L.pages,C=0,_=n.map(S=>{let M=p.get(S),{geometry:I}=M?Js(M):w.items[C++];return{regions:I.regions,layer:S.layer,sourceSpan:S.sourceSpan,paint(z){I.paint(z)}}}),E={x:0,y:0,w:0,h:0};function*v(){for(let S of A)yield S.bounds;for(let S of x)yield St(S);for(let S of _)yield*S.regions}return Oe(E,v()),{diagnostics:r.diagnostics,objects:x,attachments:_,bounds:E,lineCount:d.length,pages:A}}function ul(r){if(r.decorations.length===0)return;let t=0,e=-1/0,n=0,o=-1/0;for(let i of["above","below"]){let a=i==="above",c=r.decorations.length===1?r.decorations:r.decorations.filter(m=>m[i]);c.length>1&&c.sort((m,d)=>m[i].order-d[i].order);let l=a?0:r.ports["decoration.below"]?.y??r.box.h,u=a?-1/0:r.box.h,p=u;for(let m of c){let d=m[i];if(!d)continue;let f=Math.max(0,d.height??0);!a&&!m.paint&&(l=Math.max(l,p));let x=a?l-(d.gap??0)-f:l+(d.gap??0);d.place?.(x),l=a?x:x+f,n=Math.min(n,x),u=a?Math.max(u,x+f):l,m.paint&&(t=Math.min(t,x),p=a?Math.max(p,x+f):l)}o=Math.max(o,u),e=Math.max(e,p)}r.box.h=e;let s=Math.max(0,o-e);(n!==0||s!==0)&&en.set(r,{top:n,bottom:s,contentTop:t})}function pl(r){let t=()=>({columns:[],hostExtents:new Map,attachmentExtents:new Map}),e=[],n=[],o=t();for(let s of r.columns){let i=[];for(;e.length<s[0].layoutLine;)e.push(o),o=t();for(let a of s){let c=a.addon?.pageBreakBefore;c!==void 0&&(n[e.length]=(n[e.length]??!0)&&c),W(a)&&i.push(a)}i.length&&o.columns.push(i)}return(o.columns.length>0||n[e.length]!==void 0||e.length===0)&&e.push(o),{lines:e,pageBreaks:n}}function tn(r,t,e){r.top=Math.min(r.top,t),r.bottom=Math.max(r.bottom,e)}function Fo(r,t,e,n){let o=r.get(t);o?tn(o,e,n):r.set(t,{top:e,bottom:n})}function Io(r,t,e={},n=!1){let o=[],s=new Map,i=new Map,a;for(let l=0;l<r.length;l++)for(let u of r[l]){s.set(u,l),Pn(u.springConfig,e.globalC);let p=i.get(u.track);p?p.push(u):i.set(u.track,[u])}let c={index:t,columns:r,trackRuns:i,columnOf:l=>s.get(l)??-1,trackIndexOf(l){if(!a){a=new Map;for(let u of i.values())for(let p=0;p<u.length;p++)a.set(u[p],p)}return a.get(l)??-1},registerHorizontalLayoutHook(l,u,p){let m=s.get(l),d=s.get(u);m===void 0||d===void 0||o.push({start:Math.min(m,d),end:Math.max(m,d),hook:p})}};for(let l of r)for(let u of l)u.prepareHorizontal?.(c);return{view:c,layout(l,u){let p=r.map(m=>m.map(d=>{let f=Mn(d.springConfig,d.box,d,e.globalC);return n&&(f.margin_L=f.margin_R=0),f}));return Eo(p,l,e,o,u),p}}}function Ie(r,t){return r.length===0?0:ei(r.map(e=>[e]),t).width}function ei(r,t){for(let s of r)for(let i of s)nn(i,t);let e=Io(r,r[0][0].layoutLine,{},!0),n=1/0,o=-1/0;for(let s of e.layout(1/0))for(let i of s){let a=i.box.x+i.box.anchor;n=Math.min(n,a-i.WL),o=Math.max(o,a+i.WR)}for(let s of r)for(let i of s)i.box.x-=n;return{width:o-n,view:e.view}}function ml(r,{width:t,view:e},n,o,s,i,a,c){let l=r.flat(),u={hostExtents:new Map,attachmentExtents:new Map},p=0;for(let _ of l)ri(u.hostExtents,_),p=Math.max(p,_.ast.size*ti);let m=l.map(_=>({x:_.box.x,y:0})),d=()=>{let _=si(u,n,p);return l.forEach((E,v)=>{E.box.y=m[v].y=_.axes.get(E.track)-E.box.visualAxis,E.onPlaced?.()}),_},f=d();if(o.length===0)return{height:f.height,positions:m,items:[]};let x=Mo(n),y=[],h=[];y[e.index]=u,h[e.index]=e;let g=()=>oi(o,{...s,width:t,originX:0,pages:[],lines:h,getVisualAxis:(_,E)=>f.axes.get(x(E))??0,getHostExtent:(_,E)=>y[_]?.hostExtents.get(x(E)),getRangeColumns:(_,E,v)=>_o(h[_],E,v,x)},y,x,i,a,c),b=g();b.needsRelayout&&(f=d(),b=g());let T=l[0],L={x:T.box.x,y:T.box.y},w=b.layoutItems&&ni(T,c),A=w&&(w.x!==0||w.y!==0)?{x:L.x-w.x,y:L.y-w.y}:L,C=b.items.map((_,E)=>({..._,reference:T,position:L,...b.layoutItems&&{layout:{...b.layoutItems[E],position:A}}}));return{height:f.height,positions:m,items:C}}function dl(r){let t=new Map;for(let e of r){let[n,...o]=e.endPoints??[];for(let s=n?.foldedInto;s;s=s.foldedInto){let i=s;if(!o.every(c=>fl(i,c)))continue;let a=t.get(s);a?a.push(e):t.set(s,[e])}}return t}function fl(r,t){for(let e=t.foldedInto;e;e=e.foldedInto)if(e===r)return!0;return!1}function Js(r,t=!1){let e=t?r.layout??r:r,{position:n,geometry:o}=e,s=r.reference.box.x-n.x,i=r.reference.box.y-n.y;if(s===0&&i===0)return e;let a=c=>({...c,x:c.x+s,y:c.y+i});return{geometry:{regions:o.regions.map(a),occupancy:o.occupancy?.map(a),paint:c=>o.paint(new Re(c,s,i))}}}function yl(r,t,e){if(e!==void 0)return new Array(r).fill(e);let n=new Array(r).fill(0),o=0;for(let s of t){let i=s.ast.size*ti;i>n[s.layoutLine]&&(n[s.layoutLine]=i),i>o&&(o=i)}for(let s=0;s<r;s++)n[s]||=o;return n}function ni(r,t){let e=0,n=0;for(let o=r;o&&o!==t;o=o.foldedInto)e+=o.placementOffset?.x??0,n+=o.placementOffset?.y??0;return{x:e,y:n}}function oi(r,t,e,n,o,s,i){if(r.length===0)return{items:[],needsRelayout:!1};let a=[];for(let p of s){let{x:m,y:d}=ni(p,i);(m!==0||d!==0)&&a.push({node:p,x:m,y:d,boxX:p.box.x,boxY:p.box.y})}let c=a.length>0||r.some(p=>p.placementOffset?.x||p.placementOffset?.y),l;if(c){for(let{node:p,x:m,y:d}of a)p.box.x-=m,p.box.y-=d;try{l=Rn(r,{...t,layoutOnly:!0},e,n,o,!0)}finally{for(let{node:p,boxX:m,boxY:d}of a)p.box.x=m,p.box.y=d}}else l=Rn(r,t,e,n,o,!0);if(!c)return l;let u;return{needsRelayout:l.needsRelayout,layoutItems:l.items,get items(){return u??=Rn(r,t,e,n,o,!1).items}}}function Rn(r,t,e,n,o,s){let i=new Map,a=[],c=!1;function l(d){let f=i.get(d);return f||(f=o(d,t.layoutOnly),f&&i.set(d,f)),f}function u(d,f,x){let y=t.lines[d],h=x===void 0?new Map:void 0,g,b=f&&"left"in f?f:void 0;if(!y||b&&b.left>=b.right)return h;let T=(v,S,M)=>{h?Fo(h,v,S,M):g?tn(g,S,M):g={top:S,bottom:M}},L=f&&!("left"in f)?f:void 0,{start:w,end:A}=Ro(y,L),C=x&&n(x),_=b?.left??(L?1/0:t.originX),E=b?.right??(L?-1/0:t.originX+t.width);for(let v=w;v<=A;v++)for(let S of y.columns[v]){if(C&&S.track!==C||b&&(S.box.x+S.box.w<=_||S.box.x>=E))continue;L&&(S.box.x<_&&(_=S.box.x),S.box.x+S.box.w>E&&(E=S.box.x+S.box.w));let M=en.get(S),I=M?.top??0,z=S.box.y+I-t.getVisualAxis(d,S.track);T(S.track,z,z+(S.box.h-I+(M?.bottom??0)))}for(let v of a[d]??[])C&&v.track!==C||v.right<=_||v.left>=E||T(v.track,v.top,v.bottom);return h??g}let p={...t,getRangeExtents:u,getHorizontalExtents:(d,f,x)=>u(d,{left:f,right:x}),getAttachmentOccupancy(d){let f=l(d)?.geometry;return f&&(f.occupancy??f.regions)},getAttachmentBox(d){let f=l(d);if(!f)throw new Error("Layout attachment dependency has not been measured");return f.box||(f.box={x:0,y:0,w:0,h:0},Oe(f.box,f.geometry.regions)),f.box},getContentBounds(d){let f=[];for(let y of d.nodes)W(y)&&(y.box.w>0||y.box.h>0)&&f.push(St(y,!0));for(let y of d.attachments){if(!Xt(y))continue;let h=l(y);if(!(!h&&!r.includes(y))){if(!h)throw new Error("Layout attachment dependency has not been measured");for(let g of h.geometry.regions)(g.w>0||g.h>0)&&f.push(g)}}let x={x:0,y:0,w:0,h:0};return Oe(x,f)?x:void 0}};return{items:r.map(d=>{let f=d.createGeometry(p),x={geometry:f};i.set(d,x);for(let y of f.occupancy??f.regions){if(y.line===void 0)continue;let h=e[y.line],g=n(y.track),b=y.y-t.getVisualAxis(y.line,g),T=b+y.h,L=h.hostExtents.get(g),w=h.attachmentExtents.get(g);s&&(b<Math.min(L?.top??1/0,w?.top??1/0)||T>Math.max(L?.bottom??-1/0,w?.bottom??-1/0))&&(c=!0),s&&Fo(h.attachmentExtents,g,b,T),(a[y.line]??=[]).push({track:g,left:y.x,right:y.x+y.w,top:b,bottom:T})}return x}),needsRelayout:c}}function ri(r,t){let e=en.get(t),n=e?.top??0,o=t.box.h-n+(e?.bottom??0),s=n-t.box.visualAxis;Fo(r,t.track,s,s+o)}function si(r,t,e){let n=new Map,o=c=>{let l=r.hostExtents.get(c),u=r.attachmentExtents.get(c),p=l?{top:l.top,bottom:l.bottom}:null;u&&(p?tn(p,u.top,u.bottom):p={top:u.top,bottom:u.bottom});let m=[];for(let f of c.groups){let x=f.members.map(o);if(x.every(g=>g===null))continue;let y=f.measure(x,e),h=null;for(let g of y){if(!g)continue;let b=g.offset+g.extent.top,T=g.offset+g.extent.bottom;h?tn(h,b,T):h={top:b,bottom:T}}h&&m.push({group:f,placements:y,extent:h})}let d=(f,x)=>{p??={top:0,bottom:0};for(let y=0;y<f.group.members.length;y++){let h=f.placements[y];h&&n.set(f.group.members[y],x+h.offset)}tn(p,x+f.extent.top,x+f.extent.bottom)};for(let f of m)f.group.place||d(f,0);for(let f of m){let x=f.group.place;if(!x)continue;d(f,x(p??{top:0,bottom:0},f.extent,e))}return p},s=o(t),i=new Map;if(!s)return{axes:i,height:0};let a=(c,l)=>{i.set(c,l);for(let u of c.groups)for(let p of u.members){let m=n.get(p);m!==void 0&&a(p,l+m)}};return a(t,-s.top),{axes:i,height:s.bottom-s.top}}var hl=[{op:"M",x:28.1406,y:86.06255},{op:"C",cx1:28.1406,cy1:86.06255,cx2:30.4531,cy2:84.07815,x:32.7656,y:81.42185},{op:"C",cx1:33.7656,cy1:80.43755,cx2:34.0938,cy2:79.10935,x:34.0938,y:78.10935},{op:"C",cx1:34.0938,cy1:77.12505,cx2:33.7656,cy2:76.45315,x:33.0938,y:75.79685},{op:"L",x:29.4531,y:72.15625},{op:"C",cx1:28.7969,cy1:71.50005,cx2:28.4688,cy2:70.82815,x:28.4688,y:70.17185},{op:"C",cx1:28.4688,cy1:68.84375,cx2:29.4531,cy2:68.18755,x:29.4531,y:68.18755},{op:"C",cx1:29.4531,cy1:68.18755,cx2:47.6563,cy2:47.00005,x:50.6406,y:43.68755},{op:"C",cx1:53.2969,cy1:40.04685,cx2:54.2813,cy2:36.40625,x:54.2813,y:33.09375},{op:"C",cx1:54.2813,cy1:26.14065,cx2:50.3125,cy2:19.85935,x:47.3281,y:17.21875},{op:"L",x:31.4375,y:1.32812},{op:"C",cx1:30.4531,cy1:.32812,cx2:29.7969,cy2:0,x:28.7969,y:0},{op:"C",cx1:27.1406,cy1:0,cx2:25.8125,cy2:1.32812,x:25.8125,y:1.32812},{op:"C",cx1:25.8125,cy1:1.32812,cx2:23.5,cy2:3.3125,x:21.1875,y:5.95312},{op:"C",cx1:20.1875,cy1:6.95313,cx2:19.8594,cy2:7.9375,x:19.8594,y:8.9375},{op:"C",cx1:19.8594,cy1:9.92188,cx2:20.1875,cy2:10.59375,x:20.8594,y:11.25},{op:"L",x:24.5,y:14.89063},{op:"C",cx1:25.1563,cy1:15.5625,cx2:25.4844,cy2:16.21875,x:25.4844,y:16.875},{op:"C",cx1:25.4844,cy1:18.20315,cx2:24.5,cy2:19.20315,x:24.5,y:19.20315},{op:"C",cx1:24.5,cy1:19.20315,cx2:6.625,cy2:40.37505,x:3.64063,y:43.68755},{op:"C",cx1:1,cy1:47.32815,cx2:0,cy2:50.96875,x:0,y:54.28125},{op:"C",cx1:0,cy1:61.23435,cx2:3.96875,cy2:67.51565,x:6.95313,y:70.17185},{op:"L",x:22.8438,y:86.06255},{op:"C",cx1:23.8281,cy1:87.04685,cx2:24.8281,cy2:87.37505,x:25.4844,y:87.37505},{op:"C",cx1:27.1406,cy1:87.37505,cx2:28.1406,cy2:86.06255,x:28.1406,y:86.06255}],gl=[{op:"M",x:111.8751,y:21.5156},{op:"C",cx1:112.5313,cy1:20.1875,cx2:113.5313,cy2:18.2031,x:113.5313,y:16.875},{op:"C",cx1:113.5313,cy1:12.23438,cx2:109.8907,cy2:8.9375,x:105.2501,y:8.9375},{op:"C",cx1:103.9219,cy1:8.9375,cx2:101.6094,cy2:9.26563,x:100.2813,y:10.25},{op:"L",x:72.1563,y:31.7656},{op:"L",x:72.1563,y:28.4531},{op:"C",cx1:72.1563,cy1:16.54688,cx2:66.8594,cy2:8.26563,x:58.2501,y:.98437},{op:"C",cx1:57.2657,cy1:.32812,cx2:55.9376,cy2:0,x:55.2657,y:0},{op:"C",cx1:53.6251,cy1:0,cx2:52.9532,cy2:.98437,x:52.9532,y:.98437},{op:"C",cx1:51.6251,cy1:2.3125,cx2:49.3126,cy2:4.29687,x:48.3282,y:5.625},{op:"C",cx1:47.3282,cy1:6.9375,cx2:47.0001,cy2:7.9375,x:47.0001,y:8.9375},{op:"C",cx1:47.0001,cy1:9.92188,cx2:47.3282,cy2:10.57813,x:47.6563,y:11.25},{op:"C",cx1:49.9688,cy1:13.5625,cx2:50.9688,cy2:16.21875,x:50.9688,y:18.8594},{op:"C",cx1:50.9688,cy1:24.8125,cx2:46.3282,cy2:30.1094,x:41.0469,y:30.1094},{op:"C",cx1:39.3907,cy1:30.1094,cx2:37.7344,cy2:29.4531,x:36.4063,y:28.4531},{op:"L",x:12.9063,y:10.57813},{op:"C",cx1:11.5782,cy1:9.59375,cx2:9.5938,cy2:8.9375,x:7.9375,y:8.9375},{op:"C",cx1:3.6407,cy1:8.9375,cx2:0,cy2:12.57813,x:0,y:16.875},{op:"C",cx1:0,cy1:18.2031,cx2:.6563,cy2:20.1875,x:1.3125,y:21.5156},{op:"L",x:49.9688,y:90.3594},{op:"C",cx1:51.2969,cy1:92.3438,cx2:54.2813,cy2:93.6719,x:56.5938,y:93.6719},{op:"C",cx1:58.9063,cy1:93.6719,cx2:61.8907,cy2:92.3438,x:63.2188,y:90.3594},{op:"L",x:111.8751,y:21.5156}];function ii(r,t,e,n){for(let o of t)o.op==="C"?r.push({op:"C",cx1:e(o.cx1),cy1:n(o.cy1),cx2:e(o.cx2),cy2:n(o.cy2),x:e(o.x),y:n(o.y)}):r.push({op:o.op,x:e(o.x),y:n(o.y)})}function ai(r,t,e){let n=e!=="",o=Math.max(1,Math.round(r/(t*.3))-(n?1:0)),s=n?113.5313:54.2813,i=n?85.7344+72.8125*o:87.37505+72.8125*(o-1),a=r/i,c=e!=="down",l=(m,d)=>c?f=>(m-d-f)*a:f=>(d+f)*a,u=[],p=l(s,n?27.4688:0);for(let m=0;m<o;m++)ii(u,hl,p,l(i,m*72.8125));return n&&ii(u,gl,l(s,0),l(i,o*72.8125+-7.9375)),{commands:u,width:s*a}}function ci(r){let t=r,e=t?.ast;return(e?.callName==="up"||e?.callName==="down")&&Array.isArray(t?.members)&&Array.isArray(e.contents)?t:null}function li(r){let t=r.box.anchor;for(let e of r.members){let n=ci(e);t=Math.max(t,n?li(n):e.box.anchor)}return t}var Bo=class extends B{static def={name:["arp","arpeggio"],description:"\u7436\u97F3",details:`~~~jpfun
|
|
7
7
|
@arp({1 ^ 3 ^ 5}, direction=up)
|
|
8
8
|
~~~
|
|
9
|
-
\u7ED9\u548C\u5F26\u7ED8\u5236\u7436\u97F3\u8BB0\u53F7\uFF0C\u64AD\u653E\u65F6\u6309\u65B9\u5411\u9519\u5F00\u6210\u5458\u8D77\u70B9\u5E76\u4FDD\u6301\u5171\u540C\u7EC8\u70B9\u3002\u590D\u5408\u6210\u5458\u7684\u5185\u90E8\u97F3\u7B26\u6309\u6BD4\u4F8B\u538B\u7F29\u5230\u5269\u4F59\u65F6\u503C\uFF0C\u88C5\u9970\u97F3\u5728\u786E\u5B9A\u540E\u7684\u533A\u95F4\u5185\u5C55\u5F00\u3002`,allowExtraArgs:!1,args:[{name:"content",description:"\u7531 `up` / `down` \u5806\u53E0\u5F62\u6210\u7684\u548C\u5F26",type:"content",default:null},{name:"direction",description:"\u7A7A\u503C\u4ECE\u4F4E\u5230\u9AD8\u3001\u4E0D\u753B\u7BAD\u5934\uFF1B`up` \u4ECE\u4F4E\u5230\u9AD8\u3001\u9876\u7AEF\u5E26\u7BAD\u5934\uFF1B`down` \u4ECE\u9AD8\u5230\u4F4E\u3001\u5E95\u7AEF\u5E26\u7BAD\u5934",type:"string",default:""}]};content;direction;size;get children(){return[this.content]}constructor(t,e,n,o=null){super(t,o);let[i
|
|
9
|
+
\u7ED9\u548C\u5F26\u7ED8\u5236\u7436\u97F3\u8BB0\u53F7\uFF0C\u64AD\u653E\u65F6\u6309\u65B9\u5411\u9519\u5F00\u6210\u5458\u8D77\u70B9\u5E76\u4FDD\u6301\u5171\u540C\u7EC8\u70B9\u3002\u590D\u5408\u6210\u5458\u7684\u5185\u90E8\u97F3\u7B26\u6309\u6BD4\u4F8B\u538B\u7F29\u5230\u5269\u4F59\u65F6\u503C\uFF0C\u88C5\u9970\u97F3\u5728\u786E\u5B9A\u540E\u7684\u533A\u95F4\u5185\u5C55\u5F00\u3002`,allowExtraArgs:!1,args:[{name:"content",description:"\u7531 `up` / `down` \u5806\u53E0\u5F62\u6210\u7684\u548C\u5F26",type:"content",default:null},{name:"direction",description:"\u7A7A\u503C\u4ECE\u4F4E\u5230\u9AD8\u3001\u4E0D\u753B\u7BAD\u5934\uFF1B`up` \u4ECE\u4F4E\u5230\u9AD8\u3001\u9876\u7AEF\u5E26\u7BAD\u5934\uFF1B`down` \u4ECE\u9AD8\u5230\u4F4E\u3001\u5E95\u7AEF\u5E26\u7BAD\u5934",type:"string",default:""}]};content;direction;size;get children(){return[this.content]}timeFlowModel(){return null}constructor(t,e,n,o=null){super(t,o);let[s,i]=this.getArgValue(e,n),a="";i!==""&&i!=="up"&&i!=="down"?n.diagnostics.push(new K("W_ARPEGGIO_INVALID_DIRECTION","@arp \u7684 direction \u53EA\u80FD\u662F up \u6216 down\uFF0C\u5DF2\u56DE\u9000\u5230\u65E0\u7BAD\u5934\u4E0A\u884C\u7436\u97F3",t)):a=i,this.content=s,this.direction=a,this.size=n.variables.fontsize,s.parent=this}loweringEnter(t,e){let n=t.isolateFromLoweringGroups(()=>t.trackedEvents(this.content,new G,e).flat()),o=n.length===1?ci(n[0]):null;if(!o||o.members.length<2)throw new k("E_ARPEGGIO_INVALID_CONTENT","@arp \u53EA\u63A5\u53D7\u81F3\u5C11\u5305\u542B\u4E24\u4E2A\u6210\u5458\u7684\u540C\u8F68 @up/@down \u6298\u53E0\u4F53",this.content.sourceSpan);return[new Do(this,o)]}toString(t){let e=this.direction?`, direction=${this.direction}`:"";return`@arp(${this.content.toString(t)}${e})`}},ui=Bo,Do=class extends tt{host;slots;hostX=0;markCommands=[];constructor(t,e){super(),this.ast=t,this.host=e;let n=e.ast.contents.length,o=[...e.members.slice(n).reverse(),...e.members.slice(0,n)],s=t.direction==="down"?o.reverse():o;this.slots=new Map(s.map((i,a)=>[i,a])),this.T.copyFrom(e.T),this.mergeKey=e.mergeKey,this.initLayoutBox(),e.addon&&(this.addon={...e.addon}),e.addon=void 0,e.foldedInto=this}onTimeState(t){this.host.t.copyFrom(this.t),this.host.T.copyFrom(this.T),this.host.track=this.track,this.host.layoutLine=this.layoutLine;let e=this.host.onTimeState?.(t);return this.T.copyFrom(this.host.T),e}prepareHorizontal(t){this.host.prepareHorizontal?.(t)}prepareLayout(t){let{host:e}=this;ye(this,e),nn(e,t),this.springConfig={...e.springConfig};let n=this.ast.size,o=St(e,!0),s=St(e),{commands:i,width:a}=ai(o.h,n,this.ast.direction);this.markCommands=i,this.hostX=a+n*.16+li(e)-e.box.anchor,this.box.w=this.hostX+e.box.w,this.box.h=s.h,this.box.anchor=this.hostX+e.box.anchor,this.box.visualAxis=e.box.visualAxis-s.y;for(let c in e.ports){let l=e.ports[c];this.ports[c]={...l,x:this.hostX+l.x,y:l.y-s.y}}}onPlaced(){this.host.box.x=this.box.x+this.hostX,this.host.box.y=this.box.y-(St(this.host).y-this.host.box.y),this.host.onPlaced?.()}emitPlayback(t){t.play(this.host);let e=t.end.clone().sub(t.start);if(e.compare(0)<=0)return;let n=new G(1,8),o=e.clone().div(2).div(this.slots.size-1);n.compare(o)>0&&n.copyFrom(o);let{slots:s}=this,i=this;t.defer(a=>{let c;for(let l=a.spans.length-1;l>=0;l--){let u=a.spans[l],p=u.origins.find(y=>y.node===i);if(!p||c&&p!==c)break;c=p;let m=u.origins.find(y=>s.has(y.node))?.node,d=m?s.get(m):void 0;if(!d)continue;let f=n.clone().mul(d).add(t.start),x=t.end.clone().sub(f).div(e);u.start.sub(t.start).mul(x).add(f),u.end.sub(t.start).mul(x).add(f)}})}paint(t){t.drawPath(this.markCommands,{fill:"#000"},{x:this.box.x,y:St(this.host,!0).y,scaleX:1,scaleY:1}),this.host.paint(t);for(let e of this.host.decorations)e.paint?.(t)}};function pi(r,t,e){r.deferFinalize(n=>{let o=[],s=new G,i=1,a=!1,c=-1;for(let l of n.columns){let u=l[0].t;if(l.some(p=>p.mergeKey===gt))u.compare(s)>0&&(i++,s.copyFrom(u),a=!1);else if(l.some(p=>!p.T.isZero()&&W(p))){let p=l[0].layoutLine;p!==c&&(c>=0&&!a&&o.push({line:p,number:i}),c=p),a=!0}}o.length>0&&n.attachments.push(new Ho(o,t,e))})}var Vo=class extends B{static def={name:["bar","|"],description:"\u5C0F\u8282\u7EBF",details:`~~~jpfun
|
|
10
10
|
@bar(0, length=1.25em)
|
|
11
11
|
~~~
|
|
12
|
-
\u6709\u8BED\u6CD5\u7CD6\u7B80\u5199\uFF0C\u89C1 type \u53C2\u6570\u7684\u8BF4\u660E\u3002`,allowExtraArgs:!1,args:[{name:"type",description:"0\uFF1A\u666E\u901A\u7EBF `|`\uFF1B1\uFF1A\u53CC\u7AD6\u7EBF `||`\uFF1B2\uFF1A\u7EC8\u6B62\u7EBF `|||`\uFF08\u5DE6\u7EC6\u53F3\u7C97\uFF09\uFF1B3\uFF1A\u53CD\u590D\u8D77\u70B9 `|:`\uFF1B4\uFF1A\u53CD\u590D\u7EC8\u70B9 `:|`\uFF1B5\uFF1A\u5DE6\u53F3\u53CD\u590D `:|:`",type:"number",default:0},{name:"length",description:"\u5C0F\u8282\u7EBF\u9AD8\u5EA6",type:"length",default:{value:1.25,unit:"em"}}]};static deSugarAtom(t,e,n){let o=e,i=0,r=t.slice(o,o+3),a=t.slice(o,o+2);if(r==="|||")i=2,o+=3;else if(a==="||")i=1,o+=2;else if(a==="|:")i=3,o+=2;else if(a===":|")t[o+2]===":"?(i=5,o+=3):(i=4,o+=2);else if(t[o]==="|")i=0,o+=1;else return null;let c=new Map;return c.set("type",i),{next:o,node:{kind:"call",typed:!0,name:"bar",args:c,span:{start:e,end:o},syntaxKind:"atom"}}}type;size;constructor(t,e,n,o=null){super(t,o);let[i,r]=this.getArgValue(e,n);this.type=i,this.size=n.length2px(r)}loweringEnter(){return[this.type>=3&&this.type<=5?new Co(this):new Tn(this)]}toString(){return`@bar(${this.type}, ${this.size}px)`}},Hi=To,Tn=class extends tt{lines=[];repeatDots=[];constructor(t){super(),this.ast=t,this.mergeKey=mt,this.initLayoutBox(),this.springConfig={alpha_L:128,alpha_R:128}}prepareHorizontal(t){let e=this;for(;e.foldedInto;)e=e.foldedInto;if(!X(e))return;let n=t.trackRuns.get(e.track),o=t.trackIndexOf(e);if(!n||o<0)return;let i=n[o-1];i&&(i.springConfig.mu_R*=4,e.springConfig.mu_L*=4);let r=n[o+1];r&&r.mergeKey!==mt&&(e.springConfig.mu_R*=4,r.springConfig.mu_L*=4)}prepareLayout(){let{type:t,size:e}=this.ast;this.lines.length=0;let n=[],o=e,i=Math.max(1,e*.065),r=i*2.6,a=i*1.8,c=i*.8,l=a+c,p=t===4||t===5,f=t===3||t===5,u=p?c*2+l:0;if(t===1?(this.lines.push({x:u,w:i}),u+=i+a,this.lines.push({x:u,w:i}),u+=i):t===2||t===4||t===5?(this.lines.push({x:u,w:i}),u+=i+a,this.lines.push({x:u,w:r}),u+=r):t===3?(this.lines.push({x:u,w:r}),u+=r+a,this.lines.push({x:u,w:i}),u+=i):(this.lines.push({x:u,w:i}),u+=i),p){let d=c;n.push({x:d,y:o*.38}),n.push({x:d,y:o*.62})}if(f){let d=u+l;n.push({x:d,y:o*.38}),n.push({x:d,y:o*.62}),u=d+c}this.box.w=u,this.box.h=o;let h=t>=3&&t<=5?this.lines[0]:void 0;this.box.anchor=h?h.x+h.w/2:u/2,this.box.visualAxis=o/2;for(let d of this.lines)d.x-=this.box.anchor;this.repeatDots=n.map(d=>({x:d.x-this.box.anchor,y:d.y,r:c}))}paint(t){for(let e of this.lines)t.drawRect(this.box.x+this.box.anchor+e.x,this.box.y,e.w,this.box.h,{fill:"#000"});for(let e of this.repeatDots)t.drawCircle(this.box.x+this.box.anchor+e.x,this.box.y+e.y,e.r,{fill:"#000"})}},Lo="repeat.start";function Wi(s,t){return s.visits(s.seek(Lo,t+1,-1)??0)}var Co=class extends Tn{playbackMarks(){return this.ast.type===4?[]:[Lo]}playbackFlow(t){if(this.ast.type===3)return;let e=t(this);if(e!==void 0)return{range:[e,e],run:n=>n.visits(e)>1?void 0:{kind:"jump",column:n.seek(Lo,e,-1)??0}}}};var Gi="div",fe=ce(Gi);function Kt(s,t){return`div.${s}.${t}`}function Vi(s,t){let e=s.ports[Kt(t,"left")];e&&(e.state.claimed=!0)}function Mo(s){return Math.max(1,s*.055)}function*Ui(s){for(let t=0;;t++){let e=!1,n=-1;for(let o=0;o<=s.length;o++){let i=s[o]?.ports,r=i?.[Kt(t,"left")],a=i?.[Kt(t,"right")];if((r||a)&&(e=!0),r&&a){n<0&&(n=o);continue}n>=0&&o-n>=2&&(yield{level:t,from:n,to:o-1}),n=-1}if(!e)return}}var vo=class s extends ${static def={name:[Gi,"/"],description:"\u51CF\u65F6\u7EBF",details:"~~~jpfun\n@div({1 2 -}, n=2, autobeam=true)\n~~~\n**\u7B80\u5199**\uFF1A\u5728\u76EE\u6807\u540E\u52A0 `/`\uFF0C\u53EF\u91CD\u590D\u6216\u4F5C\u7528\u4E8E\u5185\u5BB9\u5757\u3002`@div(1, 2)` \u7B49\u4EF7\u4E8E `1//`\uFF0C`@div({1 2/ -}, 2)` \u7B49\u4EF7\u4E8E `{1 2/ -}//`\u3002\u9ED8\u8BA4\u53C2\u6570\u4F7F\u7528 `div.n`\u3001`div.autobeam` \u8BBE\u7F6E\u3002",allowExtraArgs:!1,args:[{type:"content",description:"\u8981\u51CF\u65F6\u7684\u5185\u5BB9\uFF0C\u53EF\u5305\u542B\u591A\u4E2A\u97F3\u7B26\u6216\u589E\u65F6\u7EBF",default:null},{name:"n",description:"\u51CF\u65F6\u5C42\u6570\uFF0C\u6BCF\u7EA7\u5C06\u65F6\u503C\u51CF\u534A\uFF0C\u53D6\u975E\u8D1F\u6574\u6570",type:"number",default:1},{name:"autobeam",description:"\u662F\u5426\u53C2\u4E0E\u4E0D\u540C div \u4E4B\u95F4\u7684\u81EA\u52A8\u8FDE\u7EBF\uFF0C\u540C\u4E00 div \u5185\u90E8\u7684\u8FDE\u7EBF\u4E0D\u53D7\u5F71\u54CD",type:"boolean",default:!0}]};static deSugarAtom(t,e,n){let o=0,i=e;for(;i<n&&t[i]==="/";)o++,i++;return o===0?null:{next:i,node:{kind:"sugar",data:{class:s,n:o},span:{start:e,end:i}}}}static deSugarRelation(t,e,n){let o=e[n++];if(o.data?.class!==s)return null;let i=$.findLastFuncContentIndex(t.nodes,t.nodes.length-1);if(i<0)return n;let r=t.nodes[i];if(r instanceof s)return r.n+=o.data.n,n;let a=new Map;a.set(0,r),a.set("n",o.data.n);let c=r.sourceSpan,l=new s({start:Math.min(c.start,o.span.start),end:Math.max(c.end,o.span.end)},a,t,null);return t.nodes[i]=l,n}static layoutDecorationHandler=(t,e)=>{let n=Math.max(0,Math.floor(Number(e)||0));if(n===0)return null;let o=t.ast.size*.14,i=Mo(t.ast.size),r=(n-1)*o+i,a=0,c=0,l=0;return{below:{order:0,gap:t.box.h-(t.ports["decoration.below"]?.y??t.box.h)-t.ast.size*.08,height:r,place(p){a=t.ports["body.left"]?.x??0,c=t.ports["body.right"]?.x??t.box.w,l=p+i/2;for(let f=0;f<n;f++){let u=l+f*o;t.ports[Kt(f,"left")]={x:a,y:u,state:{claimed:!1}},t.ports[Kt(f,"right")]={x:c,y:u}}}},paint(p){for(let f=0;f<n;f++){if(t.ports[Kt(f,"left")].state.claimed)continue;let h=t.box.y+l+f*o;p.drawLine(t.box.x+a,h,t.box.x+c,h,{stroke:"#000",strokeWidth:i})}}}};loweringEnter(t){let e=this.n;return t.beginLoweringGroup(this,{onTemporal(n){if(e===0)return;let o=n.addon??={};o[fe]=(Number(o[fe])||0)+e,n.T.divPow2(e)}}),[]}loweringExit(t){return t.endLoweringGroup(this),[]}content;n;autoBeamEnabled;get children(){return[this.content]}timeFlowModel(){return{children:[this.content],mode:"sequence"}}constructor(t,e,n,o=null){super(t,o),[this.content,this.n,this.autoBeamEnabled]=this.getArgValue(e,n),this.content.parent=this;let i=Math.max(0,Math.trunc(this.n));i!==this.n&&(n.diagnostics.push(new q("W_DIV_INVALID_N",`@div \u7684\u6570\u91CF\u53C2\u6570 n \u5FC5\u987B\u4E3A\u975E\u8D1F\u6574\u6570\uFF0C\u5DF2\u88AB\u4FEE\u6B63\u4E3A ${i}`,this.sourceSpan)),this.n=i)}toString(t){return`@div(${this.content.toString(t)}, ${this.n})`}},_e=vo;function Ie(s,t,e){return new qe(s,t,e)}function ji(s){let t=new Map,e=new Map;for(let n of s.columns)for(let o of n){if(!X(o)||o.mergeKey===mt&&o.T.isZero())continue;let i=t.get(o.layoutLine);i||(i=new Map,t.set(o.layoutLine,i));let r=i.get(o.track)??0;e.set(o,{line:o.layoutLine,track:o.track,index:r}),i.set(o.track,r+1)}for(let n of s.attachments)if(!(!(n instanceof qe)||!n.explicit))for(let o=1;o<n.endPoints.length;o++){let i=n.endPoints[o-1],r=n.endPoints[o];if(!X(i)||!X(r))continue;let a=e.get(i),c=e.get(r);if(!(i!==r&&a!==void 0&&c!==void 0&&a.line===c.line&&a.track===c.track&&c.index===a.index+1))throw new k("E_NON_ADJACENT_BEAM","@beam \u7684\u7AEF\u70B9\u5FC5\u987B\u6309\u65F6\u95F4\u987A\u5E8F\u8FDE\u63A5\u540C\u4E00\u8F68\u9053\u3001\u540C\u4E00\u8C31\u9762\u884C\u4E2D\u7684\u76F8\u90BB\u53EF\u89C1\u5143\u7D20\uFF08\u53EF\u8DE8\u5C0F\u8282\u7EBF\uFF09",n.sourceSpan)}}function Ki(s){let t=new Set;for(let e of s)if(!(!(e instanceof qe)||!e.explicit))for(let n of e.endPoints)t.add(n);return t}var qe=class{layer="foreground";endPoints;explicit;sourceSpan;fontSize;strokeWidth;constructor(t,e,n){this.endPoints=t,this.explicit=e,this.sourceSpan=n,this.fontSize=t.reduce((o,i)=>X(i)?Math.max(o,i.ast.size):o,0),this.strokeWidth=Mo(this.fontSize)}prepareHorizontal(t){let e;for(let n of this.endPoints)if(X(n)){if(e&&e.layoutLine===n.layoutLine&&e.track===n.track){let o=t[e.layoutLine],i=o?o.trackIndexOf(e):-1;i>=0&&i+1===o.trackIndexOf(n)&&(e.springConfig.alpha_R*=.8,n.springConfig.alpha_L*=.8)}e=n}}createGeometry(t){let e=this.collectLines(t),n=this.strokeWidth;return{regions:e.map(i=>({x:Math.min(i.start.x,i.end.x),y:i.start.y-n/2,w:Math.abs(i.end.x-i.start.x),h:n,line:i.line,track:i.track})),paint(i){for(let r of e)i.drawLine(r.start.x,r.start.y,r.end.x,r.end.y,{stroke:"#000",strokeWidth:n})}}}absolutePort(t,e){let n=t.ports[e];return{x:t.box.x+n.x,y:t.box.y+n.y}}collectLines(t){let e=[],n=this.endPoints.filter(X);if(n.length<2)return e;for(let{level:o,from:i,to:r}of Ui(n)){let a=[];for(let c=i;c<=r;c++){let l=n[c];a.push({left:this.absolutePort(l,Kt(o,"left")),right:this.absolutePort(l,Kt(o,"right")),line:l.layoutLine,track:l.track,node:l})}this.addSystemLines(a,t,o,e)}if(e.length===0&&this.explicit){let o=this.fontSize*.12,i=n.map(r=>{let a={x:r.box.x+r.box.anchor,y:r.box.y+r.box.h+o};return{left:a,right:a,line:r.layoutLine,track:r.track,node:r}});this.addSystemLines(i,t,null,e)}return e}addSystemLines(t,e,n,o){let i=Math.min(...t.map(p=>p.line)),r=Math.max(...t.map(p=>p.line)),a=t[0].track,c=e.getVisualAxis(t[0].line,a),l=t[0].left.y-c;for(let p=i;p<=r;p++){let f=t.filter(g=>g.line===p).sort((g,x)=>g.left.x-x.left.x);if(f.length===0){let x=e.getVisualAxis(p,a)+l;o.push({start:{x:e.originX,y:x},end:{x:e.originX+e.width,y:x},line:p,track:a});continue}let u=f[0],h=f[f.length-1],d=u.left.y,y={x:u.left.x,y:d},m={x:h.right.x,y:d};if(p>i&&(y.x=e.originX),p<r&&(m.x=e.originX+e.width),!(y.x===m.x&&i===r)){if(n!==null)for(let g of f)Vi(g.node,n);o.push({start:y,end:m,line:p,track:u.track})}}}};function vc(s){let t=Math.max(0,Math.floor(Number(s.addon?.[fe])||0));if(t<=0)return[];let e=[],n=r=>{e.push(r),t-=Math.max(0,r.n)},o=s.ast.parent;for(;o&&t>0;)o instanceof _e&&n(o),o=o.parent;if(t<=0)return e;let i=r=>{for(let a of r.children??[]){if(t<=0)return;a instanceof _e&&n(a),i(a)}};return i(s.ast),e}function Mc(s){let t=new Map,e=new Map;for(let n of s.columns)for(let o of n){if(!X(o))continue;let i=vc(o);if(i.length===0)continue;let r=[];for(let a of i){let c=t.get(a);c||(c={owner:a,nodes:[]},t.set(a,c)),c.nodes.push(o),r.push(c)}e.set(o,r)}return{scopes:[...t.values()],nodeScopes:e}}function Nc(s){let t=new Set(s.map(e=>e.owner));return s.filter(e=>{let n=e.owner.parent;for(;n;){if(n instanceof _e&&t.has(n))return!1;n=n.parent}return!0})}function Yi(s,t){let e=1/0,n=-1/0;for(let o of s){e=Math.min(e,o.ast.sourceSpan.start),n=Math.max(n,o.ast.sourceSpan.end);for(let{owner:i}of t.get(o)??[])e=Math.min(e,i.sourceSpan.start),n=Math.max(n,i.sourceSpan.end)}return Ie(s,!1,{start:e,end:n})}function kc(s,t,e){let n=[];for(let o of Nc(s)){let i=new Map;for(let r of o.nodes){let a=i.get(r.track);a?a.push(r):i.set(r.track,[r])}for(let r of i.values()){let a=[],c=()=>{a.length>=2&&n.push(Yi(a,t)),a=[]};for(let l of r){if(e.has(l)){c();continue}a.push(l)}c()}}return n}function _c(s){return Math.floor(s.numerator/s.denominator)}function Ic(s,t,e){let n=[],o=new Map,i=new Map,r=new F,a=new F;for(let p of s.columns)for(let f of p){let u=i.get(f.layoutLine);(u===void 0||f.t.compare(u)<0)&&i.set(f.layoutLine,f.t)}let c=p=>{let f=o.get(p);f&&(o.delete(p),f.nodes.length>=2&&n.push(Yi(f.nodes,t)))},l=()=>{for(let p of[...o.keys()])c(p)};for(let p of s.columns){let f=p.find(u=>u.mergeKey===mt);f&&(l(),r.copyFrom(f.t));for(let u of p){if(u.mergeKey===mt)continue;let h=X(u)?t.get(u):void 0,d=h?.every(S=>S.nodes.length===1)??!1,y=h?.every(S=>S.owner.autoBeamEnabled)??!1;if(!(X(u)&&d&&y&&u.T.compare(1)<0&&!e.has(u))){(X(u)||!u.T.isZero())&&c(u.track);continue}let g=i.get(u.layoutLine)??u.t,x=r.compare(g)>=0?r:g,b=_c(a.copyFrom(u.t).sub(x)),A=o.get(u.track),E=A&&u.t.equals(A.endTime);if(!A||u.layoutLine!==A.line||b!==A.beat||!E){c(u.track),o.set(u.track,{nodes:[u],line:u.layoutLine,beat:b,endTime:u.t.clone().add(u.T)});continue}A.nodes.push(u),A.endTime.copyFrom(u.t).add(u.T)}}return l(),n}function Xi(s){let{scopes:t,nodeScopes:e}=Mc(s);if(t.length===0)return[];let n=Ki(s.attachments);return[...kc(t,e,n),...Ic(s,e,n)]}var No=class extends ${static loweringAugment=Xi;static loweringFinalize=ji;static def={name:["beam"],description:"\u51CF\u65F6\u7EBF\u8FDE\u63A5",details:"\u4E8B\u540E\u5C06\u591A\u4E2A\u51CF\u65F6\u7EBF**\u5F3A\u884C**\u76F8\u8FDE\n~~~jpfun\n1/@a 2/@b | 3/@c @beam(a, b, c)\n~~~\n**\u4F4D\u7F6E\u53C2\u6570**\uFF1A\u5DF2\u6807\u8BB0\u97F3\u7B26\u7684\u6807\u7B7E\uFF0C\u6309\u4F20\u5165\u987A\u5E8F\u8FDE\u63A5\u51CF\u65F6\u7EBF\uFF0C\u663E\u5F0F\u6307\u5B9A\u4E00\u7EC4\u3002\u5148\u7528 `/` \u6216 `@div` \u4E3A\u76EE\u6807\u6DFB\u52A0\u51CF\u65F6\u7EBF\uFF0C\u518D\u7528 `@beam` \u63A7\u5236\u8FDE\u63A5\u3002\u7AEF\u70B9\u987B\u540C\u8F68\u3001\u540C\u8C31\u9762\u884C\u4E14\u76F8\u90BB\uFF0C\u53EF\u8DE8\u5C0F\u8282\u7EBF\uFF1B\u8FDE\u7EBF\u76F4\u63A5\u7A7F\u8FC7\u5C0F\u8282\u7EBF\uFF0C\u4FDD\u7559\u539F\u6709\u95F4\u8DDD\u3002",allowExtraArgs:!0,extraArgType:"label",args:[]};endPoints=[];constructor(t,e,n,o=null){super(t,o);for(let[,r]of e){let a=r instanceof $?r:n.parseArgWithType(r.valueSpan,"label",t.start);a instanceof $&&this.endPoints.push(a)}let i=n.labelableNodes.length-1;for(;this.endPoints.length<2&&i>=0;){let r=n.labelableNodes[i--];!r||this.endPoints.includes(r)||this.endPoints.unshift(r)}if(this.endPoints.length<2)throw new k("E_NOT_ENOUGH_ARGS","@beam \u81F3\u5C11\u9700\u8981\u4E24\u4E2A\u7AEF\u70B9",t)}loweringEnter(t){let e=[];for(let n of this.endPoints){let o=t.getTemporalNodes(n).at(-1);for(;o?.foldedInto;)o=o.foldedInto;o&&e.push(o)}return e.length<2?(t.diagnostics.push(H.warning.UnresolvedEndpoint("beam",this.sourceSpan)),[]):(t.addAttachment(Ie(e,!0,this.sourceSpan)),[])}},qi=No;var ko=class extends ${static def={name:["box"],description:"\u7ED9\u76EE\u6807\u7ED3\u6784\u6216\u5BF9\u8C61\u52A0\u5916\u6846",details:`~~~jpfun
|
|
12
|
+
\u6709\u8BED\u6CD5\u7CD6\u7B80\u5199\uFF0C\u89C1 type \u53C2\u6570\u7684\u8BF4\u660E\u3002`,allowExtraArgs:!1,args:[{name:"type",description:"0\uFF1A\u666E\u901A\u7EBF `|`\uFF1B1\uFF1A\u53CC\u7AD6\u7EBF `||`\uFF1B2\uFF1A\u7EC8\u6B62\u7EBF `|||`\uFF08\u5DE6\u7EC6\u53F3\u7C97\uFF09\uFF1B3\uFF1A\u53CD\u590D\u8D77\u70B9 `|:`\uFF1B4\uFF1A\u53CD\u590D\u7EC8\u70B9 `:|`\uFF1B5\uFF1A\u5DE6\u53F3\u53CD\u590D `:|:`",type:"number",default:0},{name:"length",description:"\u5C0F\u8282\u7EBF\u9AD8\u5EA6",type:"length",default:{value:1.25,unit:"em"}}]};static deSugarAtom(t,e,n){let o=e,s=0,i=t.slice(o,o+3),a=t.slice(o,o+2);if(i==="|||")s=2,o+=3;else if(a==="||")s=1,o+=2;else if(a==="|:")s=3,o+=2;else if(a===":|")t[o+2]===":"?(s=5,o+=3):(s=4,o+=2);else if(t[o]==="|")s=0,o+=1;else return null;let c=new Map;return c.set("type",s),{next:o,node:{kind:"call",typed:!0,name:"bar",args:c,span:{start:e,end:o},syntaxKind:"atom"}}}type;size;constructor(t,e,n,o=null){super(t,o);let[s,i]=this.getArgValue(e,n);this.type=s,this.size=n.length2px(i)}loweringEnter(){return[this.type>=3&&this.type<=5?new Go(this):new _n(this)]}toString(){return`@bar(${this.type}, ${this.size}px)`}},Ho=class{constructor(t,e,n){this.items=t;this.pattern=e;this.font=n}items;pattern;font;layer="foreground";sourceSpan=void 0;createGeometry(t){let e=this.items.map(({line:n,number:o})=>{let i=t.lines[n].columns[0].reduce((x,y)=>t.getVisualAxis(n,y.track)<t.getVisualAxis(n,x.track)?y:x),a=i.ast.size,c=i.ports["bar.number"],l={fontSize:a*.5,fontFamily:this.font,textAlign:c?"center":"right",fill:"#000"},u=this.pattern.replace("1",String(o)),p=t.textMeasurer.measureText(u,l),m=c?i.box.x+c.x:t.originX-a*.15,f=(c?i.box.y+c.y:Math.min(i.box.y,t.getVisualAxis(n,i.track)-a*.5))-a*.04;return{text:u,x:m,y:f,style:l,region:{x:c?m-p.w/2:m-p.w,y:f-p.baseline,w:p.w,h:p.baseline,line:n,track:i.track}}});return{regions:e.map(n=>n.region),paint(n){for(let o of e)n.drawText(o.text,o.x,o.y,o.style)}}}},mi=Vo,_n=class extends tt{lines=[];repeatDots=[];constructor(t){super(),this.ast=t,this.mergeKey=gt,this.initLayoutBox()}prepareHorizontal(t){let e=this.rootHost;if(!W(e))return;let n=t.trackRuns.get(e.track),o=t.trackIndexOf(e);if(!n||o<0)return;let s=n[o-1];s&&(s.springConfig.mu_R*=4,e.springConfig.mu_L*=4);let i=n[o+1];i&&i.mergeKey!==gt&&(e.springConfig.mu_R*=4,i.springConfig.mu_L*=4)}prepareLayout(){this.springConfig={alpha_L:128,alpha_R:128};let{type:t,size:e}=this.ast;this.lines.length=0;let n=[],o=e,s=Math.max(1,e*.065),i=s*2.6,a=s*1.8,c=s*.8,l=a+c,u=t===4||t===5,p=t===3||t===5,m=u?c*2+l:0;if(t===1?(this.lines.push({x:m,w:s}),m+=s+a,this.lines.push({x:m,w:s}),m+=s):t===2||t===4||t===5?(this.lines.push({x:m,w:s}),m+=s+a,this.lines.push({x:m,w:i}),m+=i):t===3?(this.lines.push({x:m,w:i}),m+=i+a,this.lines.push({x:m,w:s}),m+=s):(this.lines.push({x:m,w:s}),m+=s),u){let f=c;n.push({x:f,y:o*.38}),n.push({x:f,y:o*.62})}if(p){let f=m+l;n.push({x:f,y:o*.38}),n.push({x:f,y:o*.62}),m=f+c}this.box.w=m,this.box.h=o;let d=t>=3&&t<=5?this.lines[0]:void 0;this.box.anchor=d?d.x+d.w/2:m/2,this.box.visualAxis=o/2;for(let f of this.lines)f.x-=this.box.anchor;this.repeatDots=n.map(f=>({x:f.x-this.box.anchor,y:f.y,r:c}))}paint(t){for(let e of this.lines)t.drawRect(this.box.x+this.box.anchor+e.x,this.box.y,e.w,this.box.h,{fill:"#000"});for(let e of this.repeatDots)t.drawCircle(this.box.x+this.box.anchor+e.x,this.box.y+e.y,e.r,{fill:"#000"})}},zo="repeat.start";function di(r,t){return r.visits(r.seek(zo,t+1,-1)??0)}var Go=class extends _n{playbackMarks(){return this.ast.type===4?[]:[zo]}playbackFlow(t){if(this.ast.type===3)return;let e=t(this);if(e!==void 0)return{range:[e,e],run:n=>n.visits(e)>1?void 0:{kind:"jump",column:n.seek(zo,e,-1)??0}}}};var Fn=class{min=1/0;max=-1/0;add(t){t<this.min&&(this.min=t),t>this.max&&(this.max=t)}};function $o(r,t,e,n,o,s){if(!(r>0&&r<1))return;let i=1-r;s.add(i*i*i*t+3*i*i*r*e+3*i*r*r*n+r*r*r*o)}function fi(r,t,e,n,o){o.add(r),o.add(n);let s=-r+3*t-3*e+n,i=2*(r-2*t+e),a=t-r;if(Math.abs(s)<1e-12){Math.abs(i)>1e-12&&$o(-a/i,r,t,e,n,o);return}let c=i*i-4*s*a;if(c<0)return;let l=Math.sqrt(c);$o((-i+l)/(2*s),r,t,e,n,o),$o((-i-l)/(2*s),r,t,e,n,o)}function yi(r,t,e,n){n.add(r),n.add(e);let o=r-2*t+e;if(Math.abs(o)<1e-12)return;let s=(r-t)/o;if(!(s>0&&s<1))return;let i=1-s;n.add(i*i*r+2*i*s*t+s*s*e)}function Gt(r){let t=new Fn,e=new Fn,n=0,o=0,s=0,i=0;for(let a of r){if(a.op==="Z"){n=s,o=i;continue}a.op==="C"?(fi(n,a.cx1,a.cx2,a.x,t),fi(o,a.cy1,a.cy2,a.y,e)):a.op==="Q"?(yi(n,a.cx,a.x,t),yi(o,a.cy,a.y,e)):(t.add(a.x),e.add(a.y),a.op==="M"&&(s=a.x,i=a.y)),n=a.x,o=a.y}return Number.isFinite(t.min)?{x:t.min,y:e.min,w:t.max-t.min,h:e.max-e.min}:{x:0,y:0,w:0,h:0}}var hi=new WeakMap;function he(r){let t=1/0,e=1/0,n=-1/0,o=-1/0,s=(i,a,c,l)=>{t=Math.min(t,i),e=Math.min(e,a),n=Math.max(n,i+c),o=Math.max(o,a+l)};for(let i of r){let a=i.dx??0;if(i.line){let{x1:c,y1:l,x2:u,y2:p}=i.line,m=(i.style.strokeWidth??1)/2;s(Math.min(c,u)+a-m,Math.min(l,p)-m,Math.abs(u-c)+m*2,Math.abs(p-l)+m*2)}if(i.circle){let{cx:c,cy:l,r:u}=i.circle,p=i.style.stroke&&i.style.stroke!=="none"?(i.style.strokeWidth??1)/2:0,m=u+p;s(c+a-m,l-m,2*m,2*m)}if(i.path?.length){let c=hi.get(i.path)??Gt(i.path);hi.set(i.path,c),s(c.x+a,c.y,c.w,c.h)}}return Number.isFinite(t)?{x:t,y:e,w:Math.max(1e-9,n-t),h:Math.max(1e-9,o-e)}:{x:0,y:0,w:1e-9,h:1e-9}}function On(r,t,e,n,o){let s=n.x-e.x*o,i=n.y-e.y*o;for(let a of t){let c=a.style,l=c.strokeWidth??(a.line||a.circle?1:void 0),u=l===void 0?c:{...c,strokeWidth:l*o},p=s+(a.dx??0)*o;if(a.line){let{x1:m,y1:d,x2:f,y2:x}=a.line;r.drawLine(p+m*o,i+d*o,p+f*o,i+x*o,u)}a.path&&r.drawPath(a.path,u,{x:p,y:i,scaleX:o,scaleY:o}),a.circle&&r.drawCircle(p+a.circle.cx*o,i+a.circle.cy*o,a.circle.r*o,u)}}var jo=[{path:[{op:"M",x:1,y:34},{op:"C",cx1:23,cy1:36,cx2:57,cy2:28,x:82,y:23},{op:"C",cx1:91,cy1:21,cx2:98,cy2:24,x:102,y:29},{op:"Q",cx:106,cy:34,x:98,y:34},{op:"C",cx1:68,cy1:30,cx2:37,cy2:39,x:13,y:43},{op:"Q",cx:7,cy:44,x:1,y:39},{op:"Q",cx:-3,cy:35,x:1,y:34},{op:"Z"}],style:{fill:"#000"}},{path:[{op:"M",x:29,y:5},{op:"Q",cx:27,cy:3,x:31,y:4},{op:"Q",cx:44,cy:7,x:42,y:12},{op:"C",cx1:39,cy1:26,cx2:43,cy2:43,x:42,y:60},{op:"Q",cx:41,cy:69,x:38,y:62},{op:"C",cx1:34,cy1:47,cx2:35,cy2:20,x:29,y:5},{op:"Z"}],style:{fill:"#000"}},{path:[{op:"M",x:59,y:1},{op:"Q",cx:56,cy:-2,x:61,y:0},{op:"Q",cx:76,cy:4,x:74,y:9},{op:"C",cx1:71,cy1:17,cx2:74,cy2:32,x:69,y:48},{op:"C",cx1:64,cy1:66,cx2:55,cy2:77,x:40,y:84},{op:"Q",cx:37,cy:85,x:40,y:82},{op:"C",cx1:57,cy1:66,cx2:63,cy2:47,x:64,y:29},{op:"C",cx1:65,cy1:17,cx2:63,cy2:7,x:59,y:1},{op:"Z"}],style:{fill:"#000"}}],on=he(jo);var In=new WeakMap;function gi(r){return In.get(r)?.meter}function xl(r,t){let e=r.rootHost,n=r.ast.sourceSpan,o=In.get(e);o||In.set(e,o={start:n.start,end:n.end,meter:t}),o.end=n.end,o.meter=t}var Wo=class r extends B{static def={name:["meter"],description:"\u8BBE\u7F6E\u62CD\u53F7",details:`~~~jpfun
|
|
13
|
+
@meter(6, 8)
|
|
14
|
+
~~~
|
|
15
|
+
\u8BBE\u7F6E \`6/8\` \u62CD\u53F7\uFF1A\u6BCF\u5C0F\u8282\u542B\u516D\u4E2A\u516B\u5206\u97F3\u7B26\u7684\u65F6\u503C\u3002
|
|
16
|
+
\u5206\u5B50\u6216\u5206\u6BCD\u4E3A 0 \u65F6\u8868\u793A\u6563\u677F\u3002`,allowExtraArgs:!1,args:[{name:"num",description:"\u62CD\u53F7\u5206\u5B50\uFF0C\u6BCF\u5C0F\u8282\u5305\u542B\u7684\u5355\u4F4D\u62CD\u6570",type:"number",default:null},{name:"den",description:"\u62CD\u53F7\u5206\u6BCD\uFF0C\u4EE5\u51E0\u5206\u97F3\u7B26\u4E3A\u5355\u4F4D\u62CD",type:"number",default:null},{name:"size",description:"\u62CD\u53F7\u5B57\u53F7",type:"length",default:{value:.7,unit:"em"}}]};numerator;denominator;measureDuration;size;strict;font;constructor(t,e,n,o=null){super(t,o);let[s,i,a]=this.getArgValue(e,n);if(this.font=n.variables.numberfont,!Number.isSafeInteger(s)||!Number.isSafeInteger(s*4)||s<0||!Number.isSafeInteger(i)||i<0){let c="@meter \u7684\u5206\u5B50\u548C\u5206\u6BCD\u5FC5\u987B\u662F\u975E\u8D1F\u6574\u6570";if(n.variables.strict)throw new k("E_METER_INVALID",c,t);n.diagnostics.push(new K("W_METER_INVALID",`${c}\uFF0C\u5DF2\u56DE\u843D\u4E3A 4/4`,t)),s=i=4}this.numerator=s,this.denominator=i,s!==0&&i!==0&&(this.measureDuration=new G(s*4,i)),this.size=n.length2px(a),this.strict=n.variables.strict}loweringEnter(t){return t.deferFinalize(r.loweringFinalize),[new Xo(this)]}static loweringFinalize(t){let e=new G,n=new G,o=null,s=!1,i=0,a=(c,l)=>{if(!(!o?.measureDuration||c.equals(e))){if(n.copyFrom(c).sub(e),!n.equals(o.measureDuration)&&(s||n.compare(o.measureDuration)>0)){let u="\u5C0F\u8282\u65F6\u957F\u4E3A {duration} QN\uFF0C\u4E0D\u6EE1\u8DB3 {num}/{den} \u62CD\u53F7",p={start:i,end:l},m={duration:n,num:o.numerator,den:o.denominator};if(o.strict)throw new k("E_METER_MISMATCH",u,p,m);t.diagnostics.push(new K("W_METER_MISMATCH",u,p,m))}e.copyFrom(c)}};for(let c of t.columns){let l=c[0].t;for(let p of c){let m=In.get(p);m&&(a(l,m.start),o=m.meter,e.copyFrom(l),i=m.end)}let u=c.find(p=>p.mergeKey===gt);u&&(a(l,u.ast.sourceSpan.end),i=u.ast.sourceSpan.end,s=!0)}if(o){let c=t.columns.at(-1)?.at(-1)?.ast.sourceSpan??o.sourceSpan;a(t.duration,c.end)}}toString(){return`@meter(${this.numerator}, ${this.denominator})`}},Bn=Wo,Xo=class extends tt{style;numeratorBaseline=0;denominatorBaseline=0;lineY=0;lineHeight=0;constructor(t){super(),this.ast=t,this.style={fontSize:t.size,fontFamily:t.font,textAlign:"center",fill:"#000"},this.initLayoutBox()}onTimeState(t){t.meter=this.ast.measureDuration,xl(this,this.ast)}emitPlayback(t){this.ast.measureDuration&&t.emit({kind:"time-signature",at:t.start,numerator:this.ast.numerator,denominator:this.ast.denominator})}prepareLayout(t){if(!this.ast.measureDuration){this.box.w=this.ast.size*on.w/on.h,this.box.h=this.ast.size,this.box.anchor=this.box.w/2,this.box.visualAxis=this.box.h/2;return}let e=t.textMeasurer.measureText(String(this.ast.numerator),this.style),n=t.textMeasurer.measureText(String(this.ast.denominator),this.style),o=this.ast.size*.08,s=this.ast.size*.08;this.lineHeight=Math.max(1,this.ast.size*.06),this.numeratorBaseline=e.baseline,this.lineY=e.h+o,this.denominatorBaseline=this.lineY+this.lineHeight+o+n.baseline,this.box.w=Math.max(e.w,n.w)+s*2,this.box.h=this.lineY+this.lineHeight+o+n.h,this.box.anchor=this.box.w/2,this.box.visualAxis=this.lineY+this.lineHeight/2}paint(t){if(!this.ast.measureDuration){On(t,jo,on,this.box,this.ast.size/on.h);return}let e=this.box.x+this.box.anchor;t.drawText(String(this.ast.numerator),e,this.box.y+this.numeratorBaseline,this.style),t.drawRect(this.box.x,this.box.y+this.lineY,this.box.w,this.lineHeight,{fill:"#000"}),t.drawText(String(this.ast.denominator),e,this.box.y+this.denominatorBaseline,this.style)}};function bl(r){let t=new Map;for(let e of r.columns)for(let n of e){if(!W(n))continue;let o=Dn(n);if(!o)continue;let s=t.get(o);s?s.push(n):t.set(o,[n])}return t}function xi(r){let t=1/0,e=-1/0;for(let n of r){let o=Dn(n);t=Math.min(t,n.ast.sourceSpan.start,o.sourceSpan.start),e=Math.max(e,n.ast.sourceSpan.end,o.sourceSpan.end)}return Be(r,!1,{start:t,end:e})}function Sl(r,t){let e=[],n=new Map,o=s=>{s&&s.length>=2&&e.push(xi(s))};for(let s of r)if(!(s.length<2)){for(let i of s){if(t.has(i)){o(n.get(i.track)),n.delete(i.track);continue}let a=n.get(i.track);a?a.push(i):n.set(i.track,[i])}for(let i of n.values())o(i);n.clear()}return e}function wl(r,t,e){let n=[],o=new Map,s=new G,i=new G,a=new G(1),c=1,l=0,u=m=>{let d=o.get(m);d&&(o.delete(m),d.nodes.length>=2&&n.push(xi(d.nodes)))},p=()=>{for(let m of o.keys())u(m)};for(let m of r.columns){let d=m[0].layoutLine,f,x=!1;for(let y of m)f=gi(y)??f,y.mergeKey===gt&&(x=!0);if((d!==l||f||x)&&(l=d,p(),s.copyFrom(m[0].t)),f){let{numerator:y,denominator:h}=f;y>0&&h>4?a.set(h>=8&&y%3===0?12:4,h):a.set(1),c=a.compare(1)<0?a:1}for(let y of m){if(y.mergeKey===gt)continue;let h=W(y)?Dn(y):void 0;if(!(W(y)&&h!==void 0&&h.autoBeamEnabled&&t.get(h)?.length===1&&y.T.compare(c)<0&&!e.has(y))){(W(y)||!y.T.isZero())&&u(y.track);continue}i.copyFrom(y.t).sub(s);let b=Math.floor(i.numerator*a.denominator/(i.denominator*a.numerator)),T=o.get(y.track);if(!T||b!==T.beat||!y.t.equals(T.endTime)){u(y.track),o.set(y.track,{nodes:[y],beat:b,endTime:y.t.clone().add(y.T)});continue}T.nodes.push(y),T.endTime.copyFrom(y.t).add(y.T)}}return p(),n}function bi(r){let t=bl(r);if(t.size===0)return;let e=Si(r.attachments);r.attachments.push(...Sl(t.values(),e),...wl(r,t,e))}var wi="div",rn=fe(wi),Ti=Symbol("div.owner");function Dn(r){return r.addon?.[Ti]}function ee(r,t){return`div.${r}.${t}`}function Li(r,t){let e=r.ports[ee(t,"left")];e&&(e.state.claimed=!0)}function Ko(r){return Math.max(1,r*.055)}function*Ai(r){for(let t=0;;t++){let e=!1,n=-1;for(let o=0;o<=r.length;o++){let s=r[o]?.ports,i=s?.[ee(t,"left")],a=s?.[ee(t,"right")];if((i||a)&&(e=!0),i&&a){n<0&&(n=o);continue}n>=0&&o-n>=2&&(yield{level:t,from:n,to:o-1}),n=-1}if(!e)return}}var Uo=class r extends B{static def={name:[wi,"/"],description:"\u51CF\u65F6\u7EBF",details:"~~~jpfun\n@div({1 2 -}, n=2, autobeam=true)\n~~~\n**\u7B80\u5199**\uFF1A\u5728\u76EE\u6807\u540E\u52A0 `/`\uFF0C\u53EF\u91CD\u590D\u6216\u4F5C\u7528\u4E8E\u5185\u5BB9\u5757\u3002`@div(1, 2)` \u7B49\u4EF7\u4E8E `1//`\uFF0C`@div({1 2/ -}, 2)` \u7B49\u4EF7\u4E8E `{1 2/ -}//`\u3002\u9ED8\u8BA4\u53C2\u6570\u4F7F\u7528 `div.n`\u3001`div.autobeam` \u8BBE\u7F6E\u3002",allowExtraArgs:!1,args:[{type:"content",description:"\u8981\u51CF\u65F6\u7684\u5185\u5BB9\uFF0C\u53EF\u5305\u542B\u591A\u4E2A\u97F3\u7B26\u6216\u589E\u65F6\u7EBF",default:null},{name:"n",description:"\u51CF\u65F6\u5C42\u6570\uFF0C\u6BCF\u7EA7\u5C06\u65F6\u503C\u51CF\u534A\uFF0C\u53D6\u975E\u8D1F\u6574\u6570",type:"number",default:1},{name:"autobeam",description:"\u662F\u5426\u53C2\u4E0E\u4E0D\u540C div \u4E4B\u95F4\u7684\u81EA\u52A8\u8FDE\u7EBF\uFF0C\u540C\u4E00 div \u5185\u90E8\u7684\u8FDE\u7EBF\u4E0D\u53D7\u5F71\u54CD",type:"boolean",default:!0}]};static deSugarAtom(t,e,n){let o=0,s=e;for(;s<n&&t[s]==="/";)o++,s++;return o===0?null:{next:s,node:{kind:"sugar",data:{class:r,n:o},span:{start:e,end:s}}}}static deSugarRelation(t,e,n){let o=e[n++];if(o.data?.class!==r)return null;let s=t.findLastOperandIndex();if(s<0)return n;let i=t.nodes[s];if(i instanceof r)return i.n+=o.data.n,i.sourceSpan.end=Math.max(i.sourceSpan.end,o.span.end),n;let a=new Map;a.set(0,i),a.set("n",o.data.n);let c=i.sourceSpan;return t.nodes[s]=new r({start:Math.min(c.start,o.span.start),end:Math.max(c.end,o.span.end)},a,t,null),n}static layoutDecorationHandler=(t,e)=>{let n=Math.max(0,Math.floor(Number(e)||0));if(n===0)return null;let o=t.ast.size*.14,s=Ko(t.ast.size),i=(n-1)*o+s,a=0,c=0,l=0;return{below:{order:0,gap:t.box.h-(t.ports["decoration.below"]?.y??t.box.h)-t.ast.size*.08,height:i,place(u){a=t.ports["body.left"]?.x??0,c=t.ports["body.right"]?.x??t.box.w,l=u+s/2;for(let p=0;p<n;p++){let m=l+p*o;t.ports[ee(p,"left")]={x:a,y:m,state:{claimed:!1}},t.ports[ee(p,"right")]={x:c,y:m}}}},paint(u){for(let p=0;p<n;p++){if(t.ports[ee(p,"left")].state.claimed)continue;let d=t.box.y+l+p*o;u.drawLine(t.box.x+a,d,t.box.x+c,d,{stroke:"#000",strokeWidth:s})}}}};loweringEnter(t){let e=this.n;if(e===0)return[];let n=this;return t.deferFinalize(r.loweringFinalize,-5),t.beginLoweringGroup(this,{onTemporal(o){let s=o.addon??={};s[rn]=(Number(s[rn])||0)+e,s[Ti]=n,o.T.divPow2(e)}}),[]}loweringExit(t){return this.n>0&&t.endLoweringGroup(this),[]}static loweringFinalize=bi;content;n;autoBeamEnabled;get children(){return[this.content]}constructor(t,e,n,o=null){super(t,o),[this.content,this.n,this.autoBeamEnabled]=this.getArgValue(e,n),this.content.parent=this;let s=Math.max(0,Math.trunc(this.n));s!==this.n&&(n.diagnostics.push(new K("W_DIV_INVALID_N","@div \u7684\u6570\u91CF\u53C2\u6570 n \u5FC5\u987B\u4E3A\u975E\u8D1F\u6574\u6570\uFF0C\u5DF2\u88AB\u4FEE\u6B63\u4E3A {n}",this.sourceSpan,{n:s})),this.n=s)}toString(t){return`@div(${this.content.toString(t)}, ${this.n})`}},Ci=Uo;function Be(r,t,e){return new sn(r,t,e)}function Ni(r){let t=new Map,e=new Map;for(let n of r.columns)for(let o of n){if(!W(o)||o.mergeKey===gt&&o.T.isZero())continue;let s=t.get(o.layoutLine);s||(s=new Map,t.set(o.layoutLine,s));let i=s.get(o.track)??0;e.set(o,{line:o.layoutLine,track:o.track,index:i}),s.set(o.track,i+1)}for(let n of r.attachments)if(!(!(n instanceof sn)||!n.explicit))for(let o=1;o<n.endPoints.length;o++){let s=n.endPoints[o-1],i=n.endPoints[o];if(!W(s)||!W(i))continue;let a=e.get(s),c=e.get(i);if(!(s!==i&&a!==void 0&&c!==void 0&&a.line===c.line&&a.track===c.track&&c.index===a.index+1))throw new k("E_NON_ADJACENT_BEAM","@beam \u7684\u7AEF\u70B9\u5FC5\u987B\u6309\u65F6\u95F4\u987A\u5E8F\u8FDE\u63A5\u540C\u4E00\u8F68\u9053\u3001\u540C\u4E00\u8C31\u9762\u884C\u4E2D\u7684\u76F8\u90BB\u53EF\u89C1\u5143\u7D20\uFF08\u53EF\u8DE8\u5C0F\u8282\u7EBF\uFF09",n.sourceSpan)}}function Si(r){let t=new Set;for(let e of r)if(!(!(e instanceof sn)||!e.explicit))for(let n of e.endPoints)t.add(n);return t}var sn=class{layer="foreground";endPoints;explicit;sourceSpan;fontSize;strokeWidth;constructor(t,e,n){this.endPoints=t,this.explicit=e,this.sourceSpan=n,this.fontSize=t.reduce((o,s)=>W(s)?Math.max(o,s.ast.size):o,0),this.strokeWidth=Ko(this.fontSize)}prepareHorizontal(t){let e;for(let n of this.endPoints)if(W(n)){if(e&&e.layoutLine===n.layoutLine&&e.track===n.track){let o=t[e.layoutLine],s=o?o.trackIndexOf(e):-1;s>=0&&s+1===o.trackIndexOf(n)&&(e.springConfig.alpha_R*=.8,n.springConfig.alpha_L*=.8)}e=n}}createGeometry(t){let e=this.collectLines(t),n=this.strokeWidth;return{regions:e.map(s=>({x:Math.min(s.start.x,s.end.x),y:s.start.y-n/2,w:Math.abs(s.end.x-s.start.x),h:n,line:s.line,track:s.track})),paint(s){for(let i of e)s.drawLine(i.start.x,i.start.y,i.end.x,i.end.y,{stroke:"#000",strokeWidth:n})}}}absolutePort(t,e){let n=t.ports[e];return{x:t.box.x+n.x,y:t.box.y+n.y}}collectLines(t){let e=[],n=this.endPoints.filter(W);if(n.length<2)return e;for(let{level:o,from:s,to:i}of Ai(n)){let a=[];for(let c=s;c<=i;c++){let l=n[c];a.push({left:this.absolutePort(l,ee(o,"left")),right:this.absolutePort(l,ee(o,"right")),line:l.layoutLine,track:l.track,node:l})}this.addSystemLines(a,t,o,e)}if(e.length===0&&this.explicit){let o=this.fontSize*.12,s=n.map(i=>{let a={x:i.box.x+i.box.anchor,y:i.box.y+i.box.h+o};return{left:a,right:a,line:i.layoutLine,track:i.track,node:i}});this.addSystemLines(s,t,null,e)}return e}addSystemLines(t,e,n,o){let s=Math.min(...t.map(u=>u.line)),i=Math.max(...t.map(u=>u.line)),a=t[0].track,c=e.getVisualAxis(t[0].line,a),l=t[0].left.y-c;for(let u=s;u<=i;u++){let p=t.filter(h=>h.line===u).sort((h,g)=>h.left.x-g.left.x);if(p.length===0){let g=e.getVisualAxis(u,a)+l;o.push({start:{x:e.originX,y:g},end:{x:e.originX+e.width,y:g},line:u,track:a});continue}let m=p[0],d=p[p.length-1],f=m.left.y,x={x:m.left.x,y:f},y={x:d.right.x,y:f};if(u>s&&(x.x=e.originX),u<i&&(y.x=e.originX+e.width),!(x.x===y.x&&s===i)){if(n!==null)for(let h of p)Li(h.node,n);o.push({start:x,end:y,line:u,track:m.track})}}}};var Yo=class r extends B{static loweringFinalize=Ni;static def={name:["beam"],description:"\u51CF\u65F6\u7EBF\u8FDE\u63A5",details:"\u4E8B\u540E\u5C06\u591A\u4E2A\u51CF\u65F6\u7EBF**\u5F3A\u884C**\u76F8\u8FDE\n~~~jpfun\n1/@a 2/@b | 3/@c @beam(a, b, c)\n~~~\n**\u4F4D\u7F6E\u53C2\u6570**\uFF1A\u5DF2\u6807\u8BB0\u97F3\u7B26\u7684\u6807\u7B7E\uFF0C\u6309\u4F20\u5165\u987A\u5E8F\u8FDE\u63A5\u51CF\u65F6\u7EBF\uFF0C\u663E\u5F0F\u6307\u5B9A\u4E00\u7EC4\u3002\u5148\u7528 `/` \u6216 `@div` \u4E3A\u76EE\u6807\u6DFB\u52A0\u51CF\u65F6\u7EBF\uFF0C\u518D\u7528 `@beam` \u63A7\u5236\u8FDE\u63A5\u3002\u7AEF\u70B9\u987B\u540C\u8F68\u3001\u540C\u8C31\u9762\u884C\u4E14\u76F8\u90BB\uFF0C\u53EF\u8DE8\u5C0F\u8282\u7EBF\uFF1B\u8FDE\u7EBF\u76F4\u63A5\u7A7F\u8FC7\u5C0F\u8282\u7EBF\uFF0C\u4FDD\u7559\u539F\u6709\u95F4\u8DDD\u3002",allowExtraArgs:!0,extraArgType:"label",args:[]};endPoints=[];constructor(t,e,n,o=null){super(t,o);for(let[i,a]of e)typeof i=="number"&&this.endPoints.push(a);let s=n.labelableNodes.length-1;for(;this.endPoints.length<2&&s>=0;){let i=n.labelableNodes[s--];!i||this.endPoints.includes(i)||this.endPoints.unshift(i)}if(this.endPoints.length<2)throw new k("E_NOT_ENOUGH_ARGS","@{fn} \u81F3\u5C11\u9700\u8981\u4E24\u4E2A\u7AEF\u70B9",t,{fn:"beam"})}loweringEnter(t){let e=[];for(let n of this.endPoints){let o=t.getTemporalNodes(n).at(-1)?.rootHost;o&&e.push(o)}return e.length<2?(t.diagnostics.push(Y.warning.UnresolvedEndpoint("beam",this.sourceSpan)),[]):(t.addAttachment(Be(e,!0,this.sourceSpan)),t.deferFinalize(r.loweringFinalize),[])}},vi=Yo;var qo=class extends B{static def={name:["box"],description:"\u7ED9\u76EE\u6807\u7ED3\u6784\u6216\u5BF9\u8C61\u52A0\u5916\u6846",details:`~~~jpfun
|
|
13
17
|
@box({1 2 3}, padding=0.2em, stroke=0.08em)
|
|
14
|
-
~~~`,allowExtraArgs:!1,args:[{type:"content",description:"\u9700\u8981\u52A0\u6846\u7684\u5185\u5BB9\u6216\u7ED3\u6784",default:null},{name:"padding",description:"\u5185\u5BB9\u5230\u6846\u7EBF\u7684\u5185\u8FB9\u8DDD\uFF0C\u8D1F\u503C\u5411\u5185\u6536\u7F29",type:"length",default:{value:0,unit:"em"}},{name:"stroke",description:"\u6846\u7EBF\u5BBD\u5EA6",type:"length",default:{value:1,unit:"px"}},{name:"width",description:"\u7EA6\u675F\u5185\u90E8\u6392\u7248\u7684\u5BBD\u5EA6\uFF0C\u975E\u6B63\u503C\u8868\u793A\u968F\u5185\u5BB9\u81EA\u52A8\u786E\u5B9A",type:"length",default:{value:-1,unit:"px"}}]};target;padding;stroke;width;get children(){return[this.target]}
|
|
18
|
+
~~~`,allowExtraArgs:!1,args:[{type:"content",description:"\u9700\u8981\u52A0\u6846\u7684\u5185\u5BB9\u6216\u7ED3\u6784",default:null},{name:"padding",description:"\u5185\u5BB9\u5230\u6846\u7EBF\u7684\u5185\u8FB9\u8DDD\uFF0C\u8D1F\u503C\u5411\u5185\u6536\u7F29",type:"length",default:{value:0,unit:"em"}},{name:"stroke",description:"\u6846\u7EBF\u5BBD\u5EA6",type:"length",default:{value:1,unit:"px"}},{name:"width",description:"\u7EA6\u675F\u5185\u90E8\u6392\u7248\u7684\u5BBD\u5EA6\uFF0C\u975E\u6B63\u503C\u8868\u793A\u968F\u5185\u5BB9\u81EA\u52A8\u786E\u5B9A",type:"length",default:{value:-1,unit:"px"}}]};target;padding;stroke;width;get children(){return[this.target]}loweringEnter(t){let e={nodes:[],attachments:[],onTemporal(n){W(n)&&e.nodes.push(n)},onAttachment(n){e.attachments.push(n)}};return t.beginLoweringGroup(this,e),[]}loweringExit(t){let e=t.endLoweringGroup(this),n=new Zo(e,this);t.addAttachment(n);let o=e.nodes[0];if(o){if(n.reservedHost){let i=o.prepareLayout;o.prepareLayout=a=>{i.call(o,a);let c={order:1/0,height:Math.max(0,this.padding+this.stroke/2)};o.decorations.push({above:c,below:c})}}let s=o.prepareHorizontal;o.prepareHorizontal=i=>{s?.call(o,i),n.registerHorizontal(i)}}return[]}constructor(t,e,n,o=null){super(t,o);let[s,i,a,c]=this.getArgValue(e,n);s.parent=this,this.target=s,this.padding=n.length2px(i),this.stroke=Math.max(0,n.length2px(a)),this.width=n.length2px(c)}toString(t){return`@box(${this.target.toString(t)}, padding=${this.padding}px, stroke=${this.stroke}px, width=${this.width}px)`}},ki=qo,Zo=class r{constructor(t,e){this.content=t;this.owner=e;let[n]=t.nodes;t.nodes.length===1&&t.attachments.every(o=>o instanceof r&&o.reservedHost===n)&&(this.reservedHost=n)}content;owner;layer="background";reservedHost;fixedStart=null;wallOffset=0;get sourceSpan(){return this.owner.sourceSpan}registerHorizontal(t){let e=this.content.nodes,n=e[0];if(!n)return;if(e.some(c=>c.layoutLine!==n.layoutLine))throw new k("E_BOX_CROSS_LINE","@box \u7684\u5185\u5BB9\u4E0D\u80FD\u8DE8\u8D8A\u8C31\u9762\u884C",this.owner.sourceSpan);let o=n;for(let c of e){let l=t.columnOf(c);if(l<0)return;l<t.columnOf(n)&&(n=c),l>t.columnOf(o)&&(o=c)}let{width:s,padding:i,stroke:a}=this.owner;t.registerHorizontalLayoutHook(n,o,({columns:c,rows:l,start:u,end:p,X:m,fixed:d,options:f})=>{let x=b=>c[b].filter(T=>e.some(L=>L.box===T.box)),y=x(u),h=x(p);if(s>0){let b=Math.max(...y.map(w=>w.WL)),T=Math.max(...h.map(w=>w.WR));if(s<b+T-1e-6)throw new k("E_BOX_WIDTH_TOO_SMALL","@box \u7684\u5BBD\u5EA6\u5C0F\u4E8E\u9996\u672B\u5143\u7D20\u7684\u56FA\u6709\u5BBD\u5EA6",this.owner.sourceSpan);if(d[u-1]||d[p])throw new k("E_BOX_CONSTRAINT_CROSSING","\u5B9A\u5BBD @box \u53EF\u4EE5\u5D4C\u5957\uFF0C\u4F46\u4E0D\u80FD\u90E8\u5206\u4EA4\u53C9",this.owner.sourceSpan);let L=m.subarray(u,p+1);if(u===p){let w=(s-b-T)/2;for(let A of y)A.WL+=w;for(let A of h)A.WR+=w;L[0]=b+w}else{_e(c.slice(u,p+1),l,L,d.subarray(u,p),s,f,0);let w=L[L.length-1]-L[0]+b+T;if(Math.abs(w-s)>1e-6)throw new k("E_BOX_CONSTRAINT_CONFLICT","\u591A\u4E2A @box \u4E3A\u76F8\u540C\u5185\u5BB9\u6307\u5B9A\u4E86\u4E0D\u540C\u5BBD\u5EA6",this.owner.sourceSpan)}this.fixedStart=n,this.wallOffset=-L[0]}let g=i+a/2;for(let b of y)b.WL+=g;for(let b of h)b.WR+=g})}createGeometry(t){let{padding:e,stroke:n}=this.owner,o=t.getContentBounds(this.content);if(!o)return{regions:[],paint(){}};let s=e+n/2,a={x:(this.fixedStart?this.fixedStart.box.x+this.fixedStart.box.anchor+this.wallOffset:o.x)-s,y:o.y-s,w:(this.fixedStart?this.owner.width:o.w)+s*2,h:o.h+s*2};if(a.w<n||a.h<n)throw new k("E_BOX_PADDING_TOO_SMALL","@box \u7684\u8D1F\u5185\u8FB9\u8DDD\u4F7F\u8FB9\u6846\u5BBD\u5EA6\u6216\u9AD8\u5EA6\u5C0F\u4E8E\u96F6",this.owner.sourceSpan);return{regions:[a],occupancy:this.reservedHost?[]:this.occupancy(t,a),paint(c){let l=n/2;c.drawRect(a.x+l,a.y+l,Math.max(0,a.w-n),Math.max(0,a.h-n),{stroke:"#000",strokeWidth:n})}}}occupancy(t,e){let n=new Set,o,s=(c,l)=>{if(o!==void 0&&o!==c)throw new k("E_BOX_CROSS_LINE","@box \u7684\u5185\u5BB9\u4E0D\u80FD\u8DE8\u8D8A\u8C31\u9762\u884C",this.owner.sourceSpan);o=c,n.add(l)};for(let c of this.content.nodes)s(c.layoutLine,c.track);for(let c of this.content.attachments){if(!Xt(c))continue;let l=t.getAttachmentOccupancy(c);if(l){for(let u of c.endPoints??[])s(u.layoutLine,u.track);for(let u of l)u.line!==void 0&&s(u.line,u.track)}}if(o===void 0)return[];let i=o,a=[...n].sort((c,l)=>t.getVisualAxis(i,c)-t.getVisualAxis(i,l));return[{...e,h:0,line:i,track:a[0]},{...e,y:e.y+e.h,h:0,line:i,track:a.at(-1)}]}};var Qo=class extends B{static def={name:["dash","-"],description:"\u589E\u65F6\u7EBF",details:"~~~jpfun\n1 @dash()\n~~~\n\u65E0\u53C2\u6570\u3002\u6DFB\u52A0\u4E00\u6839\u589E\u65F6\u7EBF\uFF0C\u6269\u5C55\u524D\u65B9\u97F3\u7B26\u6216\u4F11\u6B62\u7B26\u7684\u5B8C\u6574\u65F6\u503C\uFF1B\u4E5F\u53EF\u7B80\u5199\u4E3A `1 -`\u3002\u6BCF\u6839\u7EBF\u7684\u57FA\u7840\u65F6\u503C\u4E3A\u4E00\u4E2A\u56DB\u5206\u97F3\u7B26\uFF0C\u53EF\u7528\u51CF\u65F6\u7EBF\u6216\u9644\u70B9\u8C03\u6574\u3002\u88C5\u9970\u97F3\u8986\u76D6\u5EF6\u957F\u540E\u7684\u5B8C\u6574\u97F3\u7B26\uFF0C\u4F8B\u5982 `1 ^ $tr -` \u5728\u4E24\u62CD\u5185\u6301\u7EED\u98A4\u97F3\u3002",allowExtraArgs:!1,args:[]};static deSugarAtom(t,e,n){if(t[e]!=="-")return null;let o={kind:"call",typed:!0,name:"-",args:new Map,span:{start:e,end:e+1},syntaxKind:"atom"};return{next:e+1,node:o}}size;constructor(t,e,n,o=null){super(t,o),this.size=n.variables.fontsize}loweringEnter(){return[new Jo(this)]}labelable(){return this}toString(){return"-"}},Ei=Qo,Jo=class extends tt{lineWidth=0;constructor(t){super(),this.ast=t,this.T.set(1),this.mergeKey=zt,this.initLayoutBox()}onTimeState(t){this.playbackState={bpm:t.bpm}}prepareLayout(){let t=this.ast.size;this.lineWidth=t*.42,this.box.w=this.lineWidth,this.box.h=t,this.box.anchor=this.lineWidth/2,this.box.visualAxis=t*.5}emitPlayback(t){let e=t.start.clone(),n=t.track,o=this.ast.sourceSpan;t.defer(s=>{let i,a=!1;for(let c=s.spans.length-1;c>=0;c--){let l=s.spans[c];if(i){if(l.origins[0]!==i)break}else{if(l.track!==n)continue;i=l.origins[0]}l.end.equals(e)&&(t.extend(l),a=!0)}a||s.diagnostics.push(new K("W_PLAYBACK_SUSTAIN_WITHOUT_TARGET","\u589E\u65F6\u7EBF\u524D\u6CA1\u6709\u53EF\u5EF6\u7EED\u7684\u97F3\u6BB5",o))})}paint(t){let e=this.box.y+this.box.visualAxis;t.drawLine(this.box.x,e,this.box.x+this.lineWidth,e,{stroke:"#000",strokeWidth:Math.max(1,this.ast.size*.1)})}};var Ri="dot",Pi=fe(Ri);function Mi(r){let t=2**r;return[2*t-1,t]}var tr=class r extends B{static def={name:[Ri,"."],description:"\u9644\u70B9",details:"~~~jpfun\n@dot(1, n=2)\n~~~\n**\u7B80\u5199**\uFF1A\u76EE\u6807\u540E\u52A0 `.`\uFF0C\u53EF\u91CD\u590D\u3002`@dot(1, 2)` \u7B49\u4EF7\u4E8E `1..`\uFF1B`{1^2}.` \u7B49\u4EF7\u4E8E `{1.^2}`\u3002\n\n`@dot({1 2/ -}, 2)` \u5305\u542B\u591A\u4E2A\u65F6\u95F4\u5143\u7D20\uFF0C\u4F1A\u62A5\u9519\uFF1B\u9700\u8981\u5206\u522B\u4E3A\u5404\u5143\u7D20\u6DFB\u52A0\u9644\u70B9\u3002",allowExtraArgs:!1,args:[{type:"content",description:"\u5355\u4E2A\u53EF\u89C1\u65F6\u95F4\u5143\u7D20\uFF0C\u5982\u97F3\u7B26\u3001\u589E\u65F6\u7EBF\u6216\u6298\u53E0\u548C\u5F26",default:null},{name:"n",description:"\u9644\u70B9\u6570\uFF0C\u7B2C\u4E00\u70B9\u589E\u52A0\u539F\u65F6\u503C\u7684\u4E00\u534A\uFF0C\u540E\u7EED\u5404\u70B9\u589E\u52A0\u91CF\u518D\u51CF\u534A",type:"number",default:1}]};static deSugarAtom(t,e,n){let o=0,s=e;for(;s<n&&t[s]===".";)o++,s++;return o===0?null:{next:s,node:{kind:"sugar",data:{class:r,n:o},span:{start:e,end:s}}}}static deSugarRelation(t,e,n){let o=e[n++];if(o.data?.class!==r)return null;let s=t.findLastOperandIndex();if(s<0)return n;let i=t.nodes[s];if(i instanceof r)return i.n+=o.data.n,i.sourceSpan.end=Math.max(i.sourceSpan.end,o.span.end),n;let a=new Map;a.set(0,i),a.set("n",o.data.n);let c=i.sourceSpan;return t.nodes[s]=new r({start:Math.min(c.start,o.span.start),end:Math.max(c.end,o.span.end)},a,t,null),n}static layoutDecorationHandler=(t,e)=>{let n=Math.max(0,Math.floor(Number(e)||0));if(n===0)return null;let o=t.ast.size*.075,s=t.ast.size*.12,i=t.ports.dot??{x:t.box.w,y:t.box.visualAxis},a=i.x+s+o,c=o*2+s,l=a+(n-1)*c+o;return t.box.w=Math.max(t.box.w,l),{paint(u){let p=t.box.y+i.y;for(let m=0;m<n;m++)u.drawCircle(t.box.x+a+m*c,p,o,{fill:"#000"})}}};loweringEnter(t){let e=this.n,n={temporalCount:0,onTemporal(o){if(n.temporalCount++,e===0)return;let s=o.addon??={},i=Number(s[Pi])||0,a=i+e,[c,l]=Mi(a),[u,p]=Mi(i);o.T.mul(c*p,l*u),s[Pi]=a}};return t.beginLoweringGroup(this,n),[]}loweringExit(t){let e=t.endLoweringGroup(this);if(e.temporalCount!==1)throw new k("E_DOT_INVALID_CONTENT","\u51FD\u6570 @dot \u53EA\u80FD\u63A5\u6536 1\u4E2A\u5143\u7D20\uFF0C\u4F46\u627E\u5230\u4E86 {count} \u4E2A",this.sourceSpan,{count:e.temporalCount});return[]}content;n;get children(){return[this.content]}constructor(t,e,n,o=null){super(t,o),[this.content,this.n]=this.getArgValue(e,n),this.content.parent=this;let s=Math.max(0,Math.trunc(this.n));s!==this.n&&(n.diagnostics.push(new K("W_DOT_INVALID_N","@dot \u7684\u6570\u91CF\u53C2\u6570 n \u5FC5\u987B\u4E3A\u975E\u8D1F\u6574\u6570\uFF0C\u5DF2\u88AB\u4FEE\u6B63\u4E3A {n}",this.sourceSpan,{n:s})),this.n=s)}toString(t){return`@dot(${this.content.toString(t)}, ${this.n})`}},_i=tr;function Vn(r,t,e=!1){let n=0,o=r.length;for(;n<o;){let s=n+o>>>1,i=r[s].host.t.compare(t);(e?i<=0:i<0)?n=s+1:o=s}return n}var er=class r extends B{static def={name:["dyn"],description:"\u6E10\u5F3A\u6E10\u5F31",details:`~~~jpfun
|
|
15
19
|
1 ^ $p 2@a 3 4@b
|
|
16
20
|
@dyn(a, b, 24)
|
|
17
21
|
~~~
|
|
18
22
|
\u7AEF\u70B9\u987B\u4F4D\u4E8E\u540C\u4E00\u97F3\u8F68\u3001\u4E0D\u540C\u65F6\u95F4\uFF1B\u53D8\u5316\u91CF\u6CBF\u533A\u95F4\u7EBF\u6027\u589E\u52A0\uFF0C\u53E0\u52A0\u5728\u6BCF\u4E2A\u97F3\u7B26\u539F\u6709\u529B\u5EA6\u4E0A\u3002\u672C\u4F8B\u4ECE \`a\` \u5230 \`b\` \u6E10\u5F3A\uFF0C\u7EC8\u70B9\u589E\u52A0 24 \u7684\u529B\u5EA6\u3002
|
|
19
23
|
|
|
20
|
-
\u7AEF\u70B9\u4E5F\u53EF\u6807\u5728\u589E\u65F6\u7EBF\u4E0A\u3002\u7EC8\u70B9\u6CA1\u6709\u529B\u5EA6\u65F6\uFF0C\u53D6\u540C\u8F68\u3001\u4E0D\u665A\u4E8E\u7EC8\u70B9\u7684\u6700\u540E\u4E00\u4E2A\u539F\u59CB\u529B\u5EA6\u4F5C\u4E3A\u4FDD\u6301\u57FA\u51C6\uFF1B\u627E\u4E0D\u5230\u65F6\u7ED9\u51FA\u8B66\u544A\u5E76\u4EC5\u7ED8\u5236\u3002\u589E\u65F6\u7EBF\u5EF6\u7EED\u7684\u97F3\u7B26\u4FDD\u6301\u8D77\u97F3\u65F6\u7684\u529B\u5EA6\u3002`,allowExtraArgs:!1,args:[{name:"from",description:"\u6E10\u53D8\u8D77\u70B9\u7684\u6807\u7B7E",type:"label",default:null},{name:"to",description:"\u6E10\u53D8\u7EC8\u70B9\u7684\u6807\u7B7E",type:"label",default:null},{name:"dv",description:"\u529B\u5EA6\u53D8\u5316\u91CF\uFF0C\u6B63\u6570\u6E10\u5F3A\uFF0C\u8D1F\u6570\u6E10\u5F31",type:"number",default:null}]};static loweringFinalize=t=>{let e=t.attachments.filter(o=>o instanceof Ze);if(e.length===0)return;let n=[];for(let o of t.astToTemporal.values())for(let i of o){let r=i.playbackState?.velocity;if(r===void 0)continue;let a=i;for(;a.foldedInto;)a=a.foldedInto;n.push({node:i,host:a,velocity:r,increment:0})}n.sort((o,i)=>o.host.t.compare(i.host.t)||o.node.order-i.node.order);for(let o of e){let i=o.end.playbackState?.velocity??n.find(c=>c.host===o.toHost)?.velocity;for(let c=n.length-1;i===void 0&&c>=0;c--){let l=n[c];l.host.track===o.track&&l.host.t.compare(o.toHost.t)<=0&&(i=l.velocity)}if(i===void 0){t.diagnostics.push(new q("W_DYN_NO_VELOCITY","@dyn \u7EC8\u70B9\u53CA\u6B64\u524D\u540C\u8F68\u6CA1\u6709\u53EF\u7528\u7684\u529B\u5EA6\u57FA\u51C6\uFF0C\u4EC5\u7ED8\u5236\u6E10\u53D8\u7EBF",o.sourceSpan));continue}let r=n.find(c=>c.host.track===o.track&&c.host.t.compare(o.toHost.t)>0&&c.velocity!==i)?.host.t,a=o.toHost.t.clone().sub(o.fromHost.t);for(let c of n){if(c.host.track!==o.track||c.host.t.compare(o.fromHost.t)<0||r&&c.host.t.compare(r)>=0)continue;let p=c.host.t.compare(o.toHost.t)>=0?1:c.host.t.clone().sub(o.fromHost.t).div(a).toNumber();c.increment+=o.dv*p}}for(let o of n){if(o.increment===0)continue;let i=Math.max(1,Math.min(127,o.velocity+o.increment));o.node.playbackState={...o.node.playbackState,velocity:i}}};from;to;dv;size;loweringEnter(t){let e=t.getTemporalNodes(this.from).at(0),n=t.getTemporalNodes(this.to).at(-1);if(!e||!n)return t.diagnostics.push(H.warning.UnresolvedEndpoint("dyn",this.sourceSpan)),[];let o=e,i=n;for(;o.foldedInto;)o=o.foldedInto;for(;i.foldedInto;)i=i.foldedInto;if(!X(o)||!X(i))return t.diagnostics.push(H.warning.UnresolvedEndpoint("dyn",this.sourceSpan)),[];if(o.track!==i.track)throw new k("E_DYN_CROSS_TRACK","@dyn \u7684\u4E24\u4E2A\u7AEF\u70B9\u5FC5\u987B\u4F4D\u4E8E\u540C\u4E00\u97F3\u8F68",this.sourceSpan);if(o.t.equals(i.t))throw new k("E_DYN_ZERO_SPAN","@dyn \u7684\u4E24\u4E2A\u7AEF\u70B9\u5FC5\u987B\u4F4D\u4E8E\u4E0D\u540C\u65F6\u95F4",this.sourceSpan);return o.t.compare(i.t)<0?t.addAttachment(new Ze(this,n,o,i)):t.addAttachment(new Ze(this,e,i,o)),[]}constructor(t,e,n,o=null){super(t,o);let[i,r,a]=this.getArgValue(e,n),c=a;if(!Number.isFinite(c)||c===0)throw new k("E_DYN_INVALID_DELTA","@dyn \u7684 dv \u5FC5\u987B\u662F\u975E\u96F6\u6709\u9650\u6570",t);c=Math.max(-127,Math.min(127,c)),c!==a&&n.diagnostics.push(new q("W_DYN_DELTA_CLAMPED",`@dyn \u7684 dv \u5FC5\u987B\u5728 -127 \u5230 127 \u4E4B\u95F4\uFF0C\u5DF2\u88AB\u9650\u5236\u4E3A ${c}`,t)),this.from=i,this.to=r,this.dv=c,this.size=n.variables.fontsize}toString(t){let e=n=>n.label??n.toString(t);return`@dyn(${e(this.from)}, ${e(this.to)}, ${this.dv})`}},or=$o,Ze=class{ast;end;fromHost;toHost;layer="foreground";constructor(t,e,n,o){this.ast=t,this.end=e,this.fromHost=n,this.toHost=o}get sourceSpan(){return this.ast.sourceSpan}get endPoints(){return[this.fromHost,this.toHost]}get dv(){return this.ast.dv}get track(){return this.fromHost.track}createGeometry(t){let e=this.fromHost.layoutLine,n=this.toHost.layoutLine,o=[this.fromHost,this.toHost],i=[],r=this.ast.size;for(let d=e;d<=n;d++){let y=t.getRangeColumns(d,o,this.track);if(y.some(m=>m.length>0)){for(let m of y)for(let g of m)r=Math.max(r,g.ast.size);i.push({line:d,startX:d===e?this.fromHost.box.x:this.lineEntryX(t,d),endX:d===n?this.toHost.box.x+this.toHost.box.w:this.lineRightX(t,d)})}}for(let d of i)d.line>e&&(d.startX-=r/4);let a=Math.max(.75,r*.035),c=i.filter(d=>d.startX!==d.endX),l=c.reduce((d,y)=>d+Math.abs(y.endX-y.startX),0);if(l===0)return{regions:[],paint(){}};let p=r*.4,f=a/2,u=0,h=c.map(d=>{let y=Math.abs(d.endX-d.startX),m=u/l,g=(u+y)/l;u+=y;let x=t.getRangeExtents(d.line,o,this.track),b=t.getVisualAxis(d.line,this.track),A=x?b+x.top:b;return{line:d.line,startX:d.startX,endX:d.endX,lineY:A-r*.62,startOpen:p*(this.dv>0?m:1-m),endOpen:p*(this.dv>0?g:1-g)}});return{regions:h.map(d=>({x:Math.min(d.startX,d.endX)-f,y:d.lineY-Math.max(d.startOpen,d.endOpen)/2-f,w:Math.abs(d.endX-d.startX)+a,h:Math.max(d.startOpen,d.endOpen)+a,line:d.line,track:this.track})),paint(d){let y={stroke:"#000",strokeWidth:a};for(let m of h)d.drawLine(m.startX,m.lineY-m.startOpen/2,m.endX,m.lineY-m.endOpen/2,y),d.drawLine(m.startX,m.lineY+m.startOpen/2,m.endX,m.lineY+m.endOpen/2,y)}}}lineEntryX(t,e){return t.lines[e].trackRuns.get(this.track)?.find(o=>!o.T.isZero())?.box.x??t.originX}lineRightX(t,e){let n=t.lines[e].trackRuns;if(n.size===0)return t.originX+t.width;let o=t.originX;for(let i of n.values())for(let r of i)o=Math.max(o,r.box.x+r.box.w);return o}};var pe=class s{parent;groups=[];constructor(t=null){this.parent=t}group(t,e){let n=this.groups.find(o=>o.laneKey===t.laneKey);for(n||(n={laneKey:t.laneKey,members:[],measure:t.measure,place:t.place},this.groups.push(n));n.members.length<e;)n.members.push(new s(this));return n}};var Re=.7,sr="shoulder";function rr(s,t){let e=s;typeof e.size=="number"&&(e.size*=t);for(let n of s.children??[])rr(n,t)}var Po=class s extends ${static def={name:["grace"],description:"\u501A\u97F3",details:"~~~jpfun\n@grace(1, {3 2}, side=pre)\n~~~\n**\u7B80\u5199**\uFF1A\u7BAD\u5934\u59CB\u7EC8\u6307\u5411\u5BBF\u4E3B\n- `2>1`\uFF1A`2` \u662F `1` \u7684\u524D\u501A\u97F3\uFF0C\u4F4D\u4E8E\u5DE6\u4E0A\u65B9\n- `1<2`\uFF1A`2` \u662F `1` \u7684\u540E\u501A\u97F3\uFF0C\u4F4D\u4E8E\u53F3\u4E0A\u65B9\n- `{3 2}>1`\uFF1A\u4E00\u7EC4\u524D\u501A\u97F3\uFF0C\u7B49\u4EF7\u4E8E\u4E0A\u4F8B\n- `1>2>3`\uFF1A\u5141\u8BB8\u5D4C\u5957\uFF0C`1` \u4FEE\u9970 `2`\uFF0C`2` \u4FEE\u9970 `3`\n\n\u501A\u97F3\u9ED8\u8BA4\u5E26\u4E00\u6761\u51CF\u65F6\u7EBF\uFF0C\u6309\u516B\u5206\u97F3\u7B26\u4E66\u5199\uFF1B\u518D\u52A0 `/` \u53D8\u4E3A\u5341\u516D\u5206\u97F3\u7B26\n\n\u501A\u97F3\u5185\u5BB9\u53EF\u4EE5\u662F\u6362\u884C\u4EE5\u5916\u7684\u4EFB\u610F\u7ED3\u6784\uFF0C\u4F8B\u5982 `{1 & 3}>2` \u7684\u4E24\u4E2A\u58F0\u90E8\u540C\u65F6\u594F\u51FA",allowExtraArgs:!1,args:[{name:"host",description:"\u88AB\u501A\u97F3\u4FEE\u9970\u7684\u5BBF\u4E3B\u5185\u5BB9",type:"content",default:null},{name:"grace",description:"\u501A\u97F3\u5185\u5BB9\uFF0C\u591A\u4E2A\u97F3\u7B26\u53EF\u7528\u5927\u62EC\u53F7\u7EC4\u5408\uFF0C\u4E5F\u53EF\u4EE5\u542B\u591A\u4E2A\u58F0\u90E8",type:"content",default:null},{name:"side",description:"`pre` \u4E3A\u524D\u501A\u97F3\uFF0C`post` \u4E3A\u540E\u501A\u97F3",type:"string",default:"pre"}]};labelable(){return $.findLabelable(this.host)}static deSugarAtom(t,e,n){let o=t[e];switch(o){case">":o="pre";break;case"<":o="post";break;default:return null}return{next:e+1,node:{kind:"sugar",data:{class:s,side:o},span:{start:e,end:e+1}}}}static deSugarRelation(t,e,n){let o=e[n++];if(o.kind!=="sugar"||o.data?.class!==s)return null;let i=o.data.side,r=t.nodes.length-1;for(;r>=0&&t.nodes[r]instanceof xt;)r--;if(r<0)throw new k("E_GRACE_NO_TARGET","@grace\u8BED\u6CD5\u7CD6\u9519\u8BEF: \u5DE6\u8FB9\u6CA1\u6709\u627E\u5230\u76EE\u6807",o.span);let a=t.nodes[r],c=r;if(a instanceof Ht){let p=a.target;for(;p&&!t.nodes.includes(p);)p=p.parent;for(let f=r-1;f>=0;f--)if(t.nodes[f]===p){a=new dt({start:p.sourceSpan.start,end:a.sourceSpan.end},t.nodes.slice(f,r+1),null),c=f;break}}let l=t.nodes;t.nodes=[],t.makeNodes(e,n);for(let p=0;p<t.nodes.length;p++){let f=t.nodes[p];if(f instanceof xt)continue;let u=i==="pre"?s.attachPre(a,f,o.span,t):s.create(t,o.span,"post",a,f);for(l.length=c,l.push(u);++p<t.nodes.length;)l.push(t.nodes[p]);return t.nodes=l,e.length}throw new k("E_GRACE_NO_TARGET","@grace\u8BED\u6CD5\u7CD6\u9519\u8BEF: \u53F3\u8FB9\u6CA1\u6709\u627E\u5230\u76EE\u6807",o.span)}host;grace;side="pre";size;static attachPre(t,e,n,o){if(e instanceof s&&e.side==="pre"){let i=e,r=1;for(;i.grace instanceof s&&i.grace.side==="pre";)i=i.grace,r++;let a=new Map;a.set(0,i.grace),a.set(1,t);let c=Re**r,l=new s(n,a,o,null,Re*c);return l.size*=c,i.setGrace(l,1),e}return s.create(o,n,"pre",e,t)}static create(t,e,n,o,i){let r=new Map;return r.set(0,o),r.set(1,i),r.set("side",n),new s(e,r,t)}get children(){let t=[];return this.host&&t.push(this.host),this.grace&&t.push(this.grace),t}constructor(t,e,n,o=null,i=Re){if(super(t,o),this.size=n.variables.fontsize,[this.host,this.grace,this.side]=this.getArgValue(e,n),this.side!=="pre"&&this.side!=="post")throw new k("E_GRACE_INVALID_SIDE","@grace \u7684 side \u53C2\u6570\u5FC5\u987B\u662F 'pre' \u6216 'post'",t);this.adopt(this.host),this.setGrace(this.grace,i)}setGrace(t,e=Re){rr(t,e),this.grace=t,this.adopt(t)}adopt(t){t.parent=this,this.sourceSpan.start=Math.min(this.sourceSpan.start,t.sourceSpan.start),this.sourceSpan.end=Math.max(this.sourceSpan.end,t.sourceSpan.end)}loweringEnter(t,e){let n=this.host,o=this.grace;if(!n||!o)throw new k("E_GRACE_MISSING_ARGS","@grace \u9700\u8981\u540C\u65F6\u7ED9\u51FA\u5BBF\u4E3B\u548C\u501A\u97F3",this.sourceSpan);let i=new pe(e),r=[],a=[],c=[],l=(h,d)=>t.trackedEvents(h,new F,d);t.isolateFromLoweringGroups(()=>{this.side==="post"&&(r=l(n,e).flat()),t.beginLoweringGroup(this,{onAttachment(h){c.push(h)}}),a=l(o,i),t.endLoweringGroup(this),this.side==="pre"&&(r=l(n,e).flat())});let[p]=r;if(r.length!==1||!X(p))throw new k("E_GRACE_INVALID_HOST","@grace \u7684\u5BBF\u4E3B\u5FC5\u987B\u6070\u597D\u4EA7\u751F\u4E00\u4E2A\u53EF\u89C1 Temporal",n.sourceSpan);let f=a.flat();if(!f.some(X)||f.some(h=>(h.addon?.breakBefore??0)>0))throw new k("E_GRACE_INVALID_CONTENT","@grace \u7684\u501A\u97F3\u81F3\u5C11\u4EA7\u751F\u4E00\u4E2A\u53EF\u89C1\u5BF9\u8C61\uFF0C\u4E14\u4E0D\u80FD\u6362\u884C",o.sourceSpan);let u=new Do(this,p,a,i,c,this.side);for(let h of u.graceRuns)h.length<2||t.addAttachment(Ie([...h],!1,o.sourceSpan));return[u]}toString(t){let e=this.host?.toString(t)??"",n=this.grace?.toString(t)??"";return`@grace(${e}, ${n}, side=${this.side})`}},ar=Po,Rc=[{op:"M",x:0,y:0},{op:"C",cx1:-.01,cy1:.26,cx2:.14,cy2:.42,x:.29,y:.36}],Oc=.07,$c=.18,ir=new F(3,4),Do=class extends tt{host;graceColumns;graces;graceRuns;side;root;attachments;events;starts;hostOffset={x:0,y:0};graceOffsets=[];hookOrigin=null;constructor(t,e,n,o,i,r){super(),this.ast=t,this.host=e,this.root=o,this.attachments=i,this.side=r,this.T.copyFrom(e.T),this.mergeKey=e.mergeKey,this.initLayoutBox(),e.addon&&(this.addon={...e.addon}),e.addon=void 0,e.foldedInto=this;let a=[],c=[],l=[];for(let u of n){let h=u[0].t.clone().divPow2(),d=[];for(let y of u)y.foldedInto=this,c.push(y),l.push(h),X(y)&&d.push(y);d.length>0&&a.push(d)}this.graceColumns=a,this.graces=a.flat(),this.events=c,this.starts=l;let p=new Map,f=[];for(let u of this.graces){if(u.T.isZero()){p.delete(u.track);continue}let h=p.get(u.track);h||(p.set(u.track,h=[]),f.push(h)),h.push(u);let d=u.addon={...u.addon};d[fe]=(Number(d[fe])||0)+1,u.T.divPow2()}this.graceRuns=f}onTimeState(t){this.host.T.copyFrom(this.T);let e;for(let n of this.side==="pre"?[...this.events,this.host]:[this.host,...this.events]){n.t.copyFrom(this.t),n.layoutLine=this.layoutLine;let o=n.onTimeState?.(t);n===this.host&&(this.T.copyFrom(n.T),e=o)}return e}prepareHorizontal(t){this.host.prepareHorizontal?.(t)}emitPlayback(t){let e=new F,n=new F;this.events.forEach((p,f)=>{n.copyFrom(this.starts[f]).add(p.T),n.compare(e)>0&&e.copyFrom(n)});let o=e.compare(ir)>0?ir:e,i=t.end.clone().sub(t.start),r=i.clone().mul(o),a=i.sub(r),c=e.isZero()?new F:r.clone().div(e),l=this.side==="pre"?t.start.clone():t.start.clone().add(a);this.side==="post"&&t.play(this.host,t.start.clone(),a),this.events.forEach((p,f)=>{t.play(p,this.starts[f].clone().mul(c).add(l),p.T.clone().mul(c))}),this.side==="pre"&&t.play(this.host,l.add(r),a)}prepareLayout(t){le(this,this.host);let e=t.layoutSubdomain(this,this.graceColumns,this.root,this.attachments),n=ke([this.host],t);this.springConfig={...this.host.springConfig,...this.springConfig};let o=this.ast.size*Re,i=o*.2,r=o*$c,c=(this.host.ports[sr]?.y??0)-r-e.height,l=wt(this.host),p=Math.max(0,-c,-l.y),f=this.side==="pre"?0:n+i;this.hostOffset={x:this.host.box.x+(this.side==="pre"?e.width+i:0),y:p},this.graceOffsets=e.positions.map(d=>({x:f+d.x,y:c+p+d.y})),this.box.w=n+i+e.width,this.box.h=p+l.y+l.h,this.box.anchor=this.hostOffset.x+this.host.box.anchor,this.box.visualAxis=p+this.host.box.visualAxis;for(let d in this.host.ports){let y=this.host.ports[d];this.ports[d]={...y,x:this.hostOffset.x+y.x,y:this.hostOffset.y+y.y}}this.ports[sr]??={x:this.box.anchor,y:this.hostOffset.y};let u=this.graces.filter(d=>!d.T.isZero()),h=this.side==="pre"?u.at(-1):u[0];this.hookOrigin=h?{x:this.graceOffsets[this.graces.indexOf(h)].x+h.box.anchor,y:Math.max(...this.graces.map((d,y)=>this.graceOffsets[y].y+d.box.h))}:null}onPlaced(){this.host.box.x=this.box.x+this.hostOffset.x,this.host.box.y=this.box.y+this.hostOffset.y,this.host.onPlaced?.(),this.graces.forEach((t,e)=>{t.box.x=this.box.x+this.graceOffsets[e].x,t.box.y=this.box.y+this.graceOffsets[e].y,t.onPlaced?.()})}paint(t){for(let i of[this.host,...this.graces]){i.paint(t);for(let r of i.decorations)r.paint?.(t)}if(!this.hookOrigin)return;let e=this.ast.size*Re,n=this.hookOrigin,o=this.side==="pre"?1:-1;t.drawPath(Rc,{stroke:"#000",strokeWidth:Math.max(.8,e*Oc)},{x:this.box.x+n.x,y:this.box.y+n.y,scaleX:e*o,scaleY:e})}};function cr(s){let{resolvedMidi:t}=s;return typeof t=="number"?t:void 0}var Bo=class extends ${static def={name:["gliss"],description:"\u6ED1\u97F3\u8FDE\u7EBF",details:`~~~jpfun
|
|
24
|
+
\u7AEF\u70B9\u4E5F\u53EF\u6807\u5728\u589E\u65F6\u7EBF\u4E0A\u3002\u7EC8\u70B9\u6CA1\u6709\u529B\u5EA6\u65F6\uFF0C\u53D6\u540C\u8F68\u3001\u4E0D\u665A\u4E8E\u7EC8\u70B9\u7684\u6700\u540E\u4E00\u4E2A\u539F\u59CB\u529B\u5EA6\u4F5C\u4E3A\u4FDD\u6301\u57FA\u51C6\uFF1B\u627E\u4E0D\u5230\u65F6\u7ED9\u51FA\u8B66\u544A\u5E76\u4EC5\u7ED8\u5236\u3002\u589E\u65F6\u7EBF\u5EF6\u7EED\u7684\u97F3\u7B26\u4FDD\u6301\u8D77\u97F3\u65F6\u7684\u529B\u5EA6\u3002`,allowExtraArgs:!1,args:[{name:"from",description:"\u6E10\u53D8\u8D77\u70B9\u7684\u6807\u7B7E",type:"label",default:null},{name:"to",description:"\u6E10\u53D8\u7EC8\u70B9\u7684\u6807\u7B7E",type:"label",default:null},{name:"dv",description:"\u529B\u5EA6\u53D8\u5316\u91CF\uFF0C\u6B63\u6570\u6E10\u5F3A\uFF0C\u8D1F\u6570\u6E10\u5F31",type:"number",default:null}]};static loweringFinalize(t){let e=t.attachments.filter(o=>o instanceof an);if(e.length===0)return;let n=new Map(e.map(o=>[o.track,[]]));for(let o of t.astToTemporal.values())for(let s of o){let i=s.playbackState?.velocity;if(i===void 0)continue;let a=s.rootHost;n.get(a.track)?.push({node:s,host:a,velocity:i,increment:0})}for(let o of n.values())o.sort((s,i)=>s.host.t.compare(i.host.t)||s.node.order-i.node.order);for(let o of e){let s=n.get(o.track),i=Vn(s,o.toHost.t),a=Vn(s,o.toHost.t,!0),c=o.end.playbackState?.velocity;for(let m=i;c===void 0&&m<a;m++)s[m].host===o.toHost&&(c=s[m].velocity);if(c??=s[a-1]?.velocity,c===void 0){t.diagnostics.push(new K("W_DYN_NO_VELOCITY","@dyn \u7EC8\u70B9\u53CA\u6B64\u524D\u540C\u8F68\u6CA1\u6709\u53EF\u7528\u7684\u529B\u5EA6\u57FA\u51C6\uFF0C\u4EC5\u7ED8\u5236\u6E10\u53D8\u7EBF",o.sourceSpan));continue}let l=s.length;for(let m=a;m<s.length;m++)if(s[m].velocity!==c){l=Vn(s,s[m].host.t);break}let u=Vn(s,o.fromHost.t),p=o.toHost.t.clone().sub(o.fromHost.t);for(let m=u;m<l;m++){let d=m>=i?1:s[m].host.t.clone().sub(o.fromHost.t).div(p).toNumber();s[m].increment+=o.dv*d}}for(let o of n.values())for(let s of o){if(s.increment===0)continue;let i=Math.max(1,Math.min(127,s.velocity+s.increment));s.node.playbackState={...s.node.playbackState,velocity:i}}}from;to;dv;size;loweringEnter(t){let e=t.getTemporalNodes(this.from).at(0),n=t.getTemporalNodes(this.to).at(-1);if(!e||!n)return t.diagnostics.push(Y.warning.UnresolvedEndpoint("dyn",this.sourceSpan)),[];let o=e.rootHost,s=n.rootHost;if(!W(o)||!W(s))return t.diagnostics.push(Y.warning.UnresolvedEndpoint("dyn",this.sourceSpan)),[];if(o.track!==s.track)throw new k("E_DYN_CROSS_TRACK","@dyn \u7684\u4E24\u4E2A\u7AEF\u70B9\u5FC5\u987B\u4F4D\u4E8E\u540C\u4E00\u97F3\u8F68",this.sourceSpan);if(o.t.equals(s.t))throw new k("E_DYN_ZERO_SPAN","@dyn \u7684\u4E24\u4E2A\u7AEF\u70B9\u5FC5\u987B\u4F4D\u4E8E\u4E0D\u540C\u65F6\u95F4",this.sourceSpan);return o.t.compare(s.t)<0?t.addAttachment(new an(this,n,o,s)):t.addAttachment(new an(this,e,s,o)),t.deferFinalize(r.loweringFinalize),[]}constructor(t,e,n,o=null){super(t,o);let[s,i,a]=this.getArgValue(e,n),c=a;if(!Number.isFinite(c)||c===0)throw new k("E_DYN_INVALID_DELTA","@dyn \u7684 dv \u5FC5\u987B\u662F\u975E\u96F6\u6709\u9650\u6570",t);c=Math.max(-127,Math.min(127,c)),c!==a&&n.diagnostics.push(new K("W_DYN_DELTA_CLAMPED","@dyn \u7684 dv \u5FC5\u987B\u5728 -127 \u5230 127 \u4E4B\u95F4\uFF0C\u5DF2\u88AB\u9650\u5236\u4E3A {dv}",t,{dv:c})),this.from=s,this.to=i,this.dv=c,this.size=n.variables.fontsize}toString(t){let e=n=>n.label??n.toString(t);return`@dyn(${e(this.from)}, ${e(this.to)}, ${this.dv})`}},Fi=er,an=class{constructor(t,e,n,o){this.ast=t;this.end=e;this.fromHost=n;this.toHost=o}ast;end;fromHost;toHost;layer="foreground";get sourceSpan(){return this.ast.sourceSpan}get endPoints(){return[this.fromHost,this.toHost]}get dv(){return this.ast.dv}get track(){return this.fromHost.track}createGeometry(t){let e=this.fromHost.layoutLine,n=this.toHost.layoutLine,o=[this.fromHost,this.toHost],s=[],i=this.ast.size;for(let f=e;f<=n;f++){let x=t.getRangeColumns(f,o,this.track);if(x.some(y=>y.length>0)){for(let y of x)for(let h of y)i=Math.max(i,h.ast.size);s.push({line:f,startX:f===e?this.fromHost.box.x:Ut(t,f,this.track),endX:f===n?this.toHost.box.x+this.toHost.box.w:Kt(t,f)})}}for(let f of s)f.line>e&&(f.startX-=i/4);let a=Math.max(.75,i*.035),c=s.filter(f=>f.startX!==f.endX),l=c.reduce((f,x)=>f+Math.abs(x.endX-x.startX),0);if(l===0)return{regions:[],paint(){}};let u=i*.4,p=a/2,m=0,d=c.map(f=>{let x=Math.abs(f.endX-f.startX),y=m/l,h=(m+x)/l;m+=x;let g=t.getRangeExtents(f.line,o,this.track),b=t.getVisualAxis(f.line,this.track),T=g?b+g.top:b;return{line:f.line,startX:f.startX,endX:f.endX,lineY:T-i*.62,startOpen:u*(this.dv>0?y:1-y),endOpen:u*(this.dv>0?h:1-h)}});return{regions:d.map(f=>({x:Math.min(f.startX,f.endX)-p,y:f.lineY-Math.max(f.startOpen,f.endOpen)/2-p,w:Math.abs(f.endX-f.startX)+a,h:Math.max(f.startOpen,f.endOpen)+a,line:f.line,track:this.track})),paint(f){let x={stroke:"#000",strokeWidth:a};for(let y of d)f.drawLine(y.startX,y.lineY-y.startOpen/2,y.endX,y.lineY-y.endOpen/2,x),f.drawLine(y.startX,y.lineY+y.startOpen/2,y.endX,y.lineY+y.endOpen/2,x)}}}};var ge=class r{constructor(t=null){this.parent=t}parent;groups=[];group(t,e){let n=this.groups.find(o=>o.laneKey===t.laneKey);for(n||(n={laneKey:t.laneKey,members:[],measure:t.measure,place:t.place},this.groups.push(n));n.members.length<e;)n.members.push(new r(this));return n}};var xe=.7,Oi="shoulder";function Ii(r,t){if(t===1)return;let e=r;typeof e.size=="number"&&(e.size*=t),typeof e.gap=="number"&&(e.gap*=t),typeof e.minGap=="number"&&(e.minGap*=t),e.aboveGaps?.forEach((n,o,s)=>s[o]*=t),e.belowGaps?.forEach((n,o,s)=>s[o]*=t);for(let n of r.children??[])Ii(n,t)}var nr=class r extends B{static def={name:["grace"],description:"\u501A\u97F3",details:"~~~jpfun\n@grace(1, {3 2}, side=pre)\n~~~\n**\u7B80\u5199**\uFF1A\u7BAD\u5934\u59CB\u7EC8\u6307\u5411\u5BBF\u4E3B\n- `2>1`\uFF1A`2` \u662F `1` \u7684\u524D\u501A\u97F3\uFF0C\u4F4D\u4E8E\u5DE6\u4E0A\u65B9\n- `1<2`\uFF1A`2` \u662F `1` \u7684\u540E\u501A\u97F3\uFF0C\u4F4D\u4E8E\u53F3\u4E0A\u65B9\n- `{3 2}>1`\uFF1A\u4E00\u7EC4\u524D\u501A\u97F3\uFF0C\u7B49\u4EF7\u4E8E\u4E0A\u4F8B\n- `1>2>3`\uFF1A\u5141\u8BB8\u5D4C\u5957\uFF0C`1` \u4FEE\u9970 `2`\uFF0C`2` \u4FEE\u9970 `3`\n\n\u501A\u97F3\u9ED8\u8BA4\u5E26\u4E00\u6761\u51CF\u65F6\u7EBF\uFF0C\u6309\u516B\u5206\u97F3\u7B26\u4E66\u5199\uFF1B\u518D\u52A0 `/` \u53D8\u4E3A\u5341\u516D\u5206\u97F3\u7B26\n\n\u501A\u97F3\u5185\u5BB9\u53EF\u4EE5\u662F\u6362\u884C\u4EE5\u5916\u7684\u4EFB\u610F\u7ED3\u6784\uFF0C\u4F8B\u5982 `{1 & 3}>2` \u7684\u4E24\u4E2A\u58F0\u90E8\u540C\u65F6\u594F\u51FA",allowExtraArgs:!1,args:[{name:"host",description:"\u88AB\u501A\u97F3\u4FEE\u9970\u7684\u5BBF\u4E3B\u5185\u5BB9",type:"content",default:null},{name:"grace",description:"\u501A\u97F3\u5185\u5BB9\uFF0C\u591A\u4E2A\u97F3\u7B26\u53EF\u7528\u5927\u62EC\u53F7\u7EC4\u5408\uFF0C\u4E5F\u53EF\u4EE5\u542B\u591A\u4E2A\u58F0\u90E8",type:"content",default:null},{name:"side",description:"`pre` \u4E3A\u524D\u501A\u97F3\uFF0C`post` \u4E3A\u540E\u501A\u97F3",type:"string",default:"pre"}]};labelable(){return B.findLabelable(this.host)}static deSugarAtom(t,e,n){let o=t[e];switch(o){case">":o="pre";break;case"<":o="post";break;default:return null}return{next:e+1,node:{kind:"sugar",data:{class:r,side:o},span:{start:e,end:e+1}}}}static deSugarRelation(t,e,n){let o=e[n++];if(o.kind!=="sugar"||o.data?.class!==r)return null;let s=o.data.side,i=t.takeLeftOperand();if(!i)throw new k("E_GRACE_NO_TARGET","@grace\u8BED\u6CD5\u7CD6\u9519\u8BEF: \u5DE6\u8FB9\u6CA1\u6709\u627E\u5230\u76EE\u6807",o.span);let a=t.consumeRightOperand(e,n,c=>s==="pre"?r.attachPre(i,c,o.span,t):r.create(t,o.span,"post",i,c));if(a!==null)return a;throw new k("E_GRACE_NO_TARGET","@grace\u8BED\u6CD5\u7CD6\u9519\u8BEF: \u53F3\u8FB9\u6CA1\u6709\u627E\u5230\u76EE\u6807",o.span)}host;grace;side="pre";size;static attachPre(t,e,n,o){if(e instanceof r&&e.side==="pre"){let s=e,i=1;for(;s.grace instanceof r&&s.grace.side==="pre";)s=s.grace,i++;let a=xe**i,c=r.create(o,n,"pre",s.grace,t,xe*a);return c.size*=a,s.setGrace(c,1),e}return r.create(o,n,"pre",e,t)}static create(t,e,n,o,s,i=xe){let a=new Map;return a.set(0,o),a.set(1,s),a.set("side",n),new r(e,a,t,null,i)}get children(){return[this.host,this.grace]}timeFlowModel(){return null}constructor(t,e,n,o=null,s=xe){if(super(t,o),this.size=n.variables.fontsize,[this.host,this.grace,this.side]=this.getArgValue(e,n),this.side!=="pre"&&this.side!=="post")throw new k("E_GRACE_INVALID_SIDE","@grace \u7684 side \u53C2\u6570\u5FC5\u987B\u662F 'pre' \u6216 'post'",t);this.adopt(this.host),this.setGrace(this.grace,s)}setGrace(t,e=xe){Ii(t,e),this.grace=t,this.adopt(t)}adopt(t){t.parent=this,this.sourceSpan.start=Math.min(this.sourceSpan.start,t.sourceSpan.start),this.sourceSpan.end=Math.max(this.sourceSpan.end,t.sourceSpan.end)}loweringEnter(t,e){let{host:n,grace:o}=this,s=new ge(e),i=[],a=[],c=[],l=(m,d)=>t.trackedEvents(m,new G,d);t.isolateFromLoweringGroups(()=>{this.side==="post"&&(i=l(n,e).flat()),t.beginLoweringGroup(this,{onAttachment(m){c.push(m)}}),a=l(o,s),t.endLoweringGroup(this),this.side==="pre"&&(i=l(n,e).flat())});let[u]=i;if(i.length!==1||!W(u))throw new k("E_GRACE_INVALID_HOST","@grace \u7684\u5BBF\u4E3B\u5FC5\u987B\u6070\u597D\u4EA7\u751F\u4E00\u4E2A\u53EF\u89C1 Temporal",n.sourceSpan);let p=a.flat();if(!p.some(W)||p.some(m=>(m.addon?.breakBefore??0)>0))throw new k("E_GRACE_INVALID_CONTENT","@grace \u7684\u501A\u97F3\u81F3\u5C11\u4EA7\u751F\u4E00\u4E2A\u53EF\u89C1\u5BF9\u8C61\uFF0C\u4E14\u4E0D\u80FD\u6362\u884C",o.sourceSpan);return[new or(this,u,a,s,c,t)]}toString(t){return`@grace(${this.host.toString(t)}, ${this.grace.toString(t)}, side=${this.side})`}},Bi=nr,Tl=[{op:"M",x:0,y:0},{op:"C",cx1:-.01,cy1:.26,cx2:.14,cy2:.42,x:.29,y:.36}],Ll=.07,Al=.18,or=class extends tt{host;graceColumns;graces;root;attachments;events;starts;hostOffset={x:0,y:0};graceOffsets=[];hookOrigin=null;constructor(t,e,n,o,s,i){super(),this.ast=t,this.host=e,this.root=o,this.attachments=s,this.T.copyFrom(e.T),this.mergeKey=e.mergeKey,this.initLayoutBox(),e.addon&&(this.addon={...e.addon}),e.addon=void 0,e.foldedInto=this;let a=[],c=[],l=[];for(let m of n){let d=m[0].t.clone().divPow2(),f=[];for(let x of m)x.foldedInto=this,c.push(x),l.push(d),W(x)&&f.push(x);f.length>0&&a.push(f)}this.graceColumns=a,this.graces=a.flat(),this.events=c,this.starts=l;let u=new Map,p=[];for(let m of this.graces){if(m.T.isZero()){u.delete(m.track);continue}let d=u.get(m.track);d||(u.set(m.track,d=[]),p.push(d)),d.push(m);let f=m.addon={...m.addon};f[rn]=(Number(f[rn])||0)+1,m.T.divPow2()}for(let m of p)m.length>=2&&i.addAttachment(Be(m,!1,t.grace.sourceSpan))}onTimeState(t){this.host.T.copyFrom(this.T);let e;for(let n of this.ast.side==="pre"?[...this.events,this.host]:[this.host,...this.events]){n.t.copyFrom(this.t),n.layoutLine=this.layoutLine;let o=n.onTimeState?.(t);n===this.host&&(this.T.copyFrom(n.T),e=o)}return e}prepareHorizontal(t){this.host.prepareHorizontal?.(t)}emitPlayback(t){let e=new G,n=new G;this.events.forEach((p,m)=>{n.copyFrom(this.starts[m]).add(p.T),n.compare(e)>0&&e.copyFrom(n)});let o=t.end.clone().sub(t.start),s=new G(1,4),i=e.clone().mul(s),a=o.clone().divPow2();i.compare(a)>0&&(s.copyFrom(a).div(e),i.copyFrom(a));let c=o.sub(i),l=this.ast.side==="pre",u=l?t.start.clone():t.start.clone().add(c);l||t.play(this.host,t.start.clone(),c),this.events.forEach((p,m)=>{t.play(p,this.starts[m].clone().mul(s).add(u),p.T.clone().mul(s))}),l&&t.play(this.host,u.add(i),c)}prepareLayout(t){ye(this,this.host);let e=t.layoutSubdomain(this,this.graceColumns,this.root,this.attachments),n=Ie([this.host],t);this.springConfig={...this.host.springConfig};let o=this.ast.size*xe,s=o*.2,i=o*Al,a=this.ast.side==="pre",l=(this.host.ports[Oi]?.y??0)-i-e.height,u=St(this.host),p=Math.max(0,-l,-u.y),m=a?0:n+s;this.hostOffset={x:this.host.box.x+(a?e.width+s:0),y:p},this.graceOffsets=e.positions.map(x=>({x:m+x.x,y:l+p+x.y})),this.box.w=n+s+e.width,this.box.h=p+u.y+u.h,this.box.anchor=this.hostOffset.x+this.host.box.anchor,this.box.visualAxis=p+this.host.box.visualAxis;for(let x in this.host.ports){let y=this.host.ports[x];this.ports[x]={...y,x:this.hostOffset.x+y.x,y:this.hostOffset.y+y.y}}this.ports[Oi]??={x:this.box.anchor,y:this.hostOffset.y};let d=this.graces.filter(x=>!x.T.isZero()),f=a?d.at(-1):d[0];this.hookOrigin=f?{x:this.graceOffsets[this.graces.indexOf(f)].x+f.box.anchor,y:Math.max(...this.graces.map((x,y)=>this.graceOffsets[y].y+x.box.h))}:null}onPlaced(){this.host.box.x=this.box.x+this.hostOffset.x,this.host.box.y=this.box.y+this.hostOffset.y,this.host.onPlaced?.(),this.graces.forEach((t,e)=>{t.box.x=this.box.x+this.graceOffsets[e].x,t.box.y=this.box.y+this.graceOffsets[e].y,t.onPlaced?.()})}paint(t){for(let s of[this.host,...this.graces]){s.paint(t);for(let i of s.decorations)i.paint?.(t)}if(!this.hookOrigin)return;let e=this.ast.size*xe,n=this.hookOrigin,o=this.ast.side==="pre"?1:-1;t.drawPath(Tl,{stroke:"#000",strokeWidth:Math.max(.8,e*Ll)},{x:this.box.x+n.x,y:this.box.y+n.y,scaleX:e*o,scaleY:e})}};function Di(r,t,e){let n=o=>typeof o?.resolvedMidi=="number"?o:void 0;if("resolvedMidi"in t)return n(t);for(let o=r.findIndex(s=>s.includes(e))-1;o>=0;o--){let s=r[o].find(i=>i.track===e.track&&"resolvedMidi"in i);if(s)return n(s)}}var rr=class extends B{static def={name:["gliss"],description:"\u6ED1\u97F3\u8FDE\u7EBF",details:`~~~jpfun
|
|
21
25
|
1 -@a 5@b @gliss(a, b)
|
|
22
26
|
~~~
|
|
23
|
-
\u82E5\u9644\u5C5E\u5BF9\u8C61\u65E0\u97F3\u9AD8\uFF0C\u5C06\u4F7F\u7528\u524D\u9762\u6700\u8FD1\u7684\
|
|
27
|
+
\u82E5\u9644\u5C5E\u5BF9\u8C61\u65E0\u97F3\u9AD8\uFF0C\u5C06\u4F7F\u7528\u524D\u9762\u6700\u8FD1\u7684\u540C\u8F68\u6709\u97F3\u9AD8\u5BF9\u8C61\u7684\u97F3\u9AD8\uFF1B\u64AD\u653E\u65F6\u4ECE\u8D77\u70B9\u97F3\u6BB5\u6309\u534A\u97F3\u9636\u79BB\u6563\u8FC7\u6E21\u81F3\u7EC8\u70B9\u97F3\u9AD8\u3002`,allowExtraArgs:!1,args:[{type:"label",default:null,description:"\u4E00\u4E2A\u7AEF\u70B9\u7684\u6807\u7B7E\uFF0C\u5148\u540E\u6309\u8C31\u9762\u65F6\u95F4\u786E\u5B9A"},{type:"label",default:null,description:"\u53E6\u4E00\u4E2A\u7AEF\u70B9\u7684\u6807\u7B7E"}]};from;to;constructor(t,e,n,o=null){super(t,o),[this.from,this.to]=this.getArgValue(e,n)}loweringEnter(t){let e=t.getTemporalNodes(this.from).at(-1),n=t.getTemporalNodes(this.to).at(-1);if(!e||!n||!W(e)||!W(n))throw new k("E_GLISS_ENDPOINT","@gliss \u7684\u6807\u7B7E\u5FC5\u987B\u6307\u5411\u5DF2\u751F\u6210\u4E14\u5177\u6709\u6392\u7248\u76D2\u5B50\u7684\u5BF9\u8C61",this.sourceSpan);let o=new sr(e,n,this.sourceSpan);return t.addAttachment(o),t.deferFinalize(s=>o.finalize(s),1),[]}toString(t){let e=this.from instanceof B?this.from.label:void 0,n=this.to instanceof B?this.to.label:void 0;return e&&n?`@gliss(${e}, ${n})`:t.slice(this.sourceSpan.start,this.sourceSpan.end)}},Vi=rr;function Hn(r,t){for(;r.foldedInto&&W(r.foldedInto)&&(!t||t.columnOf(r)<0);)r=r.foldedInto;return r}var sr=class{constructor(t,e,n){this.sourceSpan=n;this.endPoints=[t,e]}sourceSpan;layer="foreground";endPoints;direction;finalize({columns:t,diagnostics:e}){let[n,o]=this.endPoints,s=Hn(n),i=Hn(o);if(s.t.equals(i.t))throw new k("E_GLISS_ORDER","@gliss \u4E24\u4E2A\u7AEF\u70B9\u4E0D\u80FD\u4F4D\u4E8E\u540C\u4E00\u65F6\u523B",this.sourceSpan);s.t.compare(i.t)>0&&(this.endPoints=[o,n],[s,i]=[i,s]);let[a,c]=this.endPoints,l=Di(t,a,s),u=Di(t,c,i);if(!l||!u){e.push(new K("W_GLISS_NO_PITCH","@gliss \u7AEF\u70B9\u6CA1\u6709\u53EF\u7528\u97F3\u9AD8",this.sourceSpan));return}this.direction=Math.sign(u.resolvedMidi-l.resolvedMidi);let p=a.emitPlayback,m=u.resolvedMidi+(u.playbackState?.pitchShift??0);a.emitPlayback=d=>{p?.call(a,d);let{start:f,end:x}=d;d.defer(y=>{for(let h=y.notes.length-1;h>=0;h--){let g=y.notes[h];if(g.track===d.track){if(!g.end.equals(x))return;y.transform(g,(b,T)=>{let L=T.at(-1),w=f.compare(L.start)>0?f:L.start,A=Math.abs(m-L.midi);if(L.end.compare(w)<=0||A<=1)return;let C=Math.sign(m-L.midi),_=L.end.clone().sub(w).div(A);return[...T.slice(0,-1),...Array.from({length:A},(E,v)=>({...L,start:v===0?L.start.clone():_.clone().mul(v).add(w),end:_.clone().mul(v+1).add(w),midi:L.midi+v*C}))]});return}}})}}prepareHorizontal(t){let[e,n]=this.endPoints,o=t[e.layoutLine],s=t[n.layoutLine],i=o&&Hn(e,o),a=s&&Hn(n,s),c=i?o.columnOf(i):-1,l=a?s.columnOf(a):-1;if(!o||!s||c<0||l<0||o===s&&l<=c)throw new k("E_GLISS_DOMAIN","@gliss \u7684\u7AEF\u70B9\u5FC5\u987B\u4F4D\u4E8E\u540C\u4E00\u6392\u7248\u57DF\u7684\u4E0D\u540C\u65F6\u95F4\u5217",this.sourceSpan);let u=Math.max(e.ast.size,n.ast.size)*1.4,p=i.box.w-i.box.anchor+u;if(o.registerHorizontalLayoutHook(i,i,({columns:m})=>{for(let d of m[c])d.WR=Math.max(d.WR,p)}),o!==s){let m=a.box.anchor+u;s.registerHorizontalLayoutHook(a,a,({columns:d})=>{for(let f of d[l])f.WL=Math.max(f.WL,m)})}}createGeometry(t){let[e,n]=this.endPoints,o=Math.max(e.ast.size,n.ast.size),s=o*.12,i=e.track===n.track?(this.direction??0)*o*.24:0,a={x:e.box.x+e.box.w+s,y:e.box.y+e.box.visualAxis+i},c={x:n.box.x-s,y:e.track===n.track&&this.direction===void 0&&e.layoutLine===n.layoutLine?a.y:n.box.y+n.box.visualAxis-i},l=[[a,c,e.layoutLine,e.track]];if(e.layoutLine!==n.layoutLine){let d=Math.max(a.x+o,Kt(t,e.layoutLine)),f=Math.min(c.x-o,Ut(t,n.layoutLine,n.track,c.x)),x=d-a.x,y=i*(1-2*x/(x+c.x-f));l[0]=[a,{x:d,y:a.y-i+y},e.layoutLine,e.track],l.push([{x:f,y:c.y+i+y},c,n.layoutLine,n.track])}else if(c.x<=a.x)throw new k("E_GLISS_SPACE","@gliss \u7684\u7AEF\u70B9\u4E4B\u95F4\u6CA1\u6709\u53EF\u7528\u7684\u6C34\u5E73\u7ED8\u5236\u7A7A\u95F4",this.sourceSpan);let u=o*.05,p=[],m=l.map(([d,f,x,y],h)=>{let g=[{op:"M",...d},{op:"L",...f}];if(h===l.length-1){let T=Math.atan2(f.y-d.y,f.x-d.x),L=Math.min(o*.3,Math.hypot(f.x-d.x,f.y-d.y)*.35),w=A=>({x:f.x-L*Math.cos(T+A),y:f.y-L*Math.sin(T+A)});g.push({op:"M",...w(-Math.PI/6)},{op:"L",...f},{op:"L",...w(Math.PI/6)})}p.push(...g);let b=Gt(g);return{x:b.x-u/2,y:b.y-u/2,w:b.w+u,h:b.h+u,line:x,track:y}});return{regions:m,occupancy:e.track===n.track?m:[],paint:d=>{d.drawPath(p,{fill:"none",stroke:"#000",strokeWidth:u})}}}};var ir=class extends B{static def={name:["slide"],description:"\u6ED1\u5165\u6216\u6ED1\u51FA\u8BB0\u53F7",details:`~~~jpfun
|
|
24
28
|
@slide(5, side=pre, direction=up)
|
|
25
29
|
~~~
|
|
26
|
-
\u4EC5\u7ED8\u5236\uFF0C\u4E0D\u6539\u53D8\u65F6\u503C\u548C\u64AD\u653E\u3002pre \u4FEE\u9970\u5185\u5BB9\u9996\u7AEF\uFF0Cpost \u4FEE\u9970\u672B\u7AEF\uFF1Bup/down \u8868\u793A\u968F\u65F6\u95F4\u4E0A\u884C/\u4E0B\u884C\u3002`,allowExtraArgs:!1,args:[{type:"content",default:null,description:"\u88AB\u4FEE\u9970\u7684\u5185\u5BB9"},{name:"side",type:"string",default:"pre",description:"pre \u6ED1\u5165\uFF0Cpost \u6ED1\u51FA"},{name:"direction",type:"string",default:"up",description:"up \u4E0A\u884C\uFF0Cdown \u4E0B\u884C"}]};content;side;direction;get children(){return[this.content]}timeFlowModel(){return{children:this.children,mode:"sequence"}}labelable(){return $.findLabelable(this.content)}constructor(t,e,n,o=null){super(t,o);let[i,r,a]=this.getArgValue(e,n);if(r!=="pre"&&r!=="post")throw new k("E_SLIDE_SIDE","@slide \u7684 side \u5FC5\u987B\u662F pre \u6216 post",t);if(a!=="up"&&a!=="down")throw new k("E_SLIDE_DIRECTION","@slide \u7684 direction \u5FC5\u987B\u662F up \u6216 down",t);this.content=i,this.side=r,this.direction=a,i.parent=this}loweringEnter(t){let e=this.side==="pre",n={onTemporal(o){X(o)&&(!e||!n.host)&&(n.host=o)}};return t.beginLoweringGroup(this,n),[]}loweringExit(t){let{host:e}=t.endLoweringGroup(this);if(!e)throw new k("E_SLIDE_CONTENT","@slide \u7684\u5185\u5BB9\u5FC5\u987B\u5305\u542B\u53EF\u7ED8\u5236\u5BF9\u8C61",this.sourceSpan);let n=new Ho(e,this);t.addAttachment(n);let o=e.prepareHorizontal;return e.prepareHorizontal=i=>{o?.call(e,i),!(i.columnOf(e)<0)&&i.registerHorizontalLayoutHook(e,e,({columns:r,start:a})=>{let c=this.side==="pre",l=c?"WL":"WR",f=(c?e.box.anchor:e.box.w-e.box.anchor)+n.length+e.ast.size*.22;for(let u of r[a])u.box===e.box&&(u[l]=Math.max(u[l],f))})},[]}toString(t){return`@slide(${this.content.toString(t)}, side=${this.side}, direction=${this.direction})`}},fr=zo,Ho=class{host;owner;layer="foreground";endPoints;get sourceSpan(){return this.owner.sourceSpan}constructor(t,e){this.host=t,this.owner=e,this.endPoints=[t]}get length(){let{host:t}=this;return t.box.visualAxis-(t.ports.shoulder?.y??0)+t.ast.size*.1}createGeometry(){let{host:t,owner:e}=this,n=t.ast.size,o=e.side==="pre",i=this.length,r=e.direction==="up",a=t.box.y+t.box.visualAxis,c=o?t.box.x-n*.12-i:t.box.x+t.box.w+n*.12,l={x:c,y:r?a:a-i},p={x:c+i,y:r?a-i:a},f=r?-Math.PI/4:Math.PI/4,u=g=>({x:p.x-n*.25*Math.cos(f+g),y:p.y-n*.25*Math.sin(f+g)}),h=[{op:"M",...l},{op:"L",...p},{op:"M",...u(-Math.PI/6)},{op:"L",...p},{op:"L",...u(Math.PI/6)}],d=n*.05,y=Bt(h);return{regions:[{x:y.x-d/2,y:y.y-d/2,w:y.w+d,h:y.h+d,line:t.layoutLine,track:t.track}],paint(g){g.drawPath(h,{fill:"none",stroke:"#000",strokeWidth:d})}}}};var Oe="sans-serif",Go="'Cascadia Mono', Consolas, 'Liberation Mono', 'Noto Sans Mono', monospace";function Cn(s){return`${s.fontStyle?`${s.fontStyle} `:""}${s.fontWeight??"normal"} ${s.fontSize}px ${s.fontFamily??Oe}`}var Ln=class{measureText(t,e){let n=e.fontSize,o=e.fontFamily?.toLowerCase().includes("mono")??!1,i=0;for(let r of t)i+=r.charCodeAt(0)>127?1:o?.62:.58;return{w:Math.max(i*n,n*.25),h:n,baseline:n*.8}}},Vo=new Ln,Wo=class{context;widths=new Map;constructor(t){this.context=t}clearCache(){this.widths.clear()}measureText(t,e){let n=Cn(e),o=`${n}\0${t}`,i=this.widths.get(o);return i===void 0&&(this.context.font=n,i=this.context.measureText(t).width,this.widths.set(o,i)),{w:Math.max(i,e.fontSize*.25),h:e.fontSize,baseline:e.fontSize*.8}}};var Pc=/[A-Za-z0-9_./-]/;function tn(s,t,e){let n=t+1;for(;n<e&&Pc.test(s[n]);)n++;let o=s.slice(t+1,n);if(!o||n>=e||s[n]!=="(")return null;let i=n,r=1,a=0,c=null,l=!1,p=[],f=i+1,u=(d,y,m=!1)=>{let g=Je(s,f,d);if(!m&&g.start>=g.end)return;let x=Dc(s,g.start,g.end),b=x>g.start?Je(s,g.start,x):void 0,A=x>g.start?Je(s,x+1,g.end):g;p.push({span:g,valueSpan:A,nameSpan:b,equalsSpan:x>g.start?{start:x,end:x+1}:void 0,commaSpan:y===void 0?void 0:{start:y,end:y+1}})},h=(d,y)=>({name:o,span:{start:t,end:d},nameSpan:{start:t,end:i},openParenSpan:{start:i,end:i+1},closeParenSpan:y,args:p});for(n++;n<e;n++){let d=s[n];if(c){l?l=!1:d==="\\"?l=!0:d===c&&(c=null);continue}if(d==='"'){c=d;continue}if(d==="{")a++;else if(d==="}")a=Math.max(0,a-1);else if(d==="("&&a===0)r++;else if(d===")"&&a===0){if(--r)continue;return u(n),h(n+1,{start:n,end:n+1})}else d===","&&r===1&&a===0&&(u(n,n,!0),f=n+1)}return u(e),h(e)}var pr=/\s/;function Je(s,t,e){let n=t,o=e;for(;n<o&&pr.test(s[n]);)n+=1;for(;o>n&&pr.test(s[o-1]);)o-=1;return{start:n,end:o}}function Dc(s,t=0,e=s.length){let n=0,o=0,i=null,r=!1;for(let a=t;a<e;a++){let c=s[a];if(i){r?r=!1:c==="\\"?r=!0:c===i&&(i=null);continue}if(c==='"')i=c;else if(c==="("&&o===0)n++;else if(c===")"&&o===0)n=Math.max(0,n-1);else if(c==="{")o++;else if(c==="}")o=Math.max(0,o-1);else if(c==="="&&n===0&&o===0)return a}return-1}function ur(s,t,e){let n=1,o=null,i=!1;for(let r=t;r<e;r++){let a=s[r];if(o){i?i=!1:a==="\\"?i=!0:a===o&&(o=null);continue}if(a==='"')o=a;else if(a==="(")n++;else if(a===")"&&--n===0)return r}return-1}function te(s,t,e){for(let n=t+1;n<e;n++)if(s[n]==="\\")n++;else if(s[n]==='"')return n;return-1}function ue(s){return s.length<2||!s.startsWith('"')||!s.endsWith('"')?s:s.slice(1,-1).replace(/\\(.)/gs,"$1")}function ht(s){return`"${s.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function hr(s,t,e){let n=1,o=null,i=!1;for(let r=t+1;r<e;r++){let a=s[r];if(o){i?i=!1:a==="\\"?i=!0:a===o&&(o=null);continue}if(a==='"')o=a;else if(a==="{")n++;else if(a==="}"&&(n--,n===0))return r}return-1}var Bc=/\s|\(|\)|\{|\}|,/;function dr(s,t,e){let n=t+1;for(;n<e&&!Bc.test(s[n]);)n++;return n<=t+1?null:{label:s.slice(t+1,n),next:n}}var Fc=/^(-?(?:\d+(?:\.\d*)?|\.\d+))([a-z%]+)?$/i,zc=["em","px"];function Uo(s){let t=s.match(Fc);if(!t)return H.warning.InvalidLength(s,{start:0,end:s.length});let e=parseFloat(t[1]);if(!Number.isFinite(e))return H.warning.InvalidLength(s,{start:0,end:s.length});if(t[2]){let n=t[2].toLowerCase();return zc.includes(n)?{value:e,unit:n}:H.warning.InvalidLengthUnit(n,{start:t[1].length,end:s.length})}else return{value:e,unit:"px"}}var mr=/^(true|false)$/;function Hc(s,t){if(s)return s==="content"?void 0:s;if(mr.test(t))return"boolean";if(t.startsWith('"'))return"string";if(!isNaN(Number(t)))return"number";if(!(Uo(t)instanceof H))return"length"}var xr=22,Wc=4,_t=class s{static systemVariables={fontsize:{type:"length",default:xr},font:{type:"string",default:Oe},numberfont:{type:"string",default:Go},strict:{type:"boolean",default:!1}};scopeDepth;source;syntax;commentIndex;diagnostics;variables;documentDeclarations;functions;deSugarAtomFns;deSugarRelationFns;labelableNodes;nodes;constructor(t){t instanceof s?(this.scopeDepth=t.scopeDepth+1,this.documentDeclarations=t.documentDeclarations,this.source=t.source,this.diagnostics=t.diagnostics,this.syntax=t.syntax,this.commentIndex=t.commentIndex,this.variables={...t.variables},this.functions=t.functions,this.deSugarAtomFns=t.deSugarAtomFns,this.deSugarRelationFns=t.deSugarRelationFns,this.labelableNodes=t.labelableNodes,this.nodes=[]):(this.scopeDepth=0,this.documentDeclarations={},this.source=t.source,this.diagnostics=t.diagnostics??[],this.syntax={tokens:(t.commentSpans??[]).map(e=>({kind:"comment",span:e})),calls:[]},this.commentIndex=0,this.variables=Object.fromEntries(Object.entries(s.systemVariables).map(([e,n])=>[e,n.default])),Object.assign(this.variables,t.variables),this.functions=t.functions??new Map,this.labelableNodes=t.labelableNodes??[],this.nodes=t.toConsume??[],t.functions?[this.deSugarAtomFns,this.deSugarRelationFns]=s.getDeSugarFns(this.functions.values()):(this.deSugarAtomFns=[],this.deSugarRelationFns=[]))}static getDeSugarFns(t){let e=new Set(t),n=[],o=[];for(let i of e){let r=i.deSugarAtom;r&&r!==$.deSugarAtom&&n.push(r);let a=i.deSugarRelation;a&&a!==$.deSugarRelation&&o.push(a)}return[n,o]}pushNode(t){this.nodes.push(t);let e=t.labelable?.();e!==void 0&&this.labelableNodes.push(e)}setVariable(t,e){Object.hasOwn(s.systemVariables,t)&&(t==="fontsize"&&e&&(e=this.length2px(e)),(e===void 0||e===""||e===0)&&(e=s.systemVariables[t].default)),this.variables[t]=e}registerFunctions(t){let e=this.functions;for(let n of t){let o=n.def;if(!o)continue;let i=Array.isArray(o.name)?o.name:[o.name];for(let r of i){if(e.has(r.toLowerCase()))throw new Error(`Duplicate function name detected: ${r}`);e.set(r.toLowerCase(),n)}}[this.deSugarAtomFns,this.deSugarRelationFns]=s.getDeSugarFns(this.functions.values())}parse(t=0,e=this.source.length){return this.makeNodes(this.parseGrammar(t,e)),this.nodes}parseSyntax(t=0,e=this.source.length){if(this.parseGrammar(t,e,!0),this.scopeDepth===0){let n=(o,i)=>o.span.start-i.span.start||o.span.end-i.span.end;this.syntax.tokens.sort(n),this.syntax.calls.sort(n)}return this.syntax}addSyntax(t,e){if(!e||e.start>=e.end)return;let n=e.start,o=this.syntax.tokens;for(;o[this.commentIndex]?.kind==="comment"&&o[this.commentIndex].span.end<=n;)this.commentIndex++;for(let i=this.commentIndex;i<o.length;i++){let r=o[i];if(r.kind!=="comment"||r.span.start>=e.end)break;n<r.span.start&&o.push({kind:t,span:{start:n,end:r.span.start}}),n=r.span.end,this.commentIndex=i+1}n<e.end&&o.push({kind:t,span:{start:n,end:e.end}})}recordSyntax(t){if(t.kind==="brace"){this.addSyntax("punctuation",{start:t.span.start,end:t.span.start+1});let a=Math.min(this.source.length,t.span.end-1);new s(this).parseSyntax(t.span.start+1,a),this.source[a]==="}"&&this.addSyntax("punctuation",{start:a,end:a+1});return}if(t.kind==="label"){this.addSyntax("label",t.span);return}if(t.kind==="sugar"||t.typed){this.addSyntax(t.syntaxKind??"operator",t.span);return}let{kind:e,typed:n,syntaxKind:o,...i}=t;this.syntax.calls.push(i),this.addSyntax("function",i.nameSpan),this.addSyntax("punctuation",i.openParenSpan);let r=this.functions.get(i.name.toLowerCase())?.def;for(let a=0;a<i.args.length;a++){let c=i.args[a];this.addSyntax("property",c.nameSpan),this.addSyntax("punctuation",c.equalsSpan);let l=c.nameSpan?this.source.slice(c.nameSpan.start,c.nameSpan.end).toLowerCase():void 0,p=r&&Te(r,l,a);if(p==="content")new s(this).parseSyntax(c.valueSpan.start,c.valueSpan.end);else{let f=this.source.slice(c.valueSpan.start,c.valueSpan.end),u=Hc(p,f);u&&this.addSyntax(u,c.valueSpan)}this.addSyntax("punctuation",c.commaSpan)}this.addSyntax("punctuation",i.closeParenSpan)}makeNodes(t,e=0,n=t.length){t:for(;e<n;e++){let o=t[e];if(typeof o=="number"){let i=this.nodes.at(-1);i instanceof xt&&i.sourceSpan.end===o?i.sourceSpan.end=o+1:this.nodes.push(new xt({start:o,end:o+1},null));continue}switch(o.kind){case"call":this.pushNode(this.parseCallNode(o));break;case"brace":let i=new s(this);this.nodes.push(new dt(o.span,i.parse(o.span.start+1,o.span.end-1),null));break;case"label":let r=this.labelableNodes.at(-1);r?r.label!==void 0?this.diagnostics.push(H.warning.TargetAlreadyLabeled(o.label,r.label,o.span)):(r.label=o.label,this.nodes.push(new Ht(o.span,o.label,r))):this.diagnostics.push(H.warning.LabelWithoutTarget(o.label,o.span));break;case"sugar":for(let c of this.deSugarRelationFns){let l=c(this,t,e);if(l!==null){e=l-1;continue t}}let a=this.nodes.at(-1);a instanceof xt&&a.sourceSpan.end===o.span.start?a.sourceSpan.end=o.span.end:this.nodes.push(new xt(o.span,null));break}}return e}parseGrammar(t,e,n=!1){let o=[],i=r=>{o.push(r),n&&this.recordSyntax(r)};t:for(;(t=Yt(this.source,t,e))<e;){let r=this.source[t];if(r==="@"){let a=tn(this.source,t,e);if(a){i(Object.assign(a,{kind:"call",typed:!1}));let l=!1;for(let p of a.args){let f=p.nameSpan!==void 0;if(f&&!l)l=!0;else if(!f&&l){let u=H.error.PosAfterNamedArg(a.name,p.span);if(!n)throw u;this.diagnostics.push(u)}}if(!a.closeParenSpan){let p=H.error.UnterminatedCall(a.name,a.span);if(!n)throw p;this.diagnostics.push(p)}t=a.span.end;continue}let c=dr(this.source,t,e);if(c){i({kind:"label",span:{start:t,end:c.next},label:c.label}),t=c.next;continue}}if(r==="{"){let a=hr(this.source,t,e);(a<0||a>=e||a<=t)&&(this.diagnostics.push(H.warning.UnmatchedBrace({start:t,end:e})),a=e),i({kind:"brace",span:{start:t,end:a+1}}),t=a+1;continue}for(let a of this.deSugarAtomFns)try{let c=a(this.source,t,e,this.scopeDepth);if(c){i(c.node),t=c.next;continue t}}catch(c){throw c instanceof H?this.diagnostics.push(c):this.diagnostics.push(H.error.Bug(c.toString(),{start:t,end:e})),c}o.push(t++)}return o}parseCallNode(t){let e=this.functions.get(t.name.toLowerCase()),n=e?.def;if(!e||!n){if(this.variables.strict)throw H.error.UnknownFunction(t.name,t.span);return this.diagnostics.push(H.warning.UnknownFunction(t.name,t.span)),new $(t.span,null)}let o=n.args;if(!t.typed){let i=new Map;for(let r=0;r<t.args.length;r++){let a=t.args[r],c=a.nameSpan?this.source.slice(a.nameSpan.start,a.nameSpan.end).toLowerCase():void 0,l=Te(n,c,r),p=c??r;if(l===void 0){n.allowExtraArgs?i.set(p,a):this.diagnostics.push(H.warning.TooManyPosArgs(t.name,o.filter(u=>!u.namedOnly).length,r+1,a.valueSpan));continue}let f=this.parseArgWithType(a.valueSpan,l,t.span.start);f!==null&&i.set(p,f)}return new e(t.span,i,this,null)}return new e(t.span,t.args,this,null)}parseArgWithType(t,e,n){let o=Je(this.source,t.start,t.end),i=o.start,r=o.end;if(i>=r)return null;let a=e==="content"?"":this.source.slice(i,r);switch(e){case"number":let c=Number(a);return Number.isFinite(c)?c:(this.diagnostics.push(H.warning.InvalidNumber(a,o)),null);case"boolean":return mr.test(a)?a==="true":(this.diagnostics.push(H.warning.InvalidBoolean(a,o)),null);case"content":{let p=this.labelableNodes,f=p.length,u=p.at(-1),h=u?.label,d=u&&Object.hasOwn(u,"label");try{let m=new s(this).parse(i,r);return m.length===1?m[0]:new dt(o,m,null)}catch(y){if(p.length=f,u&&(d?u.label=h:delete u.label),this.variables.strict||!(y instanceof H))throw y;return this.diagnostics.push(y,H.warning.InvalidContent(o)),null}}case"label":n??=t.start;for(let p=this.labelableNodes.length-1;p>=0;p--){let f=this.labelableNodes[p];if(f&&!(f.sourceSpan.start>=n)&&f.label==a)return f}throw H.error.UnknownLabel(a,o);case"length":let l=Uo(a);return l instanceof H?(l.span.start+=i,l.span.end+=i,this.diagnostics.push(l),null):l;default:return ue(a)}}length2px(t){return t.unit==="em"?t.value*this.variables.fontsize:t.value}};function Yt(s,t,e){for(;t<e&&yr(s[t]);)t++;return t}function en(s,t,e=0){for(;t>=e&&yr(s[t]);)t--;return t}function yr(s){switch(s){case" ":case" ":case"\v":case"\f":case"\xA0":case"\uFEFF":case"\u3000":return!0;default:return!1}}var Gc=/^[A-GXZ]/,vn=/^[0-9]/,Mn=/^[#bn]+/,gr=/^[+-]?\d+/,br=/^[,']+/;function he(s,t=0,e=s.length){if(e-t===0)return new k("E_WRONG_NOTE_NAME",'\u51FD\u6570 @note \u7684\u53C2\u6570 [0]:"name" \u4E0D\u80FD\u4E3A\u7A7A',{start:t,end:e});let n=0,o=null,i=null,r=null,a=!1,c;for(let l=t;l<e;l++){let p=s[l];switch(n){case 0:if(Gc.test(p))o=p,a=!0,n=1;else if(vn.test(p))o=p,a=!1,n=3;else{let u=s.slice(l,e).match(Mn);if(u)i=u[0],l+=i.length-1,a=!1,n=2;else return new k("E_WRONG_NOTE_NAME",`\u51FD\u6570 @note \u7684\u53C2\u6570 [0]:"name" \u683C\u5F0F\u9519\u8BEF: \u9996\u5B57\u7B26 "${p}" \u4E0D\u5408\u6CD5\uFF0C\u671F\u671B A-G (a-g)\u30010-9\u3001X \u6216 Z \u5F00\u5934\uFF0C\u6216\u5728\u5F00\u5934\u76F4\u63A5\u4F7F\u7528\u5347\u964D\u53F7(#/b/n)`,{start:l,end:l+1})}break;case 1:let f=s.slice(l,e);if(c=f.match(gr),c){r=parseInt(c[0],10),l+=c[0].length-1,n=4;break}if(c=f.match(Mn),c){i=c[0],l+=i.length-1,n=5;break}return{name:o,next:l,acc:null,octave:null,absOctave:a};case 2:if(vn.test(p)){o=p,n=6;break}else return new k("E_WRONG_NOTE_NAME",`\u51FD\u6570 @note \u7684\u53C2\u6570 [0]:"name" \u683C\u5F0F\u9519\u8BEF: \u5728\u5347\u964D\u53F7\u5F00\u5934\u65F6\uFF0C\u5E94\u8BE5\u63A5\u6570\u5B57\u97F3\u540D\uFF0C\u4F46\u53D1\u73B0\u5B57\u7B26 "${p}"`,{start:l,end:l+1});case 3:if(c=s.slice(l,e).match(br),c){let u=c[0];return r=wr(u),{name:o,next:l+u.length,acc:i,octave:r,absOctave:a}}if(c=s.slice(l,e).match(Mn),c&&!vn.test(s[l+c[0].length]??"")){let u=c[0];i=u,l+=u.length-1,n=6;break}return{name:o,next:l,acc:i,octave:r,absOctave:a};case 4:if(c=s.slice(l,e).match(Mn),c&&!vn.test(s[l+c[0].length]??"")){let u=c[0];return i=u,{name:o,next:l+u.length,acc:i,octave:r,absOctave:a}}return{name:o,next:l,acc:null,octave:r,absOctave:a};case 5:return c=s.slice(l,e).match(gr),c?(r=parseInt(c[0],10),{name:o,next:l+c[0].length,acc:i,octave:r,absOctave:a}):{name:o,next:l,acc:i,octave:null,absOctave:a};case 6:if(c=s.slice(l,e).match(br),c){let u=c[0];return r=wr(u),{name:o,next:l+u.length,acc:i,octave:r,absOctave:a}}return{name:o,next:l,acc:i,octave:r,absOctave:a};default:return H.error.Bug("\u97F3\u7B26\u540D\u79F0\u89E3\u6790\u72B6\u6001\u673A\u8FDB\u5165\u4E86\u672A\u5B9A\u4E49\u7684\u72B6\u6001",{start:l,end:e})}}return o===null?new k("E_WRONG_NOTE_NAME",'\u51FD\u6570 @note \u7684\u53C2\u6570 [0]:"name" \u683C\u5F0F\u9519\u8BEF: \u5728\u5347\u964D\u53F7\u5F00\u5934\u65F6\uFF0C\u5E94\u8BE5\u63A5\u6570\u5B57\u97F3\u540D\uFF0C\u4F46\u8F93\u5165\u5DF2\u7ED3\u675F',{start:t,end:e}):{name:o,next:e,acc:i,octave:r,absOctave:a}}function wr(s){let t=0;for(let e=0;e<s.length;e++)s[e]===","?t--:s[e]==="'"&&t++;return t}var ee=["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"],Sr=["C","Db","D","Eb","E","F","Gb","G","Ab","A","Bb","B"],vt={C:0,"C#":1,Db:1,D:2,"D#":3,Eb:3,E:4,F:5,"F#":6,Gb:6,G:7,"G#":8,Ab:8,A:9,"A#":10,Bb:10,B:11,1:0,2:2,3:4,4:5,5:7,6:9,7:11},Nn=["C","D","E","F","G","A","B"],jo=[0,2,4,5,7,9,11];function de(s,t){let e=s[0],n="",o=1;o<s.length&&(s[o]==="#"||s[o]==="b"||s[o]==="n")&&(n=s[o],o++);let i=vt[e+n];if(i===void 0)throw H.error.InvalidTonality(s,{start:0,end:o});if(o<s.length){let r=s.slice(o);if(t=Number(r),!/^-?\d+$/.test(r)||!Number.isSafeInteger(t))throw H.error.InvalidTonality(s,{start:o,end:s.length})}return(t+1)*12+i}function Yo(s,t=!0,e=0){for(let n of s)n==="#"?e++:n==="b"?e--:n==="n"&&!t&&(e=0);return e}function Xo(s,t,e,n){let o=vt[s];if(o===void 0)return null;let i=Yo(t);return s>="1"&&s<="7"?de(n,4)+o+i+e*12:(e+1)*12+o+i}function Ar(s,t,e,n){let o,i;if(s>="1"&&s<="7")o=Number(s)-1,i=e;else{let c=nn(s,t,e,n);if(!c)return;o=Number(c.renderName)-1,i=c.renderOctave}let r=de(n,4),a=i*7+o;return c=>{let l=a+c,p=Math.floor(l/7);return r+jo[(l%7+7)%7]+p*12}}function Ko(s){return(s%12+12)%12}function Vc(s){let t=Ko(s);return t>6?t-12:t}function Uc(s){return s===0?"":s>0?"#".repeat(s):"b".repeat(-s)}function nn(s,t,e,n){let o=Nn.indexOf(n[0]),i=Nn.indexOf(s),r=Xo(s,t,e,n);if(o<0||i<0||r===null)return null;let a=de(n,4),c=(i-o+Nn.length)%Nn.length,l=Ko(a+jo[c]),p=Vc(Ko(r)-l),f=(r-a-jo[c]-p)/12;return{renderName:String(c+1),renderAcc:Uc(p),renderOctave:f}}var jc={"#":{w:.46,h:.78,baseline:.63,commands:[{op:"M",x:.34,y:.05},{op:"L",x:.27,y:.95},{op:"M",x:.72,y:.05},{op:"L",x:.65,y:.95},{op:"M",x:.08,y:.38},{op:"L",x:.9,y:.28},{op:"M",x:.05,y:.72},{op:"L",x:.87,y:.62}]},b:{w:.38,h:.82,baseline:.67,commands:[{op:"M",x:.3,y:.04},{op:"L",x:.3,y:.94},{op:"M",x:.3,y:.5},{op:"Q",cx:.92,cy:.36,x:.76,y:.68},{op:"Q",cx:.63,cy:.87,x:.3,y:.86}]},n:{w:.42,h:.82,baseline:.67,commands:[{op:"M",x:.28,y:.05},{op:"L",x:.28,y:.82},{op:"L",x:.72,y:.68},{op:"L",x:.72,y:.95},{op:"M",x:.72,y:.95},{op:"L",x:.72,y:.18},{op:"L",x:.28,y:.32}]}};function kn(s,t,e,n,o){let i=[],r=t*.72,a=t*.42,c=e,l=0;for(let p of s){let f=jc[p];if(!f)continue;let u={w:f.w*r,h:f.h*r,baseline:f.baseline*r,strokeWidth:t*.06,commands:f.commands},h=n-u.baseline-a;i.push({shape:u,x:c,y:h}),h<l&&(l=h),c+=u.w+o}return{placed:i,right:c,top:l}}function _n(s,{shape:t,x:e,y:n},o,i){s.drawPath(t.commands,{stroke:i,strokeWidth:t.strokeWidth},{x:o.x+e,y:o.y+n,scaleX:t.w,scaleY:t.h})}function Kc(s){try{return de(s,4),s}catch{}let t=he(s.replace(/^[a-g]/,a=>a.toUpperCase()));if(t instanceof H||t.next!==s.length)return null;let e=vt[t.name];if(e===void 0)return null;let n=Yo(t.acc??"",!1),i=((t.absOctave?t.octave??4:4+(t.octave??0))+1)*12+e+n,r=Object.keys(vt).filter(a=>vt[a]===(i%12+12)%12&&/^[A-G]/.test(a));return(n<0?r.at(-1):r[0])+(Math.floor(i/12)-1)}var Zo=class extends ${static def={name:["key","1"],description:"\u8BBE\u7F6E\u65F6\u95F4\u7EBF\u4E0A\u7684 1= \u8C03\u6027\u57FA\u51C6",details:`~~~jpfun
|
|
30
|
+
\u4EC5\u7ED8\u5236\uFF0C\u4E0D\u6539\u53D8\u65F6\u503C\u548C\u64AD\u653E\u3002pre \u4FEE\u9970\u5185\u5BB9\u9996\u7AEF\uFF0Cpost \u4FEE\u9970\u672B\u7AEF\uFF1Bup/down \u8868\u793A\u968F\u65F6\u95F4\u4E0A\u884C/\u4E0B\u884C\u3002`,allowExtraArgs:!1,args:[{type:"content",default:null,description:"\u88AB\u4FEE\u9970\u7684\u5185\u5BB9"},{name:"side",type:"string",default:"pre",description:"pre \u6ED1\u5165\uFF0Cpost \u6ED1\u51FA"},{name:"direction",type:"string",default:"up",description:"up \u4E0A\u884C\uFF0Cdown \u4E0B\u884C"}]};content;side;direction;get children(){return[this.content]}labelable(){return B.findLabelable(this.content)}constructor(t,e,n,o=null){super(t,o);let[s,i,a]=this.getArgValue(e,n);if(i!=="pre"&&i!=="post")throw new k("E_SLIDE_SIDE","@slide \u7684 side \u5FC5\u987B\u662F pre \u6216 post",t);if(a!=="up"&&a!=="down")throw new k("E_SLIDE_DIRECTION","@slide \u7684 direction \u5FC5\u987B\u662F up \u6216 down",t);this.content=s,this.side=i,this.direction=a,s.parent=this}loweringEnter(t){let e=this.side==="pre",n={onTemporal(o){W(o)&&(!e||!n.host)&&(n.host=o)}};return t.beginLoweringGroup(this,n),[]}loweringExit(t){let{host:e}=t.endLoweringGroup(this);if(!e)throw new k("E_SLIDE_CONTENT","@slide \u7684\u5185\u5BB9\u5FC5\u987B\u5305\u542B\u53EF\u7ED8\u5236\u5BF9\u8C61",this.sourceSpan);let n=new ar(e,this);t.addAttachment(n);let o=e.prepareHorizontal;return e.prepareHorizontal=s=>{o?.call(e,s),!(s.columnOf(e)<0)&&s.registerHorizontalLayoutHook(e,e,({columns:i,start:a})=>{let c=this.side==="pre",l=c?"WL":"WR",p=(c?e.box.anchor:e.box.w-e.box.anchor)+n.length+e.ast.size*.22;for(let m of i[a])m.box===e.box&&(m[l]=Math.max(m[l],p))})},[]}toString(t){return`@slide(${this.content.toString(t)}, side=${this.side}, direction=${this.direction})`}},Hi=ir,ar=class{constructor(t,e){this.host=t;this.owner=e;this.endPoints=[t]}host;owner;layer="foreground";endPoints;get sourceSpan(){return this.owner.sourceSpan}get length(){let{host:t}=this;return t.box.visualAxis-(t.ports.shoulder?.y??0)+t.ast.size*.1}createGeometry(){let{host:t,owner:e}=this,n=t.ast.size,o=e.side==="pre",s=this.length,i=e.direction==="up",a=t.box.y+t.box.visualAxis,c=o?t.box.x-n*.12-s:t.box.x+t.box.w+n*.12,l={x:c,y:i?a:a-s},u={x:c+s,y:i?a-s:a},p=i?-Math.PI/4:Math.PI/4,m=h=>({x:u.x-n*.25*Math.cos(p+h),y:u.y-n*.25*Math.sin(p+h)}),d=[{op:"M",...l},{op:"L",...u},{op:"M",...m(-Math.PI/6)},{op:"L",...u},{op:"L",...m(Math.PI/6)}],f=n*.05,x=Gt(d);return{regions:[{x:x.x-f/2,y:x.y-f/2,w:x.w+f,h:x.h+f,line:t.layoutLine,track:t.track}],paint(h){h.drawPath(d,{fill:"none",stroke:"#000",strokeWidth:f})}}}};var De="sans-serif",Ve="'Cascadia Mono', Consolas, 'Liberation Mono', 'Noto Sans Mono', monospace";function ne(r,t,e){let n=r.at(-1);n&&n.mask===e?n.text+=t:r.push({text:t,mask:e})}function cn(r,t,e="\\*_^"){let n=0;for(let o=0;o<r.length;o++){let s=String.fromCodePoint(r.codePointAt(o));if(o+=s.length-1,s==="\\"&&o+1<r.length&&e.includes(r[o+1])){t(r[++o],n,!0);continue}if(s==="*"){n^=r[o+1]==="*"?(o++,1):2;continue}if(s==="_"){n^=4;continue}if(s==="^"){n^=8;continue}t(s,n,!1)}}function lr(r){let t=[[]];return cn(r,(e,n)=>{e===`
|
|
31
|
+
`?t.push([]):ne(t.at(-1),e,n)}),t}function Gn(r){return(r&1?"**":"")+(r&2?"*":"")+(r&4?"_":"")+(r&8?"^":"")}var Cl=.7,Nl=.35;function Yt(r,t,e){let n=[];typeof r=="string"?cn(r,(c,l)=>ne(n,c,l)):n.push(...r);let o=0,s,i=n.length>1&&t.textAlign&&t.textAlign!=="left",a=n.map(c=>{let l=!i&&(c.mask&11)===0?t:{...t,...i?{textAlign:"left"}:{},...c.mask&8?{fontSize:t.fontSize*Cl}:{},...c.mask&1?{fontWeight:"bold"}:{},...c.mask&2?{fontStyle:"italic"}:{}},u=e.measureText(c.text,l);return(c.mask&8)===0&&(s??=u),o+=u.w,{...c,style:l,w:u.w}});return s??=e.measureText("",t),{runs:a,style:t,w:n.length?o:s.w,h:s.h,baseline:s.baseline}}function oe(r,t,e,n){let{runs:o,style:s,w:i}=t,{textAlign:a}=s,c=a==="center"?e-i/2:a==="right"?e-i:e,l=p=>p&8?n-s.fontSize*Nl:n,u=c;for(let p of o)r.drawText(p.text,o.length===1?e:u,l(p.mask),p.style),u+=p.w;for(let p=0,m=c;p<o.length;){let{mask:d,style:f,w:x}=o[p++];if(!(d&4)){m+=x;continue}let y=m+x;for(;p<o.length&&(o[p].mask&12)===(d&12);)y+=o[p++].w;let h=l(d)+f.fontSize*.12;r.drawLine(m,h,y,h,{stroke:s.fill??"#000",strokeWidth:Math.max(1,f.fontSize*.06)}),m=y}}function $n(r){return`${r.fontStyle?`${r.fontStyle} `:""}${r.fontWeight??"normal"} ${r.fontSize}px ${r.fontFamily??De}`}var zn=class{measureText(t,e){let n=e.fontSize,o=e.fontFamily?.toLowerCase().includes("mono")??!1,s=0;for(let i of t)s+=i.charCodeAt(0)>127?1:o?.62:.58;return{w:Math.max(s*n,n*.25),h:n,baseline:n*.8}}},ur=new zn,cr=class{constructor(t){this.context=t}context;widths=new Map;clearCache(){this.widths.clear()}measureText(t,e){let n=$n(e),o=`${n}\0${t}`,s=this.widths.get(o);return s===void 0&&(this.context.font=n,s=this.context.measureText(t).width,this.widths.set(o,s)),{w:Math.max(s,e.fontSize*.25),h:e.fontSize,baseline:e.fontSize*.8}}};var vl=/[A-Za-z0-9_./-]/;function un(r,t,e){let n=t+1;for(;n<e&&vl.test(r[n]);)n++;let o=r.slice(t+1,n);if(!o||n>=e||r[n]!=="(")return null;let s=n,i=1,a=0,c=null,l=!1,u=[],p=s+1,m=-1,d=(x,y,h=!1)=>{let g=ln(r,p,x);if(!h&&g.start>=g.end)return;let b=m>g.start?ln(r,g.start,m):void 0,T=m>g.start?ln(r,m+1,g.end):g;u.push({span:g,valueSpan:T,nameSpan:b,equalsSpan:m>g.start?{start:m,end:m+1}:void 0,commaSpan:y===void 0?void 0:{start:y,end:y+1}})},f=(x,y)=>({name:o,span:{start:t,end:x},nameSpan:{start:t,end:s},openParenSpan:{start:s,end:s+1},closeParenSpan:y,args:u});for(n++;n<e;n++){let x=r[n];if(c){l?l=!1:x==="\\"?l=!0:x===c&&(c=null);continue}if(x==='"'){c=x;continue}if(x==="{")a++;else if(x==="}")a=Math.max(0,a-1);else if(x==="("&&a===0)i++;else if(x===")"&&a===0){if(--i)continue;return d(n),f(n+1,{start:n,end:n+1})}else x===","&&i===1&&a===0?(d(n,n,!0),p=n+1,m=-1):x==="="&&m===-1&&i===1&&a===0&&(m=n)}return d(e),f(e)}var zi=/\s/;function ln(r,t,e){let n=t,o=e;for(;n<o&&zi.test(r[n]);)n+=1;for(;o>n&&zi.test(r[o-1]);)o-=1;return{start:n,end:o}}function Gi(r,t,e){let n=1,o=null,s=!1;for(let i=t;i<e;i++){let a=r[i];if(o){s?s=!1:a==="\\"?s=!0:a===o&&(o=null);continue}if(a==='"')o=a;else if(a==="(")n++;else if(a===")"&&--n===0)return i}return-1}function $t(r,t,e){for(let n=t+1;n<e;n++)if(r[n]==="\\")n++;else if(r[n]==='"')return n;return-1}function jn(r){let t=r.length>=2&&r.startsWith('"')&&r.endsWith('"'),e=t?r.slice(1,-1):r,n,o=e.replace(/\\(u.{0,4}|.)/gs,(s,i,a)=>{if(i==='"'||i==="\\")return i;if(i[0]!=="u")return s;if(!/^u[0-9a-f]{4}$/i.test(i)){let c=a+(t?1:0);return n??=Y.warning.InvalidUnicodeEscape({start:c,end:c+s.length}),s}return String.fromCharCode(Number.parseInt(i.slice(1),16))});return n??o}function lt(r){return`"${r.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function $i(r,t,e){let n=1,o=null,s=!1;for(let i=t+1;i<e;i++){let a=r[i];if(o){s?s=!1:a==="\\"?s=!0:a===o&&(o=null);continue}if(a==='"')o=a;else if(a==="{")n++;else if(a==="}"&&(n--,n===0))return i}return-1}var kl=/\s|\(|\)|\{|\}|,/;function ji(r,t,e){let n=t+1;for(;n<e&&!kl.test(r[n]);)n++;return n<=t+1?null:{label:r.slice(t+1,n),next:n}}var El=/^(-?(?:\d+(?:\.\d*)?|\.\d+))([a-z%]+)?$/i,Pl=["em","px"];function pr(r){let t=r.match(El);if(!t)return Y.warning.InvalidLength(r,{start:0,end:r.length});let e=parseFloat(t[1]);if(!Number.isFinite(e))return Y.warning.InvalidLength(r,{start:0,end:r.length});if(t[2]){let n=t[2].toLowerCase();return Pl.includes(n)?{value:e,unit:n}:Y.warning.InvalidLengthUnit(n,{start:t[1].length,end:r.length})}else return{value:e,unit:"px"}}var Wi=/^(true|false)$/;function Ml(r,t){if(r)return r==="content"?void 0:r;if(Wi.test(t))return"boolean";if(t.startsWith('"'))return"string";if(!isNaN(Number(t)))return"number";if(!(pr(t)instanceof Y))return"length"}var Xi=22,_t=class r{static systemVariables={fontsize:{type:"length",default:Xi},font:{type:"string",default:De},numberfont:{type:"string",default:Ve},strict:{type:"boolean",default:!1}};scopeDepth;source;syntax;commentIndex;diagnostics;variables;documentDeclarations;functions;deSugarAtomFns;deSugarRelationFns;labelableNodes;nodes;constructor(t){t instanceof r?(this.scopeDepth=t.scopeDepth+1,this.documentDeclarations=t.documentDeclarations,this.source=t.source,this.diagnostics=t.diagnostics,this.syntax=t.syntax,this.commentIndex=t.commentIndex,this.variables={...t.variables},this.functions=t.functions,this.deSugarAtomFns=t.deSugarAtomFns,this.deSugarRelationFns=t.deSugarRelationFns,this.labelableNodes=t.labelableNodes,this.nodes=[]):(this.scopeDepth=0,this.documentDeclarations={},this.source=t.source,this.diagnostics=t.diagnostics??[],this.syntax={tokens:(t.commentSpans??[]).map(e=>({kind:"comment",span:e})),calls:[]},this.commentIndex=0,this.variables=Object.fromEntries(Object.entries(r.systemVariables).map(([e,n])=>[e,n.default])),Object.assign(this.variables,t.variables),this.functions=t.functions??new Map,this.labelableNodes=t.labelableNodes??[],this.nodes=t.toConsume??[],t.functions?[this.deSugarAtomFns,this.deSugarRelationFns]=r.getDeSugarFns(this.functions.values()):(this.deSugarAtomFns=[],this.deSugarRelationFns=[]))}static getDeSugarFns(t){let e=new Set(t),n=[],o=[];for(let s of e){let i=s.deSugarAtom;i&&i!==B.deSugarAtom&&n.push(i);let a=s.deSugarRelation;a&&a!==B.deSugarRelation&&o.push(a)}return[n,o]}pushNode(t){this.nodes.push(t);let e=t.labelable?.();e!==void 0&&this.labelableNodes.push(e)}setVariable(t,e){Object.hasOwn(r.systemVariables,t)&&(t==="fontsize"&&e&&(e=this.length2px(e)),(e===void 0||e===""||e===0)&&(e=r.systemVariables[t].default)),this.variables[t]=e}registerFunctions(t){let e=this.functions;for(let n of t){let o=n.def;if(!o)continue;let s=Array.isArray(o.name)?o.name:[o.name];for(let i of s){if(e.has(i.toLowerCase()))throw new Error(`Duplicate function name detected: ${i}`);e.set(i.toLowerCase(),n)}}[this.deSugarAtomFns,this.deSugarRelationFns]=r.getDeSugarFns(this.functions.values())}parse(t=0,e=this.source.length){return this.makeNodes(this.parseGrammar(t,e)),this.nodes}parseSyntax(t=0,e=this.source.length){if(this.parseGrammar(t,e,!0),this.scopeDepth===0){let n=(o,s)=>o.span.start-s.span.start||o.span.end-s.span.end;this.syntax.tokens.sort(n),this.syntax.calls.sort(n)}return this.syntax}addSyntax(t,e){if(!e||e.start>=e.end)return;let n=e.start,o=this.syntax.tokens;for(;o[this.commentIndex]?.kind==="comment"&&o[this.commentIndex].span.end<=n;)this.commentIndex++;for(let s=this.commentIndex;s<o.length;s++){let i=o[s];if(i.kind!=="comment"||i.span.start>=e.end)break;n<i.span.start&&o.push({kind:t,span:{start:n,end:i.span.start}}),n=i.span.end,this.commentIndex=s+1}n<e.end&&o.push({kind:t,span:{start:n,end:e.end}})}recordSyntax(t){if(t.kind==="brace"){this.addSyntax("punctuation",{start:t.span.start,end:t.span.start+1});let a=Math.min(this.source.length,t.span.end-1);new r(this).parseSyntax(t.span.start+1,a),this.source[a]==="}"&&this.addSyntax("punctuation",{start:a,end:a+1});return}if(t.kind==="label"){this.addSyntax("label",t.span);return}if(t.kind==="sugar"||t.typed){this.addSyntax(t.syntaxKind??"operator",t.span);return}let{kind:e,typed:n,syntaxKind:o,...s}=t;this.syntax.calls.push(s),this.addSyntax("function",s.nameSpan),this.addSyntax("punctuation",s.openParenSpan);let i=this.functions.get(s.name.toLowerCase())?.def;for(let a=0;a<s.args.length;a++){let c=s.args[a];this.addSyntax("property",c.nameSpan),this.addSyntax("punctuation",c.equalsSpan);let l=c.nameSpan?this.source.slice(c.nameSpan.start,c.nameSpan.end).toLowerCase():void 0,u=i&&Pe(i,l,a);if(u==="content")new r(this).parseSyntax(c.valueSpan.start,c.valueSpan.end);else{let p=this.source.slice(c.valueSpan.start,c.valueSpan.end),m=Ml(u,p);m&&this.addSyntax(m,c.valueSpan)}this.addSyntax("punctuation",c.commaSpan)}this.addSyntax("punctuation",s.closeParenSpan)}findLastOperandIndex(){let t=this.nodes.length-1;for(;t>=0&&this.nodes[t]instanceof kt;)t--;if(t<0)return-1;let e=this.nodes[t];if(e instanceof Ee){let n=e.target;for(;n.parent;)n=n.parent;let o=this.nodes.lastIndexOf(n,t-1);return o<0?-1:(this.nodes.splice(o,t-o+1,new Nt({start:n.sourceSpan.start,end:e.sourceSpan.end},this.nodes.slice(o,t+1),null)),o)}return t}takeLeftOperand(){let t=this.findLastOperandIndex();if(t<0)return null;let e=this.nodes[t];return this.nodes.length=t,e}consumeRightOperand(t,e,n){let o=this.nodes;this.nodes=[];try{this.makeNodes(t,e);for(let s=0;s<this.nodes.length;s++){let i=this.nodes[s];if(!(i instanceof kt)){for(o.push(n(i));++s<this.nodes.length;)o.push(this.nodes[s]);return t.length}}return null}finally{this.nodes=o}}makeNodes(t,e=0,n=t.length){t:for(;e<n;e++){let o=t[e];if(typeof o=="number"){let s=this.nodes.at(-1);s instanceof kt&&s.sourceSpan.end===o?s.sourceSpan.end=o+1:this.nodes.push(new kt({start:o,end:o+1},null));continue}switch(o.kind){case"call":this.pushNode(this.parseCallNode(o));break;case"brace":let s=new r(this);this.nodes.push(new Nt(o.span,s.parse(o.span.start+1,o.span.end-1),null));break;case"label":let i=this.labelableNodes.at(-1);i?i.label!==void 0?this.diagnostics.push(Y.warning.TargetAlreadyLabeled(o.label,i.label,o.span)):(i.label=o.label,this.nodes.push(new Ee(o.span,o.label,i))):this.diagnostics.push(Y.warning.LabelWithoutTarget(o.label,o.span));break;case"sugar":for(let c of this.deSugarRelationFns){let l=c(this,t,e);if(l!==null){e=l-1;continue t}}let a=this.nodes.at(-1);a instanceof kt&&a.sourceSpan.end===o.span.start?a.sourceSpan.end=o.span.end:this.nodes.push(new kt(o.span,null));break}}return e}parseGrammar(t,e,n=!1){let o=[],s=i=>{o.push(i),n&&this.recordSyntax(i)};t:for(;(t=re(this.source,t,e))<e;){let i=this.source[t];if(i==="@"){let a=un(this.source,t,e);if(a){s(Object.assign(a,{kind:"call",typed:!1}));let l=!1;for(let u of a.args){let p=u.nameSpan!==void 0;if(p&&!l)l=!0;else if(!p&&l){let m=Y.error.PosAfterNamedArg(a.name,u.span);if(!n)throw m;this.diagnostics.push(m)}}if(!a.closeParenSpan){let u=Y.error.UnterminatedCall(a.name,a.span);if(!n)throw u;this.diagnostics.push(u)}t=a.span.end;continue}let c=ji(this.source,t,e);if(c){s({kind:"label",span:{start:t,end:c.next},label:c.label}),t=c.next;continue}}if(i==="{"){let a=$i(this.source,t,e);(a<0||a>=e||a<=t)&&(this.diagnostics.push(Y.warning.UnmatchedBrace({start:t,end:e})),a=e),s({kind:"brace",span:{start:t,end:a+1}}),t=a+1;continue}for(let a of this.deSugarAtomFns)try{let c=a(this.source,t,e,this.scopeDepth);if(c){s(c.node),t=c.next;continue t}}catch(c){throw c instanceof Y?this.diagnostics.push(c):this.diagnostics.push(Y.error.Bug(c.toString(),{start:t,end:e})),c}o.push(t++)}return o}parseCallNode(t){let e=this.functions.get(t.name.toLowerCase()),n=e?.def;if(!e||!n){if(this.variables.strict)throw Y.error.UnknownFunction(t.name,t.span);return this.diagnostics.push(Y.warning.UnknownFunction(t.name,t.span)),new B(t.span,null)}let o=n.args;if(!t.typed){let s=new Map;for(let i=0;i<t.args.length;i++){let a=t.args[i],c=a.nameSpan?this.source.slice(a.nameSpan.start,a.nameSpan.end).toLowerCase():void 0,l=Pe(n,c,i),u=c??i;if(l===void 0){n.allowExtraArgs?s.set(u,a):this.diagnostics.push(Y.warning.TooManyPosArgs(t.name,o.filter(m=>!m.namedOnly).length,i+1,a.valueSpan));continue}let p=this.parseArgWithType(a.valueSpan,l,t.span.start);p!==null&&s.set(u,p)}return new e(t.span,s,this,null)}return new e(t.span,t.args,this,null)}parseArgWithType(t,e,n){let o=ln(this.source,t.start,t.end),s=o.start,i=o.end;if(s>=i)return null;let a=e==="content"?"":this.source.slice(s,i);switch(e){case"number":let c=Number(a);return Number.isFinite(c)?c:(this.diagnostics.push(Y.warning.InvalidNumber(a,o)),null);case"boolean":return Wi.test(a)?a==="true":(this.diagnostics.push(Y.warning.InvalidBoolean(a,o)),null);case"content":{let p=this.labelableNodes,m=p.length,d=p.at(-1),f=d?.label,x=d&&Object.hasOwn(d,"label");try{let h=new r(this).parse(s,i);return h.length===1?h[0]:new Nt(o,h,null)}catch(y){if(p.length=m,d&&(x?d.label=f:delete d.label),this.variables.strict||!(y instanceof Y))throw y;return this.diagnostics.push(y,Y.warning.InvalidContent(o)),null}}case"label":n??=t.start;for(let p=this.labelableNodes.length-1;p>=0;p--){let m=this.labelableNodes[p];if(m&&!(m.sourceSpan.start>=n)&&m.label==a)return m}throw Y.error.UnknownLabel(a,o);case"length":let l=pr(a);return l instanceof Y?(l.span.start+=s,l.span.end+=s,this.diagnostics.push(l),null):l;default:let u=jn(a);return u instanceof Y?(u.span.start+=s,u.span.end+=s,this.diagnostics.push(u),a.length>=2&&a.startsWith('"')&&a.endsWith('"')?a.slice(1,-1):a):u}}length2px(t){return t.unit==="em"?t.value*this.variables.fontsize:t.value}};function re(r,t,e){for(;t<e&&Ui(r[t]);)t++;return t}function pn(r,t,e=0){for(;t>=e&&Ui(r[t]);)t--;return t}function Ui(r){switch(r){case" ":case" ":case"\v":case"\f":case"\xA0":case"\uFEFF":case"\u3000":return!0;default:return!1}}function Rl(r){return r>="A"&&r<="G"||r==="X"||r==="Z"}function Wn(r){return r>="0"&&r<="9"}function Zi(r){return r==="#"||r==="b"||r==="n"}function mr(r,t,e){for(;t<e&&Zi(r[t]);)t++;return t}function Ki(r,t,e){let n=mr(r,t,e);return n>t&&!Wn(r[n]??"")?r.slice(t,n):null}function Yi(r,t,e){t<e&&(r[t]==="+"||r[t]==="-")&&t++;let n=t;for(;t<e&&Wn(r[t]);)t++;return t>n?t:-1}function qi(r,t,e,n,o){let s=0,i=t;for(;i<e&&(r[i]===","||r[i]==="'");)s+=r[i++]==="'"?1:-1;return{name:n,next:i,acc:o,octave:i>t?s:null,absOctave:!1}}function be(r,t=0,e=r.length,n=!0){if(e-t===0)return n?new k("E_WRONG_NOTE_NAME",'\u51FD\u6570 @note \u7684\u53C2\u6570 [0]:"name" \u4E0D\u80FD\u4E3A\u7A7A',{start:t,end:e}):null;let o=r[t];if(Rl(o)){let s=t+1,i=null,a=null,c=Yi(r,s,e);if(c>0)a=parseInt(r.slice(s,c),10),s=c,i=Ki(r,s,e),i&&(s+=i.length);else{let l=mr(r,s,e);if(l>s){i=r.slice(s,l);let u=Yi(r,l,e);u>0?(a=parseInt(r.slice(l,u),10),s=u):s=l}}return{name:o,next:s,acc:i,octave:a,absOctave:!0}}if(Wn(o)){let s=Ki(r,t+1,e);return qi(r,t+1+(s?s.length:0),e,o,s)}if(Zi(o)){let s=mr(r,t,e);if(s>=e)return n?new k("E_WRONG_NOTE_NAME",'\u51FD\u6570 @note \u7684\u53C2\u6570 [0]:"name" \u683C\u5F0F\u9519\u8BEF: \u5728\u5347\u964D\u53F7\u5F00\u5934\u65F6\uFF0C\u5E94\u8BE5\u63A5\u6570\u5B57\u97F3\u540D\uFF0C\u4F46\u8F93\u5165\u5DF2\u7ED3\u675F',{start:t,end:e}):null;let i=r[s];return Wn(i)?qi(r,s+1,e,i,r.slice(t,s)):n?new k("E_WRONG_NOTE_NAME",'\u51FD\u6570 @note \u7684\u53C2\u6570 [0]:"name" \u683C\u5F0F\u9519\u8BEF: \u5728\u5347\u964D\u53F7\u5F00\u5934\u65F6\uFF0C\u5E94\u8BE5\u63A5\u6570\u5B57\u97F3\u540D\uFF0C\u4F46\u53D1\u73B0\u5B57\u7B26 "{ch}"',{start:s,end:s+1},{ch:i}):null}return n?new k("E_WRONG_NOTE_NAME",'\u51FD\u6570 @note \u7684\u53C2\u6570 [0]:"name" \u683C\u5F0F\u9519\u8BEF: \u9996\u5B57\u7B26 "{ch}" \u4E0D\u5408\u6CD5\uFF0C\u671F\u671B A-G (a-g)\u30010-9\u3001X \u6216 Z \u5F00\u5934\uFF0C\u6216\u5728\u5F00\u5934\u76F4\u63A5\u4F7F\u7528\u5347\u964D\u53F7(#/b/n)',{start:t,end:t+1},{ch:o}):null}var He=["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"],Qi=["C","Db","D","Eb","E","F","Gb","G","Ab","A","Bb","B"],Et={C:0,"C#":1,Db:1,D:2,"D#":3,Eb:3,E:4,F:5,"F#":6,Gb:6,G:7,"G#":8,Ab:8,A:9,"A#":10,Bb:10,B:11,1:0,2:2,3:4,4:5,5:7,6:9,7:11},Xn=["C","D","E","F","G","A","B"],dr=[0,2,4,5,7,9,11];function mn(r){let t=r[0];if(!t||t<"A"||t>"G")return null;let e="",n=1;n<r.length&&(r[n]==="#"||r[n]==="b")&&(e=r[n],n++);let o=Et[t+e];if(o===void 0)return null;let s=r.slice(n),i=Number(s);return!/^-?\d+$/.test(s)||!Number.isSafeInteger(i)?null:(i+1)*12+o}function yr(r,t=!0,e=0){for(let n of r)n==="#"?e++:n==="b"?e--:n==="n"&&!t&&(e=0);return e}function hr(r,t,e,n){let o=Et[r];if(o===void 0)return null;let s=yr(t);return r>="1"&&r<="7"?mn(n)+o+s+e*12:(e+1)*12+o+s}function Ji(r,t,e){if(r<"1"||r>"7")return;let n=mn(e),o=t*7+Number(r)-1;return s=>{let i=o+s,a=Math.floor(i/7);return n+dr[(i%7+7)%7]+a*12}}function fr(r){return(r%12+12)%12}function _l(r){let t=fr(r);return t>6?t-12:t}function Fl(r){return r===0?"":r>0?"#".repeat(r):"b".repeat(-r)}function Un(r,t,e,n){let o=Xn.indexOf(n[0]),s=Xn.indexOf(r),i=hr(r,t,e,n);if(o<0||s<0||i===null)return null;let a=mn(n),c=(s-o+Xn.length)%Xn.length,l=fr(a+dr[c]),u=_l(fr(i)-l),p=(i-a-dr[c]-u)/12;return{renderName:String(c+1),renderAcc:Fl(u),renderOctave:p}}var Ol={"#":{w:.46,h:.78,baseline:.63,commands:[{op:"M",x:.34,y:.05},{op:"L",x:.27,y:.95},{op:"M",x:.72,y:.05},{op:"L",x:.65,y:.95},{op:"M",x:.08,y:.38},{op:"L",x:.9,y:.28},{op:"M",x:.05,y:.72},{op:"L",x:.87,y:.62}]},b:{w:.38,h:.82,baseline:.67,commands:[{op:"M",x:.3,y:.04},{op:"L",x:.3,y:.94},{op:"M",x:.3,y:.5},{op:"Q",cx:.92,cy:.36,x:.76,y:.68},{op:"Q",cx:.63,cy:.87,x:.3,y:.86}]},n:{w:.42,h:.82,baseline:.67,commands:[{op:"M",x:.28,y:.05},{op:"L",x:.28,y:.82},{op:"L",x:.72,y:.68},{op:"L",x:.72,y:.95},{op:"M",x:.72,y:.95},{op:"L",x:.72,y:.18},{op:"L",x:.28,y:.32}]}};function Kn(r,t,e,n,o){let s=[],i=t*.72,a=t*.42,c=e,l=0;for(let u of r){let p=Ol[u];if(!p)continue;let m={w:p.w*i,h:p.h*i,baseline:p.baseline*i,strokeWidth:t*.06,commands:p.commands},d=n-m.baseline-a;s.push({shape:m,x:c,y:d}),d<l&&(l=d),c+=m.w+o}return{placed:s,right:c,top:l}}function Yn(r,{shape:t,x:e,y:n},o,s){r.drawPath(t.commands,{stroke:s,strokeWidth:t.strokeWidth},{x:o.x+e,y:o.y+n,scaleX:t.w,scaleY:t.h})}function Il(r){let t=r.replace(/^[a-g]/,c=>c.toUpperCase()),e=be(t,0,t.length,!1);if(!e||e.next!==t.length)return null;let n=Et[e.name];if(n===void 0)return null;let o=yr(e.acc??"",!1),i=((e.absOctave?e.octave??4:4+(e.octave??0))+1)*12+n+o;if(!Number.isSafeInteger(i))return null;let a=Object.keys(Et).filter(c=>Et[c]===(i%12+12)%12&&/^[A-G]/.test(c));return(o<0?a.at(-1):a[0])+(Math.floor(i/12)-1)}var xr=class extends B{static def={name:["key","1"],description:"\u8BBE\u7F6E\u65F6\u95F4\u7EBF\u4E0A\u7684 1= \u8C03\u6027\u57FA\u51C6",details:`~~~jpfun
|
|
27
32
|
1 ^ @key(F#3)
|
|
28
33
|
~~~
|
|
29
|
-
\u8C03\u6027\u6CBF\u65F6\u95F4\u7EBF\u5F71\u54CD\u540E\u7EED\u6570\u5B57\u97F3\u540D\u3002\u8C31\u9762\u8BB0\u53F7\u663E\u793A\u97F3\u540D\u4E0E\u5347\u964D\u53F7\uFF0C\u7701\u7565\u516B\u5EA6\uFF1B\u901A\u5E38\u7528 \`^\` \u53E0\u5728\u97F3\u7B26\u4E0A\u65B9\u3002`,allowExtraArgs:!1,args:[{name:"tonality",description:"`1=` \u7684\u97F3\u9AD8\u57FA\u51C6\uFF0C\u5982 `C4`\u3001`F#3`",type:"string",default:null},{name:"size",description:"\u8C03\u6027\u8BB0\u53F7\u5B57\u53F7",type:"length",default:{value:1,unit:"em"}}]};tonality;size;font;displayName;displayAcc;constructor(t,e,n,o=null){super(t,o);let[i
|
|
30
|
-
@meter(6, 8)
|
|
31
|
-
~~~
|
|
32
|
-
\u8BBE\u7F6E \`6/8\` \u62CD\u53F7\uFF1A\u6BCF\u5C0F\u8282\u542B\u516D\u4E2A\u516B\u5206\u97F3\u7B26\u7684\u65F6\u503C\u3002
|
|
33
|
-
\u5206\u5B50\u6216\u5206\u6BCD\u4E3A 0 \u65F6\u8868\u793A\u6563\u677F\u3002`,allowExtraArgs:!1,args:[{name:"num",description:"\u62CD\u53F7\u5206\u5B50\uFF0C\u6BCF\u5C0F\u8282\u5305\u542B\u7684\u5355\u4F4D\u62CD\u6570",type:"number",default:null},{name:"den",description:"\u62CD\u53F7\u5206\u6BCD\uFF0C\u4EE5\u51E0\u5206\u97F3\u7B26\u4E3A\u5355\u4F4D\u62CD",type:"number",default:null},{name:"size",description:"\u62CD\u53F7\u5B57\u53F7",type:"length",default:{value:.7,unit:"em"}}]};numerator;denominator;measureDuration;size;strict;font;constructor(t,e,n,o=null){super(t,o);let[i,r,a]=this.getArgValue(e,n);if(this.font=n.variables.numberfont,!Number.isSafeInteger(i)||!Number.isSafeInteger(i*4)||i<0||!Number.isSafeInteger(r)||r<0){let c="@meter \u7684\u5206\u5B50\u548C\u5206\u6BCD\u5FC5\u987B\u662F\u975E\u8D1F\u6574\u6570";if(n.variables.strict)throw new k("E_METER_INVALID",c,t);n.diagnostics.push(new q("W_METER_INVALID",`${c}\uFF0C\u5DF2\u56DE\u843D\u4E3A 4/4`,t)),i=r=4}this.numerator=i,this.denominator=r,i!==0&&r!==0&&(this.measureDuration=new F(i*4,r)),this.size=n.length2px(a),this.strict=n.variables.strict}loweringEnter(){return[new ns(this)]}static loweringFinalize=t=>{let e=new F,n=new F,o=null,i=!1,r=0,a=(c,l)=>{if(!(!o?.measureDuration||c.equals(e))){if(n.copyFrom(c).sub(e),!n.equals(o.measureDuration)&&(i||n.compare(o.measureDuration)>0)){let p=`\u5C0F\u8282\u65F6\u957F\u4E3A ${n} QN\uFF0C\u4E0D\u6EE1\u8DB3 ${o.numerator}/${o.denominator} \u62CD\u53F7`,f={start:r,end:l};if(o.strict)throw new k("E_METER_MISMATCH",p,f);t.diagnostics.push(new q("W_METER_MISMATCH",p,f))}e.copyFrom(c)}};for(let c of t.columns){let l=c[0].t;for(let f of c){let u=ts.get(f);u&&(a(l,u.start),o=u.meter,e.copyFrom(l),r=u.end)}let p=c.find(f=>f.mergeKey===mt);p&&(a(l,p.ast.sourceSpan.end),r=p.ast.sourceSpan.end,i=!0)}if(o){let c=t.columns.at(-1)?.at(-1)?.ast.sourceSpan??o.sourceSpan;a(t.duration,c.end)}};toString(){return`@meter(${this.numerator}, ${this.denominator})`}},On=es,ns=class extends tt{style;numeratorBaseline=0;denominatorBaseline=0;lineY=0;lineHeight=0;constructor(t){super(),this.ast=t,this.style={fontSize:t.size,fontFamily:t.font,textAlign:"center",fill:"#000"},this.initLayoutBox()}onTimeState(t){t.meter=this.ast.measureDuration,Yc(t,this,this.ast)}emitPlayback(t){this.ast.measureDuration&&t.emit({kind:"time-signature",at:t.start,numerator:this.ast.numerator,denominator:this.ast.denominator})}prepareLayout(t){if(!this.ast.measureDuration){this.box.w=this.ast.size*on.w/on.h,this.box.h=this.ast.size,this.box.anchor=this.box.w/2,this.box.visualAxis=this.box.h/2;return}let e=t.textMeasurer.measureText(String(this.ast.numerator),this.style),n=t.textMeasurer.measureText(String(this.ast.denominator),this.style),o=this.ast.size*.08,i=this.ast.size*.08;this.lineHeight=Math.max(1,this.ast.size*.06),this.numeratorBaseline=e.baseline,this.lineY=e.h+o,this.denominatorBaseline=this.lineY+this.lineHeight+o+n.baseline,this.box.w=Math.max(e.w,n.w)+i*2,this.box.h=this.lineY+this.lineHeight+o+n.h,this.box.anchor=this.box.w/2,this.box.visualAxis=this.lineY+this.lineHeight/2}paint(t){if(!this.ast.measureDuration){Rn(t,Jo,on,this.box,this.ast.size/on.h);return}let e=this.box.x+this.box.anchor;t.drawText(String(this.ast.numerator),e,this.box.y+this.numeratorBaseline,this.style),t.drawRect(this.box.x,this.box.y+this.lineY,this.box.w,this.lineHeight,{fill:"#000"}),t.drawText(String(this.ast.denominator),e,this.box.y+this.denominatorBaseline,this.style)}};var Xc=[{op:"M",x:3.864,y:8.5},{op:"Q",cx:3.864,cy:9.228,x:3.5,y:9.76},{op:"Q",cx:3.136,cy:10.292,x:2.555,y:10.586},{op:"Q",cx:1.974,cy:10.88,x:1.302,y:10.88},{op:"Q",cx:.826,cy:10.88,x:.413,y:10.621},{op:"Q",cx:0,cy:10.362,x:0,y:9.844},{op:"Q",cx:0,cy:9.34,x:.364,y:8.899},{op:"Q",cx:.728,cy:8.458,x:1.288,y:8.185},{op:"Q",cx:1.848,cy:7.912,x:2.422,y:7.912},{op:"Q",cx:2.968,cy:7.912,x:3.304,y:8.094},{op:"L",x:3.304,y:0},{op:"L",x:3.864,y:0},{op:"Z"}];function Tr(s){let t=s/11;return{w:3.864*t,h:10.88*t,stemCenterX:(3.304+3.864)/2*t,commands:Xc,scale:t}}var os=class extends ${static def={name:["tempo"],description:"\u8BBE\u7F6E\u65F6\u95F4\u7EBF\u4E0A\u7684\u901F\u5EA6",details:`~~~jpfun
|
|
34
|
+
\u8C03\u6027\u6CBF\u65F6\u95F4\u7EBF\u5F71\u54CD\u540E\u7EED\u6570\u5B57\u97F3\u540D\u3002\u8C31\u9762\u8BB0\u53F7\u663E\u793A\u97F3\u540D\u4E0E\u5347\u964D\u53F7\uFF0C\u7701\u7565\u516B\u5EA6\uFF1B\u901A\u5E38\u7528 \`^\` \u53E0\u5728\u97F3\u7B26\u4E0A\u65B9\u3002`,allowExtraArgs:!1,args:[{name:"tonality",description:"`1=` \u7684\u97F3\u9AD8\u57FA\u51C6\uFF0C\u5982 `C4`\u3001`F#3`",type:"string",default:null},{name:"size",description:"\u8C03\u6027\u8BB0\u53F7\u5B57\u53F7",type:"length",default:{value:1,unit:"em"}}]};tonality;size;font;displayName;displayAcc;constructor(t,e,n,o=null){super(t,o);let[s,i]=this.getArgValue(e,n);this.font=n.variables.numberfont,this.tonality=s,this.size=n.length2px(i);let a=Il(s);if(this.tonality=a??Qe,a!==s&&a!==`${s}4`){if(n.variables.strict)throw new k("E_KEY_TONALITY",'@key \u65E0\u6CD5\u89E3\u6790\u8C03\u6027 "{tonality}"',t,{tonality:s});n.diagnostics.push(new K("W_KEY_TONALITY",'@key \u7684\u8C03\u6027 "{input}" \u4E0D\u662F\u89C4\u8303\u5199\u6CD5\uFF0C\u5DF2\u81EA\u52A8\u5207\u6362\u5230 {tonality}',t,{input:s,tonality:this.tonality}))}this.displayName=this.tonality[0],this.displayAcc=this.tonality[1]==="#"||this.tonality[1]==="b"?this.tonality[1]:""}loweringEnter(){return[new br(this)]}toString(){return`@1(${this.tonality})`}},qn=xr,gr="1=",br=class extends tt{accidentals=[];nameX=0;textBaselineY=0;style;constructor(t){super(),this.ast=t,this.style={fontSize:t.size,fontFamily:t.font,fill:"#000"},this.initLayoutBox()}onTimeState(t){t.keySignature=this.ast.tonality}prepareLayout(t){let e=this.ast.size,n=this.style,o=t.textMeasurer.measureText(gr,n),s=t.textMeasurer.measureText(this.ast.displayName,n),i=e*.02,{placed:a,right:c,top:l}=Kn(this.ast.displayAcc,e,o.w,o.baseline,i);this.accidentals=a;let u=-l;for(let p of a)p.y+=u;this.nameX=c,this.textBaselineY=u+o.baseline,this.box.w=c+s.w,this.box.h=u+Math.max(o.h,s.h),this.box.anchor=t.textMeasurer.measureText(gr[0],n).w/2,this.box.visualAxis=this.box.h/2}paint(t){let e=this.style;t.drawText(gr,this.box.x,this.box.y+this.textBaselineY,e);for(let n of this.accidentals)Yn(t,n,this.box,"#000");t.drawText(this.ast.displayName,this.box.x+this.nameX,this.box.y+this.textBaselineY,e)}};var Bl=[{op:"M",x:3.864,y:8.5},{op:"Q",cx:3.864,cy:9.228,x:3.5,y:9.76},{op:"Q",cx:3.136,cy:10.292,x:2.555,y:10.586},{op:"Q",cx:1.974,cy:10.88,x:1.302,y:10.88},{op:"Q",cx:.826,cy:10.88,x:.413,y:10.621},{op:"Q",cx:0,cy:10.362,x:0,y:9.844},{op:"Q",cx:0,cy:9.34,x:.364,y:8.899},{op:"Q",cx:.728,cy:8.458,x:1.288,y:8.185},{op:"Q",cx:1.848,cy:7.912,x:2.422,y:7.912},{op:"Q",cx:2.968,cy:7.912,x:3.304,y:8.094},{op:"L",x:3.304,y:0},{op:"L",x:3.864,y:0},{op:"Z"}];function ta(r){let t=r/11;return{w:3.864*t,h:10.88*t,stemCenterX:(3.304+3.864)/2*t,commands:Bl,scale:t}}var Sr=class extends B{static def={name:["tempo"],description:"\u8BBE\u7F6E\u65F6\u95F4\u7EBF\u4E0A\u7684\u901F\u5EA6",details:`~~~jpfun
|
|
34
35
|
@tempo(96)
|
|
35
36
|
~~~
|
|
36
|
-
\u901F\u5EA6\u4ECE\u5F53\u524D\u65F6\u95F4\u4F4D\u7F6E\u8D77\u751F\u6548\uFF1B\u7528 \`1 ^ @tempo(96)\` \u53EF\u5C06\u8BB0\u53F7\u53E0\u5728\u97F3\u7B26\u4E0A\u65B9`,allowExtraArgs:!1,args:[{name:"bpm",description:"\u6BCF\u5206\u949F\u56DB\u5206\u97F3\u7B26\u6570",type:"number",default:null},{name:"size",description:"\u901F\u5EA6\u8BB0\u53F7\u5B57\u53F7",type:"length",default:{value:1,unit:"em"}}]};bpm;size;font;constructor(t,e,n,o=null){super(t,o);let[i
|
|
37
|
-
|
|
38
|
-
~~~
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
`;)t++;return t}function Qc({columns:s,rows:t,start:e,end:n,X:o,fixed:i,options:r},a){ve(s.slice(e,n+1),t,o.subarray(e,n+1),i.subarray(e,n),1/0,r);let c=1/0,l=-1/0;for(let p=e+1;p<n;p++)for(let f=0;f<t;f++)c=Math.min(c,o[p]-s[p][f].WL),l=Math.max(l,o[p]+s[p][f].WR);a&&c<=l?(o[e]=c,o[n]=l):o[n]=o[e]}var Bn=class extends tt{members=[];slots=[];titleBottom=0;sideExtents={left:null,right:null};constructor(t){super(),this.ast=t,this.initLayoutBox()}validateDuration(){for(let t of this.members)if(!t.T.isZero())throw new k("E_HEAD_NONZERO_DURATION","@head \u7684\u5185\u5BB9\u5FC5\u987B\u5168\u90E8\u4E3A\u96F6\u65F6\u957F",t.ast.sourceSpan)}prepareLayout(){this.box.w=this.box.h=this.box.anchor=this.box.visualAxis=0}prepareHorizontal(t){this.slots.length>0&&this.prepareHead(t)}onPlaced(){this.slots.length>0&&this.alignHead()}onTemporal(t){this.members.push(t)}createTracks(t){let{name:e,owner:n}=t;return{laneKey:`head/rows/${n.sourceSpan.start}/${e}`,hostIndex:null,measure:o=>{let i,r;e==="center"&&(this.titleBottom=0);let a=o.map(c=>{if(!c)return null;let l=r===void 0?0:r+n.gap-c.top;return r===void 0&&e==="center"&&(this.titleBottom=c.bottom),i??=l+c.top,r=l+c.bottom,{offset:l,extent:c}});return e!=="center"&&(this.sideExtents[e]=i===void 0||r===void 0?null:{top:i,bottom:r}),a},place:e==="center"?void 0:()=>{let o=this.sideExtents[e];if(!o)return this.titleBottom;let{left:i,right:r}=this.sideExtents,a=i?i.bottom-i.top:0,c=r?r.bottom-r.top:0;return this.titleBottom+Math.max(a,c)-o.bottom}}}prepareHead(t){if(this.members.some(i=>X(i)&&i.layoutLine!==t.index))throw new k("E_HEAD_INTERNAL_BREAK","@head \u7684\u5185\u5BB9\u4E0D\u80FD\u8DE8\u8C31\u9762\u884C",this.ast.owner.sourceSpan);let[e,n,o]=this.slots;e.start.springConfig.alpha_L=0,o.end.springConfig.alpha_R=0,this.stretch(n.start,"L"),this.stretch(n.end,"R");for(let i of this.slots)t.registerHorizontalLayoutHook(i.start,i.end,r=>Qc(r,i===n))}alignHead(){let t=new Map;for(let o of this.members){if(!X(o))continue;let i=this.sideCellOf(o.ast);if(!i)continue;let r=t.get(i);r?r.push(o):t.set(i,[o])}let[e,,n]=this.slots;this.packRows(e.ast,e.start.box.x,t),this.packRows(n.ast,n.end.box.x,t)}stretch(t,e){let n=e==="L"?"alpha_L":"alpha_R",o=e==="L"?"beta_L":"beta_R";t.springConfig[n]=t.springConfig[n]*vr,t.springConfig[o]=t.springConfig[o]*3/vr}packRows(t,e,n){let o=this.ast.owner.size*Zc,i=t.name==="left",r=i?1:-1;for(let a of t.rows){let c=a instanceof dt?a.content:[a],l=e;for(let p=i?0:c.length-1;p>=0&&p<c.length;p+=r){let f=n.get(c[p]);if(!f)continue;let u=1/0,h=-1/0;for(let y of f)u=Math.min(u,y.box.x),h=Math.max(h,y.box.x+y.box.w);let d=l-(i?u:h);for(let y of f)y.box.x+=d;for(let y of f)y.onPlaced?.();l+=r*(h-u+o)}}}sideCellOf(t){let e=t;for(;e.parent;){let n=e.parent,o=n instanceof me?n:n instanceof dt&&n.parent instanceof me?n.parent:null;if(o?.owner===this.ast.owner)return o.name==="center"?null:e;e=n}return null}},me=class extends Tt{owner;name;rows;constructor(t,e,n,o){super(t,e),this.owner=e,this.name=n,this.rows=o;for(let i of this.rows)i.parent=this}get size(){return this.owner.size}get children(){return this.rows}timeFlowModel(t){if(this.rows.length===0)return null;let e=t.getTemporalNodes(this.owner.slots[0])[0];return{mode:"parallel",children:this.rows,tracks:e.createTracks(this)}}loweringEnter(t){let e=new Bn(this);return this.name==="left"&&t.beginLoweringGroup(this.owner,e),[e]}loweringExit(){return[new Bn(this)]}addRow(t){t.parent=this,this.rows.push(t)}},as=class s extends ${static def={name:["head"],description:"\u5DE6\u3001\u4E2D\u3001\u53F3\u4E09\u533A\u5E03\u5C40",details:"\u5E38\u7528\u4E8E\u8C31\u5934\uFF1A\n~~~jpfun\n@head(left={{@key(C) @meter(4,4)}},\n center={@text(\u6807\u9898)}, right={@text(\u4F5C\u8005)})\n~~~\n**\u7B80\u5199**\uFF1A\u76F8\u90BB\u7684 `H.*:` \u884C\u5408\u5E76\u4E3A\u540C\u4E00\u4E2A\u8C31\u5934\uFF0C\u6BCF\u6761\u58F0\u660E\u751F\u6210\u6240\u5728\u533A\u7684\u4E00\u884C\uFF1B\u7A7A\u884C\u6216\u666E\u901A\u5185\u5BB9\u7ED3\u675F\u7EC4\u5408\n~~~jpfun\nH.title: \u6807\u9898\nH.subtitle: \u526F\u6807\u9898\nH.author: \u4F5C\u8005\nH.signature: 1=C 4/4\nH.tempo: 94\n~~~\n`title` / `subtitle` \u5C45\u4E2D\uFF0C\u5206\u522B\u9884\u8BBE\u5927\u3001\u5C0F\u5B57\u53F7\uFF1B`author` \u5C0F\u5B57\u53F7\u53F3\u5BF9\u9F50\uFF1B`signature` \u548C `tempo` \u653E\u5728\u5DE6\u533A\u3002`H.left:`\u3001`H.center:`\u3001`H.right:` \u53EF\u76F4\u63A5\u5199\u5BF9\u5E94\u533A\u7684\u96F6\u65F6\u957F\u5185\u5BB9\u3002\u4EE5 `@` \u6216 `{` \u5F00\u5934\u7684\u503C\u6309 jpFun \u89E3\u6790\uFF0C\u5176\u4F59\u6309\u5B57\u6BB5\u7684\u6587\u672C\u89C4\u5219\u5904\u7406\u3002",allowExtraArgs:!1,args:[{name:"left",description:"\u5DE6\u533A\u96F6\u65F6\u957F\u5185\u5BB9\uFF0C\u5982\u8C03\u6027\u3001\u62CD\u53F7\u4E0E\u901F\u5EA6\u8BB0\u53F7",type:"content",default:""},{name:"center",description:"\u4E2D\u533A\u96F6\u65F6\u957F\u5185\u5BB9\uFF0C\u5982\u6807\u9898\u4E0E\u526F\u6807\u9898",type:"content",default:""},{name:"right",description:"\u53F3\u533A\u96F6\u65F6\u957F\u5185\u5BB9\uFF0C\u5982\u4F5C\u8005\u4E0E\u7F72\u540D",type:"content",default:""},{name:"gap",description:"\u6BCF\u4E2A\u533A\u5185\u76F8\u90BB\u884C\u7684\u5782\u76F4\u95F4\u8DDD",type:"length",default:{value:Cr,unit:"px"}}]};slots;size;gap;createdBySugar=!1;get children(){return this.slots}timeFlowModel(){return{mode:"sequence",children:this.slots}}static deSugarAtom(t,e,n){if(t[e]!=="H"||t[e+1]!==".")return null;let o=e+2;for(;o<n&&t[o]>="a"&&t[o]<="z";)o++;let i=t.slice(e+2,o);if(!Object.hasOwn(Lr,i)||t[o]!==":")return null;o++;let r=Mr(t,o,n),a=Yt(t,o,r);return{next:t[a]==="@"||t[a]==="{"?o:r,node:{kind:"sugar",data:{class:s,field:i},span:{start:e,end:o}}}}static deSugarRelation(t,e,n){let o=e[n++];if(o.data?.class!==s)return null;let i=o.data.field,r=n;for(;r<e.length;r++){let g=e[r];if(typeof g=="number"&&(t.source[g]==="\r"||t.source[g]===`
|
|
42
|
-
`)||typeof g!="number"&&g.kind==="sugar"&&g.data?.class===s)break}let a=e[r],c;if(typeof a=="number")c=a;else if(a)c=a.span.start;else if(r>n){let g=e[r-1];c=typeof g=="number"?g+1:g.span.end}else c=Mr(t.source,o.span.end);let l=Yt(t.source,o.span.end,c),p=en(t.source,c-1,l),f={start:l,end:Math.max(l,p+1)};if(f.start>=f.end)throw new k("E_HEAD_EMPTY_DECLARATION",`H.${i}: \u540E\u5FC5\u987B\u6709\u5185\u5BB9`,o.span);let u=t.source.slice(f.start,f.end).trim(),h;if(u.startsWith("@")||u.startsWith("{")){let g=new _t(t);g.makeNodes(e.slice(n,r)),h=g.nodes}let d=t.nodes.at(-1),y=d instanceof s&&d.createdBySugar?d:new s(o.span,new Map,t,null);if(y.createdBySugar=!0,y.slots.find(g=>g.name===Lr[i]).addRow(s.parseSugarRow(t,i,f,u,h)),y.sourceSpan.end=f.end,y!==d&&t.pushNode(y),typeof a!="number")return r;let m=r+1;if(t.source[a]==="\r"){let g=e[m];typeof g=="number"&&t.source[g]===`
|
|
43
|
-
`&&m++}return m}static parseSugarRow(t,e,n,o,i){if(i!==void 0)return Dn(n,i);if(e==="signature"){let c=/^(1\s*=\s*(\S+))\s+((\d+)\s*\/\s*(\d+))$/.exec(o);if(!c)throw new k("E_HEAD_INVALID_SIGNATURE","H.signature \u7684\u683C\u5F0F\u5E94\u4E3A 1=C 4/4",n);let l={start:n.start,end:n.start+c[1].length},p={start:n.end-c[3].length,end:n.end};return Dn(n,[new In(l,new Map([["tonality",c[2]]]),t,null),new On(p,new Map([["num",Number(c[4])],["den",Number(c[5])]]),t,null)])}if(e==="tempo"){let c=Number(o);if(!Number.isFinite(c)||c<=0)throw new k("E_HEAD_INVALID_TEMPO","H.tempo \u540E\u5FC5\u987B\u662F\u6B63\u6570",n);return Dn(n,[new $n(n,new Map([["bpm",c]]),t,null)])}let r=new Map([[0,o]]),a=qc[e];return a&&(r.set("size",{value:a[0],unit:"em"}),r.set("align",a[1])),Dn(n,[new Pn(n,r,t,null)])}constructor(t,e,n,o=null){super(t,o),this.size=n.variables.fontsize,this.gap=n.length2px(this.getArgValue(e,n)[3]);let i=(r,a)=>{let c=e.get(r)??e.get(a);return c instanceof Tt?c instanceof dt?c.content:[c]:[]};this.slots=[new me(t,this,"left",i("left",0)),new me(t,this,"center",i("center",1)),new me(t,this,"right",i("right",2))]}loweringExit(t){let e=t.endLoweringGroup(this);e.slots=this.slots.map(n=>{let[o,i]=t.getTemporalNodes(n);return{ast:n,start:o,end:i}}),e.slots[2].end.onTimeState=()=>e.validateDuration();for(let n of e.members)if((n.addon?.breakBefore??0)>0)throw new k("E_HEAD_INTERNAL_BREAK","@head \u7684\u5185\u90E8\u4E0D\u80FD\u6362\u884C\u6216\u6362\u9875\uFF1B\u7B2C\u4E00\u5C42\u5185\u5BB9\u5DF2\u7ECF\u8868\u793A\u89C6\u89C9\u884C",n.ast.sourceSpan);return[]}toString(t){let e=this.slots.filter(n=>n.rows.length>0).map(n=>{let o=n.rows.map(i=>` ${i.toString(t).replaceAll(`
|
|
37
|
+
\u901F\u5EA6\u4ECE\u5F53\u524D\u65F6\u95F4\u4F4D\u7F6E\u8D77\u751F\u6548\uFF1B\u7528 \`1 ^ @tempo(96)\` \u53EF\u5C06\u8BB0\u53F7\u53E0\u5728\u97F3\u7B26\u4E0A\u65B9`,allowExtraArgs:!1,args:[{name:"bpm",description:"\u6BCF\u5206\u949F\u56DB\u5206\u97F3\u7B26\u6570",type:"number",default:null},{name:"size",description:"\u901F\u5EA6\u8BB0\u53F7\u5B57\u53F7",type:"length",default:{value:1,unit:"em"}}]};bpm;size;font;constructor(t,e,n,o=null){super(t,o);let[s,i]=this.getArgValue(e,n);this.bpm=s,this.size=n.length2px(i),this.font=n.variables.font}loweringEnter(){return[new wr(this)]}toString(){return`@tempo(${this.bpm}, size=${this.size}px)`}},Zn=Sr,wr=class extends tt{glyph;text;style;glyphY=0;textX=0;textBaselineY=0;constructor(t){super(),this.ast=t,this.glyph=ta(t.size),this.text=`= ${t.bpm}`,this.style={fontSize:t.size,fontFamily:t.font,fill:"#000"},Number.isFinite(t.bpm)&&t.bpm>0&&(this.playbackState={bpm:t.bpm}),this.initLayoutBox()}onTimeState(t){let e=this.playbackState?.bpm;e!==void 0&&(t.bpm=e)}prepareLayout(t){let e=this.glyph,n=t.textMeasurer.measureText(this.text,this.style),o=Math.max(0,e.h-n.baseline);this.textX=e.w+this.ast.size*.26,this.textBaselineY=o+n.baseline,this.glyphY=this.textBaselineY-e.h,this.box.w=this.textX+n.w,this.box.h=o+n.h,this.box.anchor=e.stemCenterX,this.box.visualAxis=o+n.h/2}paint(t){t.drawPath(this.glyph.commands,{fill:"#000"},{x:this.box.x,y:this.box.y+this.glyphY,scaleX:this.glyph.scale,scaleY:this.glyph.scale}),t.drawText(this.text,this.box.x+this.textX,this.box.y+this.textBaselineY,this.style)}};var Tr=class r extends B{static def={name:["text"],description:"\u6587\u672C\u6807\u8BB0",details:'~~~jpfun\n@text(\u8FDB\u5165\u4E3B\u9898, size=0.8em, align=center)\n~~~\n**\u7B80\u5199**\uFF1A\u76F4\u63A5\u5199\u53CC\u5F15\u53F7\u6587\u672C\uFF0C\u5982 `"\u8FDB\u5165\u4E3B\u9898"`\uFF1B\u53EF\u8DE8\u884C\uFF0C\u53CC\u5F15\u53F7\u987B\u914D\u5BF9\u3002\n\n\u652F\u6301 `*\u659C\u4F53*`\u3001`**\u7C97\u4F53**`\u3001`_\u4E0B\u5212\u7EBF_`\u3001`^\u4E0A\u6807^`\uFF08\u518D\u6B21\u51FA\u73B0\u5373\u5173\u95ED\uFF0C\u4E0D\u5173\u95ED\u5219\u4E00\u76F4\u751F\u6548\uFF1B\u5199 `\\*`\u3001`\\_`\u3001`\\^` \u663E\u793A\u539F\u5B57\u7B26\uFF09\u3002\u652F\u6301 `\\uE050` \u5F62\u5F0F\u7684 Unicode \u8F6C\u4E49\uFF1B\u53CD\u659C\u6760\u5199 `\\\\`\u3002',allowExtraArgs:!1,args:[{type:"string",description:"\u6587\u672C\u5185\u5BB9\uFF0C\u53EF\u76F4\u63A5\u6362\u884C\uFF1B\u542B\u9017\u53F7\u7B49\u6B67\u4E49\u5B57\u7B26\u65F6\u9700\u52A0\u5F15\u53F7",default:null},{name:"size",description:"\u6587\u672C\u5B57\u53F7",type:"length",default:{value:.8,unit:"em"}},{name:"lineheight",description:"\u76F8\u5BF9\u81EA\u8EAB\u5B57\u53F7\u7684\u884C\u9AD8\u500D\u6570",type:"number",default:1.25},{name:"align",description:"\u6587\u672C\u5BF9\u9F50\u65B9\u5F0F\uFF1A`left`\u3001`center` \u6216 `right`",type:"string",default:"left"},{name:"font",description:"\u6587\u672C\u5B57\u4F53\uFF0C\u7A7A\u503C\u6CBF\u7528\u5F53\u524D\u5B57\u4F53\u8BBE\u7F6E",type:"string",default:""}]};static deSugarAtom(t,e,n){if(t[e]!=='"')return null;let o=$t(t,e,n);if(o<0)return null;let s={kind:"sugar",data:r,span:{start:e,end:o+1},syntaxKind:"string"};return{next:o+1,node:s}}static deSugarRelation(t,e,n){let o=e[n];return o.data!==r?null:(t.pushNode(new r(o.span,new Map([[0,t.parseArgWithType(o.span,"string")]]),t,null)),n+1)}text;size;lineHeight;align;font;constructor(t,e,n,o=null){super(t,o);let[s,i,a,c,l]=this.getArgValue(e,n);if(this.font=l||n.variables.font,c!=="left"&&c!=="center"&&c!=="right")throw new k("E_TEXT_INVALID_ALIGN","@text \u7684 align \u53C2\u6570\u5FC5\u987B\u662F 'left'\u3001'center' \u6216 'right'",t);this.text=s.replace(/\r?\n/g,`
|
|
38
|
+
`),this.size=n.length2px(i),this.lineHeight=a,this.align=c}loweringEnter(){return[new Lr(this)]}toString(){return`@text(${lt(this.text)}, size=${this.size}px, lineheight=${this.lineHeight}, align=${this.align}, font=${lt(this.font)})`}},Qn=Tr,Lr=class extends tt{preparedLines=[];constructor(t){super(),this.ast=t,this.mergeKey=zt,this.initLayoutBox()}prepareLayout(t){let{text:e,align:n,size:o,font:s,lineHeight:i}=this.ast,a={fontSize:o,fontFamily:s,fill:"#000",textAlign:n};this.preparedLines=lr(e).map(u=>Yt(u,a,t.textMeasurer));let c=this.preparedLines[0],l=Math.max(...this.preparedLines.map(u=>u.w));if(this.box.w=l,this.box.h=(this.preparedLines.length-1)*i*o+c.h,this.box.visualAxis=this.box.h/2,n==="center")this.box.anchor=l/2;else{let u=n==="right"?-1:0,p=c.runs.at(u),m=p?t.textMeasurer.measureText([...p.text].at(u),p.style).w/2:0;this.box.anchor=n==="right"?l-m:m}}paint(t){let{align:e,lineHeight:n,size:o}=this.ast,s=this.box.x+(e==="center"?this.box.w/2:e==="right"?this.box.w:0),i=this.box.y+this.preparedLines[0].baseline;for(let a of this.preparedLines)oe(t,a,s,i),i+=n*o}};var ea={title:"center",subtitle:"center",author:"right",signature:"left",tempo:"left",left:"left",center:"center",right:"right"},Dl={title:[2,"center"],subtitle:[.85,"center"],author:[.8,"right"]},Vl=.25,na=5,oa=1e4;function Jn(r,t){return t.length===1&&t[0]instanceof Nt?t[0]:new Nt(r,t)}function ra(r,t,e=r.length){for(;t<e&&r[t]!=="\r"&&r[t]!==`
|
|
39
|
+
`;)t++;return t}function Hl({columns:r,rows:t,start:e,end:n,X:o,fixed:s,options:i},a){_e(r.slice(e,n+1),t,o.subarray(e,n+1),s.subarray(e,n),1/0,i);let c=1/0,l=-1/0;for(let u=e+1;u<n;u++)for(let p=0;p<t;p++)c=Math.min(c,o[u]-r[u][p].WL),l=Math.max(l,o[u]+r[u][p].WR);a&&c<=l?(o[e]=c,o[n]=l):o[n]=o[e]}var to=class extends tt{members=[];slots=[];titleBottom=0;aligned=!1;sideExtents={left:null,right:null};constructor(t){super(),this.ast=t,this.initLayoutBox()}validateDuration(){for(let t of this.members)if(!t.T.isZero())throw new k("E_HEAD_NONZERO_DURATION","@head \u7684\u5185\u5BB9\u5FC5\u987B\u5168\u90E8\u4E3A\u96F6\u65F6\u957F",t.ast.sourceSpan)}prepareLayout(){this.box.w=this.box.h=this.box.anchor=this.box.visualAxis=0,this.aligned=!1}prepareHorizontal(t){this.slots.length>0&&this.prepareHead(t)}onPlaced(){this.slots.length>0&&!this.aligned&&(this.aligned=!0,this.alignHead())}onTemporal(t){this.members.push(t)}createTracks(t){let{name:e,owner:n}=t;return{laneKey:`head/rows/${n.sourceSpan.start}/${e}`,hostIndex:null,measure:o=>{let s,i;e==="center"&&(this.titleBottom=0);let a=o.map(c=>{if(!c)return null;let l=i===void 0?0:i+n.gap-c.top;return i===void 0&&e==="center"&&(this.titleBottom=c.bottom),s??=l+c.top,i=l+c.bottom,{offset:l,extent:c}});return e!=="center"&&(this.sideExtents[e]=s===void 0||i===void 0?null:{top:s,bottom:i}),a},place:e==="center"?void 0:()=>{let o=this.sideExtents[e];if(!o)return this.titleBottom;let{left:s,right:i}=this.sideExtents,a=s?s.bottom-s.top:0,c=i?i.bottom-i.top:0;return this.titleBottom+Math.max(a,c)-o.bottom}}}prepareHead(t){if(this.members.some(s=>W(s)&&s.layoutLine!==t.index))throw new k("E_HEAD_INTERNAL_BREAK","@head \u7684\u5185\u5BB9\u4E0D\u80FD\u8DE8\u8C31\u9762\u884C",this.ast.owner.sourceSpan);let[e,n,o]=this.slots;e.start.springConfig.alpha_L=0,o.end.springConfig.alpha_R=0,this.stretch(n.start,"L"),this.stretch(n.end,"R");for(let s of this.slots)t.registerHorizontalLayoutHook(s.start,s.end,i=>Hl(i,s===n))}alignHead(){let t=new Map;for(let o of this.members){if(!W(o))continue;let s=this.sideCellOf(o.ast);if(!s)continue;let i=t.get(s);i?i.push(o):t.set(s,[o])}let[e,,n]=this.slots;this.packRows(e.ast,e.start.box.x-(e.start.placementOffset?.x??0),t),this.packRows(n.ast,n.end.box.x,t)}stretch(t,e){let n=e==="L"?"alpha_L":"alpha_R",o=e==="L"?"beta_L":"beta_R";t.springConfig[n]=t.springConfig[n]*oa,t.springConfig[o]=t.springConfig[o]*3/oa}packRows(t,e,n){let o=this.ast.owner.size*Vl,s=t.name==="left",i=s?1:-1;for(let a of t.rows){let c=a instanceof Nt?a.content:[a],l=e;for(let u=s?0:c.length-1;u>=0&&u<c.length;u+=i){let p=n.get(c[u]);if(!p)continue;let m=1/0,d=-1/0;for(let x of p)m=Math.min(m,x.box.x),d=Math.max(d,x.box.x+x.box.w);let f=l-(s?m:d);for(let x of p)x.box.x+=f;for(let x of p)x.onPlaced?.();l+=i*(d-m+o)}}}sideCellOf(t){let e=t;for(;e.parent;){let n=e.parent,o=n instanceof Se?n:n instanceof Nt&&n.parent instanceof Se?n.parent:null;if(o?.owner===this.ast.owner)return o.name==="center"?null:e;e=n}return null}},Se=class extends Ht{constructor(e,n,o,s){super(e,n);this.owner=n;this.name=o;this.rows=s;for(let i of this.rows)i.parent=this}owner;name;rows;get size(){return this.owner.size}get children(){return this.rows}timeFlowModel(e){if(this.rows.length===0)return null;let n=e.getTemporalNodes(this.owner.slots[0])[0];return{mode:"parallel",children:this.rows,tracks:n.createTracks(this)}}loweringEnter(e){let n=new to(this);return this.name==="left"&&e.beginLoweringGroup(this.owner,n),[n]}loweringExit(){return[new to(this)]}addRow(e){e.parent=this,this.rows.push(e)}},Ar=class r extends B{static def={name:["head"],description:"\u5DE6\u3001\u4E2D\u3001\u53F3\u4E09\u533A\u5E03\u5C40",details:"\u5E38\u7528\u4E8E\u8C31\u5934\uFF1A\n~~~jpfun\n@head(left={{@key(C) @meter(4,4)}},\n center={@text(\u6807\u9898)}, right={@text(\u4F5C\u8005)})\n~~~\n**\u7B80\u5199**\uFF1A\u76F8\u90BB\u7684 `H.*:` \u884C\u5408\u5E76\u4E3A\u540C\u4E00\u4E2A\u8C31\u5934\uFF0C\u6BCF\u6761\u58F0\u660E\u751F\u6210\u6240\u5728\u533A\u7684\u4E00\u884C\uFF1B\u7A7A\u884C\u6216\u666E\u901A\u5185\u5BB9\u7ED3\u675F\u7EC4\u5408\n~~~jpfun\nH.title: \u6807\u9898\nH.subtitle: \u526F\u6807\u9898\nH.author: \u4F5C\u8005\nH.signature: 1=C 4/4\nH.tempo: 94\n~~~\n`title` / `subtitle` \u5C45\u4E2D\uFF0C\u5206\u522B\u9884\u8BBE\u5927\u3001\u5C0F\u5B57\u53F7\uFF1B`author` \u5C0F\u5B57\u53F7\u53F3\u5BF9\u9F50\uFF1B`signature` \u548C `tempo` \u653E\u5728\u5DE6\u533A\u3002`H.left:`\u3001`H.center:`\u3001`H.right:` \u53EF\u76F4\u63A5\u5199\u5BF9\u5E94\u533A\u7684\u96F6\u65F6\u957F\u5185\u5BB9\u3002\u4EE5 `@` \u6216 `{` \u5F00\u5934\u7684\u503C\u6309 jpFun \u89E3\u6790\uFF0C\u5176\u4F59\u6309\u5B57\u6BB5\u7684\u6587\u672C\u89C4\u5219\u5904\u7406\u3002",allowExtraArgs:!1,args:[{name:"left",description:"\u5DE6\u533A\u96F6\u65F6\u957F\u5185\u5BB9\uFF0C\u5982\u8C03\u6027\u3001\u62CD\u53F7\u4E0E\u901F\u5EA6\u8BB0\u53F7",type:"content",default:""},{name:"center",description:"\u4E2D\u533A\u96F6\u65F6\u957F\u5185\u5BB9\uFF0C\u5982\u6807\u9898\u4E0E\u526F\u6807\u9898",type:"content",default:""},{name:"right",description:"\u53F3\u533A\u96F6\u65F6\u957F\u5185\u5BB9\uFF0C\u5982\u4F5C\u8005\u4E0E\u7F72\u540D",type:"content",default:""},{name:"gap",description:"\u6BCF\u4E2A\u533A\u5185\u76F8\u90BB\u884C\u7684\u5782\u76F4\u95F4\u8DDD",type:"length",default:{value:na,unit:"px"}}]};slots;size;gap;createdBySugar=!1;get children(){return this.slots}static deSugarAtom(t,e,n){if(t[e]!=="H"||t[e+1]!==".")return null;let o=e+2;for(;o<n&&t[o]>="a"&&t[o]<="z";)o++;let s=t.slice(e+2,o);if(!Object.hasOwn(ea,s)||t[o]!==":")return null;o++;let i=ra(t,o,n),a=re(t,o,i);return{next:t[a]==="@"||t[a]==="{"?o:i,node:{kind:"sugar",data:{class:r,field:s},span:{start:e,end:o}}}}static deSugarRelation(t,e,n){let o=e[n++];if(o.data?.class!==r)return null;let s=o.data.field,i=n;for(;i<e.length;i++){let h=e[i];if(typeof h=="number"&&(t.source[h]==="\r"||t.source[h]===`
|
|
40
|
+
`)||typeof h!="number"&&h.kind==="sugar"&&h.data?.class===r)break}let a=e[i],c;if(typeof a=="number")c=a;else if(a)c=a.span.start;else if(i>n){let h=e[i-1];c=typeof h=="number"?h+1:h.span.end}else c=ra(t.source,o.span.end);let l=re(t.source,o.span.end,c),u=pn(t.source,c-1,l),p={start:l,end:Math.max(l,u+1)};if(p.start>=p.end)throw new k("E_HEAD_EMPTY_DECLARATION","H.{field}: \u540E\u5FC5\u987B\u6709\u5185\u5BB9",o.span,{field:s});let m=t.source.slice(p.start,p.end).trim(),d;if(m.startsWith("@")||m.startsWith("{")){let h=new _t(t);h.makeNodes(e.slice(n,i)),d=h.nodes}let f=t.nodes.at(-1),x=f instanceof r&&f.createdBySugar?f:new r(o.span,new Map,t,null);if(x.createdBySugar=!0,x.slots.find(h=>h.name===ea[s]).addRow(r.parseSugarRow(t,s,p,m,d)),x.sourceSpan.end=p.end,x!==f&&t.pushNode(x),typeof a!="number")return i;let y=i+1;if(t.source[a]==="\r"){let h=e[y];typeof h=="number"&&t.source[h]===`
|
|
41
|
+
`&&y++}return y}static parseSugarRow(t,e,n,o,s){if(s!==void 0)return Jn(n,s);if(e==="signature"){let c=/^(1\s*=\s*(\S+))\s+((\d+)\s*\/\s*(\d+))$/.exec(o);if(!c)throw new k("E_HEAD_INVALID_SIGNATURE","H.signature \u7684\u683C\u5F0F\u5E94\u4E3A 1=C 4/4",n);let l={start:n.start,end:n.start+c[1].length},u={start:n.end-c[3].length,end:n.end};return Jn(n,[new qn(l,new Map([["tonality",c[2]]]),t,null),new Bn(u,new Map([["num",Number(c[4])],["den",Number(c[5])]]),t,null)])}if(e==="tempo"){let c=Number(o);if(!Number.isFinite(c)||c<=0)throw new k("E_HEAD_INVALID_TEMPO","H.tempo \u540E\u5FC5\u987B\u662F\u6B63\u6570",n);return Jn(n,[new Zn(n,new Map([["bpm",c]]),t,null)])}let i=new Map([[0,o]]),a=Dl[e];return a&&(i.set("size",{value:a[0],unit:"em"}),i.set("align",a[1])),Jn(n,[new Qn(n,i,t,null)])}constructor(t,e,n,o=null){super(t,o),this.size=n.variables.fontsize,this.gap=n.length2px(this.getArgValue(e,n)[3]);let s=(i,a)=>{let c=e.get(i)??e.get(a);return c instanceof Ht?c instanceof Nt?c.content:[c]:[]};this.slots=[new Se(t,this,"left",s("left",0)),new Se(t,this,"center",s("center",1)),new Se(t,this,"right",s("right",2))]}loweringExit(t){let e=t.endLoweringGroup(this);e.slots=this.slots.map(n=>{let[o,s]=t.getTemporalNodes(n);return{ast:n,start:o,end:s}}),e.slots[2].end.onTimeState=()=>e.validateDuration();for(let n of e.members)if((n.addon?.breakBefore??0)>0)throw new k("E_HEAD_INTERNAL_BREAK","@head \u7684\u5185\u90E8\u4E0D\u80FD\u6362\u884C\u6216\u6362\u9875\uFF1B\u7B2C\u4E00\u5C42\u5185\u5BB9\u5DF2\u7ECF\u8868\u793A\u89C6\u89C9\u884C",n.ast.sourceSpan);return[]}toString(t){let e=this.slots.filter(n=>n.rows.length>0).map(n=>{let o=n.rows.map(s=>` ${s.toString(t).replaceAll(`
|
|
44
42
|
`,`
|
|
45
43
|
`)}`).join(`
|
|
46
44
|
`);return` ${n.name}={
|
|
47
45
|
${o}
|
|
48
|
-
}`});return this.gap!==
|
|
46
|
+
}`});return this.gap!==na&&e.push(` gap=${this.gap}px`),`@head(
|
|
49
47
|
${e.join(`,
|
|
50
48
|
`)}
|
|
51
|
-
)`}},
|
|
49
|
+
)`}},sa=Ar;var Cr=class r extends B{static def={name:["br"],description:"\u6362\u884C",details:`~~~jpfun
|
|
52
50
|
1 2 @br() 3 4
|
|
53
51
|
~~~
|
|
54
52
|
|
|
55
53
|
\`@br()\` \u6362\u5230\u4E0B\u4E00\u884C\uFF0C\`@br(2)\` \u7A7A\u51FA\u4E00\u884C\u518D\u7EE7\u7EED
|
|
56
54
|
|
|
57
55
|
**\u7B80\u5199**\uFF1A\u4EC5\u5728\u9876\u5C42\uFF0C\u8FDE\u7EED\u81F3\u5C11\u4E24\u4E2A\u6362\u884C\u8868\u793A\u6362\u884C`,allowExtraArgs:!1,args:[{name:"offset",description:"\u540E\u7EED\u5185\u5BB9\u504F\u79FB\u7684\u8C31\u9762\u884C\u6570\uFF0C2 \u8868\u793A\u7A7A\u51FA\u4E00\u884C\u518D\u7EE7\u7EED",type:"number",default:1}]};static deSugarAtom(t,e,n,o){if(o>0||t[e]!==`
|
|
58
|
-
`||t[
|
|
59
|
-
`)return null;let
|
|
60
|
-
`;)i=++r;return{next:i,node:{kind:"call",typed:!0,name:"br",args:new Map,span:{start:e,end:i}}}}offset;loweringEnter(){let t=new tt;return t.ast=this,t.mergeKey=-1,t.addon={breakBefore:this.offset},[t]}static loweringFinalize=t=>{let e=new F,n=new F,o=null;for(let i of t.columns){if(o&&e.compare(i[0].t)>0&&i.some(r=>(r.addon?.breakBefore??0)>0))throw H.error.BreakInsideEvent(o.ast.sourceSpan);for(let r of i)r.T.isZero()||(n.copyFrom(r.t).add(r.T),(!o||n.compare(e)>0)&&(e.copyFrom(n),o=r))}};constructor(t,e,n,o=null){super(t,o);let[i]=this.getArgValue(e,n);this.offset=Number.isFinite(i)?Math.max(1,Math.floor(i)):1,this.offset!==i&&n.diagnostics.push(new q("W_BR_OFFSET",`@br \u7684 offset \u5FC5\u987B\u662F\u5927\u4E8E\u7B49\u4E8E 1 \u7684\u6574\u6570\uFF0C\u5DF2\u88AB\u4FEE\u6B63\u4E3A ${this.offset}`,this.sourceSpan))}toString(){return`@br(${this.offset})`}},Fn=cs;var ls=10,fs=13,Jc=9,tl=11,el=12,nl=32,ol=160,sl=5760,il=8239,rl=8287,al=12288,cl=65279,ll=34,kr=92,fl=37,pl=32,ul=[];function hl(s){return s>pl?" ".repeat(s):ul[s]??=" ".repeat(s)}function _r(s){return s===nl||s===Jc||s===tl||s===el?!0:s<128?!1:s===ol||s===sl||s>=8192&&s<=8202||s===il||s===rl||s===al||s===cl}function Pe(s){let t=s.length,e=[0],n=[],o=[],i=(m,g)=>{if(m>=g)return;let x=o.length;if(x>=2&&m<=o[x-1]){g>o[x-1]&&(o[x-1]=g);return}o.push(m,g)},r=(m,g)=>{if(g<=0)return;let x=m+g;for(let b=m;b<x;b+=2)i(b,b+1)},a=0,c=!1,l=!1,p=-1,f=-1,u=0,h=(m,g)=>{if(g===kr){u>0&&f+u===m?u++:(f=m,u=1);return}f=-1,u=0};for(let m=0;m<t;){let g=s.charCodeAt(m);if(g===fs||g===ls){let x=g===fs&&m+1<t&&s.charCodeAt(m+1)===ls?2:1;e.push(m+x);let b=(u&1)===1;r(f,u),p>=0&&(i(p,m),n.push({start:p,end:m}),p=-1),b?i(m,m+x):a===0&&x===2&&i(m,m+1),f=-1,u=0,l=!1,m+=x;continue}if(a!==0){l?l=!1:g===kr?l=!0:g===a&&(a=0),_r(g)||h(m,g),m++;continue}if(g===ll){c||(te(s,m,t)<0?c=!0:a=g),h(m,g),m++;continue}if(g===fl){for(p=m,m++;m<t;){let x=s.charCodeAt(m);if(x===fs||x===ls)break;m++}continue}_r(g)||h(m,g),m++}if(r(f,u),p>=0&&(i(p,t),n.push({start:p,end:t})),o.length===0)return{maskedSource:s,lineStarts:e,commentSpans:n};let d=[],y=0;for(let m=0;m<o.length;m+=2){let g=o[m],x=o[m+1];y<g&&d.push(s.slice(y,g)),d.push(hl(x-g)),y=x}return y<t&&d.push(s.slice(y)),{maskedSource:d.join(""),lineStarts:e,commentSpans:n}}var ne="CDEFGAB",zn=(s,t)=>(s%t+t)%t,dl=s=>s<0?"b".repeat(-s):"#".repeat(s);function Hn(s){throw new k("E_NOTE_TRANSFORM","\u65E0\u6CD5\u5B89\u5168\u6539\u5199\u6B64\u97F3\u7B26\u7684\u97F3\u9AD8",s)}function ml(s,t){let e=t==="to-absolute"||t!=="to-relative"&&ne.includes(s.ast.name),n=s.resolvedMidi+(t==="semitone-up"?1:t==="semitone-down"?-1:0),o=de(s.keySignature,4);[n,o,s.ast.octave,s.ast.jeOctaveOffset].every(Number.isSafeInteger)||Hn(s.ast.sourceSpan);let i=t==="semitone-down"?Sr:ee,r,a,c;if(t==="to-absolute"){let l=ne.indexOf(s.keySignature[0]),p=l<0?ne.indexOf(ee[zn(o,12)][0]):l,f=Number(s.ast.name)-1;r=ne[(p+f)%7];let u=zn(o-vt[ne[p]]+6,12)-6;c=Math.floor((o-u)/12)-1+Math.floor((p+f)/7)+s.ast.octave+s.ast.jeOctaveOffset,a=dl(n-((c+1)*12+vt[r]))}else if(t==="to-relative"){let l=s.ast,p=ne.includes(s.keySignature[0])?s.keySignature:ee[zn(o,12)]+(Math.floor(o/12)-1),f=nn(l.name,l.acc,l.octave+l.jeOctaveOffset,p);f||Hn(l.sourceSpan),{renderName:r,renderAcc:a,renderOctave:c}=f}else{let l=e?n:n-o,p=i[zn(l,12)];r=e?p[0]:String(ne.indexOf(p[0])+1),a=p.slice(1),c=Math.floor(l/12)-(e?1:0)}return{name:r,acc:a,octave:c-s.ast.jeOctaveOffset,absolute:e}}function xl(s,t){for(let e=t.parent;e;e=e.parent){let n=tn(s,e.sourceSpan.start,e.sourceSpan.end);if(!n)continue;let o=n.args.find(r=>r.valueSpan.start<=t.sourceSpan.start&&r.valueSpan.end>=t.sourceSpan.end);if(!o)continue;let i=0;for(let r=o.valueSpan.start;r<t.sourceSpan.start;r++)s[r]==='"'?r=te(s,r,o.valueSpan.end):s[r]==="{"?i++:s[r]==="}"&&i--;return i===0}return!1}function Ir(s,t,e,n){let{maskedSource:o}=Pe(s),i=[],r=[];function a(l,p){s.slice(l.start,l.end)!==p&&(s.slice(l.start,l.end)!==o.slice(l.start,l.end)&&Hn(l),i.push({span:l,text:p}))}for(let l of t){let v=function(L,I,w){let M=!w||w.includes(",")||L&&s[L.start]==='"'?ht(w):w;L?a(L,M):S.push(`${I}=${M}`)};var c=v;let{ast:p}=l,f=p.sourceSpan,u=tn(o,f.start,f.end),h=u?.span.end===f.end&&u.closeParenSpan,d=e==="to-absolute"&&ne.includes(p.name)||e==="to-relative"&&/^[1-7]$/.test(p.name);if(h||r.push({span:f,text:s.slice(f.start,f.end)}),n&&!n.some(L=>L.start<=f.start&&L.end>=f.end)||l.resolvedMidi===null||d)continue;let y=ml(l,e),m=y.absolute?String(y.octave):y.octave<0?",".repeat(-y.octave):"'".repeat(y.octave),g=(L,I)=>y.absolute?y.name+L+I:L+y.name+I;if(!h){let L=g(y.acc,m);L.includes(",")&&xl(o,p)&&(L=`{${L}}`),r[r.length-1].text=L;continue}let x=new Map;u.args.forEach((L,I)=>{L.valueSpan.start!==L.valueSpan.end&&x.set(L.nameSpan?o.slice(L.nameSpan.start,L.nameSpan.end).toLowerCase():I,L.valueSpan)});let b=x.get("name")??x.get(0),A=x.get("acc")??x.get(1),E=x.get("octave")??x.get(2),S=[];if(v(b,"name",g(A?"":y.acc,E?"":m)),A?v(A,"acc",y.acc):p.hasDefaultAcc&&S.push('acc=""'),E&&a(E,String(y.octave)),S.length){let L=u.closeParenSpan.start,I=o.slice(u.openParenSpan.end,L).trimEnd();a({start:L,end:L},(I?I.endsWith(",")?" ":", ":"")+S.join(", "))}}r.sort((l,p)=>l.span.start-p.span.start);for(let l=0;l<r.length-1;l++){let p=r[l],f=r[l+1];if(p.span.end!==f.span.start||p.text.endsWith("}"))continue;let u=he(p.text+f.text);(u instanceof H||u.next!==p.text.length)&&(p.text!==s.slice(p.span.start,p.span.end)?p.text+=" ":f.text=" "+f.text)}for(let l of r)a(l.span,l.text);i.sort((l,p)=>l.span.start-p.span.start);for(let l=1;l<i.length;l++)i[l-1].span.end>i[l].span.start&&Hn(i[l].span);return i}function Rr(s,t,e,n){let o=t.diagnostics.find(a=>a instanceof k);if(o)throw o;let i=[...t.astToTemporal.values()].flat().filter(a=>a instanceof Wn),r=t.diagnostics.find(a=>i.some(c=>a.span.start<c.ast.sourceSpan.end&&a.span.end>c.ast.sourceSpan.start));if(r)throw r;return Ir(s,i,e,n)}var ps="note.jeOctaveOffset",us=class extends ${static def={name:["note","n"],description:"\u521B\u5EFA\u97F3\u7B26",details:"~~~jpfun\n@note(A, acc=#, octave=3, color=#c33)\n~~~\n**\u7B80\u5199**\uFF1A\u6570\u5B57\u97F3\u540D\u6309\u201C\u5347\u964D\u53F7\u3001\u97F3\u540D\u3001\u76F8\u5BF9\u516B\u5EA6\u201D\u4E66\u5199\uFF1B\u5B57\u6BCD\u97F3\u540D\u6309\u201C\u97F3\u540D\u3001\u5347\u964D\u53F7\u3001\u7EDD\u5BF9\u516B\u5EA6\u201D\u4E66\u5199\u3002`1,,` \u6BD4\u5F53\u524D\u8C03\u6027\u57FA\u51C6\u4F4E\u4E24\u4E2A\u516B\u5EA6\uFF0C`1'` \u9AD8\u4E00\u4E2A\u516B\u5EA6\u3002\n- \u7B80\u5199\u7684\u5347\u964D\u53F7\u5B8C\u5168\u7531\u81EA\u8EAB\u51B3\u5B9A\uFF0C\u7701\u7565\u65F6\u4E3A\u7A7A\uFF0C\u4E0D\u7EE7\u627F `@set(note.acc=...)`\uFF1B\u663E\u5F0F\u8C03\u7528\u7701\u7565 `acc` \u65F6\u4ECD\u7EE7\u627F\u9ED8\u8BA4\u503C\n- `A#3` \u7B49\u4EF7\u4E8E `@note(A, #, 3)`\uFF0C\u9ED8\u8BA4 `acc` \u4E3A\u7A7A\u65F6\u4E5F\u7B49\u4EF7\u4E8E `@note(A#3)`\n- `#1'` \u7B49\u4EF7\u4E8E `@note(1, #, 1)`\uFF0C\u9ED8\u8BA4 `acc` \u4E3A\u7A7A\u65F6\u4E5F\u7B49\u4EF7\u4E8E `@note(\"#1'\")`\n- \u652F\u6301\u7EC4\u5408\u5347\u964D\u53F7\uFF0C\u5982 `A##bn99`\uFF1B\u65E0\u6B67\u4E49\u65F6\u4E5F\u63A5\u53D7\u540E\u7F6E\u5199\u6CD5\uFF0C\u5982 `A3#`\u3001`6#,,`\n- \u5347\u964D\u53F7\u540E\u7D27\u8DDF\u6570\u5B57\u65F6\u5F52\u5165\u4E0B\u4E00\u97F3\u7B26\uFF1A`6#3` \u89E3\u6790\u4E3A `6` \u548C `#3`",allowExtraArgs:!1,args:[{name:"name",description:"\u6570\u5B57\u97F3\u540D\u6216\u5927\u5199\u5B57\u6BCD\u97F3\u540D\uFF0C\u53EF\u81EA\u5E26\u5347\u964D\u53F7\u4E0E\u516B\u5EA6\uFF1B`0` / `Z` \u4E3A\u4F11\u6B62\u7B26\uFF0C`8` \u4E3A\u9690\u5F62\u5360\u4F4D\uFF0C`9` / `X` \u4E3A\u8282\u62CD\u8BB0\u53F7\uFF0C\u540E\u4E09\u7C7B\u4E0D\u663E\u793A\u5347\u964D\u53F7\u548C\u516B\u5EA6\u70B9",type:"string",default:null},{name:"acc",description:"\u989D\u5916\u5347\u964D\u53F7\uFF0C`##` \u518D\u5347\u4E24\u4E2A\u534A\u97F3\uFF0C`b` \u518D\u964D\u4E00\u4E2A\u534A\u97F3",type:"string",default:""},{name:"octave",description:"\u5B57\u6BCD\u97F3\u540D\u4F7F\u7528\u7EDD\u5BF9\u516B\u5EA6\uFF1B\u6570\u5B57\u97F3\u540D\u4F7F\u7528\u76F8\u5BF9\u516B\u5EA6\uFF0C\u7701\u7565\u65F6\u4E3A 0",type:"number",default:4},{name:"color",description:"\u97F3\u7B26\u989C\u8272\uFF0C\u4F7F\u7528 CSS \u989C\u8272\u503C",type:"string",default:"#000"}]};static deSugarAtom(t,e,n){let o=0;switch(t[e]){case"(":case"]":o=-1;break;case"[":case")":o=1;break}if(o)return{next:e+1,node:{kind:"sugar",data:{jeOffset:o},span:{start:e,end:e+1},syntaxKind:"punctuation"}};let i=he(t,e,n);if(i instanceof H)return null;let r=new Map;r.set("name",i.name),i.octave!==null&&r.set("octave",i.octave),r.set("acc",i.acc??"");let a={kind:"call",typed:!0,name:"note",args:r,span:{start:e,end:i.next},syntaxKind:"atom"};return{next:i.next,node:a}}static deSugarRelation(t,e,n){let o=e[n],i=o.data?.jeOffset;return typeof i!="number"?null:(t.variables[ps]=(t.variables[ps]??0)+i,t.nodes.push(new xt(o.span)),n+1)}labelable(){return this}loweringEnter(){return[new Wn(this)]}name;octave;acc;color;size;font;jeOctaveOffset;hasDefaultAcc;constructor(t,e,n,o=null){super(t,o),this.hasDefaultAcc=!!n.variables["note.acc"],[this.name,this.acc,this.octave,this.color]=this.getArgValue(e,n),this.font=n.variables.numberfont,this.size=n.variables.fontsize;let i=he(this.name);if(i instanceof H)throw i.span=t,i;if(i.next!==this.name.length)throw new k("E_WRONG_NOTE_NAME",`\u51FD\u6570 @note \u7684\u53C2\u6570 [0]:"name" \u683C\u5F0F\u9519\u8BEF: \u65E0\u6CD5\u89E3\u6790\u5C3E\u90E8 "${this.name.slice(i.next)}"`,t);this.name=i.name==="X"?"9":i.name==="Z"?"0":i.name;let r=e.get("octave")??e.get(2);if(r!==void 0){if(i.octave!==null&&i.octave!=r)throw new k("E_NOTE_OCTAVE_CONFLICT",`\u51FD\u6570 @note \u7684\u53C2\u6570 "octave" \u4E0E\u97F3\u7B26\u540D\u79F0\u4E2D\u7684\u516B\u5EA6\u4FE1\u606F\u51B2\u7A81: ${r} != ${i.octave}`,t)}else i.octave!==null?this.octave=i.octave:i.absOctave||(this.octave=0);this.jeOctaveOffset=n.variables[ps]??0,i.acc!==null&&(this.acc=i.acc+this.acc)}toString(){return`@n(${this.name}, ${this.acc||'""'}, ${this.octave}, ${this.color})`}},Or=us,yl={8:"",9:"X"},Wn=class extends tt{resolvedMidi=null;keySignature="C4";transposeDiatonic;name;acc;octave;accidentals=[];numberStyle;numberY=0;constructor(t){super(),this.ast=t,this.T.set(1),this.mergeKey=Dt,this.name=t.name,this.acc=t.acc,this.octave=t.octave+t.jeOctaveOffset,this.numberStyle={fontSize:t.size,fontFamily:t.font,fontWeight:400,textAlign:"center",fill:t.color},this.initLayoutBox()}prepareLayout(t){let{size:e,color:n}=this.ast,o=t.textMeasurer.measureText("0",this.numberStyle);this.numberY=o.baseline;let i=e*.01,{placed:r,right:a}=kn(this.acc,e,0,this.numberY,i);this.accidentals=r,this.box.w=a+o.w,this.box.h=o.h,this.box.anchor=a+o.w/2,this.box.visualAxis=o.h/2,this.ports["body.left"]={x:this.box.anchor-o.w/2,y:this.box.visualAxis},this.ports["body.right"]={x:this.box.anchor+o.w/2,y:this.box.visualAxis},this.ports.shoulder={x:this.box.anchor,y:0},this.ports["decoration.below"]={x:this.box.anchor,y:this.numberY+e*.04},this.ports.dot={x:this.box.w,y:o.h*.64};let c=Math.abs(this.octave);if(c===0)return;let l=this.octave>0,p=e*.075,f=e*.08,u=p*2+f,h={fill:n},d=0,y=c*p*2+(c-1)*f,m={[l?"above":"below"]:{order:100,gap:f,height:y,place:g=>{d=g}},paint:g=>{for(let x=0;x<c;x++){let b=l?d+y-p-x*u:d+p+x*u;g.drawCircle(this.box.x+this.box.anchor,this.box.y+b,p,h)}}};this.decorations.push(m)}finalizeLayout(){this.ports.lyric={x:this.box.anchor,y:this.box.h},this.octave>0&&(this.ports["tie.top"]={x:this.box.anchor,y:wt(this,!0).y-this.box.y-this.ast.size*.05})}paint(t){let e=this.ast.color;for(let o of this.accidentals)_n(t,o,this.box,e);let n=yl[this.name]??this.name;n&&t.drawText(n,this.box.x+this.box.anchor,this.box.y+this.numberY,this.numberStyle)}onTimeState(t){let e=this.keySignature=t.keySignature;if(this.playbackState={bpm:t.bpm,velocity:t.velocity,program:t.program},this.resolvedMidi=Xo(this.name,this.acc,this.octave,e),this.transposeDiatonic=Ar(this.name,this.acc,this.octave,e),this.name>="0"&&this.name<="9")(this.name==="0"||this.name>="8")&&(this.octave=0,this.acc="");else{let n=nn(this.name,this.acc,this.octave,e);n&&(this.name=n.renderName,this.acc=n.renderAcc,this.octave=n.renderOctave)}}emitPlayback(t){let e=this.ast.name==="9",n=e?37:this.resolvedMidi,o=e?0:this.playbackState?.pitchShift??0,i=this.transposeDiatonic;if(!(t.end.compare(t.start)<=0)){if(n===null){t.span({start:t.start,end:t.end});return}t.note({start:t.start,end:t.end,midi:n+o,velocity:this.playbackState?.velocity??Le,...e?{percussion:!0}:{transpose:o&&i?r=>i(r)+o:i}})}}};function hs(s){for(;s.foldedInto;)s=s.foldedInto;return s}var ds=class extends ${static def={name:["ottava"],description:"\u516B\u5EA6\u53F7",details:"~~~jpfun\n1@a 2 3 -@b | 4\n@ottava(a, b, 1)\n~~~\n`shift` \u4E3A\u975E\u96F6\u6574\u6570\u516B\u5EA6\u6570\uFF0C\u6B63\u6570\u5728\u4E0A\u65B9\u6807\u9AD8\u516B\u5EA6\u53F7\uFF0C\u8D1F\u6570\u5728\u4E0B\u65B9\u6807\u4F4E\u516B\u5EA6\u53F7\uFF0C\u9ED8\u8BA4 `1`\u3002\u6807\u7B7E\u4F7F\u7528\u8C31\u9762\u6570\u5B57\u5B57\u4F53\u7684\u659C\u4F53\u3002",allowExtraArgs:!1,args:[{description:"\u8D77\u70B9\u6807\u7B7E",type:"label",default:null},{description:"\u7EC8\u70B9\u6807\u7B7E",type:"label",default:null},{name:"shift",description:"\u975E\u96F6\u6574\u6570\u516B\u5EA6\u6570\uFF0C\u6B63\u6570\u4E3A\u9AD8\uFF0C\u8D1F\u6570\u4E3A\u4F4E",type:"number",default:1}]};static loweringFinalize=t=>{let e=t.attachments.filter(n=>n instanceof Gn).map(n=>{let[o,i]=n.endPoints;return{from:o,end:i.t.clone().add(i.T),shift:n.ast.shift*12}});if(e.length!==0)for(let n of t.astToTemporal.values())for(let o of n){if(!o.playbackState)continue;let i=hs(o),r=0;for(let a of e)i.track===a.from.track&&i.t.compare(a.from.t)>=0&&i.t.compare(a.end)<0&&(r+=a.shift);r!==0&&(o.playbackState={...o.playbackState,pitchShift:(o.playbackState.pitchShift??0)+r})}};from;to;shift;size;font;constructor(t,e,n,o=null){super(t,o);let[i,r,a]=this.getArgValue(e,n);if(!Number.isSafeInteger(a)||a===0||!Number.isSafeInteger(a*12))throw new k("E_OTTAVA_INVALID_SHIFT","@ottava \u7684 shift \u5FC5\u987B\u4E3A\u53EF\u5B89\u5168\u6362\u7B97\u4E3A\u534A\u97F3\u7684\u975E\u96F6\u6574\u6570",t);this.from=i,this.to=r,this.shift=a,this.size=n.variables.fontsize,this.font=n.variables.numberfont}loweringEnter(t){let e=t.getTemporalNodes(this.from).at(0),n=t.getTemporalNodes(this.to).at(-1),o=e&&hs(e),i=n&&hs(n);if(!o||!i||!X(o)||!X(i))return t.diagnostics.push(H.warning.UnresolvedEndpoint("ottava",this.sourceSpan)),[];if(o.track!==i.track)throw new k("E_OTTAVA_CROSS_TRACK","@ottava \u7684\u4E24\u4E2A\u7AEF\u70B9\u5FC5\u987B\u4F4D\u4E8E\u540C\u4E00\u97F3\u8F68",this.sourceSpan);return t.addAttachment(new Gn(this,o,i)),[]}toString(t){let e=n=>(n instanceof $?n.label:void 0)??n.toString(t);return`@ottava(${e(this.from)}, ${e(this.to)}, ${this.shift})`}},$r=ds,Gn=class{ast;from;to;layer="foreground";constructor(t,e,n){this.ast=t,this.from=e,this.to=n}get sourceSpan(){return this.ast.sourceSpan}get endPoints(){return(this.from.t.compare(this.to.t)||this.from.order-this.to.order)>0?[this.to,this.from]:[this.from,this.to]}createGeometry(t){let e=this.endPoints,[n,o]=e,i=n.layoutLine,r=o.layoutLine;if(t.lines[i].columnOf(n)<0||t.lines[r].columnOf(o)<0)return{regions:[],paint(){}};let{size:a,font:c,shift:l}=this.ast,p=l>0,f=n.track,u=Math.max(.75,a*.035),h={stroke:"#000",strokeWidth:u},d=a*.22,y=d+a*.14,m=u/2,g=a*.45,x=a*.2,b=a*.08,A=String(Math.abs(l)*7+1),E={fontSize:a*.6,fontFamily:c,fontStyle:"italic",textAlign:"left",fill:"#000"},S=t.textMeasurer.measureText(A,E),v=p?-m:m-S.h,L=v+S.baseline,I=Array.from({length:r-i+1},(w,M)=>{let C=i+M,_=C===i,P=C===r,W=t.lines[C].trackRuns,Z=_?n.box.x+(n.ports["body.left"]?.x??0):W.get(f)?.find(B=>!B.T.isZero())?.box.x??t.originX,Q=o.box.x+(o.ports["body.right"]?.x??o.box.w);if(!P){Q=t.originX+(W.size===0?t.width:0);for(let B of W.values())for(let G of B)Q=Math.max(Q,G.box.x+G.box.w)}Z>Q&&([Z,Q]=[Q,Z]);let K=_?Z+S.w+b:Z,N=(B,G,T,D)=>({x:B,y:G,w:T,h:D,line:C,track:f}),R=K<Q?[N(K-m,-m,Q-K+u,u)]:[];_&&R.push(N(Z,v,S.w,S.h)),P&&R.push(N(Q-m,p?-m:-g-m,u,g+u));let O=N(0,0,0,0);Ne(O,R);let j=p?1/0:-1/0;for(let B of R)for(let[G,T]of t.getHorizontalExtents(C,B.x,B.x+B.w)){let D=t.getVisualAxis(C,G);j=p?Math.min(j,D+T.top-x-B.y-B.h):Math.max(j,D+T.bottom+x-B.y)}if(!Number.isFinite(j)){let B=t.getRangeExtents(C,_||P?e:void 0,f),G=t.getVisualAxis(C,f);j=p?G+(B?.top??0)-x-(O.y+O.h):G+(B?.bottom??0)+x-O.y}for(let B of R)B.y+=j;return O.y+=j,{left:Z,right:Q,lineStart:K,lineY:j,first:_,last:P,parts:R,region:O}});return{regions:I.map(w=>w.region),occupancy:I.flatMap(w=>w.parts),paint(w){for(let M of I){let{left:C,right:_,lineStart:P,lineY:W,first:Z,last:Q}=M;for(let K=P;K<_;K+=y)w.drawLine(K,W,Math.min(K+d,_),W,h);Z&&w.drawText(A,C,W+L,E),Q&&w.drawLine(_,W,_,W+(p?g:-g),h)}}}}};var ms=Number.MAX_VALUE,De=new WeakMap,xs=class extends ${static def={name:["rest"],description:"\u591A\u5C0F\u8282\u4F11\u6B62",details:`~~~jpfun
|
|
56
|
+
`||t[pn(t,e-1)]!==`
|
|
57
|
+
`)return null;let s=e+1,i=s;for(;(i=re(t,i,n))<n&&t[i]===`
|
|
58
|
+
`;)s=++i;return{next:s,node:{kind:"call",typed:!0,name:"br",args:new Map,span:{start:e,end:s}}}}offset;loweringEnter(t){t.deferFinalize(r.loweringFinalize);let e=new tt;return e.ast=this,e.mergeKey=-1,e.addon={breakBefore:this.offset},[e]}static loweringFinalize(t){let e=new G,n=new G,o=null;for(let s of t.columns){if(o&&e.compare(s[0].t)>0&&s.some(i=>(i.addon?.breakBefore??0)>0))throw Y.error.BreakInsideEvent(o.ast.sourceSpan);for(let i of s)i.T.isZero()||(n.copyFrom(i.t).add(i.T),(!o||n.compare(e)>0)&&(e.copyFrom(n),o=i))}}constructor(t,e,n,o=null){super(t,o);let[s]=this.getArgValue(e,n);this.offset=Number.isFinite(s)?Math.max(1,Math.floor(s)):1,this.offset!==s&&n.diagnostics.push(new K("W_BR_OFFSET","@br \u7684 offset \u5FC5\u987B\u662F\u5927\u4E8E\u7B49\u4E8E 1 \u7684\u6574\u6570\uFF0C\u5DF2\u88AB\u4FEE\u6B63\u4E3A {offset}",this.sourceSpan,{offset:this.offset}))}toString(){return`@br(${this.offset})`}},eo=Cr;var Nr=10,vr=13,zl=9,Gl=11,$l=12,jl=32,Wl=160,Xl=5760,Ul=8239,Kl=8287,Yl=12288,ql=65279,Zl=34,ia=92,Ql=37,Jl=32,tu=[];function eu(r){return r>Jl?" ".repeat(r):tu[r]??=" ".repeat(r)}function aa(r){return r===jl||r===zl||r===Gl||r===$l?!0:r<128?!1:r===Wl||r===Xl||r>=8192&&r<=8202||r===Ul||r===Kl||r===Yl||r===ql}function ze(r){let t=r.length,e=[0],n=[],o=[],s=(y,h)=>{if(y>=h)return;let g=o.length;if(g>=2&&y<=o[g-1]){h>o[g-1]&&(o[g-1]=h);return}o.push(y,h)},i=(y,h)=>{if(h<=0)return;let g=y+h;for(let b=y;b<g;b+=2)s(b,b+1)},a=0,c=!1,l=!1,u=-1,p=-1,m=0,d=(y,h)=>{if(h===ia){m>0&&p+m===y?m++:(p=y,m=1);return}p=-1,m=0};for(let y=0;y<t;){let h=r.charCodeAt(y);if(h===vr||h===Nr){let g=h===vr&&y+1<t&&r.charCodeAt(y+1)===Nr?2:1;e.push(y+g);let b=(m&1)===1;i(p,m),u>=0&&(s(u,y),n.push({start:u,end:y}),u=-1),b?s(y,y+g):a===0&&g===2&&s(y,y+1),p=-1,m=0,l=!1,y+=g;continue}if(a!==0){l?l=!1:h===ia?l=!0:h===a&&(a=0),aa(h)||d(y,h),y++;continue}if(h===Zl){c||($t(r,y,t)<0?c=!0:a=h),d(y,h),y++;continue}if(h===Ql){for(u=y,y++;y<t;){let g=r.charCodeAt(y);if(g===vr||g===Nr)break;y++}continue}aa(h)||d(y,h),y++}if(i(p,m),u>=0&&(s(u,t),n.push({start:u,end:t})),o.length===0)return{maskedSource:r,lineStarts:e,commentSpans:n};let f=[],x=0;for(let y=0;y<o.length;y+=2){let h=o[y],g=o[y+1];x<h&&f.push(r.slice(x,h)),f.push(eu(g-h)),x=g}return x<t&&f.push(r.slice(x)),{maskedSource:f.join(""),lineStarts:e,commentSpans:n}}var Ge="CDEFGAB",ca=(r,t)=>(r%t+t)%t,nu=r=>r<0?"b".repeat(-r):"#".repeat(r);function no(r){throw new k("E_NOTE_TRANSFORM","\u65E0\u6CD5\u5B89\u5168\u6539\u5199\u6B64\u97F3\u7B26\u7684\u97F3\u9AD8",r)}function ou(r,t){let e=t==="to-absolute"||t!=="to-relative"&&Ge.includes(r.ast.name),n=r.resolvedMidi+(t==="semitone-up"?1:t==="semitone-down"?-1:0),o=mn(r.keySignature);[n,o,r.ast.octave,r.ast.jeOctaveOffset].every(Number.isSafeInteger)||no(r.ast.sourceSpan);let s=t==="semitone-down"?Qi:He,i,a,c;if(t==="to-absolute"){let l=Ge.indexOf(r.keySignature[0]),u=Number(r.ast.name)-1;i=Ge[(l+u)%7];let p=ca(o-Et[Ge[l]]+6,12)-6;c=Math.floor((o-p)/12)-1+Math.floor((l+u)/7)+r.ast.octave+r.ast.jeOctaveOffset,a=nu(n-((c+1)*12+Et[i]))}else if(t==="to-relative"){let l=r.ast,u=Un(l.name,l.acc,l.octave+l.jeOctaveOffset,r.keySignature);u||no(l.sourceSpan),{renderName:i,renderAcc:a,renderOctave:c}=u}else{let l=e?n:n-o,u=s[ca(l,12)];i=e?u[0]:String(Ge.indexOf(u[0])+1),a=u.slice(1),c=Math.floor(l/12)-(e?1:0)}return{name:i,acc:a,octave:c-r.ast.jeOctaveOffset,absolute:e}}function ru(r,t){for(let e=t.parent;e;e=e.parent){let n=un(r,e.sourceSpan.start,e.sourceSpan.end);if(!n)continue;let o=n.args.find(i=>i.valueSpan.start<=t.sourceSpan.start&&i.valueSpan.end>=t.sourceSpan.end);if(!o)continue;let s=0;for(let i=o.valueSpan.start;i<t.sourceSpan.start;i++)r[i]==='"'?i=$t(r,i,o.valueSpan.end):r[i]==="{"?s++:r[i]==="}"&&s--;return s===0}return!1}function la(r,t,e,n){let{maskedSource:o}=ze(r),s=[],i=[];function a(l,u){r.slice(l.start,l.end)!==u&&(r.slice(l.start,l.end)!==o.slice(l.start,l.end)&&no(l),s.push({span:l,text:u}))}for(let l of t){let A=function(C,_,E){let v=!E||E.includes(",")||C&&r[C.start]==='"'?lt(E):E;C?a(C,v):w.push(`${_}=${v}`)};var c=A;let{ast:u}=l,p=u.sourceSpan,m=un(o,p.start,p.end),d=m?.span.end===p.end&&m.closeParenSpan,f=e==="to-absolute"&&Ge.includes(u.name)||e==="to-relative"&&/^[1-7]$/.test(u.name);if(d||i.push({span:p,text:r.slice(p.start,p.end)}),n&&!n.some(C=>C.start<=p.start&&C.end>=p.end)||l.resolvedMidi===null||f)continue;let x=ou(l,e),y=x.absolute?String(x.octave):x.octave<0?",".repeat(-x.octave):"'".repeat(x.octave),h=(C,_)=>x.absolute?x.name+C+_:C+x.name+_;if(!d){let C=h(x.acc,y);C.includes(",")&&ru(o,u)&&(C=`{${C}}`),i[i.length-1].text=C;continue}let g=new Map;m.args.forEach((C,_)=>{C.valueSpan.start!==C.valueSpan.end&&g.set(C.nameSpan?o.slice(C.nameSpan.start,C.nameSpan.end).toLowerCase():_,C.valueSpan)});let b=g.get("name")??g.get(0),T=g.get("acc")??g.get(1),L=g.get("octave")??g.get(2),w=[];if(A(b,"name",h(T?"":x.acc,L?"":y)),T?A(T,"acc",x.acc):u.hasDefaultAcc&&w.push('acc=""'),L&&a(L,String(x.octave)),w.length){let C=m.closeParenSpan.start,_=o.slice(m.openParenSpan.end,C).trimEnd();a({start:C,end:C},(_?_.endsWith(",")?" ":", ":"")+w.join(", "))}}i.sort((l,u)=>l.span.start-u.span.start);for(let l=0;l<i.length-1;l++){let u=i[l],p=i[l+1];if(u.span.end!==p.span.start||u.text.endsWith("}"))continue;let m=u.text+p.text,d=be(m,0,m.length,!1);(!d||d.next!==u.text.length)&&(u.text!==r.slice(u.span.start,u.span.end)?u.text+=" ":p.text=" "+p.text)}for(let l of i)a(l.span,l.text);s.sort((l,u)=>l.span.start-u.span.start);for(let l=1;l<s.length;l++)s[l-1].span.end>s[l].span.start&&no(s[l].span);return s}function ua(r,t,e,n){let o=t.diagnostics.find(a=>a instanceof k);if(o)throw o;let s=[...t.astToTemporal.values()].flat().filter(a=>a instanceof oo),i=t.diagnostics.find(a=>s.some(c=>a.span.start<c.ast.sourceSpan.end&&a.span.end>c.ast.sourceSpan.start));if(i)throw i;return la(r,s,e,n)}var kr="note.jeOctaveOffset",Er=class extends B{static def={name:["note","n"],description:"\u521B\u5EFA\u97F3\u7B26",details:"~~~jpfun\n@note(A, acc=#, octave=3, color=#c33)\n~~~\n**\u7B80\u5199**\uFF1A\u6570\u5B57\u97F3\u540D\u6309\u201C\u5347\u964D\u53F7\u3001\u97F3\u540D\u3001\u76F8\u5BF9\u516B\u5EA6\u201D\u4E66\u5199\uFF1B\u5B57\u6BCD\u97F3\u540D\u6309\u201C\u97F3\u540D\u3001\u5347\u964D\u53F7\u3001\u7EDD\u5BF9\u516B\u5EA6\u201D\u4E66\u5199\u3002`1,,` \u6BD4\u5F53\u524D\u8C03\u6027\u57FA\u51C6\u4F4E\u4E24\u4E2A\u516B\u5EA6\uFF0C`1'` \u9AD8\u4E00\u4E2A\u516B\u5EA6\u3002\n- \u7B80\u5199\u7684\u5347\u964D\u53F7\u5B8C\u5168\u7531\u81EA\u8EAB\u51B3\u5B9A\uFF0C\u7701\u7565\u65F6\u4E3A\u7A7A\uFF0C\u4E0D\u7EE7\u627F `@set(note.acc=...)`\uFF1B\u663E\u5F0F\u8C03\u7528\u7701\u7565 `acc` \u65F6\u4ECD\u7EE7\u627F\u9ED8\u8BA4\u503C\n- `A#3` \u7B49\u4EF7\u4E8E `@note(A, #, 3)`\uFF0C\u9ED8\u8BA4 `acc` \u4E3A\u7A7A\u65F6\u4E5F\u7B49\u4EF7\u4E8E `@note(A#3)`\n- `#1'` \u7B49\u4EF7\u4E8E `@note(1, #, 1)`\uFF0C\u9ED8\u8BA4 `acc` \u4E3A\u7A7A\u65F6\u4E5F\u7B49\u4EF7\u4E8E `@note(\"#1'\")`\n- \u652F\u6301\u7EC4\u5408\u5347\u964D\u53F7\uFF0C\u5982 `A##bn99`\uFF1B\u65E0\u6B67\u4E49\u65F6\u4E5F\u63A5\u53D7\u540E\u7F6E\u5199\u6CD5\uFF0C\u5982 `A3#`\u3001`6#,,`\n- \u5347\u964D\u53F7\u540E\u7D27\u8DDF\u6570\u5B57\u65F6\u5F52\u5165\u4E0B\u4E00\u97F3\u7B26\uFF1A`6#3` \u89E3\u6790\u4E3A `6` \u548C `#3`",allowExtraArgs:!1,args:[{name:"name",description:"\u6570\u5B57\u97F3\u540D\u6216\u5927\u5199\u5B57\u6BCD\u97F3\u540D\uFF0C\u53EF\u81EA\u5E26\u5347\u964D\u53F7\u4E0E\u516B\u5EA6\uFF1B`0` / `Z` \u4E3A\u4F11\u6B62\u7B26\uFF0C`8` \u4E3A\u9690\u5F62\u5360\u4F4D\uFF0C`9` / `X` \u4E3A\u8282\u62CD\u8BB0\u53F7\uFF0C\u540E\u4E09\u7C7B\u4E0D\u663E\u793A\u5347\u964D\u53F7\u548C\u516B\u5EA6\u70B9",type:"string",default:null},{name:"acc",description:"\u989D\u5916\u5347\u964D\u53F7\uFF0C`##` \u518D\u5347\u4E24\u4E2A\u534A\u97F3\uFF0C`b` \u518D\u964D\u4E00\u4E2A\u534A\u97F3",type:"string",default:""},{name:"octave",description:"\u5B57\u6BCD\u97F3\u540D\u4F7F\u7528\u7EDD\u5BF9\u516B\u5EA6\uFF1B\u6570\u5B57\u97F3\u540D\u4F7F\u7528\u76F8\u5BF9\u516B\u5EA6\uFF0C\u7701\u7565\u65F6\u4E3A 0",type:"number",default:4},{name:"color",description:"\u97F3\u7B26\u989C\u8272\uFF0C\u4F7F\u7528 CSS \u989C\u8272\u503C",type:"string",default:"#000"}]};static deSugarAtom(t,e,n){let o=0;switch(t[e]){case"(":case"]":o=-1;break;case"[":case")":o=1;break}if(o)return{next:e+1,node:{kind:"sugar",data:{jeOffset:o},span:{start:e,end:e+1},syntaxKind:"punctuation"}};let s=be(t,e,n,!1);if(!s)return null;let i=new Map;i.set("name",s.name),s.octave!==null&&i.set("octave",s.octave),i.set("acc",s.acc??"");let a={kind:"call",typed:!0,name:"note",args:i,span:{start:e,end:s.next},syntaxKind:"atom"};return{next:s.next,node:a}}static deSugarRelation(t,e,n){let o=e[n],s=o.data?.jeOffset;return typeof s!="number"?null:(t.variables[kr]=(t.variables[kr]??0)+s,t.nodes.push(new kt(o.span)),n+1)}labelable(){return this}loweringEnter(){return[new oo(this)]}name;octave;acc;color;size;font;jeOctaveOffset;hasDefaultAcc;constructor(t,e,n,o=null){super(t,o),this.hasDefaultAcc=!!n.variables["note.acc"],[this.name,this.acc,this.octave,this.color]=this.getArgValue(e,n),this.font=n.variables.numberfont,this.size=n.variables.fontsize;let s=be(this.name);if(s instanceof Y)throw s.span=t,s;if(s.next!==this.name.length)throw new k("E_WRONG_NOTE_NAME",'\u51FD\u6570 @note \u7684\u53C2\u6570 [0]:"name" \u683C\u5F0F\u9519\u8BEF: \u65E0\u6CD5\u89E3\u6790\u5C3E\u90E8 "{tail}"',t,{tail:this.name.slice(s.next)});this.name=s.name==="X"?"9":s.name==="Z"?"0":s.name;let i=e.get("octave")??e.get(2);if(i!==void 0){if(s.octave!==null&&s.octave!=i)throw new k("E_NOTE_OCTAVE_CONFLICT",'\u51FD\u6570 @note \u7684\u53C2\u6570 "octave" \u4E0E\u97F3\u7B26\u540D\u79F0\u4E2D\u7684\u516B\u5EA6\u4FE1\u606F\u51B2\u7A81: {inputOctave} != {noteOctave}',t,{inputOctave:String(i),noteOctave:s.octave})}else s.octave!==null?this.octave=s.octave:s.absOctave||(this.octave=0);this.jeOctaveOffset=n.variables[kr]??0,s.acc!==null&&(this.acc=s.acc+this.acc)}toString(){return`@n(${this.name}, ${this.acc||'""'}, ${this.octave}, ${this.color})`}},pa=Er,su={8:"",9:"X"},oo=class extends tt{resolvedMidi=null;keySignature="C4";transposeDiatonic;name;acc;octave;accidentals=[];numberStyle;numberY=0;constructor(t){super(),this.ast=t,this.T.set(1),this.mergeKey=zt,this.name=t.name,this.acc=t.acc,this.octave=t.octave+t.jeOctaveOffset,this.numberStyle={fontSize:t.size,fontFamily:t.font,fontWeight:400,textAlign:"center",fill:t.color},this.initLayoutBox()}prepareLayout(t){let{size:e,color:n}=this.ast,o=t.textMeasurer.measureText("0",this.numberStyle);this.numberY=o.baseline;let s=e*.01,{placed:i,right:a}=Kn(this.acc,e,0,this.numberY,s);this.accidentals=i,this.box.w=a+o.w,this.box.h=o.h,this.box.anchor=a+o.w/2,this.box.visualAxis=o.h/2,this.ports["body.left"]={x:this.box.anchor-o.w/2,y:this.box.visualAxis},this.ports["body.right"]={x:this.box.anchor+o.w/2,y:this.box.visualAxis},this.ports.shoulder={x:this.box.anchor,y:0},this.ports["decoration.below"]={x:this.box.anchor,y:this.numberY+e*.04},this.ports.dot={x:this.box.w,y:o.h*.64};let c=Math.abs(this.octave);if(c===0)return;let l=this.octave>0,u=e*.075,p=e*.08,m=u*2+p,d={fill:n},f=0,x=c*u*2+(c-1)*p,y={[l?"above":"below"]:{order:100,gap:p,height:x,place:h=>{f=h}},paint:h=>{for(let g=0;g<c;g++){let b=l?f+x-u-g*m:f+u+g*m;h.drawCircle(this.box.x+this.box.anchor,this.box.y+b,u,d)}}};this.decorations.push(y)}finalizeLayout(){this.ports.lyric={x:this.box.anchor,y:this.box.h},this.octave>0&&(this.ports["tie.top"]={x:this.box.anchor,y:St(this,!0).y-this.box.y-this.ast.size*.05})}paint(t){let e=this.ast.color;for(let o of this.accidentals)Yn(t,o,this.box,e);let n=su[this.name]??this.name;n&&t.drawText(n,this.box.x+this.box.anchor,this.box.y+this.numberY,this.numberStyle)}onTimeState(t){let e=this.keySignature=t.keySignature;if(this.playbackState={bpm:t.bpm,velocity:t.velocity,program:t.program},this.resolvedMidi=hr(this.name,this.acc,this.octave,e),this.name>="0"&&this.name<="9")(this.name==="0"||this.name>="8")&&(this.octave=0,this.acc="");else{let n=Un(this.name,this.acc,this.octave,e);n&&(this.name=n.renderName,this.acc=n.renderAcc,this.octave=n.renderOctave)}this.transposeDiatonic=Ji(this.name,this.octave,e)}emitPlayback(t){let e=this.ast.name==="9",n=e?37:this.resolvedMidi,o=e?0:this.playbackState?.pitchShift??0,s=this.transposeDiatonic;if(!(t.end.compare(t.start)<=0)){if(n===null){t.span({start:t.start,end:t.end});return}t.note({start:t.start,end:t.end,midi:n+o,velocity:this.playbackState?.velocity??Me,...e?{percussion:!0}:{transpose:o&&s?i=>s(i)+o:s}})}}};var Pr=class r extends B{static def={name:["ottava"],description:"\u516B\u5EA6\u53F7",details:"~~~jpfun\n1@a 2 3 -@b | 4\n@ottava(a, b, 1)\n~~~\n`shift` \u4E3A\u975E\u96F6\u6574\u6570\u516B\u5EA6\u6570\uFF0C\u6B63\u6570\u5728\u4E0A\u65B9\u6807\u9AD8\u516B\u5EA6\u53F7\uFF0C\u8D1F\u6570\u5728\u4E0B\u65B9\u6807\u4F4E\u516B\u5EA6\u53F7\uFF0C\u9ED8\u8BA4 `1`\u3002\u6807\u7B7E\u4F7F\u7528\u8C31\u9762\u6570\u5B57\u5B57\u4F53\u7684\u659C\u4F53\u3002",allowExtraArgs:!1,args:[{description:"\u8D77\u70B9\u6807\u7B7E",type:"label",default:null},{description:"\u7EC8\u70B9\u6807\u7B7E",type:"label",default:null},{name:"shift",description:"\u975E\u96F6\u6574\u6570\u516B\u5EA6\u6570\uFF0C\u6B63\u6570\u4E3A\u9AD8\uFF0C\u8D1F\u6570\u4E3A\u4F4E",type:"number",default:1}]};static loweringFinalize(t){let e=new Map;for(let n of t.attachments){if(!(n instanceof ro))continue;let[o,s]=n.endPoints,i={start:o.t,end:s.t.clone().add(s.T),shift:n.ast.shift*12},a=e.get(o.track);a?a.push(i):e.set(o.track,[i])}if(e.size!==0){for(let n of e.values())n.sort((o,s)=>o.start.compare(s.start));for(let n of t.astToTemporal.values())for(let o of n){if(!o.playbackState)continue;let s=o.rootHost,i=e.get(s.track);if(!i)continue;let a=0;for(let c of i){if(s.t.compare(c.start)<0)break;s.t.compare(c.end)<0&&(a+=c.shift)}a!==0&&(o.playbackState={...o.playbackState,pitchShift:(o.playbackState.pitchShift??0)+a})}}}from;to;shift;size;font;constructor(t,e,n,o=null){super(t,o);let[s,i,a]=this.getArgValue(e,n);if(!Number.isSafeInteger(a)||a===0||!Number.isSafeInteger(a*12))throw new k("E_OTTAVA_INVALID_SHIFT","@ottava \u7684 shift \u5FC5\u987B\u4E3A\u53EF\u5B89\u5168\u6362\u7B97\u4E3A\u534A\u97F3\u7684\u975E\u96F6\u6574\u6570",t);this.from=s,this.to=i,this.shift=a,this.size=n.variables.fontsize,this.font=n.variables.numberfont}loweringEnter(t){let e=t.getTemporalNodes(this.from).at(0)?.rootHost,n=t.getTemporalNodes(this.to).at(-1)?.rootHost;if(!e||!n||!W(e)||!W(n))return t.diagnostics.push(Y.warning.UnresolvedEndpoint("ottava",this.sourceSpan)),[];if(e.track!==n.track)throw new k("E_OTTAVA_CROSS_TRACK","@ottava \u7684\u4E24\u4E2A\u7AEF\u70B9\u5FC5\u987B\u4F4D\u4E8E\u540C\u4E00\u97F3\u8F68",this.sourceSpan);return t.addAttachment(new ro(this,e,n)),t.deferFinalize(r.loweringFinalize),[]}toString(t){let e=n=>(n instanceof B?n.label:void 0)??n.toString(t);return`@ottava(${e(this.from)}, ${e(this.to)}, ${this.shift})`}},ma=Pr,ro=class{constructor(t,e,n){this.ast=t;this.endPoints=(e.t.compare(n.t)||e.order-n.order)>0?[n,e]:[e,n]}ast;layer="foreground";endPoints;get sourceSpan(){return this.ast.sourceSpan}createGeometry(t){let[e,n]=this.endPoints,o=e.layoutLine,s=n.layoutLine;if(t.lines[o].columnOf(e)<0||t.lines[s].columnOf(n)<0)return{regions:[],paint(){}};let{size:i,font:a,shift:c}=this.ast,l=c>0,u=e.track,p=Math.max(.75,i*.035),m={stroke:"#000",strokeWidth:p},d=i*.22,f=d+i*.14,x=p/2,y=i*.45,h=i*.2,g=i*.08,b=String(Math.abs(c)*7+1),T={fontSize:i*.6,fontFamily:a,fontStyle:"italic",textAlign:"left",fill:"#000"},L=t.textMeasurer.measureText(b,T),w=l?-x:x-L.h,A=w+L.baseline,C=Array.from({length:s-o+1},(_,E)=>{let v=o+E,S=v===o,M=v===s,I=S?e.box.x+(e.ports["body.left"]?.x??0):Ut(t,v,u),z=M?n.box.x+(n.ports["body.right"]?.x??n.box.w):Kt(t,v);I>z&&([I,z]=[z,I]);let j=S?I+L.w+g:I,q=(R,D,U,Q)=>({x:R,y:D,w:U,h:Q,line:v,track:u}),et=j<z?[q(j-x,-x,z-j+p,p)]:[];S&&et.push(q(I,w,L.w,L.h)),M&&et.push(q(z-x,l?-x:-y-x,p,y+p));let N=q(0,0,0,0);Oe(N,et);let O=l?1/0:-1/0;for(let R of et)for(let[D,U]of t.getHorizontalExtents(v,R.x,R.x+R.w)){let Q=t.getVisualAxis(v,D);O=l?Math.min(O,Q+U.top-h-R.y-R.h):Math.max(O,Q+U.bottom+h-R.y)}if(!Number.isFinite(O)){let R=t.getRangeExtents(v,S||M?this.endPoints:void 0,u),D=t.getVisualAxis(v,u);O=l?D+(R?.top??0)-h-(N.y+N.h):D+(R?.bottom??0)+h-N.y}for(let R of et)R.y+=O;return N.y+=O,{left:I,right:z,lineStart:j,lineY:O,first:S,last:M,parts:et,region:N}});return{regions:C.map(_=>_.region),occupancy:C.flatMap(_=>_.parts),paint(_){for(let E of C){let{left:v,right:S,lineStart:M,lineY:I,first:z,last:j}=E;for(let q=M;q<S;q+=f)_.drawLine(q,I,Math.min(q+d,S),I,m);z&&_.drawText(b,v,I+A,T),j&&_.drawLine(S,I,S,I+(l?y:-y),m)}}}}};var Mr=Number.MAX_VALUE,$e=new WeakMap,Rr=class r extends B{static def={name:["rest"],description:"\u591A\u5C0F\u8282\u4F11\u6B62",details:`~~~jpfun
|
|
61
59
|
@meter(4,4) | @rest(19) |
|
|
62
60
|
~~~
|
|
63
|
-
\u4F7F\u7528\u5F53\u524D\u62CD\u53F7\u4EA7\u751F 19 \u4E2A\u6574\u5C0F\u8282\u7684\u9759\u97F3\uFF08\u5FC5\u987B\u5148\u58F0\u660E\u62CD\u53F7\uFF09`,allowExtraArgs:!1,args:[{name:"n",description:"\u4F11\u6B62\u7684\u5C0F\u8282\u6570",type:"number",default:1},{name:"width",description:"\u6A2A\u7EBF\u7684\u6700\u5C0F\u5BBD\u5EA6",type:"length",default:{value:3,unit:"em"}},{name:"size",description:"\u6570\u5B57\u5B57\u53F7\u4E0E\u7B14\u753B\u5C3A\u5BF8",type:"length",default:{value:1,unit:"em"}}]};count;width;size;font;constructor(t,e,n,o=null){super(t,o);let[i,r,a]=this.getArgValue(e,n);if(!Number.isSafeInteger(i)||i<=0||i>4294967295)throw new k("E_REST_COUNT","@rest \u7684 n \u5FC5\u987B\u662F\u6B63\u5B89\u5168\u6574\u6570\uFF0C\u4E14\u5C0F\u8282\u7EBF\u6570\u91CF\u53EF\u7531\u6570\u7EC4\u8868\u793A",t);if(this.count=i,this.width=n.length2px(r),this.size=n.length2px(a),!Number.isFinite(this.width)||this.width<0||!Number.isFinite(this.size)||this.size<=0)throw new k("E_REST_SIZE","@rest \u7684 width \u5FC5\u987B\u6709\u9650\u4E14\u975E\u8D1F\uFF0Csize \u5FC5\u987B\u6709\u9650\u4E14\u4E3A\u6B63",t);this.font=n.variables.numberfont}labelable(){return this}loweringEnter(){return[new ys(this)]}static loweringFinalize(t){if(!t.columns.some(r=>r.some(a=>a.mergeKey===ms)))return;let e=0,n=new Map;for(let r of t.astToTemporal.values())for(let a of r){if(e=Math.max(e,a.order+1),!(a.ast instanceof $)||a.ast.callName!=="note"&&a.ast.callName!=="dash")continue;let c=a;for(;c.foldedInto;)c=c.foldedInto;if(a.track!==c.track)continue;let l=n.get(c);(!l||a.order<l.order)&&n.set(c,a)}let o=[],i=new Map;for(let r of t.columns){o.push(r);let a;for(let l of r){if(l.T.compare(0)>0){let f=n.get(l),u=i.get(l.track);if(u&&De.has(u)&&f?.ast instanceof $&&f.ast.callName==="dash")throw new k("E_REST_SUSTAIN","\u589E\u65F6\u7EBF\u4E0D\u80FD\u5EF6\u7EED\u6574\u5C0F\u8282\u4F11\u6B62",f.ast.sourceSpan);i.set(l.track,l)}let p=De.get(l);p&&(!a||p.T.compare(a.T)>0)&&(a=p)}if(!a)continue;let c=a.t.clone();for(let l=1;l<a.ast.count;l++){c.add(a.measureDuration);let p=new tt;p.ast=new Tt(a.ast.sourceSpan,a.ast),p.t.copyFrom(c),p.track=a.track,p.layoutLine=a.layoutLine,p.order=e++,p.mergeKey=mt,t.astToTemporal.set(p.ast,[p]),o.push([p])}}t.columns=o}toString(){return`@rest(${this.count})`}},Pr=xs,ys=class extends tt{measureDuration=new F;metrics;lineWidth=0;textStyle;constructor(t){super(),this.ast=t,this.mergeKey=ms,De.set(this,this),this.initLayoutBox(),this.textStyle={fontSize:t.size,fontFamily:t.font,textAlign:"center"}}onTimeState(t){let e=t.meter;if(!(e instanceof F))throw new k("E_REST_METER","\u6574\u5C0F\u8282\u4F11\u6B62\u524D\u5FC5\u987B\u6709\u5B9E\u9645\u751F\u6548\u7684\u663E\u5F0F\u62CD\u53F7",this.ast.sourceSpan);if(!Number.isSafeInteger(e.numerator*this.ast.count))throw new k("E_REST_COUNT","@rest \u7684\u603B\u65F6\u503C\u8D85\u51FA\u7CBE\u786E\u6574\u6570\u8303\u56F4",this.ast.sourceSpan);this.measureDuration.copyFrom(e),this.T.copyFrom(e).mul(this.ast.count);let n=t.currentEvent??this;if(n.mergeKey===ms&&this.track===n.track){let o=De.get(n);(!o||this.order<o.order)&&De.set(n,this)}return this.playbackState={bpm:t.bpm},this.T}emitPlayback(t){t.span({start:t.start,end:t.end})}prepareLayout(t){let e=this.ast.size,n=6/Math.sqrt(this.T.toNumber());this.springConfig={alpha_L:n,alpha_R:n},this.metrics=t.textMeasurer.measureText(String(this.ast.count),this.textStyle),this.lineWidth=Math.max(this.ast.width,this.metrics.w+e*.5),this.box.w=this.lineWidth+e*.25,this.box.h=this.metrics.h+e*.5,this.box.anchor=e*.4,this.box.visualAxis=this.box.h-e*.65/2}prepareHorizontal(t){let e=this;for(;t.columnOf(e)<0&&e.foldedInto&&X(e.foldedInto);)e=e.foldedInto;let n=t.columnOf(e);if(n<0)return;let o=a=>t.columns[a]?.find(c=>c.track===e.track&&c.mergeKey===mt)??e,i=o(n-1),r=o(n+1);i!==r&&t.registerHorizontalLayoutHook(i,r,({columns:a,rows:c,start:l,end:p,X:f,fixed:u})=>{for(let h=l;h<p;h++){if(u[h])continue;let d=0;for(let m=0;m<c;m++){let g=a[h][m],x=a[h+1][m],b=De.get(x.time),A=b?b.ast.size*.25:0;d=Math.max(d,g.WR+x.WL+A)}let y=f[h]+d-f[h+1];for(let m=h+1;m<f.length&&(f[m]+=y,!!u[m]);m++);u[h]=1}})}paint(t){let{size:e,count:n}=this.ast,o=this.box.x,i=o+this.lineWidth,r=this.box.y+this.box.visualAxis,a=e*.12,c=a*2,l=(e*.65-a)/2;t.drawLine(o+c/2,r,i-c/2,r,{strokeWidth:c}),t.drawLine(o+a/2,r-l,o+a/2,r+l,{strokeWidth:a}),t.drawLine(i-a/2,r-l,i-a/2,r+l,{strokeWidth:a}),t.drawText(String(n),o+this.lineWidth/2,this.box.y+this.metrics.baseline,this.textStyle)}};var Vn=class s extends ${contents=[];belows=[];size;get side(){return this.constructor.side}get children(){return this.belows.length?[...this.contents,...this.belows]:this.contents}constructor(t,e,n,o=null){super(t,o),this.size=n.variables.fontsize;for(let[,i]of e){if(i instanceof Tt){this.addContent(i,this.side,n);continue}let r=n.parseArgWithType(i.valueSpan,"content",t.start);r!==null&&this.addContent(r,this.side,n)}}labelable(){return this.children.some($.findLabelable)?this:null}addContent(t,e,n){return this.contents.length===0&&(e="above"),t instanceof s?this.flatten(t,e,n):((e==="above"?this.contents:this.belows).push(t),t.parent=this,this.growSpan(t.sourceSpan),this)}growSpan(t){this.sourceSpan.start=Math.min(this.sourceSpan.start,t.start),this.sourceSpan.end=Math.max(this.sourceSpan.end,t.end)}loweringEnter(t,e){let n=[];return t.isolateFromLoweringGroups(()=>{for(let o of this.children){let i=t.trackedEvents(o,new F,e),r=i.length===1&&i[0].length===1?i[0][0]:void 0;if(!r||!X(r)||(r.addon?.breakBefore??0)>0)throw new k("E_UP_INVALID_CHILD","@up \u7684\u6BCF\u4E2A\u53C2\u6570\u5FC5\u987B\u6070\u597D\u4EA7\u751F\u4E00\u4E2A\u53EF\u89C1 Temporal\uFF0C\u4E14\u4E0D\u80FD\u6362\u884C\u6216\u5305\u542B\u591A\u58F0\u90E8\u7ED3\u6784",o.sourceSpan);n.push(r)}}),[new ws(this,n)]}toString(t){let e=this.contents.map(o=>o.toString(t));return this.belows.length===0?`@up(${e.join(", ")})`:`@down(${[e.length>1?`@up(${e.join(", ")})`:e[0],...this.belows.map(o=>o.toString(t))].join(", ")})`}flatten(t,e,n){let o=t.sourceSpan.start<this.sourceSpan.start?t:this,i=o===t?this:t,[r,...a]=i.contents,c=r?[r]:[],l=[...o.contents,...e==="above"?c:[],...a],p=[...o.belows,...e==="below"?c:[],...i.belows];this.contents=l,this.belows=p;for(let u of this.children)u.parent=this;this.growSpan(t.sourceSpan),t.contents=[],t.belows=[];let f=n.labelableNodes.indexOf(t);return f>=0&&n.labelableNodes.splice(f,1),this}static desugar(t,e,n){let o=e[n++];if(!(o.kind==="sugar"&&o.data===this))return null;let i=this.side==="above"?"@up":"@down",r=t.nodes.length-1;for(;r>=0&&t.nodes[r]instanceof xt;)r--;if(r<0)throw new k("E_FOLD_NO_TARGET",`${i}\u8BED\u6CD5\u7CD6\u9519\u8BEF: \u5DE6\u8FB9\u6CA1\u6709\u627E\u5230\u53EF\u53E0\u52A0\u7684\u76EE\u6807`,o.span);let a=t.nodes[r],c=r;if(a instanceof Ht){let f=a,u=f.target;for(;u&&!t.nodes.includes(u);)u=u.parent;for(let h=r-1;h>=0;h--)if(t.nodes[h]===u){a=new dt({start:u.sourceSpan.start,end:f.sourceSpan.end},t.nodes.slice(h,r+1),null),c=h;break}}let l=a instanceof s?a:new this(o.span,new Map,t).addContent(a,"above",t),p=t.nodes;t.nodes=[],t.makeNodes(e,n);for(let f=0;f<t.nodes.length;f++){let u=t.nodes[f];if(u instanceof xt)continue;let h=u instanceof s?u.flatten(l,this.side,t):l.addContent(u,this.side,t);for(p.length=c,p.push(h);++f<t.nodes.length;)p.push(t.nodes[f]);return t.nodes=p,t.labelableNodes.push(h.labelable()),e.length}throw new k("E_FOLD_NO_TARGET",`${i}\u8BED\u6CD5\u7CD6\u9519\u8BEF: \u53F3\u8FB9\u6CA1\u6709\u627E\u5230\u53EF\u53E0\u52A0\u7684\u76EE\u6807`,o.span)}},gs=class s extends Vn{static side="above";static def={name:["up"],description:"\u628A\u540C\u4E00\u65F6\u95F4\u4F4D\u7F6E\u7684\u53EF\u89C1\u5BF9\u8C61\u5411\u4E0A\u5806\u53E0",details:"~~~jpfun\n@up(1, 3, 5)\n~~~\n\n\u7B2C\u4E00\u4E2A\u5185\u5BB9\u53C2\u6570\u4E3A\u5BBF\u4E3B\uFF0C\u5176\u4F59\u4F9D\u6B21\u53E0\u5728\u4E0A\u65B9\uFF1B\u6240\u6709\u6210\u5458\u5171\u4EAB\u5BBF\u4E3B\u65F6\u503C\u3002\u5E38\u7528\u4E8E\u548C\u5F26\u3001\u901F\u5EA6\u8BB0\u53F7\u548C\u97F3\u7B26\u6CE8\u91CA\u3002\n\n**\u7B80\u5199**\uFF1A`1 ^ 3 ^ 5`\u3002\u590D\u6742\u5185\u5BB9\u53EF\u7528 `{...}` \u5305\u88F9\uFF1B\u9700\u8981\u72EC\u7ACB\u8282\u594F\u7684\u5E76\u884C\u5206\u652F\u65F6\uFF0C\u4F7F\u7528 `&` / `@stack`\u3002",allowExtraArgs:!0,extraArgType:"content",args:[]};static deSugarAtom(t,e,n){if(t[e]!=="^")return null;let o={kind:"sugar",data:s,span:{start:e,end:e+1}};return{next:e+1,node:o}}static deSugarRelation(t,e,n){return s.desugar(t,e,n)}},bs=class s extends Vn{static side="below";static def={name:["down"],description:"\u628A\u540C\u4E00\u65F6\u95F4\u4F4D\u7F6E\u7684\u53EF\u89C1\u5BF9\u8C61\u5411\u4E0B\u5806\u53E0",details:"~~~jpfun\n@down(1, $p)\n~~~\n\u7B2C\u4E00\u4E2A\u5185\u5BB9\u53C2\u6570\u4E3A\u5BBF\u4E3B\uFF0C\u5176\u4F59\u4F9D\u6B21\u53E0\u5728\u4E0B\u65B9\u5E76\u5171\u4EAB\u5176\u65F6\u503C\uFF0C\u5E38\u7528\u4E8E\u529B\u5EA6\u7B49\u4E0B\u65B9\u6807\u8BB0\u3002\n\n**\u7B80\u5199**\uFF1A`1 _ $p`\u3002\u4E0E `^` \u6DF7\u5199\u65F6\u5171\u7528\u540C\u4E00\u5BBF\u4E3B\uFF1A`1^2_3` \u5C06 `2` \u653E\u5728 `1` \u4E0A\u65B9\u3001`3` \u653E\u5728\u4E0B\u65B9\u3002",allowExtraArgs:!0,extraArgType:"content",args:[]};static deSugarAtom(t,e,n){if(t[e]!=="_")return null;let o={kind:"sugar",data:s,span:{start:e,end:e+1}};return{next:e+1,node:o}}static deSugarRelation(t,e,n){return s.desugar(t,e,n)}},Dr=gs,Br=bs,ws=class extends tt{members;aboveCount;verticalOffsets=[];constructor(t,e){super(),this.ast=t,this.members=e,this.aboveCount=t.contents.length;let n=e[0];this.mergeKey=n&&n.mergeKey!==n.order?n.mergeKey:Dt;let o=this.mergeKey===Dt||this.mergeKey===mt;!o&&n&&this.T.copyFrom(n.T),this.initLayoutBox();let i=n?.addon;i&&(this.addon={...i});for(let r of e)o&&this.T.isZero()&&this.T.copyFrom(r.T),r.mergeKey===mt&&(this.mergeKey=mt),r.addon=void 0,r.foldedInto=this}onTimeState(t){let e=this.T.clone(),n,o=!1;for(let r=this.members.length-1;r>=0;r--){let a=this.members[r];!a.T.isZero()&&!this.T.isZero()&&a.T.copyFrom(this.T),a.t.copyFrom(this.t),a.track=this.track,a.layoutLine=this.layoutLine,n=a.onTimeState?.(t),o||=!a.T.isZero()&&!a.T.equals(e)}let i=this.members[0];if(i&&!i.T.isZero()&&(this.T.copyFrom(i.T),o))for(let r of this.members)r.T.isZero()||r.T.copyFrom(this.T);return n}emitPlayback(t){for(let e=this.members.length-1;e>=0;e--)t.play(this.members[e])}prepareHorizontal(t){this.members[0]?.prepareHorizontal?.(t)}prepareLayout(t){this.members[0]&&le(this,this.members[0]);let e=this.members[0];if(!e){this.box.w=this.box.h=0,this.box.anchor=this.box.visualAxis=0;return}this.box.w=ke([e],t);for(let f=1;f<this.members.length;f++)ke([this.members[f]],t);this.springConfig={...e.springConfig,...this.springConfig};let n=e.box.x+e.box.anchor,o=this.ast.size*.12;this.verticalOffsets.length=this.members.length,this.verticalOffsets[0]=0;let i=wt(e),r=i.y;for(let f=1;f<this.aboveCount;f++){let u=wt(this.members[f]);this.verticalOffsets[f]=r-o-u.y-u.h,r-=o+u.h}let a=i.y+i.h;for(let f=this.aboveCount;f<this.members.length;f++){let u=wt(this.members[f]);this.verticalOffsets[f]=a+o-u.y,a+=o+u.h}for(let f=0;f<this.verticalOffsets.length;f++)this.verticalOffsets[f]-=r;this.box.h=a-r,this.box.anchor=n,this.box.visualAxis=e.box.visualAxis-r;let c=this.verticalOffsets[0];for(let f in e.ports){let u=e.ports[f];this.ports[f]={...u,x:e.box.x+u.x,y:c+u.y}}this.ports["body.left"]??={x:e.box.x,y:this.box.visualAxis},this.ports["body.right"]??={x:e.box.x+e.box.w,y:this.box.visualAxis};let l=this.aboveCount-1,p=this.verticalOffsets[l];this.ports["tie.top"]={x:n,y:p+(this.members[l].ports["tie.top"]?.y??wt(this.members[l],!0).y)}}onPlaced(){for(let t=0;t<this.members.length;t++){let e=this.members[t];e.box.x=this.box.x+this.box.anchor-e.box.anchor,e.box.y=this.box.y+this.verticalOffsets[t],e.onPlaced?.()}}paint(t){for(let e of this.members){e.paint(t);for(let n of e.decorations)n.paint?.(t)}}};var Be=s=>({value:s,unit:"px"}),Ss=16,gl={fontSize:Ss,textAlign:"center",fill:"#606060"};function bl(s,t,e){let n=s.lastIndexOf("1"),o=s.indexOf("1")!==n;return s.replace(/1/g,(i,r)=>String(o&&r===n?e:t))}var As=class{sourceSpan;pattern;marginBottom;style;layer="foreground";constructor(t,e,n,o){this.sourceSpan=t,this.pattern=e,this.marginBottom=n,this.style=o}createGeometry(t){let e=this.style,n=t.pages.map((o,i)=>{let r=bl(this.pattern,i+1,t.pages.length),{w:a,h:c,baseline:l}=t.textMeasurer.measureText(r,e),p=o.y+o.h-this.marginBottom/2;return{text:r,x:o.x+o.w/2,y:p-c/2+l,w:a,h:c,baseline:l}});return{regions:n.map(({x:o,y:i,w:r,h:a,baseline:c})=>({x:o-r/2,y:i-c,w:r,h:a})),paint(o){for(let i of n)o.drawText(i.text,i.x,i.y,e)}}}},Es=class extends ${static def={name:["page"],description:"\u8BBE\u7F6E\u6587\u6863\u9875\u9762",details:`~~~jpfun
|
|
61
|
+
\u4F7F\u7528\u5F53\u524D\u62CD\u53F7\u4EA7\u751F 19 \u4E2A\u6574\u5C0F\u8282\u7684\u9759\u97F3\uFF08\u5FC5\u987B\u5148\u58F0\u660E\u62CD\u53F7\uFF09`,allowExtraArgs:!1,args:[{name:"n",description:"\u4F11\u6B62\u7684\u5C0F\u8282\u6570",type:"number",default:1},{name:"width",description:"\u6A2A\u7EBF\u7684\u6700\u5C0F\u5BBD\u5EA6",type:"length",default:{value:3,unit:"em"}},{name:"size",description:"\u6570\u5B57\u5B57\u53F7\u4E0E\u7B14\u753B\u5C3A\u5BF8",type:"length",default:{value:1,unit:"em"}}]};count;width;size;font;constructor(t,e,n,o=null){super(t,o);let[s,i,a]=this.getArgValue(e,n);if(!Number.isSafeInteger(s)||s<=0||s>4294967295)throw new k("E_REST_COUNT","@rest \u7684 n \u5FC5\u987B\u662F\u6B63\u5B89\u5168\u6574\u6570\uFF0C\u4E14\u5C0F\u8282\u7EBF\u6570\u91CF\u53EF\u7531\u6570\u7EC4\u8868\u793A",t);if(this.count=s,this.width=n.length2px(i),this.size=n.length2px(a),!Number.isFinite(this.width)||this.width<0||!Number.isFinite(this.size)||this.size<=0)throw new k("E_REST_SIZE","@rest \u7684 width \u5FC5\u987B\u6709\u9650\u4E14\u975E\u8D1F\uFF0Csize \u5FC5\u987B\u6709\u9650\u4E14\u4E3A\u6B63",t);this.font=n.variables.numberfont}labelable(){return this}loweringEnter(t){return t.deferFinalize(r.loweringFinalize,-10),[new _r(this)]}static loweringFinalize(t){if(!t.columns.some(i=>i.some(a=>a.mergeKey===Mr)))return;let e=0,n=new Map;for(let i of t.astToTemporal.values())for(let a of i){if(e=Math.max(e,a.order+1),!(a.ast instanceof B)||a.ast.callName!=="note"&&a.ast.callName!=="dash")continue;let c=a.rootHost;if(a.track!==c.track)continue;let l=n.get(c);(!l||a.order<l.order)&&n.set(c,a)}let o=[],s=new Map;for(let i of t.columns){o.push(i);let a;for(let l of i){if(l.T.compare(0)>0){let p=n.get(l),m=s.get(l.track);if(m&&$e.has(m)&&p?.ast instanceof B&&p.ast.callName==="dash")throw new k("E_REST_SUSTAIN","\u589E\u65F6\u7EBF\u4E0D\u80FD\u5EF6\u7EED\u6574\u5C0F\u8282\u4F11\u6B62",p.ast.sourceSpan);s.set(l.track,l)}let u=$e.get(l);u&&(!a||u.T.compare(a.T)>0)&&(a=u)}if(!a)continue;let c=a.t.clone();for(let l=1;l<a.ast.count;l++){c.add(a.measureDuration);let u=new tt;u.ast=new Ht(a.ast.sourceSpan,a.ast),u.t.copyFrom(c),u.track=a.track,u.layoutLine=a.layoutLine,u.order=e++,u.mergeKey=gt,t.astToTemporal.set(u.ast,[u]),o.push([u])}}t.columns=o}toString(){return`@rest(${this.count})`}},da=Rr,_r=class extends tt{measureDuration=new G;metrics;lineWidth=0;textStyle;constructor(t){super(),this.ast=t,this.mergeKey=Mr,$e.set(this,this),this.initLayoutBox(),this.textStyle={fontSize:t.size,fontFamily:t.font,textAlign:"center"}}onTimeState(t){let e=t.meter;if(!(e instanceof G))throw new k("E_REST_METER","\u6574\u5C0F\u8282\u4F11\u6B62\u524D\u5FC5\u987B\u6709\u5B9E\u9645\u751F\u6548\u7684\u663E\u5F0F\u62CD\u53F7",this.ast.sourceSpan);if(!Number.isSafeInteger(e.numerator*this.ast.count))throw new k("E_REST_COUNT","@rest \u7684\u603B\u65F6\u503C\u8D85\u51FA\u7CBE\u786E\u6574\u6570\u8303\u56F4",this.ast.sourceSpan);this.measureDuration.copyFrom(e),this.T.copyFrom(e).mul(this.ast.count);let n=this.rootHost;if(n.mergeKey===Mr&&this.track===n.track){let o=$e.get(n);(!o||this.order<o.order)&&$e.set(n,this)}return this.playbackState={bpm:t.bpm},this.T}emitPlayback(t){t.span({start:t.start,end:t.end})}prepareLayout(t){let e=this.ast.size,n=6/Math.sqrt(this.T.toNumber());this.springConfig={alpha_L:n,alpha_R:n},this.metrics=t.textMeasurer.measureText(String(this.ast.count),this.textStyle),this.lineWidth=Math.max(this.ast.width,this.metrics.w+e*.5),this.box.w=this.lineWidth+e*.25,this.box.h=this.metrics.h+e*.5,this.box.anchor=e*.4,this.box.visualAxis=this.box.h-e*.65/2}prepareHorizontal(t){let e=this;for(;t.columnOf(e)<0&&e.foldedInto&&W(e.foldedInto);)e=e.foldedInto;let n=t.columnOf(e);if(n<0)return;let o=a=>t.columns[a]?.find(c=>c.track===e.track&&c.mergeKey===gt)??e,s=o(n-1),i=o(n+1);s!==i&&t.registerHorizontalLayoutHook(s,i,({columns:a,rows:c,start:l,end:u,X:p,fixed:m})=>{for(let d=l;d<u;d++){if(m[d])continue;let f=0;for(let y=0;y<c;y++){let h=a[d][y],g=a[d+1][y],b=$e.get(g.time),T=b?b.ast.size*.25:0;f=Math.max(f,h.WR+g.WL+T)}let x=p[d]+f-p[d+1];for(let y=d+1;y<p.length&&(p[y]+=x,!!m[y]);y++);m[d]=1}})}paint(t){let{size:e,count:n}=this.ast,o=this.box.x,s=o+this.lineWidth,i=this.box.y+this.box.visualAxis,a=e*.12,c=a*2,l=(e*.65-a)/2;t.drawLine(o+c/2,i,s-c/2,i,{strokeWidth:c}),t.drawLine(o+a/2,i-l,o+a/2,i+l,{strokeWidth:a}),t.drawLine(s-a/2,i-l,s-a/2,i+l,{strokeWidth:a}),t.drawText(String(n),o+this.lineWidth/2,this.box.y+this.metrics.baseline,this.textStyle)}};var ya=[{name:"gap",namedOnly:!0,type:"length",default:{value:.12,unit:"em"},description:"\u76F8\u90BB\u5806\u53E0\u6210\u5458\u4E4B\u95F4\u7684\u95F4\u8DDD"}];function fa(r,t,e,n,o){let s=t;for(let i=0;i<e.length;){let a=n[i],c=i+1;for(;c<e.length&&n[c]===a;)c++;let l=e.slice(i,c).map(u=>u.toString(o));s=`@${r}(${[s,...l,`gap=${a}px`].join(", ")})`,i=c}return s}var so=class r extends B{contents=[];belows=[];aboveGaps=[];belowGaps=[];size;gap;get side(){return this.constructor.side}get children(){return this.belows.length?[...this.contents,...this.belows]:this.contents}timeFlowModel(){return null}constructor(t,e,n,o=null){super(t,o),this.size=n.variables.fontsize;let[s]=this.getArgValue(e,n);if(this.gap=n.length2px(s),!Number.isFinite(this.gap)||this.gap<0)throw new k("E_INVALID_FOLD_GAP","@{fn} \u7684 gap \u5FC5\u987B\u662F\u975E\u8D1F\u6709\u9650\u957F\u5EA6",t,{fn:this.callName});for(let[i,a]of e)typeof i=="number"&&this.addContent(a,this.side,n)}labelable(){return this.children.some(B.findLabelable)?this:null}addContent(t,e,n,o=this.gap){return this.contents.length===0&&(e="above"),t instanceof r?this.flatten(t,e,n,o):(e==="above"?(this.contents.length>0&&this.aboveGaps.push(o),this.contents.push(t)):(this.belowGaps.push(o),this.belows.push(t)),t.parent=this,this.growSpan(t.sourceSpan),this)}growSpan(t){this.sourceSpan.start=Math.min(this.sourceSpan.start,t.start),this.sourceSpan.end=Math.max(this.sourceSpan.end,t.end)}loweringEnter(t,e){let n=[];return t.isolateFromLoweringGroups(()=>{for(let o of this.children){let s=t.trackedEvents(o,new G,e),i=s.length===1&&s[0].length===1?s[0][0]:void 0;if(!i||!W(i)||(i.addon?.breakBefore??0)>0)throw new k("E_UP_INVALID_CHILD","@up \u7684\u6BCF\u4E2A\u53C2\u6570\u5FC5\u987B\u6070\u597D\u4EA7\u751F\u4E00\u4E2A\u53EF\u89C1 Temporal\uFF0C\u4E14\u4E0D\u80FD\u6362\u884C\u6216\u5305\u542B\u591A\u58F0\u90E8\u7ED3\u6784",o.sourceSpan);n.push(i)}}),[new Ir(this,n)]}toString(t){if(this.contents.length<=1&&this.belows.length===0)return`@${this.callName}(${[...this.contents.map(n=>n.toString(t)),`gap=${this.gap}px`].join(", ")})`;let e=fa("up",this.contents[0].toString(t),this.contents.slice(1),this.aboveGaps,t);return fa("down",e,this.belows,this.belowGaps,t)}flatten(t,e,n,o=this.gap){let s=t.sourceSpan.start<this.sourceSpan.start?t:this,i=s===t?this:t,[a,...c]=i.contents,l=s.contents.length>0,u=a?[a]:[],p=l&&a?[o]:[],m=!l||e==="above";this.contents=[...s.contents,...m?u:[],...c],this.belows=[...s.belows,...m?[]:u,...i.belows],this.aboveGaps=[...s.aboveGaps,...m?p:[],...i.aboveGaps],this.belowGaps=[...s.belowGaps,...m?[]:p,...i.belowGaps];for(let f of this.children)f.parent=this;this.growSpan(t.sourceSpan),t.contents.length=t.belows.length=t.aboveGaps.length=t.belowGaps.length=0;let d=n.labelableNodes.lastIndexOf(t);return d>=0&&n.labelableNodes.splice(d,1),this}static desugar(t,e,n){let o=e[n++];if(!(o.kind==="sugar"&&o.data===this))return null;let s=this.side==="above"?"@up":"@down",i=t.takeLeftOperand();if(!i)throw new k("E_FOLD_NO_TARGET","{fn}\u8BED\u6CD5\u7CD6\u9519\u8BEF: \u5DE6\u8FB9\u6CA1\u6709\u627E\u5230\u53EF\u53E0\u52A0\u7684\u76EE\u6807",o.span,{fn:s});let a=new this({...o.span},new Map,t),c=i instanceof r?i:a.addContent(i,"above",t),l=t.consumeRightOperand(e,n,u=>{let p=u instanceof r?u.flatten(c,this.side,t,a.gap):c.addContent(u,this.side,t,a.gap);return t.labelableNodes.push(p.labelable()),p});if(l!==null)return l;throw new k("E_FOLD_NO_TARGET","{fn}\u8BED\u6CD5\u7CD6\u9519\u8BEF: \u53F3\u8FB9\u6CA1\u6709\u627E\u5230\u53EF\u53E0\u52A0\u7684\u76EE\u6807",o.span,{fn:s})}},Fr=class r extends so{static side="above";static def={name:["up"],description:"\u628A\u540C\u4E00\u65F6\u95F4\u4F4D\u7F6E\u7684\u53EF\u89C1\u5BF9\u8C61\u5411\u4E0A\u5806\u53E0",details:"~~~jpfun\n@up(1, 3, 5, gap=0.12em)\n~~~\n\n\u7B2C\u4E00\u4E2A\u5185\u5BB9\u53C2\u6570\u4E3A\u5BBF\u4E3B\uFF0C\u5176\u4F59\u4F9D\u6B21\u53E0\u5728\u4E0A\u65B9\uFF1B\u6240\u6709\u6210\u5458\u5171\u4EAB\u5BBF\u4E3B\u65F6\u503C\u3002\u4EC5\u547D\u540D\u53C2\u6570 `gap` \u6307\u5B9A\u76F8\u90BB\u6210\u5458\u7684\u95F4\u8DDD\u3002\u5E38\u7528\u4E8E\u548C\u5F26\u3001\u901F\u5EA6\u8BB0\u53F7\u548C\u97F3\u7B26\u6CE8\u91CA\u3002\n\n**\u7B80\u5199**\uFF1A`1 ^ 3 ^ 5`\u3002\u590D\u6742\u5185\u5BB9\u53EF\u7528 `{...}` \u5305\u88F9\uFF1B\u9700\u8981\u72EC\u7ACB\u8282\u594F\u7684\u5E76\u884C\u5206\u652F\u65F6\uFF0C\u4F7F\u7528 `&` / `@stack`\u3002",allowExtraArgs:!0,extraArgType:"content",args:ya};static deSugarAtom(t,e,n){if(t[e]!=="^")return null;let o={kind:"sugar",data:r,span:{start:e,end:e+1}};return{next:e+1,node:o}}static deSugarRelation(t,e,n){return r.desugar(t,e,n)}},Or=class r extends so{static side="below";static def={name:["down"],description:"\u628A\u540C\u4E00\u65F6\u95F4\u4F4D\u7F6E\u7684\u53EF\u89C1\u5BF9\u8C61\u5411\u4E0B\u5806\u53E0",details:"~~~jpfun\n@down(1, $p, gap=0.12em)\n~~~\n\u7B2C\u4E00\u4E2A\u5185\u5BB9\u53C2\u6570\u4E3A\u5BBF\u4E3B\uFF0C\u5176\u4F59\u4F9D\u6B21\u53E0\u5728\u4E0B\u65B9\u5E76\u5171\u4EAB\u5176\u65F6\u503C\uFF0C\u4EC5\u547D\u540D\u53C2\u6570 `gap` \u6307\u5B9A\u76F8\u90BB\u6210\u5458\u7684\u95F4\u8DDD\uFF0C\u5E38\u7528\u4E8E\u529B\u5EA6\u7B49\u4E0B\u65B9\u6807\u8BB0\u3002\n\n**\u7B80\u5199**\uFF1A`1 _ $p`\u3002\u4E0E `^` \u6DF7\u5199\u65F6\u5171\u7528\u540C\u4E00\u5BBF\u4E3B\uFF1A`1^2_3` \u5C06 `2` \u653E\u5728 `1` \u4E0A\u65B9\u3001`3` \u653E\u5728\u4E0B\u65B9\u3002",allowExtraArgs:!0,extraArgType:"content",args:ya};static deSugarAtom(t,e,n){if(t[e]!=="_")return null;let o={kind:"sugar",data:r,span:{start:e,end:e+1}};return{next:e+1,node:o}}static deSugarRelation(t,e,n){return r.desugar(t,e,n)}},ha=Fr,ga=Or,Ir=class extends tt{members;aboveCount;verticalOffsets=[];constructor(t,e){super(),this.ast=t,this.members=e,this.aboveCount=t.contents.length;let n=e[0];this.mergeKey=n&&n.mergeKey!==n.order?n.mergeKey:zt;let o=this.mergeKey===zt||this.mergeKey===gt;!o&&n&&this.T.copyFrom(n.T),this.initLayoutBox();let s=n?.addon;s&&(this.addon={...s});for(let i of e)o&&this.T.isZero()&&this.T.copyFrom(i.T),i.mergeKey===gt&&(this.mergeKey=gt),i.addon=void 0,i.foldedInto=this}onTimeState(t){let e=this.T.clone(),n,o=!1;for(let i=this.members.length-1;i>=0;i--){let a=this.members[i];!a.T.isZero()&&!this.T.isZero()&&a.T.copyFrom(this.T),a.t.copyFrom(this.t),a.track=this.track,a.layoutLine=this.layoutLine,n=a.onTimeState?.(t),o||=!a.T.isZero()&&!a.T.equals(e)}let s=this.members[0];if(s&&!s.T.isZero()&&(this.T.copyFrom(s.T),o))for(let i of this.members)i.T.isZero()||i.T.copyFrom(this.T);return n}emitPlayback(t){for(let e=this.members.length-1;e>=0;e--)t.play(this.members[e])}prepareHorizontal(t){this.members[0]?.prepareHorizontal?.(t)}prepareLayout(t){this.members[0]&&ye(this,this.members[0]);let e=this.members[0];if(!e){this.box.w=this.box.h=0,this.box.anchor=this.box.visualAxis=0;return}this.box.w=Ie([e],t);for(let u=1;u<this.members.length;u++)Ie([this.members[u]],t);this.springConfig={...e.springConfig};let n=e.box.x+e.box.anchor;this.verticalOffsets.length=this.members.length,this.verticalOffsets[0]=0;let o=St(e),s=o.y;for(let u=1;u<this.aboveCount;u++){let p=this.ast.aboveGaps[u-1],m=St(this.members[u]);this.verticalOffsets[u]=s-p-m.y-m.h,s-=p+m.h}let i=o.y+o.h;for(let u=this.aboveCount;u<this.members.length;u++){let p=this.ast.belowGaps[u-this.aboveCount],m=St(this.members[u]);this.verticalOffsets[u]=i+p-m.y,i+=p+m.h}for(let u=0;u<this.verticalOffsets.length;u++)this.verticalOffsets[u]-=s;this.box.h=i-s,this.box.anchor=n,this.box.visualAxis=e.box.visualAxis-s;let a=this.verticalOffsets[0];for(let u in e.ports){let p=e.ports[u];this.ports[u]={...p,x:e.box.x+p.x,y:a+p.y}}this.ports["body.left"]??={x:e.box.x,y:this.box.visualAxis},this.ports["body.right"]??={x:e.box.x+e.box.w,y:this.box.visualAxis};let c=this.aboveCount-1,l=this.verticalOffsets[c];this.ports["tie.top"]={x:n,y:l+(this.members[c].ports["tie.top"]?.y??St(this.members[c],!0).y)}}onPlaced(){for(let t=0;t<this.members.length;t++){let e=this.members[t];e.box.x=this.box.x+this.box.anchor-e.box.anchor,e.box.y=this.box.y+this.verticalOffsets[t],e.onPlaced?.()}}paint(t){for(let e of this.members){e.paint(t);for(let n of e.decorations)n.paint?.(t)}}};var je=r=>({value:r,unit:"px"}),Br=16,iu={fontSize:Br,textAlign:"center",fill:"#606060"};function au(r,t,e){let n=r.lastIndexOf("1"),o=r.indexOf("1")!==n;return r.replace(/1/g,(s,i)=>String(o&&i===n?e:t))}var Dr=class{constructor(t,e,n,o){this.sourceSpan=t;this.pattern=e;this.marginBottom=n;this.style=o}sourceSpan;pattern;marginBottom;style;layer="foreground";createGeometry(t){let e=this.style,n=t.pages.map((o,s)=>{let i=au(this.pattern,s+1,t.pages.length),{w:a,h:c,baseline:l}=t.textMeasurer.measureText(i,e),u=o.y+o.h-this.marginBottom/2;return{text:i,x:o.x+o.w/2,y:u-c/2+l,w:a,h:c,baseline:l}});return{regions:n.map(({x:o,y:s,w:i,h:a,baseline:c})=>({x:o-i/2,y:s-c,w:i,h:a})),paint(o){for(let s of n)o.drawText(s.text,s.x,s.y,e)}}}},Vr=class extends B{static def={name:["page"],description:"\u8BBE\u7F6E\u6587\u6863\u9875\u9762",details:`~~~jpfun
|
|
64
62
|
@page(
|
|
65
63
|
width=794px, height=1123px, top=48px, bottom=48px,
|
|
66
|
-
left=40px, right=40px, gap=1em,
|
|
64
|
+
left=40px, right=40px, gap=1em, minGap=0.5em, fillRatio=0.5,
|
|
65
|
+
numbering="1/1", barNumbering="(1)"
|
|
67
66
|
)
|
|
68
67
|
~~~
|
|
69
|
-
\
|
|
68
|
+
\u9875\u8FB9\u8DDD\u548C\u884C\u8DDD\u987B\u975E\u8D1F\uFF1B\u5DE6\u53F3\u8FB9\u8DDD\u4E4B\u548C\u987B\u5C0F\u4E8E\u9875\u5BBD\uFF0C\u56FA\u5B9A\u9875\u9AD8\u65F6\u4E0A\u4E0B\u8FB9\u8DDD\u4E4B\u548C\u987B\u5C0F\u4E8E\u9875\u9AD8\u3002`,allowExtraArgs:!1,args:[{name:"width",description:"\u9875\u9762\u5BBD\u5EA6\uFF0C\u987B\u5927\u4E8E\u5DE6\u53F3\u9875\u8FB9\u8DDD\u4E4B\u548C",type:"length",default:je(Lt.width)},{name:"height",description:"\u9875\u9762\u9AD8\u5EA6\uFF0C\u5C0F\u4E8E\u7B49\u4E8E 0 \u8868\u793A\u4E0D\u81EA\u52A8\u5206\u9875\u3001\u9AD8\u5EA6\u968F\u5185\u5BB9\u589E\u957F\uFF1B\u5BBD\u5EA6\u4E3A `794px` \u65F6\uFF0CA4 \u5BF9\u5E94\u9AD8\u5EA6\u7EA6\u4E3A `1123px`",type:"length",default:je(0)},{name:"top",description:"\u9875\u9762\u4E0A\u8FB9\u8DDD",type:"length",default:je(Lt.marginTop)},{name:"bottom",description:"\u9875\u9762\u4E0B\u8FB9\u8DDD\uFF0C\u542F\u7528\u9875\u7801\u65F6\u81F3\u5C11\u4E3A `16px`",type:"length",default:je(Lt.marginBottom)},{name:"left",description:"\u9875\u9762\u5DE6\u8FB9\u8DDD",type:"length",default:je(Lt.marginLeft)},{name:"right",description:"\u9875\u9762\u53F3\u8FB9\u8DDD",type:"length",default:je(Lt.marginRight)},{name:"gap",description:"\u8C31\u9762\u884C\u4E3B\u65CB\u5F8B\u4E4B\u95F4\u7684\u6807\u51C6\u95F4\u8DDD",type:"length",default:{value:1,unit:"em"}},{name:"minGap",description:"\u884C\u95F4\u4FDD\u7559\u7684\u6700\u5C0F\u95F4\u8DDD",type:"length",default:{value:.5,unit:"em"}},{name:"numbering",description:"\u9875\u7801\u683C\u5F0F\uFF0C\u7A7A\u503C\u9690\u85CF\uFF1B`1`\uFF1A\u5F53\u524D\u9875\uFF0C`1/1`\uFF1A\u663E\u793A\u5F53\u524D\u9875/\u603B\u9875\u6570",type:"string",default:""},{name:"barNumbering",description:"\u884C\u9996\u5C0F\u8282\u53F7\u683C\u5F0F\uFF0C\u9ED8\u8BA4\u7A7A\u503C\u9690\u85CF\uFF1B`1` \u663E\u793A\u5F53\u524D\u5C0F\u8282\u53F7\uFF0C`(1)` \u663E\u793A\u5E26\u62EC\u53F7\u7684\u5C0F\u8282\u53F7",type:"string",default:""},{name:"font",description:"\u9875\u7801/\u5C0F\u8282\u53F7\u5B57\u4F53\uFF0C\u7A7A\u503C\u6CBF\u7528\u5F53\u524D\u5B57\u4F53\u8BBE\u7F6E",type:"string",default:""},{name:"fillRatio",description:"\u81EA\u7136\u5BBD\u5EA6\u8FBE\u5230\u8BE5\u6BD4\u4F8B\u540E\u6491\u6EE1",type:"number",default:Lt.fillRatio}]};config;numbering="";barNumbering="";font;constructor(t,e,n,o=null){if(super(t,o),this.font=n.variables.font,n.scopeDepth!==0){n.diagnostics.push(new K("W_PAGE_NOT_TOP_LEVEL","@page \u53EA\u80FD\u5728\u6587\u6863\u9876\u5C42\u58F0\u660E\uFF1B\u5F53\u524D\u58F0\u660E\u5DF2\u5FFD\u7565",t)),this.config=null;return}if(n.documentDeclarations.page){n.diagnostics.push(new K("W_DUPLICATE_PAGE","\u6587\u6863\u53EA\u80FD\u58F0\u660E\u4E00\u4E2A @page\uFF1B\u540E\u7EED\u58F0\u660E\u5DF2\u5FFD\u7565",t)),this.config=null;return}n.documentDeclarations.page=!0;let[s,i,a,c,l,u,p,m,d,f,x,y]=this.getArgValue(e,n);this.font=x||n.variables.font;let[h,g,b,T,L,w,A,C]=[s,i,a,c,l,u,p,m].map(_=>n.length2px(_));if(!Number.isFinite(h)||h<=0)throw new k("E_INVALID_PAGE_CONFIG","@page \u7684 width \u5FC5\u987B\u662F\u6B63\u6709\u9650\u957F\u5EA6",t);if(!Number.isFinite(g))throw new k("E_INVALID_PAGE_CONFIG","@page \u7684 height \u5FC5\u987B\u662F\u6709\u9650\u957F\u5EA6\uFF1B\u5C0F\u4E8E\u7B49\u4E8E 0 \u8868\u793A\u4E0D\u81EA\u52A8\u5206\u9875",t);if([b,T,L,w,A,C].some(_=>!Number.isFinite(_)||_<0))throw new k("E_INVALID_PAGE_CONFIG","@page \u7684\u8FB9\u8DDD\u3001gap \u548C minGap \u5FC5\u987B\u662F\u975E\u8D1F\u6709\u9650\u957F\u5EA6",t);if(L+w>=h)throw new k("E_INVALID_PAGE_CONFIG","@page \u7684\u5DE6\u53F3\u8FB9\u8DDD\u6CA1\u6709\u7559\u4E0B\u53EF\u7528\u5185\u5BB9\u5BBD\u5EA6",t);if(g>0&&b+T>=g)throw new k("E_INVALID_PAGE_CONFIG","@page \u7684\u4E0A\u4E0B\u8FB9\u8DDD\u6CA1\u6709\u7559\u4E0B\u53EF\u7528\u5185\u5BB9\u9AD8\u5EA6",t);if(d&&T<Br)throw new k("E_INVALID_PAGE_CONFIG","@page \u7684 bottom \u81F3\u5C11\u9700\u8981 {minBottom}px \u624D\u80FD\u653E\u4E0B\u9875\u7801",t,{minBottom:Br});this.config=Je({width:h,height:g,marginTop:b,marginBottom:T,marginLeft:L,marginRight:w,lineGap:A,minLineGap:C,fillRatio:y}),this.numbering=d,this.barNumbering=f}loweringEnter(t){return!t||!this.config?[]:(t.setPageConfig(this.config),this.numbering&&t.addAttachment(new Dr(this.sourceSpan,this.numbering,this.config.marginBottom,{...iu,fontFamily:this.font})),this.barNumbering&&pi(t,this.barNumbering,this.font),[])}toString(){if(!this.config)return"@page()";let{width:t,height:e,marginTop:n,marginBottom:o,marginLeft:s,marginRight:i,lineGap:a,minLineGap:c,fillRatio:l}=this.config;return`@page(width=${t}px, height=${Number.isFinite(e)?e:0}px, top=${n}px, bottom=${o}px, left=${s}px, right=${i}px, gap=${a}px, minGap=${c}px, numbering=${lt(this.numbering)}, barNumbering=${lt(this.barNumbering)}, font=${lt(this.font)}, fillRatio=${l})`}},xa=Vr;var Hr=class extends B{static def={name:["pagebreak","pb"],description:"\u5F3A\u5236\u6362\u9875",details:`~~~jpfun
|
|
70
69
|
1 2 @br() 3 4 @pagebreak() 5 6
|
|
71
70
|
~~~
|
|
72
|
-
\u540C\u65F6\u6362\u884C\u5E76\u5F00\u542F\u65B0\u9875\uFF0C\u4E0D\u5360\u97F3\u4E50\u65F6\u503C\u3002\u540C\u4E00\u65F6\u523B\u7684\u5E76\u884C\u8C03\u7528\u53EA\u6362\u4E00\u6B21\u9875\uFF0C\`justify=false\` \u4F18\u5148\u3002`,allowExtraArgs:!1,args:[{name:"justify",description:"\u662F\u5426\u5206\u914D\u5F53\u524D\u9875\u7684\u5269\u4F59\u7A7A\u95F4\uFF1B\u65E0\u9650\u9875\u9AD8\u65F6\u4E0D\u62C9\u4F38",type:"boolean",default:!0}]};
|
|
71
|
+
\u540C\u65F6\u6362\u884C\u5E76\u5F00\u542F\u65B0\u9875\uFF0C\u4E0D\u5360\u97F3\u4E50\u65F6\u503C\u3002\u540C\u4E00\u65F6\u523B\u7684\u5E76\u884C\u8C03\u7528\u53EA\u6362\u4E00\u6B21\u9875\uFF0C\`justify=false\` \u4F18\u5148\u3002`,allowExtraArgs:!1,args:[{name:"justify",description:"\u662F\u5426\u5206\u914D\u5F53\u524D\u9875\u7684\u5269\u4F59\u7A7A\u95F4\uFF1B\u65E0\u9650\u9875\u9AD8\u65F6\u4E0D\u62C9\u4F38",type:"boolean",default:!0}]};justify;constructor(t,e,n,o=null){super(t,o),[this.justify]=this.getArgValue(e,n)}loweringEnter(t){t.deferFinalize(eo.loweringFinalize);let e=new tt;return e.ast=this,e.mergeKey=-1,e.addon={breakBefore:1,pageBreakBefore:this.justify},[e]}toString(){return`@pagebreak(justify=${this.justify})`}},ba=Hr;var zr=class extends B{static def={name:["program","instrument"],description:"\u8BBE\u7F6E\u5F53\u524D\u97F3\u8F68\u7684 MIDI \u97F3\u8272",details:`~~~jpfun
|
|
73
72
|
@program(40) 1 2 3
|
|
74
73
|
~~~
|
|
75
|
-
\u5207\u6362\u4E3A\u5C0F\u63D0\u7434\u97F3\u8272\u3002\u8BBE\u7F6E\u5C06\u4F5C\u7528\u4E8E\u5F53\u524D\u97F3\u8F68\u7684\u540E\u7EED\u97F3\u7B26\u3002`,allowExtraArgs:!1,args:[{name:"program",description:"\u4ECE 0 \u5F00\u59CB\u7F16\u53F7\u7684 MIDI \u97F3\u8272\uFF0C\u987B\u4E3A `0..127` \u7684\u6574\u6570",type:"number",default:null}]};program;constructor(t,e,n,o=null){super(t,o);let[
|
|
74
|
+
\u5207\u6362\u4E3A\u5C0F\u63D0\u7434\u97F3\u8272\u3002\u8BBE\u7F6E\u5C06\u4F5C\u7528\u4E8E\u5F53\u524D\u97F3\u8F68\u7684\u540E\u7EED\u97F3\u7B26\u3002`,allowExtraArgs:!1,args:[{name:"program",description:"\u4ECE 0 \u5F00\u59CB\u7F16\u53F7\u7684 MIDI \u97F3\u8272\uFF0C\u987B\u4E3A `0..127` \u7684\u6574\u6570",type:"number",default:null}]};program;constructor(t,e,n,o=null){super(t,o);let[s]=this.getArgValue(e,n);if(!Number.isSafeInteger(s)||s<0||s>127)throw new k("E_PROGRAM_INVALID","@program \u5FC5\u987B\u662F 0..127 \u7684\u6574\u6570",t);this.program=s}loweringEnter(){let t=new tt;return t.ast=this,t.playbackState={program:this.program},t.onTimeState=e=>{e.program=this.program},[t]}toString(){return`@program(${this.program})`}},Sa=zr;var wa=.4,cu=(r,t,e)=>r.top-e*wa-t.bottom,lu=(r,t)=>{let e=t*wa,n=[],o=0;for(let s of r){if(!s){n.push(null);continue}let i=o-s.bottom;n.push({offset:i,extent:s}),o=i+s.top-e}return n},uu={laneKey:"stack",measure:lu,place:cu},Gr=class r extends B{static def={name:["stack"],description:"\u4E34\u65F6\u591A\u58F0\u90E8",details:"~~~jpfun\n@stack({1 2}, {3/ 4/ 5})\n~~~\n\u63A5\u53D7\u81F3\u5C11\u4E24\u4E2A\u5185\u5BB9\u53C2\u6570\uFF0C\u5404\u5206\u652F\u540C\u65F6\u5F00\u59CB\u3001\u4FDD\u7559\u5404\u81EA\u65F6\u503C\uFF0C\u6574\u4F53\u65F6\u957F\u53D6\u6700\u957F\u5206\u652F\u3002\u9002\u5408\u8282\u594F\u4E0D\u540C\u7684\u4E34\u65F6\u591A\u58F0\u90E8\u3002\n\n**\u7B80\u5199**\uFF1A`{1 2} & {3/ 4/ 5}`\u3002\u53EF\u7EE7\u7EED\u7528 `&` \u8FDE\u63A5\u66F4\u591A\u5206\u652F\uFF1B\u82E5\u8981\u5199\u548C\u5F26\uFF0C\u8BF7\u4F7F\u7528 `up` / `down`\u3002",allowExtraArgs:!0,extraArgType:"content",args:[]};static deSugarAtom(t,e,n){if(t[e]==="&"){let o={kind:"sugar",data:r,span:{start:e,end:e+1}};return{next:e+1,node:o}}return null}static deSugarRelation(t,e,n){let o=e[n++];if(!(o.kind==="sugar"&&o.data===r))return null;let s=t.takeLeftOperand();if(!s)throw new k("E_STACK_NO_TARGET","@stack\u8BED\u6CD5\u7CD6\u9519\u8BEF: \u5DE6\u8FB9\u6CA1\u6709\u627E\u5230\u53EF\u53E0\u52A0\u7684\u76EE\u6807",o.span);let i=s instanceof r?s:new r(o.span,new Map,t).addContent(s),a=t.consumeRightOperand(e,n,c=>i.addContent(c));if(a!==null)return a;throw new k("E_STACK_NO_TARGET","@stack\u8BED\u6CD5\u7CD6\u9519\u8BEF: \u53F3\u8FB9\u6CA1\u6709\u627E\u5230\u53EF\u53E0\u52A0\u7684\u76EE\u6807",o.span)}contents=[];get children(){return this.contents}timeFlowModel(){return{children:this.contents,mode:"parallel",tracks:uu}}constructor(t,e,n,o=null){super(t,o);for(let[s,i]of e)typeof s=="number"&&this.addContent(i)}addContent(t){let e=t instanceof r?t.contents:[t],n=t.sourceSpan;this.sourceSpan.start=Math.min(this.sourceSpan.start,n.start),this.sourceSpan.end=Math.max(this.sourceSpan.end,n.end);for(let o of e)o.parent=this;return this.contents.push(...e),t instanceof r&&(t.contents.length=0),this}toString(t){return`@stack(
|
|
76
75
|
${this.contents.map(n=>n.toString(t)).join(`,
|
|
77
76
|
`).split(`
|
|
78
77
|
`).join(`
|
|
79
78
|
`)}
|
|
80
|
-
)`}},Gr=Cs;var Vr={name:"accent",description:"\u91CD\u97F3",weight:.5,shapes:[{path:[{op:"M",x:.21413,y:.4818},{op:"L",x:8.21413,y:3.72071},{op:"L",x:.29494,y:6.92724}],style:{stroke:"#000",strokeWidth:1}}],emitPlayback:s=>s.affectFollowing((t,e)=>{for(let n of e)n.velocity=Math.min(127,n.velocity+20)})};var sn="repeat.jump",Ur={name:"dc",description:"\u4ECE\u5934\u53CD\u590D\uFF1A\u8DF3\u56DE\u66F2\u9996\u518D\u6F14\u4E00\u904D",weight:.9,shapes:[{path:[{op:"M",x:1.06974,y:7.0752},{op:"L",x:2.69184,y:1.21499},{op:"C",cx1:2.69184,cy1:1.1221,cx2:2.73825,cy2:.93022,x:2.73825,y:.86039},{op:"C",cx1:2.73825,cy1:.48248,cx2:2.4825,cy2:.33152,x:1.7614,y:.23838},{op:"L",x:1.7614,y:.04641},{op:"L",x:4.88344,y:.04641},{op:"C",cx1:7.64477,cy1:.04641,cx2:9.02278,cy2:1.18018,x:9.02278,y:3.45323},{op:"C",cx1:9.02278,cy1:4.47649,cx2:8.74941,cy2:5.36592,x:8.20888,y:6.11596},{op:"C",cx1:7.6681,cy1:6.86578,cx2:6.95303,cy2:7.4297,x:6.05765,y:7.81334},{op:"C",cx1:5.16823,cy1:8.19125,cx2:4.22074,cy2:8.38316,x:3.21493,y:8.38316},{op:"L",x:0,y:8.38316},{op:"L",x:0,y:8.19119},{op:"C",cx1:.64542,cy1:8.19126,cx2:.91275,cy2:7.81343,x:1.06974,y:7.07521},{op:"L",x:1.06974,y:7.0752},{op:"Z"},{op:"M",x:4.09864,y:.66867},{op:"L",x:2.2848,y:7.35998},{op:"C",cx1:2.2848,cy1:7.42409,cx2:2.26718,cy2:7.48786,x:2.23815,y:7.55197},{op:"C",cx1:2.29051,cy1:7.84841,cx2:2.58133,cy2:7.99961,x:3.12179,y:7.99961},{op:"C",cx1:3.97639,cy1:7.99961,cx2:4.74389,cy2:7.79034,x:5.42397,y:7.37165},{op:"C",cx1:6.10429,cy1:6.94733,cx2:6.62746,cy2:6.37751,x:7.00538,y:5.65666},{op:"C",cx1:7.3833,cy1:4.92994,cx2:7.5752,cy2:4.1334,x:7.5752,y:3.26134},{op:"C",cx1:7.5752,cy1:1.372,cx2:6.69156,cy2:.43029,x:4.92984,y:.43029},{op:"C",cx1:4.53471,cy1:.43029,cx2:4.25555,cy2:.51151,x:4.09864,y:.66869},{op:"L",x:4.09864,y:.66867},{op:"Z"},{op:"M",x:18.35961,y:.04641},{op:"L",x:17.90593,y:2.62204},{op:"L",x:17.66755,y:2.62204},{op:"C",cx1:17.563,cy1:1.19183,cx2:16.91187,cy2:.47678,x:15.71418,y:.47678},{op:"C",cx1:14.96437,cy1:.47678,cx2:14.29564,cy2:.73848,x:13.70274,y:1.26165},{op:"C",cx1:13.11556,cy1:1.77911,cx2:12.65617,cy2:2.43578,x:12.33664,y:3.22668},{op:"C",cx1:12.01679,cy1:4.01155,cx2:11.85988,cy2:4.77302,x:11.85988,y:5.49984},{op:"C",cx1:11.85988,cy1:6.26131,cx2:12.03424,cy2:6.90076,x:12.37734,y:7.41814},{op:"C",cx1:12.72598,cy1:7.9356,cx2:13.24931,cy2:8.19126,x:13.95279,y:8.19126},{op:"C",cx1:15.08622,cy1:8.19126,cx2:16.11543,cy2:7.68548,x:17.02818,y:6.66825},{op:"L",x:17.21412,y:6.86023},{op:"C",cx1:16.26663,cy1:8.16232,cx2:15.08051,cy2:8.81352,x:13.66775,y:8.81352},{op:"C",cx1:13.034,cy1:8.81352,cx2:12.47014,cy2:8.65637,x:11.97608,y:8.34254},{op:"C",cx1:11.48195,cy1:8.02864,cx2:11.10411,cy2:7.60432,x:10.83074,y:7.06925},{op:"C",cx1:10.56333,cy1:6.53442,cx2:10.42974,cy2:5.94748,x:10.42974,y:5.31357},{op:"C",cx1:10.42974,cy1:4.43581,cx2:10.67383,cy2:3.58692,x:11.15655,y:2.7616},{op:"C",cx1:11.63894,cy1:1.93602,cx2:12.28427,cy2:1.26738,x:13.09223,y:.76158},{op:"C",cx1:13.90042,cy1:.25578,cx2:14.74336,cy2:3e-5,x:15.62137,y:3e-5},{op:"C",cx1:15.88283,cy1:3e-5,cx2:16.12121,cy2:.0174,x:16.33651,y:.0581},{op:"C",cx1:16.55157,cy1:.09886,cx2:16.79557,cy2:.15122,x:17.05729,y:.21501},{op:"C",cx1:17.31875,cy1:.2791,cx2:17.51072,cy2:.31979,x:17.62123,y:.33717},{op:"C",cx1:17.85961,cy1:.2557,cx2:18.03389,cy2:.15694,x:18.14432,y:.04643},{op:"L",x:18.35962,y:.04643},{op:"L",x:18.35961,y:.04644},{op:"Z"},{op:"M",x:8.19134,y:7.69151},{op:"C",cx1:8.19134,cy1:7.5169,cx2:8.25544,cy2:7.36596,x:8.38894,y:7.2322},{op:"C",cx1:8.52277,cy1:7.09838,cx2:8.69134,cy2:7.0288,x:8.88332,y:7.0288},{op:"C",cx1:9.0519,cy1:7.0288,cx2:9.19722,cy2:7.09838,x:9.3251,y:7.2322},{op:"C",cx1:9.45893,cy1:7.36603,cx2:9.5227,cy2:7.52294,x:9.5227,y:7.69151},{op:"C",cx1:9.5227,cy1:8.0925,cx2:9.23221,cy2:8.38324,x:8.88332,y:8.38324},{op:"C",cx1:8.48803,cy1:8.38324,cx2:8.19134,cy2:8.10416,x:8.19134,y:7.69151},{op:"Z"},{op:"M",x:18.00469,y:7.79028},{op:"C",cx1:18.00469,cy1:7.40068,cx2:18.27814,cy2:7.12162,x:18.64432,y:7.12162},{op:"C",cx1:19.03969,cy1:7.12162,cx2:19.31298,cy2:7.39507,x:19.31298,y:7.79028},{op:"C",cx1:19.31298,cy1:8.15653,cx2:19.0339,cy2:8.42965,x:18.64432,y:8.42965},{op:"C",cx1:18.28972,cy1:8.42965,cx2:18.00469,cy2:8.14486,x:18.00469,y:7.79028},{op:"Z"}],style:{fill:"#000"}}],playbackMarks:()=>[sn],onVisit:(s,t)=>s.visits(t)>1?void 0:{kind:"jump",column:0}};var vs="repeat.segno",jr={name:"segno",description:"\u53CD\u590D\u8BB0\u53F7\uFF1AD.S. \u7684\u56DE\u8DF3\u76EE\u6807",weight:1.15,playbackMarks:()=>[vs],shapes:[{path:[{op:"M",x:3.75502,y:7.52938},{op:"C",cx1:1.3411,cy1:6.32492,cx2:.10249,cy2:4.89115,x:.03897,y:3.23307},{op:"C",cx1:.06833,cy1:2.69176,cx2:.20975,cy2:2.17002,x:.45843,y:1.67267},{op:"C",cx1:.71191,cy1:1.1751,cx2:1.05826,cy2:.77042,x:1.49231,y:.46321},{op:"C",cx1:1.93115,cy1:.156,cx2:2.41873,cy2:0,x:2.95524,y:0},{op:"C",cx1:3.6136,cy1:0,cx2:4.17428,cy2:.17538,x:4.64747,y:.52174},{op:"C",cx1:5.12047,cy1:.8679,cx2:5.35457,cy2:1.36047,x:5.35457,y:1.99925},{op:"C",cx1:5.33499,cy1:2.26751,cx2:5.21315,cy2:2.49182,x:4.98384,y:2.66739},{op:"C",cx1:4.75473,cy1:2.83817,cx2:4.50106,cy2:2.93565,x:4.21343,y:2.95502},{op:"C",cx1:3.67691,cy1:2.90629,cx2:3.35013,cy2:2.68696,x:3.23807,y:2.29686},{op:"L",x:3.06249,y:1.73119},{op:"C",cx1:2.93086,cy1:1.31652,cx2:2.71134,cy2:1.0191,x:2.29687,y:1.0191},{op:"C",cx1:1.99446,cy1:1.0191,cx2:1.74578,cy2:1.16551,x:1.55561,y:1.46293},{op:"C",cx1:1.36544,cy1:1.76035,cx2:1.26798,cy2:2.06276,x:1.25819,y:2.37476},{op:"C",cx1:1.28735,cy1:2.79902,cx2:1.42398,cy2:3.17954,x:1.66287,y:3.50612},{op:"C",cx1:1.90677,cy1:3.8329,cx2:2.20418,cy2:4.11094,x:2.56012,y:4.34984},{op:"C",cx1:2.91627,cy1:4.58394,cx2:3.31116,cy2:4.79846,x:3.73542,y:4.99841},{op:"C",cx1:4.15967,cy1:5.19835,cx2:4.57914,cy2:5.38851,x:4.99361,y:5.57387},{op:"L",x:8.62659,y:.12183},{op:"L",x:9.70919,y:.12183},{op:"L",x:5.85194,y:5.97376},{op:"C",cx1:6.5005,cy1:6.29076,cx2:7.09535,cy2:6.65649,x:7.62705,y:7.06117},{op:"C",cx1:8.15855,cy1:7.47085,cx2:8.60221,cy2:7.95363,x:8.95835,y:8.50473},{op:"C",cx1:9.3143,cy1:9.05562,cx2:9.48985,cy2:9.65546,x:9.48985,y:10.30403},{op:"C",cx1:9.48985,cy1:10.86491,cx2:9.35822,cy2:11.39164,x:9.08996,y:11.88421},{op:"C",cx1:8.82652,cy1:12.37658,cx2:8.44618,cy2:12.77167,x:7.9488,y:13.0643},{op:"C",cx1:7.45147,cy1:13.35691,cx2:6.871,cy2:13.50314,x:6.21285,y:13.50314},{op:"C",cx1:5.62259,cy1:13.44461,cx2:5.1448,cy2:13.23009,x:4.78386,y:12.85457},{op:"C",cx1:4.42791,cy1:12.47906,cx2:4.23776,cy2:12.06938,x:4.21338,y:11.62572},{op:"C",cx1:4.23275,cy1:11.35746,cx2:4.33043,cy2:11.12338,x:4.5108,y:10.92821},{op:"C",cx1:4.69118,cy1:10.73326,cx2:4.94485,cy2:10.626,x:5.27163,y:10.60644},{op:"C",cx1:5.63239,cy1:10.60644,cx2:5.88605,cy2:10.68931,x:6.03726,y:10.85033},{op:"C",cx1:6.18828,cy1:11.01611,cx2:6.31031,cy2:11.26001,x:6.3932,y:11.58656},{op:"C",cx1:6.48092,cy1:11.91335,cx2:6.56377,cy2:12.14745,x:6.64186,y:12.2791},{op:"C",cx1:6.72476,cy1:12.41573,cx2:6.88578,cy2:12.48404,x:7.12944,y:12.48404},{op:"C",cx1:7.50019,cy1:12.48404,cx2:7.78783,cy2:12.35718,x:7.99756,y:12.10353},{op:"C",cx1:8.20729,cy1:11.85485,cx2:8.30974,cy2:11.52805,x:8.30974,y:11.12338},{op:"C",cx1:8.30974,cy1:10.57728,cx2:8.11459,cy2:10.11887,x:7.72451,y:9.74812},{op:"C",cx1:7.33918,cy1:9.38239,cx2:6.75395,cy2:9.00689,x:5.97375,y:8.62657},{op:"C",cx1:5.19353,cy1:8.25105,cx2:4.73513,cy2:8.01693,x:4.59371,y:7.92926},{op:"L",x:1.05823,y:13.42024},{op:"L",x:0,y:13.42024},{op:"L",x:3.755,y:7.52937},{op:"L",x:3.75502,y:7.52938},{op:"Z"},{op:"M",x:.07812,y:8.54848},{op:"C",cx1:.07812,cy1:8.20711,cx2:.18039,cy2:7.95364,x:.38033,y:7.78285},{op:"C",cx1:.58028,cy1:7.61227,cx2:.81937,cy2:7.5294,x:1.09721,y:7.5294},{op:"C",cx1:1.36068,cy1:7.55377,cx2:1.58499,cy2:7.65124,x:1.76535,y:7.822},{op:"C",cx1:1.94572,cy1:7.99259,cx2:2.03841,cy2:8.25105,x:2.03841,y:8.58763},{op:"C",cx1:2.03841,cy1:8.79736,cx2:1.93594,cy2:8.99731,x:1.736,y:9.19226},{op:"C",cx1:1.53606,cy1:9.39222,cx2:1.32153,cy2:9.48971,x:1.09721,y:9.48971},{op:"C",cx1:.81936,cy1:9.48971,cx2:.57548,cy2:9.41181,x:.37553,y:9.25081},{op:"C",cx1:.17558,cy1:9.08978,cx2:.07811,cy2:8.85588,x:.07811,y:8.54849},{op:"L",x:.07812,y:8.54848},{op:"Z"},{op:"M",x:8.3098,y:5.11547},{op:"C",cx1:8.3098,cy1:4.7789,cx2:8.4023,cy2:4.51564,x:8.58285,y:4.33027},{op:"C",cx1:8.76803,cy1:4.14508,cx2:9.00212,cy2:4.05242,x:9.28995,y:4.05242},{op:"C",cx1:9.57758,cy1:4.05242,cx2:9.82145,cy2:4.14011,x:10.01644,y:4.31568},{op:"C",cx1:10.21158,cy1:4.48627,cx2:10.30902,cy2:4.73994,x:10.30902,y:5.07152},{op:"C",cx1:10.30902,cy1:5.30083,cx2:10.20677,cy2:5.51036,x:10.00184,y:5.69572},{op:"C",cx1:9.7971,cy1:5.88108,cx2:9.57279,cy2:5.97376,x:9.32892,y:5.97376},{op:"C",cx1:9.07043,cy1:5.97376,cx2:8.83156,cy2:5.88587,x:8.62182,y:5.71529},{op:"C",cx1:8.41209,cy1:5.53971,cx2:8.3098,cy2:5.33977,x:8.3098,y:5.11546},{op:"L",x:8.3098,y:5.11547},{op:"Z"}],style:{fill:"#000"}}]};var Kr={name:"ds",description:"\u4ECE\u8BB0\u53F7\u5904\u53CD\u590D\uFF1A\u8DF3\u56DE\u6700\u8FD1\u7684 $segno",weight:.9,shapes:[{path:[{op:"M",x:3.30971,y:8.58253},{op:"L",x:0,y:8.58253},{op:"L",x:0,y:8.38492},{op:"C",cx1:.66434,cy1:8.38492,cx2:.93964,cy2:7.9959,x:1.10119,y:7.23595},{op:"L",x:2.77112,y:1.20293},{op:"C",cx1:2.77112,cy1:1.10732,cx2:2.81892,cy2:.90973,x:2.81892,y:.83791},{op:"C",cx1:2.81892,cy1:.44886,cx2:2.55564,cy2:.29345,x:1.81333,y:.19758},{op:"L",x:1.81333,y:0},{op:"L",x:5.02743,y:0},{op:"C",cx1:7.87013,cy1:0,cx2:9.28879,cy2:1.16713,x:9.28879,y:3.50729},{op:"C",cx1:9.28879,cy1:4.56066,cx2:9.00736,cy2:5.47632,x:8.45088,y:6.24853},{op:"C",cx1:7.89416,cy1:7.02049,cx2:7.15799,cy2:7.60099,x:6.23624,y:7.9959},{op:"C",cx1:5.32063,cy1:8.38492,cx2:4.34519,cy2:8.58253,x:3.3097,y:8.58253},{op:"L",x:3.30971,y:8.58253},{op:"Z"},{op:"M",x:4.21944,y:.64057},{op:"L",x:2.35218,y:7.52917},{op:"C",cx1:2.35218,cy1:7.59509,cx2:2.33403,cy2:7.66079,x:2.30413,y:7.72673},{op:"C",cx1:2.35806,cy1:8.03196,cx2:2.65738,cy2:8.18763,x:3.21387,y:8.18763},{op:"C",cx1:4.71023,cy1:8.18763,cx2:5.84745,cy2:7.75053,x:6.6253,y:6.88271},{op:"C",cx1:7.40952,cy1:6.00899,cx2:7.79857,cy2:4.81807,x:7.79857,y:3.30973},{op:"C",cx1:7.79857,cy1:1.36475,cx2:6.88883,cy2:.39519,x:5.07525,y:.39519},{op:"C",cx1:4.66831,cy1:.39517,cx2:4.38101,cy2:.47876,x:4.21945,y:.64056},{op:"L",x:4.21944,y:.64056},{op:"Z"},{op:"M",x:17.3325,y:1e-5},{op:"L",x:16.81794,y:2.54976},{op:"L",x:16.57254,y:2.54976},{op:"C",cx1:16.57254,cy1:1.14312,cx2:16.03984,cy2:.44299,x:14.98033,y:.44299},{op:"C",cx1:14.57337,cy1:.44299,cx2:14.24416,cy2:.56262,x:13.98698,y:.80212},{op:"C",cx1:13.72958,cy1:1.04139,cx2:13.60383,cy2:1.35272,x:13.60383,y:1.74176},{op:"C",cx1:13.60383,cy1:2.10677,cx2:13.70556,cy2:2.424,x:13.91516,y:2.70518},{op:"C",cx1:14.12452,cy1:2.98048,cx2:14.45375,cy2:3.34575,x:14.91464,y:3.7946},{op:"C",cx1:15.37551,cy1:4.24346,cx2:15.72261,cy2:4.65626,x:15.9619,y:5.03332},{op:"C",cx1:16.20729,cy1:5.40444,cx2:16.32715,cy2:5.83541,x:16.32715,y:6.32621},{op:"C",cx1:16.35708,cy1:7.82844,cx2:15.01635,cy2:8.89386,x:13.70558,y:8.87572},{op:"C",cx1:13.47219,cy1:8.87572,cx2:13.12508,cy2:8.79188,x:12.65219,y:8.63033},{op:"C",cx1:12.17955,cy1:8.46874,cx2:11.86231,cy2:8.38489,x:11.69463,y:8.38489},{op:"C",cx1:11.45538,cy1:8.38489,cx2:11.25778,cy2:8.60652,x:11.20385,y:8.82787},{op:"L",x:10.95848,y:8.82787},{op:"L",x:11.40145,y:6.00895},{op:"L",x:11.69464,y:6.00895},{op:"C",cx1:11.69464,cy1:6.12272,cx2:11.67678,cy2:6.24847,x:11.64684,y:6.374},{op:"C",cx1:11.67065,cy1:6.93075,cx2:11.85619,cy2:7.40948,x:12.20332,y:7.82232},{op:"C",cx1:12.55657,cy1:8.22948,cx2:13.00544,cy2:8.43297,x:13.55603,y:8.43297},{op:"C",cx1:14.02891,cy1:8.43297,cx2:14.42384,cy2:8.26529,x:14.74108,y:7.92405},{op:"C",cx1:15.06418,cy1:7.58305,cx2:15.22573,cy2:7.18198,x:15.22573,y:6.72112},{op:"C",cx1:15.22573,cy1:6.34406,cx2:15.11223,cy2:6.00313,x:14.89062,y:5.69764},{op:"C",cx1:14.66925,cy1:5.39246,cx2:14.32802,cy2:5.00951,x:13.85538,y:4.54279},{op:"C",cx1:13.38247,cy1:4.07579,cx2:13.03535,cy2:3.67473,x:12.80197,y:3.33374},{op:"C",cx1:12.56858,cy1:2.99248,cx2:12.45484,cy2:2.59756,x:12.45484,y:2.16072},{op:"C",cx1:12.45484,cy1:1.53216,cx2:12.67621,cy2:1.01761,x:13.12509,y:.61042},{op:"C",cx1:13.57395,cy1:.20348,cx2:14.11864,cy2:2e-5,x:14.75896,y:2e-5},{op:"C",cx1:15.18993,cy1:2e-5,cx2:15.55495,cy2:.05983,x:15.86016,y:.17358},{op:"C",cx1:16.16536,cy1:.28733,cx2:16.38697,cy2:.34714,x:16.52452,y:.34714},{op:"C",cx1:16.6922,cy1:.34714,cx2:16.86576,cy2:.23339,x:17.03932,y:2e-5},{op:"L",x:17.33249,y:2e-5},{op:"L",x:17.3325,y:1e-5},{op:"Z"},{op:"M",x:8.43275,y:7.87042},{op:"C",cx1:8.43275,cy1:7.69072,cx2:8.4987,cy2:7.5353,x:8.63622,y:7.3975},{op:"C",cx1:8.774,cy1:7.25976,cx2:8.94755,cy2:7.18816,x:9.14514,y:7.18816},{op:"C",cx1:9.3187,cy1:7.18816,cx2:9.46824,cy2:7.25975,x:9.59988,y:7.3975},{op:"C",cx1:9.73766,cy1:7.53529,cx2:9.80338,cy2:7.69685,x:9.80338,y:7.87042},{op:"C",cx1:9.80338,cy1:8.28325,cx2:9.5043,cy2:8.58254,x:9.14514,y:8.58254},{op:"C",cx1:8.7382,cy1:8.58254,cx2:8.43275,cy2:8.29521,x:8.43275,y:7.87042},{op:"Z"},{op:"M",x:16.88952,y:7.9721},{op:"C",cx1:16.88952,cy1:7.57106,cx2:17.21875,cy2:7.28373,x:17.62569,y:7.28373},{op:"C",cx1:18.00297,cy1:7.28373,cx2:18.29003,cy2:7.56516,x:18.29003,y:7.9721},{op:"C",cx1:18.29003,cy1:8.34914,cx2:17.99096,cy2:8.63036,x:17.62569,y:8.63036},{op:"C",cx1:17.42219,cy1:8.63036,cx2:17.24863,cy2:8.56461,x:17.105,y:8.43887},{op:"C",cx1:16.96135,cy1:8.31309,cx2:16.88952,cy2:8.1577,x:16.88952,y:7.9721},{op:"Z"}],style:{fill:"#000"}}],playbackMarks:()=>[sn],onVisit:(s,t)=>s.visits(t)>1?void 0:{kind:"jump",column:s.seek(vs,t,-1)??0}};var El={m:[{op:"M",x:1.13,y:10.3672},{op:"L",x:2.9911,y:5.3125},{op:"C",cx1:3.0585,cy1:5.0607,cx2:3.0955,cy2:4.8889,x:3.0955,y:4.8089},{op:"C",cx1:3.0955,cy1:4.6248,cx2:2.9972,cy2:4.5327,x:2.7944,y:4.5327},{op:"C",cx1:2.5489,cy1:4.5327,cx2:2.217,cy2:4.7782,x:1.7994,y:5.2758},{op:"C",cx1:1.3881,cy1:5.7671,cx2:.9766,cy2:6.4856,x:.5774,y:7.4254},{op:"L",x:0,y:7.4254},{op:"C",cx1:.4976,cy1:6.3628,cx2:1.0133,cy2:5.4783,x:1.5476,y:4.7782},{op:"C",cx1:2.0882,cy1:4.0781,cx2:2.7576,cy2:3.7279,x:3.5498,y:3.7279},{op:"C",cx1:4.1518,cy1:3.7279,cx2:4.4773,cy2:4.0534,x:4.5264,y:4.7045},{op:"C",cx1:5.2818,cy1:4.0167,cx2:5.9512,cy2:3.6728,x:6.5409,y:3.6728},{op:"C",cx1:7.1796,cy1:3.6728,cx2:7.5235,cy2:4.0167,x:7.5728,y:4.7045},{op:"C",cx1:7.8797,cy1:4.3976,cx2:8.2483,cy2:4.1518,x:8.6843,y:3.9614},{op:"C",cx1:9.1205,cy1:3.7709,cx2:9.5197,cy2:3.6728,x:9.8882,y:3.6728},{op:"C",cx1:10.5393,cy1:3.6728,cx2:10.8645,cy2:3.943,x:10.8645,y:4.4834},{op:"C",cx1:10.8645,cy1:4.6001,cx2:10.8339,cy2:4.7905,x:10.7664,y:5.0607},{op:"L",x:9.3846,y:9.0345},{op:"C",cx1:9.3109,cy1:9.3353,cx2:9.2616,cy2:9.4951,x:9.2309,y:9.6364},{op:"C",cx1:9.2309,cy1:9.7959,cx2:9.3169,cy2:9.9066,x:9.4827,y:9.9619},{op:"C",cx1:10.011,cy1:9.8943,cx2:10.6988,cy2:9.1512,x:11.5463,y:7.7263},{op:"L",x:12.0499,y:7.7263},{op:"C",cx1:11.7981,cy1:8.1502,cx2:11.5279,cy2:8.6045,x:11.227,y:9.0958},{op:"C",cx1:10.9322,cy1:9.5811,cx2:10.6006,cy2:9.9864,x:10.2381,y:10.2996},{op:"C",cx1:9.8759,cy1:10.613,cx2:9.4583,cy2:10.7725,x:8.9791,y:10.7725},{op:"C",cx1:8.1499,cy1:10.7725,cx2:7.6279,cy2:10.3919,x:7.4191,y:9.6365},{op:"C",cx1:7.4437,cy1:9.397,cx2:7.5235,cy2:9.0775,x:7.6649,y:8.6783},{op:"C",cx1:7.806,cy1:8.279,cx2:7.8797,cy2:8.0395,x:7.8981,y:7.9535},{op:"L",x:8.9054,y:5.3619},{op:"C",cx1:8.924,cy1:5.2572,cx2:8.9791,cy2:5.0117,x:8.9791,y:4.9073},{op:"C",cx1:8.9791,cy1:4.6922,cx2:8.887,cy2:4.5818,x:8.7028,y:4.5818},{op:"C",cx1:8.1992,cy1:4.5818,cx2:7.8246,cy2:4.9257,x:7.5728,y:5.6137},{op:"L",x:5.8838,y:10.3673},{op:"L",x:4.0781,y:10.3673},{op:"L",x:5.9389,y:5.2635},{op:"C",cx1:5.9696,cy1:5.1591,cx2:5.9882,cy2:5.0424,x:5.9882,y:4.9073},{op:"C",cx1:5.9882,cy1:4.6922,cx2:5.8592,cy2:4.5818,x:5.6073,y:4.5818},{op:"C",cx1:5.159,cy1:4.6002,cx2:4.8335,cy2:4.944,x:4.6308,y:5.6137},{op:"L",x:2.8927,y:10.3673},{op:"L",x:1.13,y:10.3673},{op:"L",x:1.13,y:10.3672},{op:"Z"}],f:[{op:"M",x:6.1601,y:4.0781},{op:"C",cx1:6.4302,cy1:3.3717,cx2:6.8234,cy2:2.7086,x:7.3391,y:2.0882},{op:"C",cx1:7.8551,cy1:1.4679,cx2:8.4754,cy2:.9642,x:9.2062,y:.5773},{op:"C",cx1:9.937,cy1:.1904,cx2:10.7355,cy2:0,x:11.5953,y:0},{op:"C",cx1:12.0559,cy1:.043,cx2:12.4061,cy2:.2088,x:12.6333,y:.4913},{op:"C",cx1:12.8607,cy1:.7678,cx2:12.9772,cy2:1.1117,x:12.9772,y:1.5109},{op:"C",cx1:12.9772,cy1:1.9345,cx2:12.8421,cy2:2.3154,x:12.5659,y:2.6472},{op:"C",cx1:12.2954,cy1:2.9788,cx2:11.9578,cy2:3.1446,x:11.5463,y:3.1446},{op:"C",cx1:11.0487,cy1:3.1446,cx2:10.7662,cy2:2.9174,x:10.7111,y:2.4691},{op:"C",cx1:10.7418,cy1:2.1743,cx2:10.8522,cy2:1.8918,x:11.0427,y:1.6276},{op:"C",cx1:11.2331,cy1:1.3635,cx2:11.4666,cy2:1.1793,x:11.7428,y:1.087},{op:"C",cx1:11.8472,cy1:1.087,cx2:11.8965,cy2:1.0379,x:11.8965,y:.9335},{op:"C",cx1:11.8965,cy1:.8108,cx2:11.614,cy2:.6327,x:11.2147,y:.6327},{op:"C",cx1:10.0908,cy1:.6327,cx2:9.237,cy2:1.7811,x:8.6535,y:4.0781},{op:"L",x:10.8646,y:4.0781},{op:"L",x:10.8646,y:4.9073},{op:"L",x:8.4508,y:4.9073},{op:"C",cx1:8.2483,cy1:5.7918,cx2:7.9902,cy2:6.6944,x:7.671,y:7.6156},{op:"C",cx1:7.3577,cy1:8.5308,cx2:7.026,cy2:9.3723,x:6.676,y:10.1401},{op:"C",cx1:6.3319,cy1:10.9076,cx2:6.0064,cy2:11.5156,x:5.7055,y:11.9762},{op:"C",cx1:5.2632,cy1:12.658,cx2:4.7966,cy2:13.2353,x:4.299,y:13.7145},{op:"C",cx1:3.8016,cy1:14.1995,cx2:3.206,cy2:14.5067,x:2.5119,y:14.6418},{op:"C",cx1:2.211,cy1:14.6788,cx2:2.0266,cy2:14.6972,x:1.9592,y:14.6972},{op:"C",cx1:1.3632,cy1:14.6972,cx2:.8905,cy2:14.5128,x:.5527,y:14.1382},{op:"C",cx1:.2149,cy1:13.7636,cx2:.0307,cy2:13.3276,x:0,y:12.83},{op:"C",cx1:.0428,cy1:12.3941,cx2:.1718,cy2:12.0623,x:.3869,y:11.8351},{op:"C",cx1:.6017,cy1:11.6079,cx2:.9149,cy2:11.4298,x:1.3326,y:11.3008},{op:"C",cx1:1.6458,cy1:11.3254,cx2:1.9039,cy2:11.4359,x:2.1066,y:11.6324},{op:"C",cx1:2.3091,cy1:11.8352,cx2:2.4135,cy2:12.0809,x:2.4135,y:12.3818},{op:"C",cx1:2.4135,cy1:12.9405,cx2:1.8548,cy2:13.4134,x:1.4309,y:13.8127},{op:"C",cx1:1.4309,cy1:13.9171,cx2:1.5476,cy2:13.9664,x:1.7811,y:13.9664},{op:"C",cx1:2.7453,cy1:13.9664,cx2:3.5129,cy2:12.9405,x:4.0718,y:10.8955},{op:"C",cx1:4.2683,cy1:10.3426,cx2:4.4404,cy2:9.8083,x:4.5938,y:9.2926},{op:"C",cx1:4.7475,cy1:8.7703,cx2:4.9624,cy2:8.0028,x:5.2449,y:6.9832},{op:"C",cx1:5.5337,cy1:5.9575,cx2:5.7362,cy2:5.2695,x:5.8592,y:4.9073},{op:"L",x:4.1702,y:4.9073},{op:"L",x:4.1702,y:4.0781},{op:"L",x:6.1601,y:4.0781},{op:"Z"}],p:[{op:"M",x:3.767,y:8.5573},{op:"L",x:5.0097,y:5.0738},{op:"C",cx1:5.0804,cy1:4.7969,cx2:5.1126,cy2:4.5909,x:5.1126,y:4.443},{op:"C",cx1:5.1126,cy1:4.2497,cx2:5.0224,cy2:4.1531,x:4.8486,y:4.1531},{op:"C",cx1:4.7262,cy1:4.1531,cx2:4.5653,cy2:4.2497,x:4.3786,y:4.443},{op:"C",cx1:3.9471,cy1:4.9001,cx2:3.6059,cy2:5.383,x:3.3484,y:5.8917},{op:"L",x:2.6851,y:5.8917},{op:"C",cx1:2.8138,cy1:5.5117,cx2:3.0264,cy2:5.1126,x:3.3163,y:4.7004},{op:"C",cx1:3.6059,cy1:4.2818,cx2:3.9471,cy2:3.9406,x:4.3335,y:3.6702},{op:"C",cx1:4.7262,cy1:3.3933,cx2:5.1192,cy2:3.258,x:5.5119,y:3.258},{op:"C",cx1:6.1623,cy1:3.258,cx2:6.613,cy2:3.5671,x:6.8575,y:4.179},{op:"C",cx1:7.1987,cy1:3.8891,cx2:7.6044,cy2:3.6444,x:8.0617,y:3.4447},{op:"C",cx1:8.5188,cy1:3.2454,cx2:8.9632,cy2:3.1486,x:9.388,y:3.1486},{op:"C",cx1:10.1286,cy1:3.1486,cx2:10.7017,cy2:3.4447,x:11.1008,y:4.0437},{op:"C",cx1:11.5064,cy1:4.636,cx2:11.706,cy2:5.3249,x:11.706,y:6.104},{op:"C",cx1:11.706,cy1:6.8187,cx2:11.5322,cy2:7.5464,x:11.178,y:8.274},{op:"C",cx1:10.8304,cy1:9.0017,cx2:10.3538,cy2:9.6004,x:9.7422,y:10.0704},{op:"C",cx1:9.1306,cy1:10.5406,cx2:8.4607,cy2:10.7724,x:7.7267,y:10.7724},{op:"C",cx1:7.0442,cy1:10.7724,cx2:6.4133,cy2:10.5148,x:5.8273,y:10.006},{op:"L",x:4.7972,y:12.9614},{op:"C",cx1:4.765,cy1:13.0453,cx2:4.7133,cy2:13.1998,x:4.6426,y:13.4122},{op:"C",cx1:4.6684,cy1:13.6377,cx2:4.7842,cy2:13.7922,x:4.9902,y:13.8695},{op:"C",cx1:5.2028,cy1:13.9531,cx2:5.5504,cy2:13.9919,x:6.0399,y:13.9919},{op:"L",x:6.0399,y:14.8095},{op:"L",x:0,y:14.8095},{op:"L",x:0,y:13.9919},{op:"C",cx1:.7469,cy1:13.9919,cx2:1.2815,cy2:13.8759,x:1.5969,y:13.6506},{op:"C",cx1:1.9124,cy1:13.4251,cx2:2.1379,cy2:13.1289,x:2.2666,y:12.7491},{op:"L",x:3.767,y:8.5573},{op:"Z"},{op:"M",x:7.0637,y:6.3166},{op:"C",cx1:6.7802,cy1:6.9604,cx2:6.6064,cy2:7.8104,x:6.5357,y:8.8727},{op:"C",cx1:6.6064,cy1:9.5619,cx2:6.7609,cy2:9.9031,x:7.012,y:9.9031},{op:"C",cx1:7.8879,cy1:9.7356,cx2:8.609,cy2:8.7248,x:9.1755,y:6.8704},{op:"C",cx1:9.3495,cy1:6.2071,cx2:9.4395,cy2:5.6084,x:9.4395,y:5.0738},{op:"C",cx1:9.4395,cy1:4.4108,cx2:9.2657,cy2:4.05,x:8.9115,y:3.9923},{op:"C",cx1:8.332,cy1:3.9923,cx2:7.7139,cy2:4.7647,x:7.0637,y:6.3166},{op:"Z"}]},Tl={mf:8.0028,mp:9.523,ff:6.67866,pp:8.8083},Ll={fill:"#000"},Cl=.79341;function oe(s,t,e){let n=0,o=Array.from(s,(i,r)=>{let a={path:El[i],style:Ll,dx:n};return n+=Tl[i+s[r+1]]??0,a});return{name:s,description:e,shapes:o,weight:s.includes("f")?1:Cl,onTimeState:i=>{i.velocity=t}}}var Yr=[oe("ppp",16,"\u6781\u5F31"),oe("pp",32,"\u5F88\u5F31"),oe("p",48,"\u5F31"),oe("mp",64,"\u4E2D\u5F31"),oe("mf",80,"\u4E2D\u5F3A"),oe("f",96,"\u5F3A"),oe("ff",112,"\u5F88\u5F3A"),oe("fff",127,"\u6781\u5F3A")];var vl={},Xr={name:"fermata",description:"\u5EF6\u957F\u8BB0\u53F7\uFF1A\u8986\u76D6\u533A\u95F4\u901F\u5EA6\u51CF\u534A\uFF0C\u76EE\u6807\u97F3\u5B9E\u9645\u65F6\u957F\u7FFB\u500D",weight:.6,paddingBottom:3,shapes:[{path:[{op:"M",x:0,y:7.46666},{op:"C",cx1:3.65834,cy1:0,cx2:8.53611,cy2:0,x:12.19445,y:7.46666},{op:"M",x:12.19445,y:7.46666},{op:"C",cx1:8.53611,cy1:.74666,cx2:3.65833,cy2:.74666,x:0,y:7.46666}],style:{fill:"#000",stroke:"#000",strokeWidth:1}},{circle:{cx:6.09723,cy:6.26666,r:1.2},style:{fill:"#000"}}],emitPlayback:s=>s.scaleFollowingBpm(vl,1,2,{followConnections:!0})};var qr={name:"fine",description:"\u7EC8\u6B62\u8BB0\u53F7\uFF1A\u56DE\u8DF3\u4E4B\u540E\u7ECF\u8FC7\u8FD9\u91CC\u5C31\u7ED3\u675F\u4E50\u66F2",weight:1.4,text:{content:"Fine.",fontFamily:'"Times New Roman", serif',fontStyle:"italic"},onVisit:(s,t)=>{let e=s.seek(sn,t,1);return e!==void 0&&s.visits(e)>0?{kind:"stop"}:void 0}};function Fe(s){return(t,e)=>{let n=[];for(let o of e){if(!o.transpose){n.push(o);continue}let i=o.end.clone().sub(o.start),r=s.body.length;if(s.repeat){let c=t.stateAt(o.start).effectiveBpm,l=Math.min(480,Math.max(60,c))/c,p=Math.floor(256/s.body.length),f=Math.min(p,Math.max(1,Math.round(i.toNumber()*8*l/s.body.length)));r*=f}let a=i.div(r);for(let c=0;c<r;c++){let l=s.body[c%s.body.length],p=a.clone().mul(c).add(o.start);n.push({...o,start:p,end:p.clone().add(a),midi:l===0?o.midi:o.transpose(l),transpose:f=>o.transpose(l+f)})}}return n}}var Zr={name:"mordent",description:"\u4E0B\u6CE2\u97F3\uFF1A\u672C\u97F3\u3001\u8C03\u5185\u4E0B\u65B9\u4E8C\u5EA6\u3001\u672C\u97F3",weight:.73423,shapes:[{path:[{op:"M",x:7.29541,y:.05944},{op:"C",cx1:7.56541,cy1:-.09056,cx2:7.92541,cy2:.05944,x:8.04541,y:.32944},{op:"C",cx1:8.10541,cy1:.44944,cx2:8.10541,cy2:.56944,x:8.10541,y:1.76943},{op:"L",x:8.10541,y:3.05943},{op:"L",x:8.67541,y:2.21943},{op:"C",cx1:9.18541,cy1:1.46943,cx2:9.24541,cy2:1.37943,x:9.36541,y:1.31943},{op:"C",cx1:9.42541,cy1:1.28943,cx2:9.54541,cy2:1.25943,x:9.60541,y:1.25943},{op:"C",cx1:9.90541,cy1:1.25943,cx2:9.87541,cy2:1.22943,x:11.49541,y:3.20943},{op:"L",x:13.02541,y:5.03943},{op:"L",x:13.50541,y:4.34943},{op:"C",cx1:14.01541,cy1:3.56943,cx2:14.04541,cy2:3.50943,x:14.19541,y:3.44943},{op:"C",cx1:14.61541,cy1:3.26943,cx2:15.06541,cy2:3.59943,x:15.00541,y:4.04943},{op:"C",cx1:14.97541,cy1:4.16943,cx2:14.70541,cy2:4.55943,x:13.50541,y:6.41943},{op:"C",cx1:12.12541,cy1:8.48943,cx2:12.00541,cy2:8.63943,x:11.88541,y:8.69943},{op:"C",cx1:11.82541,cy1:8.72943,cx2:11.70541,cy2:8.75943,x:11.64541,y:8.75943},{op:"C",cx1:11.34541,cy1:8.75943,cx2:11.37541,cy2:8.78943,x:9.81541,y:6.86943},{op:"C",cx1:9.00541,cy1:5.87943,cx2:8.31541,cy2:5.06943,x:8.28541,y:5.00943},{op:"C",cx1:8.22541,cy1:4.97943,cx2:8.22541,cy2:4.97943,x:8.16541,y:5.03943},{op:"C",cx1:8.10541,cy1:5.09943,cx2:8.10541,cy2:5.18943,x:8.10541,y:7.31943},{op:"C",cx1:8.10541,cy1:9.26943,cx2:8.10541,cy2:9.56943,x:8.04541,y:9.65943},{op:"C",cx1:7.86541,cy1:10.10943,cx2:7.23541,cy2:10.13943,x:6.99541,y:9.68943},{op:"C",cx1:6.96541,cy1:9.62943,cx2:6.93541,cy2:9.44943,x:6.93541,y:8.27943},{op:"L",x:6.93541,y:6.92943},{op:"L",x:6.36541,y:7.76943},{op:"C",cx1:5.82541,cy1:8.54943,cx2:5.76541,cy2:8.63943,x:5.64541,y:8.69943},{op:"C",cx1:5.58541,cy1:8.72943,cx2:5.46541,cy2:8.75943,x:5.40541,y:8.75943},{op:"C",cx1:5.10541,cy1:8.75943,cx2:5.13541,cy2:8.78943,x:3.51541,y:6.80943},{op:"L",x:1.98541,y:4.97943},{op:"L",x:1.50541,y:5.66943},{op:"C",cx1:.99541,cy1:6.44943,cx2:.96541,cy2:6.50943,x:.81541,y:6.56943},{op:"C",cx1:.39541,cy1:6.74943,cx2:-.05459,cy2:6.41943,x:.00541,y:5.96943},{op:"C",cx1:.03541,cy1:5.84943,cx2:.30541,cy2:5.45943,x:1.50541,y:3.59943},{op:"C",cx1:2.88541,cy1:1.52943,cx2:3.00541,cy2:1.37943,x:3.12541,y:1.31943},{op:"C",cx1:3.18541,cy1:1.28943,cx2:3.30541,cy2:1.25943,x:3.36541,y:1.25943},{op:"C",cx1:3.66541,cy1:1.25943,cx2:3.63541,cy2:1.22943,x:5.25541,y:3.20943},{op:"L",x:6.78541,y:5.03943},{op:"C",cx1:6.81541,cy1:5.03943,cx2:6.84541,cy2:4.97943,x:6.87541,y:4.94943},{op:"C",cx1:6.93541,cy1:4.82943,cx2:6.93541,cy2:4.79943,x:6.93541,y:2.66943},{op:"C",cx1:6.93541,cy1:.74943,cx2:6.93541,cy2:.44943,x:6.99541,y:.35943},{op:"C",cx1:7.05541,cy1:.20943,cx2:7.14541,cy2:.11943,x:7.29541,y:.05943},{op:"Z"}],style:{fill:"#000"}}],emitPlayback:s=>s.affectFollowing(Fe({body:[0,-1,0]}))};var Qr={name:"prall",description:"\u4E0A\u6CE2\u97F3\uFF1A\u672C\u97F3\u3001\u8C03\u5185\u4E0A\u65B9\u4E8C\u5EA6\u3001\u672C\u97F3",weight:.55,shapes:[{path:[{op:"M",x:3.12541,y:.06003},{op:"C",cx1:3.18541,cy1:.03003,cx2:3.30541,cy2:3e-5,x:3.36541,y:3e-5},{op:"C",cx1:3.66541,cy1:3e-5,cx2:3.63541,cy2:-.02997,x:5.25541,y:1.95003},{op:"L",x:6.78541,y:3.78003},{op:"C",cx1:6.81541,cy1:3.78003,cx2:7.35541,cy2:2.94003,x:8.01541,y:1.95003},{op:"C",cx1:9.15541,cy1:.27003,cx2:9.24541,cy2:.12003,x:9.36541,y:.06003},{op:"C",cx1:9.42541,cy1:.03003,cx2:9.54541,cy2:3e-5,x:9.60541,y:3e-5},{op:"C",cx1:9.90541,cy1:3e-5,cx2:9.87541,cy2:-.02997,x:11.49541,y:1.95003},{op:"L",x:13.02541,y:3.78003},{op:"L",x:13.50541,y:3.09003},{op:"C",cx1:14.01541,cy1:2.31003,cx2:14.04541,cy2:2.25003,x:14.19541,y:2.19003},{op:"C",cx1:14.61541,cy1:2.01003,cx2:15.06541,cy2:2.34003,x:15.00541,y:2.79003},{op:"C",cx1:14.97541,cy1:2.91003,cx2:14.70541,cy2:3.30003,x:13.50541,y:5.16003},{op:"C",cx1:12.12541,cy1:7.23003,cx2:12.00541,cy2:7.38003,x:11.88541,y:7.44003},{op:"C",cx1:11.82541,cy1:7.47003,cx2:11.70541,cy2:7.50003,x:11.64541,y:7.50003},{op:"C",cx1:11.34541,cy1:7.50003,cx2:11.37541,cy2:7.53003,x:9.75541,y:5.55003},{op:"L",x:8.22541,y:3.72003},{op:"C",cx1:8.19541,cy1:3.72003,cx2:7.65541,cy2:4.56003,x:6.99541,y:5.55003},{op:"C",cx1:5.85541,cy1:7.23003,cx2:5.76541,cy2:7.38003,x:5.64541,y:7.44003},{op:"C",cx1:5.58541,cy1:7.47003,cx2:5.46541,cy2:7.50003,x:5.40541,y:7.50003},{op:"C",cx1:5.10541,cy1:7.50003,cx2:5.13541,cy2:7.53003,x:3.51541,y:5.55003},{op:"L",x:1.98541,y:3.72003},{op:"L",x:1.50541,y:4.41003},{op:"C",cx1:.99541,cy1:5.19003,cx2:.96541,cy2:5.25003,x:.81541,y:5.31003},{op:"C",cx1:.39541,cy1:5.49003,cx2:-.05459,cy2:5.16003,x:.00541,y:4.71004},{op:"C",cx1:.03541,cy1:4.59004,cx2:.30541,cy2:4.20004,x:1.50541,y:2.34004},{op:"C",cx1:2.88541,cy1:.27004,cx2:3.00541,cy2:.12004,x:3.12541,y:.06004},{op:"Z"}],style:{fill:"#000"}}],emitPlayback:s=>s.affectFollowing(Fe({body:[0,1,0]}))};var rn={name:"tr",description:"\u98A4\u97F3\uFF1A\u672C\u97F3\u4E0E\u8C03\u5185\u4E0A\u65B9\u4E8C\u5EA6\u4EA4\u66FF\u3002\u53EF\u5199\u4E3A `$tr++`\uFF0C\u6BCF\u4E2A\u7D27\u63A5\u7684 `+` \u6DFB\u52A0\u4E00\u622A\u6CE2\u6D6A\u5C3E\u5DF4",pattern:{regex:/^tr(\++)/,resolve:s=>{let t=[...rn.shapes];for(let e=0;e<s[1].length;e++)t.push({...Nl,dx:14.11212+e*5.95219});return{...rn,name:s[0],anchor:Ml,shapes:t}}},shapes:[{path:[{op:"M",x:3.17992,y:5.46383},{op:"L",x:3.61827,y:3.91711},{op:"C",cx1:3.10024,cy1:3.49862,cx2:2.52947,cy2:3.29304,x:1.90541,y:3.29304},{op:"C",cx1:1.50051,cy1:3.29304,cx2:1.18833,cy2:3.40589,x:.95611,y:3.63812},{op:"C",cx1:.72361,cy1:3.87061,cx2:.59743,cy2:4.14281,x:.57105,y:4.46152},{op:"C",cx1:.57105,cy1:4.91944,cx2:.71707,cy2:5.25147,x:1.00913,y:5.47036},{op:"C",cx1:1.30118,cy1:5.68954,cx2:1.61988,cy2:5.79586,x:1.95843,y:5.79586},{op:"C",cx1:1.9916,cy1:5.79586,cx2:2.03157,cy2:5.8157,x:2.06475,y:5.84888},{op:"C",cx1:2.24394,cy1:5.82904,cx2:2.61568,cy2:5.69632,x:3.17992,y:5.46383},{op:"Z"},{op:"M",x:6.579,y:9.87204},{op:"L",x:8.40472,y:3.75096},{op:"C",cx1:8.40472,cy1:3.59162,cx2:8.35167,cy2:3.51193,x:8.23884,y:3.51193},{op:"C",cx1:7.98647,cy1:3.51193,cx2:7.4554,cy2:3.77761,x:6.63883,y:4.3152},{op:"C",cx1:5.82223,cy1:4.84655,cx2:5.37735,cy2:5.15845,x:5.30448,y:5.25145},{op:"C",cx1:5.33764,cy1:5.21147,cx2:5.39068,cy2:5.15845,x:5.46383,y:5.0853},{op:"C",cx1:6.13441,cy1:6.06127,cx2:6.47294,cy2:6.98417,x:6.47294,y:7.86061},{op:"C",cx1:6.41313,cy1:8.53088,cx2:6.18062,cy2:9.12181,x:5.7692,y:9.61968},{op:"C",cx1:5.3643,cy1:10.11758,cx2:4.85308,cy2:10.3634,x:4.24233,y:10.3634},{op:"C",cx1:3.71778,cy1:10.3634,cx2:3.25306,cy2:10.23719,x:2.83483,y:9.99138},{op:"C",cx1:2.42314,cy1:9.74586,cx2:2.20396,cy2:9.39396,x:2.17759,y:8.92271},{op:"C",cx1:2.21077,cy1:8.80986,cx2:2.23061,cy2:8.66384,x:2.23061,y:8.48436},{op:"L",x:2.85469,y:6.0944},{op:"C",cx1:2.58903,cy1:6.2339,cx2:2.21729,cy2:6.30702,x:1.73924,y:6.30702},{op:"C",cx1:1.22829,cy1:6.2804,cx2:.81007,cy2:6.1012,x:.48458,y:5.76917},{op:"C",cx1:.15935,cy1:5.43065,cx2:0,cy2:4.97926,x:0,y:4.4082},{op:"C",cx1:.03318,cy1:3.89045,cx2:.20586,cy2:3.46543,x:.53107,y:3.13369},{op:"C",cx1:.8563,cy1:2.80166,cx2:1.32782,cy2:2.63579,x:1.95843,y:2.63579},{op:"C",cx1:2.55585,cy1:2.63579,cx2:3.17992,cy2:2.87481,x:3.83716,y:3.34606},{op:"L",x:4.89277,y:0},{op:"L",x:6.85119,y:0},{op:"L",x:5.41053,y:4.51453},{op:"C",cx1:6.28694,cy1:3.83064,cx2:7.02389,cy2:3.34606,x:7.62128,y:3.06054},{op:"C",cx1:8.21899,cy1:2.77502,cx2:8.86943,cy2:2.63579,x:9.57321,y:2.63579},{op:"C",cx1:10.05773,cy1:2.63579,cx2:10.30358,cy2:2.83484,x:10.30358,y:3.23974},{op:"C",cx1:10.30358,cy1:3.44559,cx2:10.17738,cy2:3.89046,x:10.09093,y:4.18931},{op:"C",cx1:10.7283,cy1:3.15354,cx2:11.45195,cy2:2.63579,x:12.26199,y:2.63579},{op:"C",cx1:12.6272,cy1:2.63579,cx2:12.91925,cy2:2.76849,x:13.14497,y:3.03417},{op:"C",cx1:13.37717,cy1:3.29957,cx2:13.49001,cy2:3.61175,x:13.49001,y:3.97014},{op:"C",cx1:13.49001,cy1:4.62739,cx2:13.09844,cy2:5.03228,x:12.53419,y:5.03228},{op:"C",cx1:12.16899,cy1:5.03228,cx2:11.85709,cy2:4.79327,x:11.80382,y:4.29536},{op:"C",cx1:11.89029,cy1:3.91031,cx2:11.98982,cy2:3.55191,x:11.98982,y:3.34606},{op:"C",cx1:11.98982,cy1:3.27291,cx2:11.94329,cy2:3.23973,x:11.85709,y:3.23973},{op:"C",cx1:11.74403,cy1:3.23973,cx2:11.53162,cy2:3.34606,x:11.20637,y:3.56522},{op:"C",cx1:10.90752,cy1:3.7708,cx2:10.61547,cy2:4.11615,x:10.31666,y:4.61405},{op:"C",cx1:10.01808,cy1:5.11195,cx2:9.77253,cy2:5.69632,x:9.57321,y:6.36662},{op:"L",x:8.45798,y:9.87203},{op:"L",x:6.57899,y:9.87203},{op:"L",x:6.579,y:9.87204},{op:"Z"},{op:"M",x:5.05893,y:5.62971},{op:"L",x:3.94348,y:8.92274},{op:"C",cx1:3.94348,cy1:9.0288,cx2:3.92364,cy2:9.12179,x:3.89045,y:9.19495},{op:"C",cx1:3.89045,cy1:9.48047,cx2:4.06285,cy2:9.65287,x:4.40821,y:9.70617},{op:"C",cx1:5.404,cy1:9.22134,cx2:5.9019,cy2:8.51787,x:5.9019,y:7.58841},{op:"C",cx1:5.9019,cy1:6.99751,cx2:5.62318,cy2:6.34681,x:5.05893,y:5.62972},{op:"L",x:5.05893,y:5.62971},{op:"Z"}],style:{fill:"#000"}}],emitPlayback:s=>s.affectFollowing(Fe({body:[0,1],repeat:!0}))},Jr=$e(rn.shapes),Ml=Jr.x+Jr.w/2,Nl={path:[{op:"M",x:7.03619,y:4.89762},{op:"C",cx1:7.03619,cy1:4.89762,cx2:6.87351,cy2:4.70878,x:6.65687,y:4.5183},{op:"C",cx1:6.57594,cy1:4.43737,cx2:6.46721,cy2:4.41039,x:6.38546,y:4.41039},{op:"C",cx1:6.30535,cy1:4.41039,cx2:6.25058,cy2:4.43737,x:6.19662,y:4.49132},{op:"L",x:5.89905,y:4.78889},{op:"C",cx1:5.8451,cy1:4.84367,cx2:5.79033,cy2:4.87064,x:5.73719,y:4.87064},{op:"C",cx1:5.62846,cy1:4.87064,cx2:5.57451,cy2:4.78889,x:5.57451,y:4.78889},{op:"C",cx1:5.57451,cy1:4.78889,cx2:3.84223,cy2:3.30105,x:3.57164,y:3.05662},{op:"C",cx1:3.27407,cy1:2.8408,cx2:2.9765,cy2:2.75905,x:2.70591,y:2.75905},{op:"C",cx1:2.13857,cy1:2.75905,cx2:1.62355,cy2:3.08523,x:1.40773,y:3.32721},{op:"L",x:.10873,y:4.62703},{op:"C",cx1:.02698,cy1:4.70878,cx2:0,cy2:4.76192,x:0,y:4.84367},{op:"C",cx1:0,cy1:4.97773,cx2:.10873,cy2:5.08646,x:.10873,y:5.08646},{op:"C",cx1:.10873,cy1:5.08646,cx2:.27141,cy2:5.2753,x:.48723,y:5.46578},{op:"C",cx1:.56898,cy1:5.54671,cx2:.64909,cy2:5.57451,x:.73084,y:5.57451},{op:"C",cx1:.81259,cy1:5.57451,cx2:.86655,cy2:5.54671,x:.91968,y:5.49276},{op:"L",x:1.21725,y:5.19519},{op:"C",cx1:1.27284,cy1:5.14123,cx2:1.32598,cy2:5.11344,x:1.37993,y:5.11344},{op:"C",cx1:1.48866,cy1:5.11344,cx2:1.57041,cy2:5.19519,x:1.57041,y:5.19519},{op:"C",cx1:1.57041,cy1:5.19519,cx2:3.30105,cy2:6.65605,x:3.57164,y:6.89885},{op:"C",cx1:3.86921,cy1:7.1163,cx2:4.16678,cy2:7.19805,x:4.43819,y:7.19805},{op:"C",cx1:5.00635,cy1:7.19805,cx2:5.51973,cy2:6.87187,x:5.73719,y:6.62989},{op:"L",x:7.03619,y:5.33008},{op:"C",cx1:7.1163,cy1:5.24833,cx2:7.1441,cy2:5.16821,x:7.1441,y:5.11344},{op:"C",cx1:7.1441,cy1:4.97773,cx2:7.03619,cy2:4.89762,x:7.03619,y:4.89762},{op:"Z"}],style:{fill:"#000"}};var Un=new Map,ta=[];for(let s of[rn,Xr,Qr,Zr,Vr,...Yr,Ur,Kr,jr,qr]){let t=s.name.toLowerCase();if(Un.has(t))throw new Error(`Duplicate symbol name: ${s.name}`);Un.set(t,s);let e=s.pattern;if(!e)continue;let{regex:n}=e;if(n.global||n.sticky)throw new Error(`Symbol pattern must not use g or y flags: ${t}`);ta.push(n.ignoreCase?e:{...e,regex:new RegExp(n.source,`${n.flags}i`)})}var Ms=class extends ${static def={name:["symbol","$"],description:"\u521B\u5EFA\u4E00\u4E2A\u4E50\u8C31\u7B26\u53F7",details:`~~~jpfun
|
|
79
|
+
)`}},Ta=Gr;function qt(r){return(t,e)=>{let n=[];for(let o of e){if(!o.transpose){n.push(o);continue}let s=o.end.clone().sub(o.start),i=r.body.length;if(r.repeat){let c=t.stateAt(o.start).effectiveBpm,l=Math.min(480,Math.max(60,c))/c,u=Math.floor(256/r.body.length),p=Math.min(u,Math.max(1,Math.round(s.toNumber()*8*l/r.body.length)));i*=p}let a=s.div(i);for(let c=0;c<i;c++){let l=r.body[c%r.body.length],u=a.clone().mul(c).add(o.start);n.push({...o,start:u,end:u.clone().add(a),midi:l===0?o.midi:o.transpose(l),transpose:p=>o.transpose(l+p)})}}return n}}var io={name:"accent",description:"\u91CD\u97F3",weight:.5,shapes:[{path:[{op:"M",x:.21413,y:.4818},{op:"L",x:8.21413,y:3.72071},{op:"L",x:.29494,y:6.92724}],style:{stroke:"#000",strokeWidth:1}}],emitPlayback:r=>r.affectFollowing((t,e)=>{for(let n of e)n.velocity=Math.min(127,n.velocity+20)})};var $r="repeat.coda";/*!
|
|
80
|
+
* Bravura coda (U+E048), Y axis flipped; https://github.com/steinbergmedia/bravura
|
|
81
|
+
* Copyright (c) 2026, Steinberg Media Technologies GmbH. Reserved Font Name "Bravura".
|
|
82
|
+
* SPDX-License-Identifier: OFL-1.1
|
|
83
|
+
* Full license: Bravura-LICENSE.txt in the package root and dist.
|
|
84
|
+
*/var pu=[{op:"M",x:-4,y:-376},{op:"C",cx1:-4,cy1:-363,cx2:0,cy2:-352,x:14,y:-352},{op:"L",x:146,y:-352},{op:"C",cx1:157,cy1:-165,cx2:296,cy2:-13,x:458,y:0},{op:"L",x:458,y:140},{op:"C",cx1:458,cy1:154,cx2:469,cy2:158,x:482,y:158},{op:"C",cx1:495,cy1:158,cx2:506,cy2:154,x:506,y:140},{op:"L",x:506,y:0},{op:"C",cx1:668,cy1:-13,cx2:808,cy2:-165,x:818,y:-352},{op:"L",x:937,y:-352},{op:"C",cx1:951,cy1:-352,cx2:955,cy2:-363,x:955,y:-376},{op:"C",cx1:955,cy1:-389,cx2:951,cy2:-400,x:937,y:-400},{op:"L",x:818,y:-400},{op:"C",cx1:808,cy1:-588,cx2:668,cy2:-739,x:506,y:-752},{op:"L",x:506,y:-881},{op:"C",cx1:506,cy1:-894,cx2:495,cy2:-898,x:482,y:-898},{op:"C",cx1:469,cy1:-898,cx2:458,cy2:-894,x:458,y:-881},{op:"L",x:458,y:-752},{op:"C",cx1:296,cy1:-739,cx2:157,cy2:-589,x:146,y:-400},{op:"L",x:14,y:-400},{op:"C",cx1:0,cy1:-400,cx2:-4,cy2:-389,x:-4,y:-376},{op:"Z"},{op:"M",x:653,y:-400},{op:"L",x:506,y:-400},{op:"L",x:506,y:-696},{op:"C",cx1:646,cy1:-684,cx2:653,cy2:-562,x:653,y:-400},{op:"Z"},{op:"M",x:506,y:-352},{op:"L",x:653,y:-352},{op:"C",cx1:650,cy1:-199,cx2:631,cy2:-63,x:506,y:-48},{op:"Z"},{op:"M",x:316,y:-400},{op:"C",cx1:316,cy1:-562,cx2:316,cy2:-684,x:458,y:-696},{op:"L",x:458,y:-400},{op:"Z"},{op:"M",x:458,y:-352},{op:"L",x:458,y:-48},{op:"C",cx1:329,cy1:-63,cx2:317,cy2:-198,x:316,y:-352},{op:"Z"}],La={name:"coda",description:"\u5C3E\u58F0\u8BB0\u53F7\uFF1A$tocoda \u7684\u8DF3\u8F6C\u76EE\u6807",weight:1.15,playbackMarks:()=>[$r],shapes:[{path:pu,style:{fill:"#000"}}]};var we="repeat.jump",Aa={name:"dc",description:"\u4ECE\u5934\u53CD\u590D\uFF1A\u8DF3\u56DE\u66F2\u9996\u518D\u6F14\u4E00\u904D",weight:.9,shapes:[{path:[{op:"M",x:1.06974,y:7.0752},{op:"L",x:2.69184,y:1.21499},{op:"C",cx1:2.69184,cy1:1.1221,cx2:2.73825,cy2:.93022,x:2.73825,y:.86039},{op:"C",cx1:2.73825,cy1:.48248,cx2:2.4825,cy2:.33152,x:1.7614,y:.23838},{op:"L",x:1.7614,y:.04641},{op:"L",x:4.88344,y:.04641},{op:"C",cx1:7.64477,cy1:.04641,cx2:9.02278,cy2:1.18018,x:9.02278,y:3.45323},{op:"C",cx1:9.02278,cy1:4.47649,cx2:8.74941,cy2:5.36592,x:8.20888,y:6.11596},{op:"C",cx1:7.6681,cy1:6.86578,cx2:6.95303,cy2:7.4297,x:6.05765,y:7.81334},{op:"C",cx1:5.16823,cy1:8.19125,cx2:4.22074,cy2:8.38316,x:3.21493,y:8.38316},{op:"L",x:0,y:8.38316},{op:"L",x:0,y:8.19119},{op:"C",cx1:.64542,cy1:8.19126,cx2:.91275,cy2:7.81343,x:1.06974,y:7.07521},{op:"L",x:1.06974,y:7.0752},{op:"Z"},{op:"M",x:4.09864,y:.66867},{op:"L",x:2.2848,y:7.35998},{op:"C",cx1:2.2848,cy1:7.42409,cx2:2.26718,cy2:7.48786,x:2.23815,y:7.55197},{op:"C",cx1:2.29051,cy1:7.84841,cx2:2.58133,cy2:7.99961,x:3.12179,y:7.99961},{op:"C",cx1:3.97639,cy1:7.99961,cx2:4.74389,cy2:7.79034,x:5.42397,y:7.37165},{op:"C",cx1:6.10429,cy1:6.94733,cx2:6.62746,cy2:6.37751,x:7.00538,y:5.65666},{op:"C",cx1:7.3833,cy1:4.92994,cx2:7.5752,cy2:4.1334,x:7.5752,y:3.26134},{op:"C",cx1:7.5752,cy1:1.372,cx2:6.69156,cy2:.43029,x:4.92984,y:.43029},{op:"C",cx1:4.53471,cy1:.43029,cx2:4.25555,cy2:.51151,x:4.09864,y:.66869},{op:"L",x:4.09864,y:.66867},{op:"Z"},{op:"M",x:18.35961,y:.04641},{op:"L",x:17.90593,y:2.62204},{op:"L",x:17.66755,y:2.62204},{op:"C",cx1:17.563,cy1:1.19183,cx2:16.91187,cy2:.47678,x:15.71418,y:.47678},{op:"C",cx1:14.96437,cy1:.47678,cx2:14.29564,cy2:.73848,x:13.70274,y:1.26165},{op:"C",cx1:13.11556,cy1:1.77911,cx2:12.65617,cy2:2.43578,x:12.33664,y:3.22668},{op:"C",cx1:12.01679,cy1:4.01155,cx2:11.85988,cy2:4.77302,x:11.85988,y:5.49984},{op:"C",cx1:11.85988,cy1:6.26131,cx2:12.03424,cy2:6.90076,x:12.37734,y:7.41814},{op:"C",cx1:12.72598,cy1:7.9356,cx2:13.24931,cy2:8.19126,x:13.95279,y:8.19126},{op:"C",cx1:15.08622,cy1:8.19126,cx2:16.11543,cy2:7.68548,x:17.02818,y:6.66825},{op:"L",x:17.21412,y:6.86023},{op:"C",cx1:16.26663,cy1:8.16232,cx2:15.08051,cy2:8.81352,x:13.66775,y:8.81352},{op:"C",cx1:13.034,cy1:8.81352,cx2:12.47014,cy2:8.65637,x:11.97608,y:8.34254},{op:"C",cx1:11.48195,cy1:8.02864,cx2:11.10411,cy2:7.60432,x:10.83074,y:7.06925},{op:"C",cx1:10.56333,cy1:6.53442,cx2:10.42974,cy2:5.94748,x:10.42974,y:5.31357},{op:"C",cx1:10.42974,cy1:4.43581,cx2:10.67383,cy2:3.58692,x:11.15655,y:2.7616},{op:"C",cx1:11.63894,cy1:1.93602,cx2:12.28427,cy2:1.26738,x:13.09223,y:.76158},{op:"C",cx1:13.90042,cy1:.25578,cx2:14.74336,cy2:3e-5,x:15.62137,y:3e-5},{op:"C",cx1:15.88283,cy1:3e-5,cx2:16.12121,cy2:.0174,x:16.33651,y:.0581},{op:"C",cx1:16.55157,cy1:.09886,cx2:16.79557,cy2:.15122,x:17.05729,y:.21501},{op:"C",cx1:17.31875,cy1:.2791,cx2:17.51072,cy2:.31979,x:17.62123,y:.33717},{op:"C",cx1:17.85961,cy1:.2557,cx2:18.03389,cy2:.15694,x:18.14432,y:.04643},{op:"L",x:18.35962,y:.04643},{op:"L",x:18.35961,y:.04644},{op:"Z"},{op:"M",x:8.19134,y:7.69151},{op:"C",cx1:8.19134,cy1:7.5169,cx2:8.25544,cy2:7.36596,x:8.38894,y:7.2322},{op:"C",cx1:8.52277,cy1:7.09838,cx2:8.69134,cy2:7.0288,x:8.88332,y:7.0288},{op:"C",cx1:9.0519,cy1:7.0288,cx2:9.19722,cy2:7.09838,x:9.3251,y:7.2322},{op:"C",cx1:9.45893,cy1:7.36603,cx2:9.5227,cy2:7.52294,x:9.5227,y:7.69151},{op:"C",cx1:9.5227,cy1:8.0925,cx2:9.23221,cy2:8.38324,x:8.88332,y:8.38324},{op:"C",cx1:8.48803,cy1:8.38324,cx2:8.19134,cy2:8.10416,x:8.19134,y:7.69151},{op:"Z"},{op:"M",x:18.00469,y:7.79028},{op:"C",cx1:18.00469,cy1:7.40068,cx2:18.27814,cy2:7.12162,x:18.64432,y:7.12162},{op:"C",cx1:19.03969,cy1:7.12162,cx2:19.31298,cy2:7.39507,x:19.31298,y:7.79028},{op:"C",cx1:19.31298,cy1:8.15653,cx2:19.0339,cy2:8.42965,x:18.64432,y:8.42965},{op:"C",cx1:18.28972,cy1:8.42965,cx2:18.00469,cy2:8.14486,x:18.00469,y:7.79028},{op:"Z"}],style:{fill:"#000"}}],playbackMarks:()=>[we],onVisit:(r,t)=>r.visits(t)>1?void 0:{kind:"jump",column:0}};var jr="repeat.segno",Ca={name:"segno",description:"\u53CD\u590D\u8BB0\u53F7\uFF1AD.S. \u7684\u56DE\u8DF3\u76EE\u6807",weight:1.15,playbackMarks:()=>[jr],shapes:[{path:[{op:"M",x:3.75502,y:7.52938},{op:"C",cx1:1.3411,cy1:6.32492,cx2:.10249,cy2:4.89115,x:.03897,y:3.23307},{op:"C",cx1:.06833,cy1:2.69176,cx2:.20975,cy2:2.17002,x:.45843,y:1.67267},{op:"C",cx1:.71191,cy1:1.1751,cx2:1.05826,cy2:.77042,x:1.49231,y:.46321},{op:"C",cx1:1.93115,cy1:.156,cx2:2.41873,cy2:0,x:2.95524,y:0},{op:"C",cx1:3.6136,cy1:0,cx2:4.17428,cy2:.17538,x:4.64747,y:.52174},{op:"C",cx1:5.12047,cy1:.8679,cx2:5.35457,cy2:1.36047,x:5.35457,y:1.99925},{op:"C",cx1:5.33499,cy1:2.26751,cx2:5.21315,cy2:2.49182,x:4.98384,y:2.66739},{op:"C",cx1:4.75473,cy1:2.83817,cx2:4.50106,cy2:2.93565,x:4.21343,y:2.95502},{op:"C",cx1:3.67691,cy1:2.90629,cx2:3.35013,cy2:2.68696,x:3.23807,y:2.29686},{op:"L",x:3.06249,y:1.73119},{op:"C",cx1:2.93086,cy1:1.31652,cx2:2.71134,cy2:1.0191,x:2.29687,y:1.0191},{op:"C",cx1:1.99446,cy1:1.0191,cx2:1.74578,cy2:1.16551,x:1.55561,y:1.46293},{op:"C",cx1:1.36544,cy1:1.76035,cx2:1.26798,cy2:2.06276,x:1.25819,y:2.37476},{op:"C",cx1:1.28735,cy1:2.79902,cx2:1.42398,cy2:3.17954,x:1.66287,y:3.50612},{op:"C",cx1:1.90677,cy1:3.8329,cx2:2.20418,cy2:4.11094,x:2.56012,y:4.34984},{op:"C",cx1:2.91627,cy1:4.58394,cx2:3.31116,cy2:4.79846,x:3.73542,y:4.99841},{op:"C",cx1:4.15967,cy1:5.19835,cx2:4.57914,cy2:5.38851,x:4.99361,y:5.57387},{op:"L",x:8.62659,y:.12183},{op:"L",x:9.70919,y:.12183},{op:"L",x:5.85194,y:5.97376},{op:"C",cx1:6.5005,cy1:6.29076,cx2:7.09535,cy2:6.65649,x:7.62705,y:7.06117},{op:"C",cx1:8.15855,cy1:7.47085,cx2:8.60221,cy2:7.95363,x:8.95835,y:8.50473},{op:"C",cx1:9.3143,cy1:9.05562,cx2:9.48985,cy2:9.65546,x:9.48985,y:10.30403},{op:"C",cx1:9.48985,cy1:10.86491,cx2:9.35822,cy2:11.39164,x:9.08996,y:11.88421},{op:"C",cx1:8.82652,cy1:12.37658,cx2:8.44618,cy2:12.77167,x:7.9488,y:13.0643},{op:"C",cx1:7.45147,cy1:13.35691,cx2:6.871,cy2:13.50314,x:6.21285,y:13.50314},{op:"C",cx1:5.62259,cy1:13.44461,cx2:5.1448,cy2:13.23009,x:4.78386,y:12.85457},{op:"C",cx1:4.42791,cy1:12.47906,cx2:4.23776,cy2:12.06938,x:4.21338,y:11.62572},{op:"C",cx1:4.23275,cy1:11.35746,cx2:4.33043,cy2:11.12338,x:4.5108,y:10.92821},{op:"C",cx1:4.69118,cy1:10.73326,cx2:4.94485,cy2:10.626,x:5.27163,y:10.60644},{op:"C",cx1:5.63239,cy1:10.60644,cx2:5.88605,cy2:10.68931,x:6.03726,y:10.85033},{op:"C",cx1:6.18828,cy1:11.01611,cx2:6.31031,cy2:11.26001,x:6.3932,y:11.58656},{op:"C",cx1:6.48092,cy1:11.91335,cx2:6.56377,cy2:12.14745,x:6.64186,y:12.2791},{op:"C",cx1:6.72476,cy1:12.41573,cx2:6.88578,cy2:12.48404,x:7.12944,y:12.48404},{op:"C",cx1:7.50019,cy1:12.48404,cx2:7.78783,cy2:12.35718,x:7.99756,y:12.10353},{op:"C",cx1:8.20729,cy1:11.85485,cx2:8.30974,cy2:11.52805,x:8.30974,y:11.12338},{op:"C",cx1:8.30974,cy1:10.57728,cx2:8.11459,cy2:10.11887,x:7.72451,y:9.74812},{op:"C",cx1:7.33918,cy1:9.38239,cx2:6.75395,cy2:9.00689,x:5.97375,y:8.62657},{op:"C",cx1:5.19353,cy1:8.25105,cx2:4.73513,cy2:8.01693,x:4.59371,y:7.92926},{op:"L",x:1.05823,y:13.42024},{op:"L",x:0,y:13.42024},{op:"L",x:3.755,y:7.52937},{op:"L",x:3.75502,y:7.52938},{op:"Z"},{op:"M",x:.07812,y:8.54848},{op:"C",cx1:.07812,cy1:8.20711,cx2:.18039,cy2:7.95364,x:.38033,y:7.78285},{op:"C",cx1:.58028,cy1:7.61227,cx2:.81937,cy2:7.5294,x:1.09721,y:7.5294},{op:"C",cx1:1.36068,cy1:7.55377,cx2:1.58499,cy2:7.65124,x:1.76535,y:7.822},{op:"C",cx1:1.94572,cy1:7.99259,cx2:2.03841,cy2:8.25105,x:2.03841,y:8.58763},{op:"C",cx1:2.03841,cy1:8.79736,cx2:1.93594,cy2:8.99731,x:1.736,y:9.19226},{op:"C",cx1:1.53606,cy1:9.39222,cx2:1.32153,cy2:9.48971,x:1.09721,y:9.48971},{op:"C",cx1:.81936,cy1:9.48971,cx2:.57548,cy2:9.41181,x:.37553,y:9.25081},{op:"C",cx1:.17558,cy1:9.08978,cx2:.07811,cy2:8.85588,x:.07811,y:8.54849},{op:"L",x:.07812,y:8.54848},{op:"Z"},{op:"M",x:8.3098,y:5.11547},{op:"C",cx1:8.3098,cy1:4.7789,cx2:8.4023,cy2:4.51564,x:8.58285,y:4.33027},{op:"C",cx1:8.76803,cy1:4.14508,cx2:9.00212,cy2:4.05242,x:9.28995,y:4.05242},{op:"C",cx1:9.57758,cy1:4.05242,cx2:9.82145,cy2:4.14011,x:10.01644,y:4.31568},{op:"C",cx1:10.21158,cy1:4.48627,cx2:10.30902,cy2:4.73994,x:10.30902,y:5.07152},{op:"C",cx1:10.30902,cy1:5.30083,cx2:10.20677,cy2:5.51036,x:10.00184,y:5.69572},{op:"C",cx1:9.7971,cy1:5.88108,cx2:9.57279,cy2:5.97376,x:9.32892,y:5.97376},{op:"C",cx1:9.07043,cy1:5.97376,cx2:8.83156,cy2:5.88587,x:8.62182,y:5.71529},{op:"C",cx1:8.41209,cy1:5.53971,cx2:8.3098,cy2:5.33977,x:8.3098,y:5.11546},{op:"L",x:8.3098,y:5.11547},{op:"Z"}],style:{fill:"#000"}}]};var Na={name:"ds",description:"\u4ECE\u8BB0\u53F7\u5904\u53CD\u590D\uFF1A\u8DF3\u56DE\u6700\u8FD1\u7684 $segno",weight:.9,shapes:[{path:[{op:"M",x:3.30971,y:8.58253},{op:"L",x:0,y:8.58253},{op:"L",x:0,y:8.38492},{op:"C",cx1:.66434,cy1:8.38492,cx2:.93964,cy2:7.9959,x:1.10119,y:7.23595},{op:"L",x:2.77112,y:1.20293},{op:"C",cx1:2.77112,cy1:1.10732,cx2:2.81892,cy2:.90973,x:2.81892,y:.83791},{op:"C",cx1:2.81892,cy1:.44886,cx2:2.55564,cy2:.29345,x:1.81333,y:.19758},{op:"L",x:1.81333,y:0},{op:"L",x:5.02743,y:0},{op:"C",cx1:7.87013,cy1:0,cx2:9.28879,cy2:1.16713,x:9.28879,y:3.50729},{op:"C",cx1:9.28879,cy1:4.56066,cx2:9.00736,cy2:5.47632,x:8.45088,y:6.24853},{op:"C",cx1:7.89416,cy1:7.02049,cx2:7.15799,cy2:7.60099,x:6.23624,y:7.9959},{op:"C",cx1:5.32063,cy1:8.38492,cx2:4.34519,cy2:8.58253,x:3.3097,y:8.58253},{op:"L",x:3.30971,y:8.58253},{op:"Z"},{op:"M",x:4.21944,y:.64057},{op:"L",x:2.35218,y:7.52917},{op:"C",cx1:2.35218,cy1:7.59509,cx2:2.33403,cy2:7.66079,x:2.30413,y:7.72673},{op:"C",cx1:2.35806,cy1:8.03196,cx2:2.65738,cy2:8.18763,x:3.21387,y:8.18763},{op:"C",cx1:4.71023,cy1:8.18763,cx2:5.84745,cy2:7.75053,x:6.6253,y:6.88271},{op:"C",cx1:7.40952,cy1:6.00899,cx2:7.79857,cy2:4.81807,x:7.79857,y:3.30973},{op:"C",cx1:7.79857,cy1:1.36475,cx2:6.88883,cy2:.39519,x:5.07525,y:.39519},{op:"C",cx1:4.66831,cy1:.39517,cx2:4.38101,cy2:.47876,x:4.21945,y:.64056},{op:"L",x:4.21944,y:.64056},{op:"Z"},{op:"M",x:17.3325,y:1e-5},{op:"L",x:16.81794,y:2.54976},{op:"L",x:16.57254,y:2.54976},{op:"C",cx1:16.57254,cy1:1.14312,cx2:16.03984,cy2:.44299,x:14.98033,y:.44299},{op:"C",cx1:14.57337,cy1:.44299,cx2:14.24416,cy2:.56262,x:13.98698,y:.80212},{op:"C",cx1:13.72958,cy1:1.04139,cx2:13.60383,cy2:1.35272,x:13.60383,y:1.74176},{op:"C",cx1:13.60383,cy1:2.10677,cx2:13.70556,cy2:2.424,x:13.91516,y:2.70518},{op:"C",cx1:14.12452,cy1:2.98048,cx2:14.45375,cy2:3.34575,x:14.91464,y:3.7946},{op:"C",cx1:15.37551,cy1:4.24346,cx2:15.72261,cy2:4.65626,x:15.9619,y:5.03332},{op:"C",cx1:16.20729,cy1:5.40444,cx2:16.32715,cy2:5.83541,x:16.32715,y:6.32621},{op:"C",cx1:16.35708,cy1:7.82844,cx2:15.01635,cy2:8.89386,x:13.70558,y:8.87572},{op:"C",cx1:13.47219,cy1:8.87572,cx2:13.12508,cy2:8.79188,x:12.65219,y:8.63033},{op:"C",cx1:12.17955,cy1:8.46874,cx2:11.86231,cy2:8.38489,x:11.69463,y:8.38489},{op:"C",cx1:11.45538,cy1:8.38489,cx2:11.25778,cy2:8.60652,x:11.20385,y:8.82787},{op:"L",x:10.95848,y:8.82787},{op:"L",x:11.40145,y:6.00895},{op:"L",x:11.69464,y:6.00895},{op:"C",cx1:11.69464,cy1:6.12272,cx2:11.67678,cy2:6.24847,x:11.64684,y:6.374},{op:"C",cx1:11.67065,cy1:6.93075,cx2:11.85619,cy2:7.40948,x:12.20332,y:7.82232},{op:"C",cx1:12.55657,cy1:8.22948,cx2:13.00544,cy2:8.43297,x:13.55603,y:8.43297},{op:"C",cx1:14.02891,cy1:8.43297,cx2:14.42384,cy2:8.26529,x:14.74108,y:7.92405},{op:"C",cx1:15.06418,cy1:7.58305,cx2:15.22573,cy2:7.18198,x:15.22573,y:6.72112},{op:"C",cx1:15.22573,cy1:6.34406,cx2:15.11223,cy2:6.00313,x:14.89062,y:5.69764},{op:"C",cx1:14.66925,cy1:5.39246,cx2:14.32802,cy2:5.00951,x:13.85538,y:4.54279},{op:"C",cx1:13.38247,cy1:4.07579,cx2:13.03535,cy2:3.67473,x:12.80197,y:3.33374},{op:"C",cx1:12.56858,cy1:2.99248,cx2:12.45484,cy2:2.59756,x:12.45484,y:2.16072},{op:"C",cx1:12.45484,cy1:1.53216,cx2:12.67621,cy2:1.01761,x:13.12509,y:.61042},{op:"C",cx1:13.57395,cy1:.20348,cx2:14.11864,cy2:2e-5,x:14.75896,y:2e-5},{op:"C",cx1:15.18993,cy1:2e-5,cx2:15.55495,cy2:.05983,x:15.86016,y:.17358},{op:"C",cx1:16.16536,cy1:.28733,cx2:16.38697,cy2:.34714,x:16.52452,y:.34714},{op:"C",cx1:16.6922,cy1:.34714,cx2:16.86576,cy2:.23339,x:17.03932,y:2e-5},{op:"L",x:17.33249,y:2e-5},{op:"L",x:17.3325,y:1e-5},{op:"Z"},{op:"M",x:8.43275,y:7.87042},{op:"C",cx1:8.43275,cy1:7.69072,cx2:8.4987,cy2:7.5353,x:8.63622,y:7.3975},{op:"C",cx1:8.774,cy1:7.25976,cx2:8.94755,cy2:7.18816,x:9.14514,y:7.18816},{op:"C",cx1:9.3187,cy1:7.18816,cx2:9.46824,cy2:7.25975,x:9.59988,y:7.3975},{op:"C",cx1:9.73766,cy1:7.53529,cx2:9.80338,cy2:7.69685,x:9.80338,y:7.87042},{op:"C",cx1:9.80338,cy1:8.28325,cx2:9.5043,cy2:8.58254,x:9.14514,y:8.58254},{op:"C",cx1:8.7382,cy1:8.58254,cx2:8.43275,cy2:8.29521,x:8.43275,y:7.87042},{op:"Z"},{op:"M",x:16.88952,y:7.9721},{op:"C",cx1:16.88952,cy1:7.57106,cx2:17.21875,cy2:7.28373,x:17.62569,y:7.28373},{op:"C",cx1:18.00297,cy1:7.28373,cx2:18.29003,cy2:7.56516,x:18.29003,y:7.9721},{op:"C",cx1:18.29003,cy1:8.34914,cx2:17.99096,cy2:8.63036,x:17.62569,y:8.63036},{op:"C",cx1:17.42219,cy1:8.63036,cx2:17.24863,cy2:8.56461,x:17.105,y:8.43887},{op:"C",cx1:16.96135,cy1:8.31309,cx2:16.88952,cy2:8.1577,x:16.88952,y:7.9721},{op:"Z"}],style:{fill:"#000"}}],playbackMarks:()=>[we],onVisit:(r,t)=>r.visits(t)>1?void 0:{kind:"jump",column:r.seek(jr,t,-1)??0}};var mu={m:[{op:"M",x:1.13,y:10.3672},{op:"L",x:2.9911,y:5.3125},{op:"C",cx1:3.0585,cy1:5.0607,cx2:3.0955,cy2:4.8889,x:3.0955,y:4.8089},{op:"C",cx1:3.0955,cy1:4.6248,cx2:2.9972,cy2:4.5327,x:2.7944,y:4.5327},{op:"C",cx1:2.5489,cy1:4.5327,cx2:2.217,cy2:4.7782,x:1.7994,y:5.2758},{op:"C",cx1:1.3881,cy1:5.7671,cx2:.9766,cy2:6.4856,x:.5774,y:7.4254},{op:"L",x:0,y:7.4254},{op:"C",cx1:.4976,cy1:6.3628,cx2:1.0133,cy2:5.4783,x:1.5476,y:4.7782},{op:"C",cx1:2.0882,cy1:4.0781,cx2:2.7576,cy2:3.7279,x:3.5498,y:3.7279},{op:"C",cx1:4.1518,cy1:3.7279,cx2:4.4773,cy2:4.0534,x:4.5264,y:4.7045},{op:"C",cx1:5.2818,cy1:4.0167,cx2:5.9512,cy2:3.6728,x:6.5409,y:3.6728},{op:"C",cx1:7.1796,cy1:3.6728,cx2:7.5235,cy2:4.0167,x:7.5728,y:4.7045},{op:"C",cx1:7.8797,cy1:4.3976,cx2:8.2483,cy2:4.1518,x:8.6843,y:3.9614},{op:"C",cx1:9.1205,cy1:3.7709,cx2:9.5197,cy2:3.6728,x:9.8882,y:3.6728},{op:"C",cx1:10.5393,cy1:3.6728,cx2:10.8645,cy2:3.943,x:10.8645,y:4.4834},{op:"C",cx1:10.8645,cy1:4.6001,cx2:10.8339,cy2:4.7905,x:10.7664,y:5.0607},{op:"L",x:9.3846,y:9.0345},{op:"C",cx1:9.3109,cy1:9.3353,cx2:9.2616,cy2:9.4951,x:9.2309,y:9.6364},{op:"C",cx1:9.2309,cy1:9.7959,cx2:9.3169,cy2:9.9066,x:9.4827,y:9.9619},{op:"C",cx1:10.011,cy1:9.8943,cx2:10.6988,cy2:9.1512,x:11.5463,y:7.7263},{op:"L",x:12.0499,y:7.7263},{op:"C",cx1:11.7981,cy1:8.1502,cx2:11.5279,cy2:8.6045,x:11.227,y:9.0958},{op:"C",cx1:10.9322,cy1:9.5811,cx2:10.6006,cy2:9.9864,x:10.2381,y:10.2996},{op:"C",cx1:9.8759,cy1:10.613,cx2:9.4583,cy2:10.7725,x:8.9791,y:10.7725},{op:"C",cx1:8.1499,cy1:10.7725,cx2:7.6279,cy2:10.3919,x:7.4191,y:9.6365},{op:"C",cx1:7.4437,cy1:9.397,cx2:7.5235,cy2:9.0775,x:7.6649,y:8.6783},{op:"C",cx1:7.806,cy1:8.279,cx2:7.8797,cy2:8.0395,x:7.8981,y:7.9535},{op:"L",x:8.9054,y:5.3619},{op:"C",cx1:8.924,cy1:5.2572,cx2:8.9791,cy2:5.0117,x:8.9791,y:4.9073},{op:"C",cx1:8.9791,cy1:4.6922,cx2:8.887,cy2:4.5818,x:8.7028,y:4.5818},{op:"C",cx1:8.1992,cy1:4.5818,cx2:7.8246,cy2:4.9257,x:7.5728,y:5.6137},{op:"L",x:5.8838,y:10.3673},{op:"L",x:4.0781,y:10.3673},{op:"L",x:5.9389,y:5.2635},{op:"C",cx1:5.9696,cy1:5.1591,cx2:5.9882,cy2:5.0424,x:5.9882,y:4.9073},{op:"C",cx1:5.9882,cy1:4.6922,cx2:5.8592,cy2:4.5818,x:5.6073,y:4.5818},{op:"C",cx1:5.159,cy1:4.6002,cx2:4.8335,cy2:4.944,x:4.6308,y:5.6137},{op:"L",x:2.8927,y:10.3673},{op:"L",x:1.13,y:10.3673},{op:"L",x:1.13,y:10.3672},{op:"Z"}],f:[{op:"M",x:6.1601,y:4.0781},{op:"C",cx1:6.4302,cy1:3.3717,cx2:6.8234,cy2:2.7086,x:7.3391,y:2.0882},{op:"C",cx1:7.8551,cy1:1.4679,cx2:8.4754,cy2:.9642,x:9.2062,y:.5773},{op:"C",cx1:9.937,cy1:.1904,cx2:10.7355,cy2:0,x:11.5953,y:0},{op:"C",cx1:12.0559,cy1:.043,cx2:12.4061,cy2:.2088,x:12.6333,y:.4913},{op:"C",cx1:12.8607,cy1:.7678,cx2:12.9772,cy2:1.1117,x:12.9772,y:1.5109},{op:"C",cx1:12.9772,cy1:1.9345,cx2:12.8421,cy2:2.3154,x:12.5659,y:2.6472},{op:"C",cx1:12.2954,cy1:2.9788,cx2:11.9578,cy2:3.1446,x:11.5463,y:3.1446},{op:"C",cx1:11.0487,cy1:3.1446,cx2:10.7662,cy2:2.9174,x:10.7111,y:2.4691},{op:"C",cx1:10.7418,cy1:2.1743,cx2:10.8522,cy2:1.8918,x:11.0427,y:1.6276},{op:"C",cx1:11.2331,cy1:1.3635,cx2:11.4666,cy2:1.1793,x:11.7428,y:1.087},{op:"C",cx1:11.8472,cy1:1.087,cx2:11.8965,cy2:1.0379,x:11.8965,y:.9335},{op:"C",cx1:11.8965,cy1:.8108,cx2:11.614,cy2:.6327,x:11.2147,y:.6327},{op:"C",cx1:10.0908,cy1:.6327,cx2:9.237,cy2:1.7811,x:8.6535,y:4.0781},{op:"L",x:10.8646,y:4.0781},{op:"L",x:10.8646,y:4.9073},{op:"L",x:8.4508,y:4.9073},{op:"C",cx1:8.2483,cy1:5.7918,cx2:7.9902,cy2:6.6944,x:7.671,y:7.6156},{op:"C",cx1:7.3577,cy1:8.5308,cx2:7.026,cy2:9.3723,x:6.676,y:10.1401},{op:"C",cx1:6.3319,cy1:10.9076,cx2:6.0064,cy2:11.5156,x:5.7055,y:11.9762},{op:"C",cx1:5.2632,cy1:12.658,cx2:4.7966,cy2:13.2353,x:4.299,y:13.7145},{op:"C",cx1:3.8016,cy1:14.1995,cx2:3.206,cy2:14.5067,x:2.5119,y:14.6418},{op:"C",cx1:2.211,cy1:14.6788,cx2:2.0266,cy2:14.6972,x:1.9592,y:14.6972},{op:"C",cx1:1.3632,cy1:14.6972,cx2:.8905,cy2:14.5128,x:.5527,y:14.1382},{op:"C",cx1:.2149,cy1:13.7636,cx2:.0307,cy2:13.3276,x:0,y:12.83},{op:"C",cx1:.0428,cy1:12.3941,cx2:.1718,cy2:12.0623,x:.3869,y:11.8351},{op:"C",cx1:.6017,cy1:11.6079,cx2:.9149,cy2:11.4298,x:1.3326,y:11.3008},{op:"C",cx1:1.6458,cy1:11.3254,cx2:1.9039,cy2:11.4359,x:2.1066,y:11.6324},{op:"C",cx1:2.3091,cy1:11.8352,cx2:2.4135,cy2:12.0809,x:2.4135,y:12.3818},{op:"C",cx1:2.4135,cy1:12.9405,cx2:1.8548,cy2:13.4134,x:1.4309,y:13.8127},{op:"C",cx1:1.4309,cy1:13.9171,cx2:1.5476,cy2:13.9664,x:1.7811,y:13.9664},{op:"C",cx1:2.7453,cy1:13.9664,cx2:3.5129,cy2:12.9405,x:4.0718,y:10.8955},{op:"C",cx1:4.2683,cy1:10.3426,cx2:4.4404,cy2:9.8083,x:4.5938,y:9.2926},{op:"C",cx1:4.7475,cy1:8.7703,cx2:4.9624,cy2:8.0028,x:5.2449,y:6.9832},{op:"C",cx1:5.5337,cy1:5.9575,cx2:5.7362,cy2:5.2695,x:5.8592,y:4.9073},{op:"L",x:4.1702,y:4.9073},{op:"L",x:4.1702,y:4.0781},{op:"L",x:6.1601,y:4.0781},{op:"Z"}],p:[{op:"M",x:3.767,y:8.5573},{op:"L",x:5.0097,y:5.0738},{op:"C",cx1:5.0804,cy1:4.7969,cx2:5.1126,cy2:4.5909,x:5.1126,y:4.443},{op:"C",cx1:5.1126,cy1:4.2497,cx2:5.0224,cy2:4.1531,x:4.8486,y:4.1531},{op:"C",cx1:4.7262,cy1:4.1531,cx2:4.5653,cy2:4.2497,x:4.3786,y:4.443},{op:"C",cx1:3.9471,cy1:4.9001,cx2:3.6059,cy2:5.383,x:3.3484,y:5.8917},{op:"L",x:2.6851,y:5.8917},{op:"C",cx1:2.8138,cy1:5.5117,cx2:3.0264,cy2:5.1126,x:3.3163,y:4.7004},{op:"C",cx1:3.6059,cy1:4.2818,cx2:3.9471,cy2:3.9406,x:4.3335,y:3.6702},{op:"C",cx1:4.7262,cy1:3.3933,cx2:5.1192,cy2:3.258,x:5.5119,y:3.258},{op:"C",cx1:6.1623,cy1:3.258,cx2:6.613,cy2:3.5671,x:6.8575,y:4.179},{op:"C",cx1:7.1987,cy1:3.8891,cx2:7.6044,cy2:3.6444,x:8.0617,y:3.4447},{op:"C",cx1:8.5188,cy1:3.2454,cx2:8.9632,cy2:3.1486,x:9.388,y:3.1486},{op:"C",cx1:10.1286,cy1:3.1486,cx2:10.7017,cy2:3.4447,x:11.1008,y:4.0437},{op:"C",cx1:11.5064,cy1:4.636,cx2:11.706,cy2:5.3249,x:11.706,y:6.104},{op:"C",cx1:11.706,cy1:6.8187,cx2:11.5322,cy2:7.5464,x:11.178,y:8.274},{op:"C",cx1:10.8304,cy1:9.0017,cx2:10.3538,cy2:9.6004,x:9.7422,y:10.0704},{op:"C",cx1:9.1306,cy1:10.5406,cx2:8.4607,cy2:10.7724,x:7.7267,y:10.7724},{op:"C",cx1:7.0442,cy1:10.7724,cx2:6.4133,cy2:10.5148,x:5.8273,y:10.006},{op:"L",x:4.7972,y:12.9614},{op:"C",cx1:4.765,cy1:13.0453,cx2:4.7133,cy2:13.1998,x:4.6426,y:13.4122},{op:"C",cx1:4.6684,cy1:13.6377,cx2:4.7842,cy2:13.7922,x:4.9902,y:13.8695},{op:"C",cx1:5.2028,cy1:13.9531,cx2:5.5504,cy2:13.9919,x:6.0399,y:13.9919},{op:"L",x:6.0399,y:14.8095},{op:"L",x:0,y:14.8095},{op:"L",x:0,y:13.9919},{op:"C",cx1:.7469,cy1:13.9919,cx2:1.2815,cy2:13.8759,x:1.5969,y:13.6506},{op:"C",cx1:1.9124,cy1:13.4251,cx2:2.1379,cy2:13.1289,x:2.2666,y:12.7491},{op:"L",x:3.767,y:8.5573},{op:"Z"},{op:"M",x:7.0637,y:6.3166},{op:"C",cx1:6.7802,cy1:6.9604,cx2:6.6064,cy2:7.8104,x:6.5357,y:8.8727},{op:"C",cx1:6.6064,cy1:9.5619,cx2:6.7609,cy2:9.9031,x:7.012,y:9.9031},{op:"C",cx1:7.8879,cy1:9.7356,cx2:8.609,cy2:8.7248,x:9.1755,y:6.8704},{op:"C",cx1:9.3495,cy1:6.2071,cx2:9.4395,cy2:5.6084,x:9.4395,y:5.0738},{op:"C",cx1:9.4395,cy1:4.4108,cx2:9.2657,cy2:4.05,x:8.9115,y:3.9923},{op:"C",cx1:8.332,cy1:3.9923,cx2:7.7139,cy2:4.7647,x:7.0637,y:6.3166},{op:"Z"}]},du={mf:8.0028,mp:9.523,ff:6.67866,pp:8.8083},fu={fill:"#000"},yu=.79341,Wr=[49,33,16,10,5,1],Xr=[96,112,126,127];function We(r,t,e){let n=0,o=Array.from(r,(s,i)=>{let a={path:mu[s],style:fu,dx:n};return n+=du[s+r[i+1]]??0,a});return{name:r,description:e,shapes:o,weight:r.includes("f")?1:yu,onTimeState:s=>{s.velocity=t}}}var va=[{...We("p",Wr[0],"\u5F31\uFF1B\u652F\u6301 `$p`\u3001`$pp`\u3001`$ppp` \u7B49\u8FDE\u7EED p\uFF0C\u6574\u4F53\u5C45\u4E2D"),pattern:{regex:/^p+$/,resolve:([r])=>We(r,Wr[Math.min(r.length,Wr.length)-1],"\u5F31\u529B\u5EA6\u8BB0\u53F7")}},We("mp",64,"\u4E2D\u5F31"),We("mf",80,"\u4E2D\u5F3A"),{...We("f",Xr[0],"\u5F3A\uFF1B\u652F\u6301 `$f`\u3001`$ff`\u3001`$fff` \u7B49\u8FDE\u7EED f\uFF0C\u6574\u4F53\u5C45\u4E2D"),pattern:{regex:/^f+$/,resolve:([r])=>We(r,Xr[Math.min(r.length,Xr.length)-1],"\u5F3A\u529B\u5EA6\u8BB0\u53F7")}}];var hu={},ka={name:"fermata",description:"\u5EF6\u957F\u8BB0\u53F7\uFF1A\u8986\u76D6\u533A\u95F4\u901F\u5EA6\u51CF\u534A\uFF0C\u76EE\u6807\u97F3\u5B9E\u9645\u65F6\u957F\u7FFB\u500D",weight:.6,paddingBottom:3,shapes:[{path:[{op:"M",x:0,y:7.46666},{op:"C",cx1:3.65834,cy1:0,cx2:8.53611,cy2:0,x:12.19445,y:7.46666},{op:"M",x:12.19445,y:7.46666},{op:"C",cx1:8.53611,cy1:.74666,cx2:3.65833,cy2:.74666,x:0,y:7.46666}],style:{fill:"#000",stroke:"#000",strokeWidth:1}},{circle:{cx:6.09723,cy:6.26666,r:1.2},style:{fill:"#000"}}],emitPlayback:r=>r.scaleFollowingBpm(hu,1,2,{followConnections:!0})};var Ea={name:"fine",description:"\u7EC8\u6B62\u8BB0\u53F7\uFF1A\u56DE\u8DF3\u4E4B\u540E\u7ECF\u8FC7\u8FD9\u91CC\u5C31\u7ED3\u675F\u4E50\u66F2",weight:1.4,text:{content:"Fine.",fontFamily:'"Times New Roman", serif',fontStyle:"italic"},onVisit:(r,t)=>{let e=r.seek(we,t,1);return e!==void 0&&r.visits(e)>0?{kind:"stop"}:void 0}};var Pa={name:"harmonic",description:"\u6CDB\u97F3",weight:.5,shapes:[{circle:{cx:5,cy:5,r:4.5},style:{fill:"none",stroke:"#000",strokeWidth:1}}]};var Ma={name:"marcato",description:"\u5F3A\u8C03\u97F3\uFF1A\u5C16\u9876\u8BB0\u53F7\uFF1B\u64AD\u653E\u540C\u91CD\u97F3\uFF0C\u6240\u9644\u7740\u97F3\u7B26\u529B\u5EA6\u589E\u52A0 20\uFF0C\u6700\u9AD8 127",weight:.65,shapes:[{path:[{op:"M",x:0,y:10},{op:"L",x:4.5,y:0},{op:"L",x:5.5,y:0},{op:"L",x:10,y:10},{op:"L",x:8,y:10},{op:"L",x:5,y:3},{op:"L",x:2,y:10},{op:"Z"}],style:{fill:"#000"}}],emitPlayback:io.emitPlayback};var Ra={name:"mordent",description:"\u4E0B\u6CE2\u97F3\uFF1A\u672C\u97F3\u3001\u8C03\u5185\u4E0B\u65B9\u4E8C\u5EA6\u3001\u672C\u97F3",weight:.73423,shapes:[{path:[{op:"M",x:7.29541,y:.05944},{op:"C",cx1:7.56541,cy1:-.09056,cx2:7.92541,cy2:.05944,x:8.04541,y:.32944},{op:"C",cx1:8.10541,cy1:.44944,cx2:8.10541,cy2:.56944,x:8.10541,y:1.76943},{op:"L",x:8.10541,y:3.05943},{op:"L",x:8.67541,y:2.21943},{op:"C",cx1:9.18541,cy1:1.46943,cx2:9.24541,cy2:1.37943,x:9.36541,y:1.31943},{op:"C",cx1:9.42541,cy1:1.28943,cx2:9.54541,cy2:1.25943,x:9.60541,y:1.25943},{op:"C",cx1:9.90541,cy1:1.25943,cx2:9.87541,cy2:1.22943,x:11.49541,y:3.20943},{op:"L",x:13.02541,y:5.03943},{op:"L",x:13.50541,y:4.34943},{op:"C",cx1:14.01541,cy1:3.56943,cx2:14.04541,cy2:3.50943,x:14.19541,y:3.44943},{op:"C",cx1:14.61541,cy1:3.26943,cx2:15.06541,cy2:3.59943,x:15.00541,y:4.04943},{op:"C",cx1:14.97541,cy1:4.16943,cx2:14.70541,cy2:4.55943,x:13.50541,y:6.41943},{op:"C",cx1:12.12541,cy1:8.48943,cx2:12.00541,cy2:8.63943,x:11.88541,y:8.69943},{op:"C",cx1:11.82541,cy1:8.72943,cx2:11.70541,cy2:8.75943,x:11.64541,y:8.75943},{op:"C",cx1:11.34541,cy1:8.75943,cx2:11.37541,cy2:8.78943,x:9.81541,y:6.86943},{op:"C",cx1:9.00541,cy1:5.87943,cx2:8.31541,cy2:5.06943,x:8.28541,y:5.00943},{op:"C",cx1:8.22541,cy1:4.97943,cx2:8.22541,cy2:4.97943,x:8.16541,y:5.03943},{op:"C",cx1:8.10541,cy1:5.09943,cx2:8.10541,cy2:5.18943,x:8.10541,y:7.31943},{op:"C",cx1:8.10541,cy1:9.26943,cx2:8.10541,cy2:9.56943,x:8.04541,y:9.65943},{op:"C",cx1:7.86541,cy1:10.10943,cx2:7.23541,cy2:10.13943,x:6.99541,y:9.68943},{op:"C",cx1:6.96541,cy1:9.62943,cx2:6.93541,cy2:9.44943,x:6.93541,y:8.27943},{op:"L",x:6.93541,y:6.92943},{op:"L",x:6.36541,y:7.76943},{op:"C",cx1:5.82541,cy1:8.54943,cx2:5.76541,cy2:8.63943,x:5.64541,y:8.69943},{op:"C",cx1:5.58541,cy1:8.72943,cx2:5.46541,cy2:8.75943,x:5.40541,y:8.75943},{op:"C",cx1:5.10541,cy1:8.75943,cx2:5.13541,cy2:8.78943,x:3.51541,y:6.80943},{op:"L",x:1.98541,y:4.97943},{op:"L",x:1.50541,y:5.66943},{op:"C",cx1:.99541,cy1:6.44943,cx2:.96541,cy2:6.50943,x:.81541,y:6.56943},{op:"C",cx1:.39541,cy1:6.74943,cx2:-.05459,cy2:6.41943,x:.00541,y:5.96943},{op:"C",cx1:.03541,cy1:5.84943,cx2:.30541,cy2:5.45943,x:1.50541,y:3.59943},{op:"C",cx1:2.88541,cy1:1.52943,cx2:3.00541,cy2:1.37943,x:3.12541,y:1.31943},{op:"C",cx1:3.18541,cy1:1.28943,cx2:3.30541,cy2:1.25943,x:3.36541,y:1.25943},{op:"C",cx1:3.66541,cy1:1.25943,cx2:3.63541,cy2:1.22943,x:5.25541,y:3.20943},{op:"L",x:6.78541,y:5.03943},{op:"C",cx1:6.81541,cy1:5.03943,cx2:6.84541,cy2:4.97943,x:6.87541,y:4.94943},{op:"C",cx1:6.93541,cy1:4.82943,cx2:6.93541,cy2:4.79943,x:6.93541,y:2.66943},{op:"C",cx1:6.93541,cy1:.74943,cx2:6.93541,cy2:.44943,x:6.99541,y:.35943},{op:"C",cx1:7.05541,cy1:.20943,cx2:7.14541,cy2:.11943,x:7.29541,y:.05943},{op:"Z"}],style:{fill:"#000"}}],emitPlayback:r=>r.affectFollowing(qt({body:[0,-1,0]}))};var _a={name:"prall",description:"\u4E0A\u6CE2\u97F3\uFF1A\u672C\u97F3\u3001\u8C03\u5185\u4E0A\u65B9\u4E8C\u5EA6\u3001\u672C\u97F3",weight:.55,shapes:[{path:[{op:"M",x:3.12541,y:.06003},{op:"C",cx1:3.18541,cy1:.03003,cx2:3.30541,cy2:3e-5,x:3.36541,y:3e-5},{op:"C",cx1:3.66541,cy1:3e-5,cx2:3.63541,cy2:-.02997,x:5.25541,y:1.95003},{op:"L",x:6.78541,y:3.78003},{op:"C",cx1:6.81541,cy1:3.78003,cx2:7.35541,cy2:2.94003,x:8.01541,y:1.95003},{op:"C",cx1:9.15541,cy1:.27003,cx2:9.24541,cy2:.12003,x:9.36541,y:.06003},{op:"C",cx1:9.42541,cy1:.03003,cx2:9.54541,cy2:3e-5,x:9.60541,y:3e-5},{op:"C",cx1:9.90541,cy1:3e-5,cx2:9.87541,cy2:-.02997,x:11.49541,y:1.95003},{op:"L",x:13.02541,y:3.78003},{op:"L",x:13.50541,y:3.09003},{op:"C",cx1:14.01541,cy1:2.31003,cx2:14.04541,cy2:2.25003,x:14.19541,y:2.19003},{op:"C",cx1:14.61541,cy1:2.01003,cx2:15.06541,cy2:2.34003,x:15.00541,y:2.79003},{op:"C",cx1:14.97541,cy1:2.91003,cx2:14.70541,cy2:3.30003,x:13.50541,y:5.16003},{op:"C",cx1:12.12541,cy1:7.23003,cx2:12.00541,cy2:7.38003,x:11.88541,y:7.44003},{op:"C",cx1:11.82541,cy1:7.47003,cx2:11.70541,cy2:7.50003,x:11.64541,y:7.50003},{op:"C",cx1:11.34541,cy1:7.50003,cx2:11.37541,cy2:7.53003,x:9.75541,y:5.55003},{op:"L",x:8.22541,y:3.72003},{op:"C",cx1:8.19541,cy1:3.72003,cx2:7.65541,cy2:4.56003,x:6.99541,y:5.55003},{op:"C",cx1:5.85541,cy1:7.23003,cx2:5.76541,cy2:7.38003,x:5.64541,y:7.44003},{op:"C",cx1:5.58541,cy1:7.47003,cx2:5.46541,cy2:7.50003,x:5.40541,y:7.50003},{op:"C",cx1:5.10541,cy1:7.50003,cx2:5.13541,cy2:7.53003,x:3.51541,y:5.55003},{op:"L",x:1.98541,y:3.72003},{op:"L",x:1.50541,y:4.41003},{op:"C",cx1:.99541,cy1:5.19003,cx2:.96541,cy2:5.25003,x:.81541,y:5.31003},{op:"C",cx1:.39541,cy1:5.49003,cx2:-.05459,cy2:5.16003,x:.00541,y:4.71004},{op:"C",cx1:.03541,cy1:4.59004,cx2:.30541,cy2:4.20004,x:1.50541,y:2.34004},{op:"C",cx1:2.88541,cy1:.27004,cx2:3.00541,cy2:.12004,x:3.12541,y:.06004},{op:"Z"}],style:{fill:"#000"}}],emitPlayback:r=>r.affectFollowing(qt({body:[0,1,0]}))};var Fa={name:"staccato",description:"\u65AD\u594F\uFF1A\u6240\u9644\u7740\u97F3\u7B26\u7684\u5B9E\u9645\u53D1\u58F0\u65F6\u957F\u7F29\u77ED\u4E3A\u4E00\u534A",weight:.8,shapes:[{path:[{op:"M",x:0,y:0},{op:"L",x:12,y:0},{op:"L",x:6,y:13},{op:"Z"}],style:{fill:"#000"}}],emitPlayback:r=>r.affectFollowing((t,e)=>{let n=e[0].start.clone();for(let o of e)o.start.sub(n).div(2).add(n),o.end.sub(n).div(2).add(n)})};var Oa={name:"tenuto",description:"\u4FDD\u6301\u97F3",weight:.18,shapes:[{line:{x1:0,y1:0,x2:7.2,y2:0},style:{stroke:"#000",strokeWidth:1.8}}]};var Ia={name:"tocoda",description:"\u8DF3\u81F3\u5C3E\u58F0\uFF1A\u56DE\u8DF3\u4E4B\u540E\u7ECF\u8FC7\u8FD9\u91CC\u5C31\u8DF3\u5411\u6700\u8FD1\u7684 $coda",weight:1.4,text:{content:"To Coda",fontFamily:'"Times New Roman", serif',fontStyle:"italic"},onVisit:(r,t)=>{let e=r.seek(we,t,1),n=r.seek($r,t,1);return e!==void 0&&r.visits(e)>0&&n!==void 0?{kind:"jump",column:n}:void 0}};var dn={name:"tr",description:"\u98A4\u97F3\uFF1A\u672C\u97F3\u4E0E\u8C03\u5185\u4E0A\u65B9\u4E8C\u5EA6\u4EA4\u66FF\u3002\u53EF\u5199\u4E3A `$tr++`\uFF0C\u6BCF\u4E2A\u7D27\u63A5\u7684 `+` \u6DFB\u52A0\u4E00\u622A\u6CE2\u6D6A\u5C3E\u5DF4",pattern:{regex:/^tr(\++)/,resolve:r=>{let t=[...dn.shapes];for(let e=0;e<r[1].length;e++)t.push({...xu,dx:14.11212+e*5.95219});return{...dn,name:r[0],anchor:gu,shapes:t}}},shapes:[{path:[{op:"M",x:3.17992,y:5.46383},{op:"L",x:3.61827,y:3.91711},{op:"C",cx1:3.10024,cy1:3.49862,cx2:2.52947,cy2:3.29304,x:1.90541,y:3.29304},{op:"C",cx1:1.50051,cy1:3.29304,cx2:1.18833,cy2:3.40589,x:.95611,y:3.63812},{op:"C",cx1:.72361,cy1:3.87061,cx2:.59743,cy2:4.14281,x:.57105,y:4.46152},{op:"C",cx1:.57105,cy1:4.91944,cx2:.71707,cy2:5.25147,x:1.00913,y:5.47036},{op:"C",cx1:1.30118,cy1:5.68954,cx2:1.61988,cy2:5.79586,x:1.95843,y:5.79586},{op:"C",cx1:1.9916,cy1:5.79586,cx2:2.03157,cy2:5.8157,x:2.06475,y:5.84888},{op:"C",cx1:2.24394,cy1:5.82904,cx2:2.61568,cy2:5.69632,x:3.17992,y:5.46383},{op:"Z"},{op:"M",x:6.579,y:9.87204},{op:"L",x:8.40472,y:3.75096},{op:"C",cx1:8.40472,cy1:3.59162,cx2:8.35167,cy2:3.51193,x:8.23884,y:3.51193},{op:"C",cx1:7.98647,cy1:3.51193,cx2:7.4554,cy2:3.77761,x:6.63883,y:4.3152},{op:"C",cx1:5.82223,cy1:4.84655,cx2:5.37735,cy2:5.15845,x:5.30448,y:5.25145},{op:"C",cx1:5.33764,cy1:5.21147,cx2:5.39068,cy2:5.15845,x:5.46383,y:5.0853},{op:"C",cx1:6.13441,cy1:6.06127,cx2:6.47294,cy2:6.98417,x:6.47294,y:7.86061},{op:"C",cx1:6.41313,cy1:8.53088,cx2:6.18062,cy2:9.12181,x:5.7692,y:9.61968},{op:"C",cx1:5.3643,cy1:10.11758,cx2:4.85308,cy2:10.3634,x:4.24233,y:10.3634},{op:"C",cx1:3.71778,cy1:10.3634,cx2:3.25306,cy2:10.23719,x:2.83483,y:9.99138},{op:"C",cx1:2.42314,cy1:9.74586,cx2:2.20396,cy2:9.39396,x:2.17759,y:8.92271},{op:"C",cx1:2.21077,cy1:8.80986,cx2:2.23061,cy2:8.66384,x:2.23061,y:8.48436},{op:"L",x:2.85469,y:6.0944},{op:"C",cx1:2.58903,cy1:6.2339,cx2:2.21729,cy2:6.30702,x:1.73924,y:6.30702},{op:"C",cx1:1.22829,cy1:6.2804,cx2:.81007,cy2:6.1012,x:.48458,y:5.76917},{op:"C",cx1:.15935,cy1:5.43065,cx2:0,cy2:4.97926,x:0,y:4.4082},{op:"C",cx1:.03318,cy1:3.89045,cx2:.20586,cy2:3.46543,x:.53107,y:3.13369},{op:"C",cx1:.8563,cy1:2.80166,cx2:1.32782,cy2:2.63579,x:1.95843,y:2.63579},{op:"C",cx1:2.55585,cy1:2.63579,cx2:3.17992,cy2:2.87481,x:3.83716,y:3.34606},{op:"L",x:4.89277,y:0},{op:"L",x:6.85119,y:0},{op:"L",x:5.41053,y:4.51453},{op:"C",cx1:6.28694,cy1:3.83064,cx2:7.02389,cy2:3.34606,x:7.62128,y:3.06054},{op:"C",cx1:8.21899,cy1:2.77502,cx2:8.86943,cy2:2.63579,x:9.57321,y:2.63579},{op:"C",cx1:10.05773,cy1:2.63579,cx2:10.30358,cy2:2.83484,x:10.30358,y:3.23974},{op:"C",cx1:10.30358,cy1:3.44559,cx2:10.17738,cy2:3.89046,x:10.09093,y:4.18931},{op:"C",cx1:10.7283,cy1:3.15354,cx2:11.45195,cy2:2.63579,x:12.26199,y:2.63579},{op:"C",cx1:12.6272,cy1:2.63579,cx2:12.91925,cy2:2.76849,x:13.14497,y:3.03417},{op:"C",cx1:13.37717,cy1:3.29957,cx2:13.49001,cy2:3.61175,x:13.49001,y:3.97014},{op:"C",cx1:13.49001,cy1:4.62739,cx2:13.09844,cy2:5.03228,x:12.53419,y:5.03228},{op:"C",cx1:12.16899,cy1:5.03228,cx2:11.85709,cy2:4.79327,x:11.80382,y:4.29536},{op:"C",cx1:11.89029,cy1:3.91031,cx2:11.98982,cy2:3.55191,x:11.98982,y:3.34606},{op:"C",cx1:11.98982,cy1:3.27291,cx2:11.94329,cy2:3.23973,x:11.85709,y:3.23973},{op:"C",cx1:11.74403,cy1:3.23973,cx2:11.53162,cy2:3.34606,x:11.20637,y:3.56522},{op:"C",cx1:10.90752,cy1:3.7708,cx2:10.61547,cy2:4.11615,x:10.31666,y:4.61405},{op:"C",cx1:10.01808,cy1:5.11195,cx2:9.77253,cy2:5.69632,x:9.57321,y:6.36662},{op:"L",x:8.45798,y:9.87203},{op:"L",x:6.57899,y:9.87203},{op:"L",x:6.579,y:9.87204},{op:"Z"},{op:"M",x:5.05893,y:5.62971},{op:"L",x:3.94348,y:8.92274},{op:"C",cx1:3.94348,cy1:9.0288,cx2:3.92364,cy2:9.12179,x:3.89045,y:9.19495},{op:"C",cx1:3.89045,cy1:9.48047,cx2:4.06285,cy2:9.65287,x:4.40821,y:9.70617},{op:"C",cx1:5.404,cy1:9.22134,cx2:5.9019,cy2:8.51787,x:5.9019,y:7.58841},{op:"C",cx1:5.9019,cy1:6.99751,cx2:5.62318,cy2:6.34681,x:5.05893,y:5.62972},{op:"L",x:5.05893,y:5.62971},{op:"Z"}],style:{fill:"#000"}}],emitPlayback:r=>r.affectFollowing(qt({body:[0,1],repeat:!0}))},Ba=he(dn.shapes),gu=Ba.x+Ba.w/2,xu={path:[{op:"M",x:7.03619,y:4.89762},{op:"C",cx1:7.03619,cy1:4.89762,cx2:6.87351,cy2:4.70878,x:6.65687,y:4.5183},{op:"C",cx1:6.57594,cy1:4.43737,cx2:6.46721,cy2:4.41039,x:6.38546,y:4.41039},{op:"C",cx1:6.30535,cy1:4.41039,cx2:6.25058,cy2:4.43737,x:6.19662,y:4.49132},{op:"L",x:5.89905,y:4.78889},{op:"C",cx1:5.8451,cy1:4.84367,cx2:5.79033,cy2:4.87064,x:5.73719,y:4.87064},{op:"C",cx1:5.62846,cy1:4.87064,cx2:5.57451,cy2:4.78889,x:5.57451,y:4.78889},{op:"C",cx1:5.57451,cy1:4.78889,cx2:3.84223,cy2:3.30105,x:3.57164,y:3.05662},{op:"C",cx1:3.27407,cy1:2.8408,cx2:2.9765,cy2:2.75905,x:2.70591,y:2.75905},{op:"C",cx1:2.13857,cy1:2.75905,cx2:1.62355,cy2:3.08523,x:1.40773,y:3.32721},{op:"L",x:.10873,y:4.62703},{op:"C",cx1:.02698,cy1:4.70878,cx2:0,cy2:4.76192,x:0,y:4.84367},{op:"C",cx1:0,cy1:4.97773,cx2:.10873,cy2:5.08646,x:.10873,y:5.08646},{op:"C",cx1:.10873,cy1:5.08646,cx2:.27141,cy2:5.2753,x:.48723,y:5.46578},{op:"C",cx1:.56898,cy1:5.54671,cx2:.64909,cy2:5.57451,x:.73084,y:5.57451},{op:"C",cx1:.81259,cy1:5.57451,cx2:.86655,cy2:5.54671,x:.91968,y:5.49276},{op:"L",x:1.21725,y:5.19519},{op:"C",cx1:1.27284,cy1:5.14123,cx2:1.32598,cy2:5.11344,x:1.37993,y:5.11344},{op:"C",cx1:1.48866,cy1:5.11344,cx2:1.57041,cy2:5.19519,x:1.57041,y:5.19519},{op:"C",cx1:1.57041,cy1:5.19519,cx2:3.30105,cy2:6.65605,x:3.57164,y:6.89885},{op:"C",cx1:3.86921,cy1:7.1163,cx2:4.16678,cy2:7.19805,x:4.43819,y:7.19805},{op:"C",cx1:5.00635,cy1:7.19805,cx2:5.51973,cy2:6.87187,x:5.73719,y:6.62989},{op:"L",x:7.03619,y:5.33008},{op:"C",cx1:7.1163,cy1:5.24833,cx2:7.1441,cy2:5.16821,x:7.1441,y:5.11344},{op:"C",cx1:7.1441,cy1:4.97773,cx2:7.03619,cy2:4.89762,x:7.03619,y:4.89762},{op:"Z"}],style:{fill:"#000"}};/*!
|
|
85
|
+
* Bravura 1.482 ornamentTurn (U+E567), Y axis flipped; https://github.com/steinbergmedia/bravura
|
|
86
|
+
* Copyright (c) 2026, Steinberg Media Technologies GmbH. Reserved Font Name "Bravura".
|
|
87
|
+
* SPDX-License-Identifier: OFL-1.1
|
|
88
|
+
* Full license: Bravura-LICENSE.txt in the package root and dist.
|
|
89
|
+
*/var bu=[{op:"M",x:371,y:-218},{op:"C",cx1:340,cy1:-218,cx2:315,cy2:-204,x:315,y:-174},{op:"C",cx1:315,cy1:-152,cx2:330,cy2:-138,x:351,y:-138},{op:"C",cx1:380,cy1:-138,cx2:381,cy2:-161,x:402,y:-161},{op:"C",cx1:419,cy1:-161,cx2:435,cy2:-140,x:435,y:-114},{op:"C",cx1:435,cy1:-71,cx2:405,cy2:-50,x:370,y:-50},{op:"C",cx1:338,cy1:-50,cx2:305,cy2:-77,x:262,y:-125},{op:"C",cx1:213,cy1:-179,cx2:169,cy2:-217,x:104,y:-217},{op:"C",cx1:38,cy1:-217,cx2:0,cy2:-167,x:0,y:-103},{op:"C",cx1:0,cy1:-31,cx2:46,cy2:0,x:89,y:0},{op:"C",cx1:120,cy1:0,cx2:145,cy2:-14,x:145,y:-44},{op:"C",cx1:145,cy1:-66,cx2:130,cy2:-80,x:109,y:-80},{op:"C",cx1:80,cy1:-80,cx2:79,cy2:-57,x:58,y:-57},{op:"C",cx1:41,cy1:-57,cx2:25,cy2:-78,x:25,y:-104},{op:"C",cx1:25,cy1:-147,cx2:55,cy2:-168,x:90,y:-168},{op:"C",cx1:122,cy1:-168,cx2:155,cy2:-141,x:198,y:-93},{op:"C",cx1:247,cy1:-39,cx2:291,cy2:-1,x:356,y:-1},{op:"C",cx1:422,cy1:-1,cx2:460,cy2:-51,x:460,y:-115},{op:"C",cx1:460,cy1:-187,cx2:414,cy2:-218,x:371,y:-218},{op:"Z"}],Da={path:bu,style:{fill:"#000"}},Va={name:"turn",description:"\u56DE\u97F3",weight:.55,shapes:[Da],emitPlayback:r=>r.affectFollowing(qt({body:[1,0,-1,0]}))},Ha={name:"iturn",description:"\u9006\u56DE\u97F3",weight:.55*396/218,shapes:[Da,{line:{x1:230,y1:-290,x2:230,y2:74},style:{stroke:"#000",strokeWidth:32}}],emitPlayback:r=>r.affectFollowing(qt({body:[-1,0,1,0]}))};var za={name:"wheel",description:"\u8F6E\u6307",shapes:[{path:[{op:"M",x:8.8,y:0},{op:"L",x:11.2,y:0},{op:"L",x:11.2,y:6},{op:"L",x:8.8,y:6},{op:"Z"},{op:"M",x:13.43341,y:7.62266},{op:"L",x:19.13974,y:5.76856},{op:"L",x:19.88139,y:8.0511},{op:"L",x:14.17505,y:9.9052},{op:"Z"},{op:"M",x:11.38032,y:13.94141},{op:"L",x:14.90703,y:18.79551},{op:"L",x:16.84867,y:17.38483},{op:"L",x:13.32196,y:12.53073},{op:"Z"},{op:"M",x:8.61968,y:13.94141},{op:"L",x:5.09297,y:18.79551},{op:"L",x:3.15133,y:17.38483},{op:"L",x:6.67804,y:12.53073},{op:"Z"},{op:"M",x:6.56659,y:7.62266},{op:"L",x:.86026,y:5.76856},{op:"L",x:.11861,y:8.0511},{op:"L",x:5.82495,y:9.9052},{op:"Z"}],style:{fill:"#000"}}]};var fn=new Map,ao=new Map,Xe=Object.freeze({core:Object.freeze([dn,ka,_a,Ra,io,za,Pa,Oa,Ma,Fa,Va,Ha,...va,Aa,Na,Ca,Ea,La,Ia]),table:fn,register:(...r)=>{let t=r.map(e=>{let n=e.name.toLowerCase(),o=e.pattern;if(o){let{regex:s}=o;if(s.global||s.sticky)throw new Error(`Symbol pattern must not use g or y flags: ${n}`);s.ignoreCase||(o={...o,regex:new RegExp(s.source,`${s.flags}i`)})}return{name:n,definition:e,pattern:o}});for(let{name:e,definition:n,pattern:o}of t)fn.set(e,n),o?ao.set(e,o):ao.delete(e)},clear:()=>{fn.clear(),ao.clear()},reset:()=>{Xe.clear(),Xe.register(...Xe.core)},ornament:qt,bounds:he});Xe.reset();var Ur=class extends B{static def={name:["symbol","$"],description:"\u521B\u5EFA\u4E00\u4E2A\u4E50\u8C31\u7B26\u53F7",get details(){return`~~~jpfun
|
|
81
90
|
1 ^ @symbol(p, size=0.5em)
|
|
82
91
|
~~~
|
|
83
92
|
**\u7B80\u5199**\uFF1A\`$name\`\uFF0C\u5982 \`1 ^ $p\`\u3002\u540D\u79F0\u8BFB\u53D6\u5230\u4E0B\u4E00\u4E2A\u7A7A\u767D\u6216\u5F53\u524D\u5185\u5BB9\u533A\u95F4\u672B\u5C3E\uFF0C\u8FDE\u7EED\u7684\u6807\u70B9\u4E5F\u5C5E\u4E8E\u540D\u79F0\u3002
|
|
84
93
|
|
|
85
|
-
**\
|
|
86
|
-
${[...
|
|
87
|
-
`)}`,allowExtraArgs:!1,args:[{name:"name",description:"\u5185\u7F6E\u8BB0\u53F7\u540D\u79F0\uFF0C\u89C1\u51FD\u6570\u8BF4\u660E\u4E2D\u7684\u8BB0\u53F7\u5217\u8868",type:"string",default:null},{name:"size",description:"\u8BB0\u53F7\u5C3A\u5BF8",type:"length",default:{value:.5,unit:"em"}}]};static deSugarAtom(t,e,n){if(t[e]!=="$")return null;let o=/^\S+/.exec(t.slice(e+1,n))?.[0];if(!o)return null;let i=e+1+o.length;return{next:i,node:{kind:"call",typed:!0,name:"symbol",args:new Map([[0,o]]),span:{start:e,end:i},syntaxKind:"atom"}}}size;definition;constructor(t,e,n,o=null){super(t,o);let[i,r]=this.getArgValue(e,n);this.size=n.length2px(r);let a=i.toLowerCase(),c=Un.get(a);if(!c){let l;for(let p of ta){let f=p.regex.exec(a);if(!(!f||f.index!==0||f[0]!==a)){if(l)throw new Error(`Ambiguous symbol patterns: ${a}`);l={pattern:p,match:f}}}c=l?.pattern.resolve(l.match)}if(!c){let l=`@symbol: \u672A\u77E5\u7B26\u53F7: $${i}`;if(n.variables.strict)throw new k("E_UNKNOWN_SYMBOL",l,t);n.diagnostics.push(new q("W_UNKNOWN_SYMBOL",l,t));return}this.definition=c}loweringEnter(){return[this.definition?new Ns(this):new tt]}toString(t){return this.definition?`@symbol(${this.definition.name})`:super.toString(t)}},ea=Ms,Ns=class extends tt{bounds;height;label;scale=1;baseline=0;constructor(t){super(),this.ast=t,this.mergeKey=Dt,this.onTimeState=t.definition.onTimeState,this.emitPlayback=t.definition.emitPlayback,this.playbackMarks=t.definition.playbackMarks,this.bounds=$e(t.definition.shapes??[]),this.height=t.size*(t.definition.weight??1);let e=t.definition.text;this.label=e&&{content:e.content,style:{fontSize:this.height,fontFamily:e.fontFamily,fontStyle:e.fontStyle}},this.initLayoutBox()}prepareLayout(t){if(this.label){let e=t.textMeasurer.measureText(this.label.content,this.label.style);this.box.w=e.w,this.box.h=e.h,this.baseline=e.baseline}else this.scale=this.height/this.bounds.h,this.box.w=this.bounds.w*this.scale,this.box.h=this.height+(this.ast.definition.paddingBottom??0)*this.scale;this.box.anchor=!this.label&&this.ast.definition.anchor!==void 0?(this.ast.definition.anchor-this.bounds.x)*this.scale:this.box.w/2,this.box.visualAxis=this.box.h/2}paint(t){this.label?t.drawText(this.label.content,this.box.x,this.box.y+this.baseline,this.label.style):Rn(t,this.ast.definition.shapes??[],this.bounds,this.box,this.scale)}playbackFlow(t){let e=this.ast.definition.onVisit;if(!e)return;let n=t(this);return n===void 0?void 0:{range:[n,n],run:o=>e(o,n)}}};var ks=class s extends ${static def={name:["set"],description:"\u8BBE\u7F6E\u5C40\u90E8\u9ED8\u8BA4\u503C",details:"~~~jpfun\n@set(fontsize=20, strict=true)\n{ @set(note.octave=5, note.color=#f00) C D E }\n~~~\n\u63A5\u53D7\u547D\u540D\u53C2\u6570\uFF0C\u53EF\u4E00\u6B21\u8BBE\u7F6E\u591A\u9879\uFF1A\n- **\u7CFB\u7EDF\u9009\u9879**\uFF1A\u5982 `fontsize=20` \u5C06\u5B57\u53F7\u8BBE\u4E3A 20px\uFF0C`strict=true` \u5F00\u542F\u4E25\u683C\u6A21\u5F0F\n- **\u51FD\u6570\u9ED8\u8BA4\u53C2\u6570**\uFF1A\u6309 `\u51FD\u6570\u4E3B\u540D.\u53C2\u6570\u540D=\u503C` \u4E66\u5199\uFF0C\u4F8B\u5982 `note.octave=5`\u3001`note.color=#f00`\uFF1B\u663E\u5F0F\u4F20\u53C2\u4F18\u5148\n\n\u8BBE\u7F6E\u4ECE\u5F53\u524D\u4F4D\u7F6E\u8D77\u751F\u6548\uFF0C\u9650\u4E8E\u5F53\u524D\u4F5C\u7528\u57DF\u53CA\u5176\u5B50\u4F5C\u7528\u57DF\uFF1B\u79BB\u5F00\u5185\u5BB9\u5757\u540E\u6062\u590D\u5916\u5C42\u8BBE\u7F6E\u3002\u5B83\u6309\u6E90\u7801\u4F5C\u7528\u57DF\u89E3\u6790\uFF0C\u4E0E\u6F14\u594F\u65F6\u95F4\u65E0\u5173\u3002",allowExtraArgs:!0,args:[]};static resolveTarget(t,e,n){let o=e.lastIndexOf(".");if(o<0)return[e,Object.hasOwn(_t.systemVariables,e)?_t.systemVariables[e].type:"string"];let i=e.slice(o+1),r=t.functions.get(e.slice(0,o))?.prototype.def,a=r&&Te(r,i,-1);return!r||!a?(t.diagnostics.push(new q("W_SET_UNKNOWN_TARGET",`@set \u7684\u53C2\u6570 [${e}] \u6CA1\u6709\u5BF9\u5E94\u7684\u51FD\u6570\u6216\u5176\u53C2\u6570\uFF0C\u5C06\u88AB\u5FFD\u7565`,n)),null):a==="content"||a==="label"?(t.diagnostics.push(new q("W_SET_INVALID_VALUE_TYPE",`@set \u7684\u53C2\u6570 [${e}] \u5185\u5BB9\u548C\u6807\u7B7E\u4E0D\u80FD\u4F5C\u4E3A\u9ED8\u8BA4\u503C\uFF0C\u5C06\u88AB\u5FFD\u7565`,n)),null):[`${Ve(r)}.${i}`.toLowerCase(),a]}args=new Map;constructor(t,e,n,o=null){super(t,o);for(let[i,r]of e){let a=r;if(typeof i!="string"){n.diagnostics.push(new q("W_SET_POSITIONAL_ARG",`\u51FD\u6570 @set \u4E0D\u63A5\u6536\u4F4D\u7F6E\u53C2\u6570, \u4F4D\u7F6E\u53C2\u6570[${i}]\u5C06\u88AB\u5FFD\u7565`,a.span));continue}let c=s.resolveTarget(n,i.toLowerCase(),a.nameSpan??a.span);if(c===null)continue;let[l,p]=c,f=n.parseArgWithType(a.valueSpan,p,t.start);if(f===null){n.diagnostics.push(new q("W_SET_INVALID_VALUE",`\u51FD\u6570 @set \u7684\u53C2\u6570\u503C\u89E3\u6790\u5931\u8D25, \u53C2\u6570[${i}]\u5C06\u88AB\u5FFD\u7565`,a.valueSpan));continue}n.setVariable(l,f),this.args.set(l,f)}}toString(){return`@set(${Array.from(this.args,([t,e])=>{let n=typeof e=="string"?ht(e):e&&typeof e=="object"&&"unit"in e?`${e.value}${e.unit}`:e;return`${t}=${n}`}).join(", ")})`}},na=ks;var _s=class extends ${static def={name:["volta"],description:"\u53CD\u590D\u7684\u8DF3\u623F\u5B50",details:"~~~jpfun\n|: 1 2 | 3@a 4@b :| 5@c 6@d | 7\n@volta(a, b, 1) @volta(c, d, 2)\n~~~\n- **\u989D\u5916\u4F4D\u7F6E\u53C2\u6570**\uFF1A\u66F4\u591A\u904D\u6570\uFF1B\u4F8B\u5982 `@volta(a, b, 1, 2)` \u8BA9\u524D\u4E24\u904D\u5171\u7528\u4E00\u4E2A\u623F\u5B50\u3002\u904D\u6570\u987A\u5E8F\u4E0D\u9650\uFF0C\u8C31\u9762\u6309\u5347\u5E8F\u663E\u793A\u3002\n\n\u672C\u4F8B\u7B2C\u4E00\u904D\u6F14\u594F `a` \u5230 `b`\uFF0C\u7B2C\u4E8C\u904D\u6F14\u594F `c` \u5230 `d`\u3002\n\u64AD\u653E\u533A\u95F4\u5305\u542B\u7EC8\u70B9\u4E8B\u4EF6\u7684\u5B8C\u6574\u65F6\u503C\uFF0C\u4F46\u4E0D\u5305\u542B\u5176\u7ED3\u675F\u65F6\u523B\u7684\u5C0F\u8282\u7EBF\u6216\u540E\u7EED\u4E8B\u4EF6\u3002",allowExtraArgs:!0,extraArgType:"number",args:[{name:"from",description:"\u533A\u95F4\u8D77\u70B9\u7684\u6807\u7B7E\uFF0C\u533A\u95F4\u5141\u8BB8\u8DE8\u8C31\u9762\u884C",type:"label",default:null},{name:"to",description:"\u533A\u95F4\u7EC8\u70B9\u7684\u6807\u7B7E",type:"label",default:null},{name:"pass",description:"\u8FDB\u5165\u6B64\u533A\u95F4\u7684\u6F14\u594F\u904D\u6570\uFF0C\u987B\u4E3A\u6B63\u6574\u6570",type:"number",default:null}]};from;to;passes;size;font;loweringEnter(t){let e=t.getTemporalNodes(this.from).at(0),n=t.getTemporalNodes(this.to).at(-1);for(;e?.foldedInto;)e=e.foldedInto;for(;n?.foldedInto;)n=n.foldedInto;return!e||!n?(t.diagnostics.push(H.warning.UnresolvedEndpoint("volta",this.sourceSpan)),[]):(t.addAttachment(new Is(this,e,n)),[])}constructor(t,e,n,o=null){super(t,o);let[i,r,a]=this.getArgValue(e,n);this.font=n.variables.numberfont;let c=new Set([a]);for(let l=3;e.has(l);l++)c.add(e.get(l));if(this.from=i,this.to=r,this.passes=[...c].sort((l,p)=>l-p),this.size=n.variables.fontsize,this.passes.some(l=>!Number.isSafeInteger(l)||l<=0))throw new k("E_VOLTA_INVALID_PASS","@volta \u7684\u904D\u6570\u5FC5\u987B\u662F\u6B63\u6574\u6570",t)}toString(t){let e=n=>n.label??n.toString(t);return`@volta(${e(this.from)}, ${e(this.to)}, ${this.passes.join(", ")})`}},sa=_s;function oa(s){if(s?.[0]?.mergeKey===mt)return s[0]}var Is=class{ast;from;to;layer="foreground";constructor(t,e,n){this.ast=t,this.from=e,this.to=n}get sourceSpan(){return this.ast.sourceSpan}get endPoints(){return[this.from,this.to]}playbackFlow(t){let e=t(this.from),n=t(this.to);if(e===void 0||n===void 0)return;let o=Math.min(e,n),i=(this.from.t.compare(this.to.t)||this.from.T.compare(this.to.T))>0?this.from:this.to,r=t(i,"end");if(r!==void 0)return{range:[o,r],run:a=>this.ast.passes.includes(Wi(a,o))?void 0:{kind:"jump",column:r+1}}}createGeometry(t){if(!X(this.from)||!X(this.to))return{regions:[],paint(){}};let e=L=>{let I=t.lines[L.layoutLine];return{line:L.layoutLine,view:I,column:I.columnOf(L)}},[n,o]=[e(this.from),e(this.to)];if((n.line>o.line||n.line===o.line&&n.column>o.column)&&([n,o]=[o,n]),n.column<0||o.column<0)return{regions:[],paint(){}};let i=n.view.columns[n.column][0],r=o.view.columns[o.column][0],a=oa(n.view.columns[n.column-1]),c=oa(o.view.columns[o.column+1]),l=i.layoutLine,p=r.layoutLine,f=this.ast.size,u={fontSize:f*.6,fontFamily:this.ast.font,textAlign:"left",fill:"#000"},h=this.ast.passes.map(L=>`${L}.`).join(""),d=t.textMeasurer.measureText(h,u),y=Math.max(1,f*.055),m=y/2,g=d.h*1.2,x=f*.15,b=(g-d.h)/2+d.baseline+2,A=Math.max(y,m+x+d.w),E=Math.max(g+m,b-d.baseline+d.h),S=f*.2,v=Array.from({length:p-l+1},(L,I)=>{let w=l+I,M=i.track,C=1/0,_=w!==l&&w!==p?t.getRangeExtents(w):t.getRangeExtents(w,[i,r]);for(let[O,j]of _){let B=t.getVisualAxis(w,O)+j.top;B<C&&(M=O,C=B)}C===1/0&&(C=t.getVisualAxis(w,M));let P=w!==l?this.lineEntryX(t,w,M):a?.layoutLine===w?a.box.x+a.box.anchor+5:i.box.x+(i.ports["body.left"]?.x??0),W=w!==p?this.lineRightX(t,w):c?.layoutLine===w?c.box.x+c.box.anchor:r.box.x+(r.ports["body.right"]?.x??r.box.w),Z=Math.min(P,W),Q=Math.max(P,W),K=(O,j,B)=>({x:O,y:-m,w:j,h:B+m,line:w,track:M}),N=[K(Z-m,Q-Z+y,m)];w===l&&N.push(K(Z-m,A,E)),w===p&&N.push(K(Q-m,y,g+m));let R=1/0;for(let O of N)for(let[j,B]of t.getHorizontalExtents(w,O.x,O.x+O.w))R=Math.min(R,t.getVisualAxis(w,j)+B.top-S-(O.y+O.h));R===1/0&&(R=C-S-m);for(let O of N)O.y+=R;return{left:Z,right:Q,lineY:R,line:w,parts:N}});return{regions:v.map(({parts:L})=>({...L[0],w:Math.max(...L.map(I=>I.x+I.w))-L[0].x,h:Math.max(...L.map(I=>I.h))})),occupancy:v.flatMap(L=>L.parts),paint(L){let I={stroke:"#000",strokeWidth:y};for(let{left:w,right:M,lineY:C,line:_}of v)L.drawLine(w,C,M,C,I),_===l&&(L.drawLine(w,C,w,C+g,I),L.drawText(h,w+x,C+b,u)),_===p&&L.drawLine(M,C,M,C+g,I)}}}lineEntryX(t,e,n){return t.lines[e].trackRuns.get(n)?.find(i=>!i.T.isZero())?.box.x??t.originX}lineRightX(t,e){let n=t.lines[e].trackRuns;if(n.size===0)return t.originX+t.width;let o=t.originX;for(let i of n.values())for(let r of i)o=Math.max(o,r.box.x+r.box.w);return o}};var ia=4/3,kl=.09,_l=2.5,Il=.5,Rl=.45,Rs=class extends ${static def={name:["tie"],description:"\u8FDE\u97F3\u7EBF",details:"~~~jpfun\n1@a 2 3@b @tie(a, b, height=0.5em)\n~~~\n- **\u4F4D\u7F6E\u53C2\u6570**\uFF1A\u7AEF\u70B9\u6807\u7B7E\uFF0C\u53EF\u4F20\u591A\u4E2A\uFF0C\u6309\u987A\u5E8F\u8FDE\u63A5\uFF1B\u7701\u7565\u65F6\u67E5\u627E\u6700\u8FD1\u7684\u53EF\u6807\u8BB0\u5BF9\u8C61\uFF0C\u5305\u62EC\u589E\u65F6\u7EBF\n- **height**\uFF1A\u4EC5\u547D\u540D\u7684\u5F27\u7EBF\u9AD8\u5EA6\u53C2\u6570\uFF0C\u9ED8\u8BA4 `0`\uFF08\u81EA\u52A8\uFF09\uFF1B\u975E\u6B63\u6570\u6309\u6C34\u5E73\u8DE8\u5EA6\u81EA\u52A8\u8C03\u6574\uFF0C\u5728 `2.5em` \u8DE8\u5EA6\u5904\u5E73\u6ED1\u8FBE\u5230 `0.5em` \u4E0A\u9650\uFF0C\u6B63\u6570\u6307\u5B9A\u56FA\u5B9A\u5F27\u9AD8\u3002em \u76F8\u5BF9\u8C03\u7528\u5904\u5B57\u53F7\uFF1B\u53EF\u7528 `@set(tie.height=0.8em)` \u8BBE\u7F6E\u5C40\u90E8\u9ED8\u8BA4\u503C\uFF0C\u663E\u5F0F\u4F20\u53C2\u4F18\u5148\n\n\u540C\u884C\u7AEF\u70B9\u7528\u4E00\u6761\u5F27\u7EBF\u8FDE\u63A5\uFF0C\u81EA\u52A8\u9AD8\u5EA6\u6309\u6C34\u5E73\u8DE8\u5EA6\u8BA1\u7B97\uFF1B\u8DE8\u884C\u65F6\u81EA\u52A8\u62C6\u6210\u591A\u6BB5\uFF0C\u81EA\u52A8\u6A21\u5F0F\u4E0B\u5404\u6BB5\u7EDF\u4E00\u4F7F\u7528 `0.45em` \u9AD8\u5EA6\u3002\u540C\u8F68\u540C\u97F3\u4E14\u65F6\u95F4\u8FDE\u7EED\u7684\u97F3\u6BB5\u5EFA\u7ACB\u64AD\u653E\u8FDE\u63A5\uFF0C\u5404\u6BB5\u4FDD\u7559\u81EA\u5DF1\u7684\u88C5\u9970\uFF0C\u4F8B\u5982 `1 ^ $tr 1 @tie()` \u7684\u540E\u4E00\u97F3\u6BB5\u4E0D\u7EE7\u627F\u98A4\u97F3\u3002\u6D89\u53CA\u589E\u65F6\u7EBF\u7684\u8FDE\u63A5\u4EC5\u7ED8\u5236\uFF0C\u4E0D\u5408\u5E76\u64AD\u653E\u97F3\u7B26\u3002",allowExtraArgs:!0,extraArgType:"label",args:[{name:"height",namedOnly:!0,description:"\u5F27\u7EBF\u9AD8\u5EA6\uFF0C\u652F\u6301 px/em\uFF1Bem \u76F8\u5BF9\u8C03\u7528\u5904\u5B57\u53F7\uFF0C\u975E\u6B63\u6570\u81EA\u52A8\u8C03\u6574\uFF0C\u6700\u9AD8 0.5em",type:"length",default:{value:0,unit:"em"}}]};endPoints=[];height;fontSize;constructor(t,e,n,o=null){super(t,o);let[i]=this.getArgValue(e,n);for(let[a,c]of e){if(a==="height")continue;let l=c instanceof $?c:n.parseArgWithType(c.valueSpan,"label",t.start);l!==null&&this.endPoints.push(l)}let r=n.labelableNodes.length-1;for(;this.endPoints.length<2&&r>=0;){let a=n.labelableNodes[r--];!a||this.endPoints.includes(a)||this.endPoints.unshift(a)}if(this.endPoints.length<2)throw new k("E_NOT_ENOUGH_ARGS","@tie \u8FDE\u97F3\u7EBF\u9700\u8981\u81F3\u5C11\u4E24\u4E2A\u7AEF\u70B9",t);this.height=Math.max(0,n.length2px(i)),this.fontSize=n.variables.fontsize}loweringEnter(t){let e=[];for(let n of this.endPoints){let o=t.getTemporalNodes(n).at(-1);!o||!X(o)||e.push(o)}return e.length<2?(t.diagnostics.push(H.warning.UnresolvedEndpoint("tie",this.sourceSpan)),[]):(t.addAttachment(new Os(e,this.height,this.fontSize,this.sourceSpan)),[])}toString(t){let e=this.endPoints.map(n=>n.label);return e.some(n=>n===void 0)?t.slice(this.sourceSpan.start,this.sourceSpan.end):`@tie(${e.join(", ")}, height=${this.height}px)`}},ra=Rs,Os=class{layer="foreground";sourceSpan;endPoints;height;fontSize;thickness;constructor(t,e,n,o){this.endPoints=t,this.height=e,this.fontSize=n,this.sourceSpan=o;let i=t.reduce((r,a)=>Math.max(r,a.ast.size),0);this.thickness=Math.max(1.2,i*kl)}applyPlayback(t){for(let e of t.notes.filter(n=>n.origins.some(o=>o.node===this.endPoints[0]))){let n=e;for(let o=1;o<this.endPoints.length;o++){let i=t.notes.find(r=>r!==n&&r.origins.some(a=>a.node===this.endPoints[o])&&r.track===n.track&&r.midi===n.midi&&r.percussion===n.percussion&&n.end.equals(r.start)&&t.connect(n,r));if(!i)break;n=i}}}createGeometry(t){let e=this.createSegments(t),n=e.map(({commands:i,...r})=>r),o=e.map(i=>{let r=t.getHostExtent(i.line,i.track),a=r?Math.max(i.y,t.getVisualAxis(i.line,i.track)+r.top):i.y+i.h;return{x:i.x,y:i.y,w:i.w,h:a-i.y,line:i.line,track:i.track}});return{regions:n,occupancy:o,paint(i){for(let r of e)i.drawPath(r.commands,{fill:"#000"})}}}tiePort(t){let e=t.ports["tie.top"];return e?{x:t.box.x+e.x,y:t.box.y+e.y}:{x:t.box.x+t.box.anchor,y:wt(t,!0).y}}createSegments(t){let e=[];for(let n=1;n<this.endPoints.length;n++){let o=this.endPoints[n-1],i=this.endPoints[n];o.layoutLine>i.layoutLine&&([o,i]=[i,o]);let r=this.tiePort(o),a=this.tiePort(i);if(o.layoutLine===i.layoutLine){let l=this.hostTop(t,o.layoutLine,o.track),p=this.hostTop(t,i.layoutLine,i.track);e.push(this.arcSegment(r,a,o.layoutLine,l<=p?o.track:i.track));continue}let c=this.height>0?this.height:this.fontSize*Rl;e.push(this.openingSegment(r,this.lineRightX(t,o.layoutLine),c,o.layoutLine,o.track));for(let l=o.layoutLine+1;l<i.layoutLine;l++)e.push(this.horizontalSegment(this.lineEntryX(t,l,o.track),this.lineRightX(t,l),this.hostTop(t,l,o.track)-c,l,o.track));e.push(this.closingSegment(this.lineEntryX(t,i.layoutLine,i.track),a,c,i.layoutLine,i.track))}return e}resolveHeight(t){if(this.height>0)return this.height;let e=Math.min(1,t/(this.fontSize*_l));return this.fontSize*Il*e*(2-e)}lineEntryX(t,e,n){return t.lines[e].trackRuns.get(n)?.find(r=>!r.T.isZero())?.box.x??t.originX}lineRightX(t,e){let n=t.lines[e].trackRuns;if(n.size===0)return t.originX+t.width;let o=t.originX;for(let i of n.values())for(let r of i)o=Math.max(o,r.box.x+r.box.w);return o}hostTop(t,e,n){return t.getVisualAxis(e,n)+(t.getHostExtent(e,n)?.top??0)}arcSegment(t,e,n,o){let i=t,r=e;i.x>r.x&&([i,r]=[r,i]);let a=(r.x-i.x)*.25,c=i.x+a,l=r.x-a,p=this.resolveHeight(r.x-i.x)*ia,f=Math.max(0,p-this.thickness*ia),u=[{op:"M",x:i.x,y:i.y},{op:"C",cx1:c,cy1:i.y-p,cx2:l,cy2:r.y-p,x:r.x,y:r.y},{op:"C",cx1:l,cy1:r.y-f,cx2:c,cy2:i.y-f,x:i.x,y:i.y},{op:"Z"}];return jn(u,n,o)}openingSegment(t,e,n,o,i){let r=t.y-n,a=n*1.2;e=Math.max(e,t.x+a);let c=t.x+a,l=t.x+a*.45,p=r+this.thickness;return jn([{op:"M",x:t.x,y:t.y},{op:"Q",cx:l,cy:r,x:c,y:r},{op:"L",x:e,y:r},{op:"L",x:e,y:p},{op:"L",x:c,y:p},{op:"Q",cx:l,cy:p,x:t.x,y:t.y},{op:"Z"}],o,i)}closingSegment(t,e,n,o,i){let r=e.y-n,a=n*1.2;t=Math.min(t,e.x-a);let c=e.x-a,l=e.x-a*.45,p=r+this.thickness;return jn([{op:"M",x:t,y:r},{op:"L",x:c,y:r},{op:"Q",cx:l,cy:r,x:e.x,y:e.y},{op:"Q",cx:l,cy:p,x:c,y:p},{op:"L",x:t,y:p},{op:"Z"}],o,i)}horizontalSegment(t,e,n,o,i){return jn([{op:"M",x:t,y:n},{op:"L",x:e,y:n},{op:"L",x:e,y:n+this.thickness},{op:"L",x:t,y:n+this.thickness},{op:"Z"}],o,i)}};function jn(s,t,e){return{commands:s,line:t,track:e,...Bt(s)}}var $s=class extends ${static def={name:["tuplet"],description:"\u591A\u8FDE\u97F3",details:`~~~jpfun
|
|
94
|
+
**\u5DF2\u6CE8\u518C\u8BB0\u53F7**
|
|
95
|
+
${[...fn.values()].map(t=>`- \`$${t.name}\`\uFF1A${t.description}`).join(`
|
|
96
|
+
`)}`},allowExtraArgs:!1,args:[{name:"name",description:"\u5DF2\u6CE8\u518C\u8BB0\u53F7\u540D\u79F0\uFF0C\u89C1\u51FD\u6570\u8BF4\u660E\u4E2D\u7684\u8BB0\u53F7\u5217\u8868",type:"string",default:null},{name:"size",description:"\u8BB0\u53F7\u5C3A\u5BF8",type:"length",default:{value:.5,unit:"em"}}]};static deSugarAtom(t,e,n){if(t[e]!=="$")return null;let o=/^\S+/.exec(t.slice(e+1,n))?.[0];if(!o)return null;let s=e+1+o.length;return{next:s,node:{kind:"call",typed:!0,name:"symbol",args:new Map([[0,o]]),span:{start:e,end:s},syntaxKind:"atom"}}}size;definition;constructor(t,e,n,o=null){super(t,o);let[s,i]=this.getArgValue(e,n);this.size=n.length2px(i);let a=s.toLowerCase(),c=fn.get(a);if(!c){let l;for(let u of ao.values()){let p=u.regex.exec(a);if(!(!p||p.index!==0||p[0]!==a)){if(l)throw new Error(`Ambiguous symbol patterns: ${a}`);l={pattern:u,match:p}}}c=l?.pattern.resolve(l.match)}if(!c){let l="@symbol: \u672A\u77E5\u7B26\u53F7: ${name}",u={name:s};if(n.variables.strict)throw new k("E_UNKNOWN_SYMBOL",l,t,u);n.diagnostics.push(new K("W_UNKNOWN_SYMBOL",l,t,u));return}this.definition=c}loweringEnter(){return[this.definition?new Kr(this):new tt]}toString(t){return this.definition?`@symbol(${this.definition.name})`:super.toString(t)}},Ga=Ur,Kr=class extends tt{bounds;height;label;scale=1;baseline=0;constructor(t){super(),this.ast=t,this.mergeKey=zt,this.onTimeState=t.definition.onTimeState,this.emitPlayback=t.definition.emitPlayback,this.playbackMarks=t.definition.playbackMarks,this.bounds=he(t.definition.shapes??[]),this.height=t.size*(t.definition.weight??1);let e=t.definition.text;this.label=e&&{content:e.content,style:{fontSize:this.height,fontFamily:e.fontFamily,fontStyle:e.fontStyle}},this.initLayoutBox()}prepareLayout(t){if(this.label){let e=t.textMeasurer.measureText(this.label.content,this.label.style);this.box.w=e.w,this.box.h=e.h,this.baseline=e.baseline}else this.scale=this.height/this.bounds.h,this.box.w=this.bounds.w*this.scale,this.box.h=this.height+(this.ast.definition.paddingBottom??0)*this.scale;this.box.anchor=!this.label&&this.ast.definition.anchor!==void 0?(this.ast.definition.anchor-this.bounds.x)*this.scale:this.box.w/2,this.box.visualAxis=this.box.h/2}paint(t){this.label?t.drawText(this.label.content,this.box.x,this.box.y+this.baseline,this.label.style):On(t,this.ast.definition.shapes??[],this.bounds,this.box,this.scale)}playbackFlow(t){let e=this.ast.definition.onVisit;if(!e)return;let n=t(this);return n===void 0?void 0:{range:[n,n],run:o=>e(o,n)}}};var Yr=class r extends B{static def={name:["set"],description:"\u8BBE\u7F6E\u5C40\u90E8\u9ED8\u8BA4\u503C",details:"~~~jpfun\n@set(fontsize=20, strict=true)\n{ @set(note.octave=5, note.color=#f00) C D E }\n~~~\n\u63A5\u53D7\u547D\u540D\u53C2\u6570\uFF0C\u53EF\u4E00\u6B21\u8BBE\u7F6E\u591A\u9879\uFF1A\n- **\u7CFB\u7EDF\u9009\u9879**\uFF1A\u5982 `fontsize=20` \u5C06\u5B57\u53F7\u8BBE\u4E3A 20px\uFF0C`strict=true` \u5F00\u542F\u4E25\u683C\u6A21\u5F0F\n- **\u51FD\u6570\u9ED8\u8BA4\u53C2\u6570**\uFF1A\u6309 `\u51FD\u6570\u4E3B\u540D.\u53C2\u6570\u540D=\u503C` \u4E66\u5199\uFF0C\u4F8B\u5982 `note.octave=5`\u3001`note.color=#f00`\uFF1B\u663E\u5F0F\u4F20\u53C2\u4F18\u5148\n\n\u8BBE\u7F6E\u4ECE\u5F53\u524D\u4F4D\u7F6E\u8D77\u751F\u6548\uFF0C\u9650\u4E8E\u5F53\u524D\u4F5C\u7528\u57DF\u53CA\u5176\u5B50\u4F5C\u7528\u57DF\uFF1B\u79BB\u5F00\u5185\u5BB9\u5757\u540E\u6062\u590D\u5916\u5C42\u8BBE\u7F6E\u3002\u5B83\u6309\u6E90\u7801\u4F5C\u7528\u57DF\u89E3\u6790\uFF0C\u4E0E\u6F14\u594F\u65F6\u95F4\u65E0\u5173\u3002",allowExtraArgs:!0,args:[]};static resolveTarget(t,e,n){let o=e.lastIndexOf(".");if(o<0)return[e,Object.hasOwn(_t.systemVariables,e)?_t.systemVariables[e].type:"string"];let s=e.slice(o+1),i=t.functions.get(e.slice(0,o))?.prototype.def,a=i&&Pe(i,s,-1);return!i||!a?(t.diagnostics.push(new K("W_SET_UNKNOWN_TARGET","@set \u7684\u53C2\u6570 [{key}] \u6CA1\u6709\u5BF9\u5E94\u7684\u51FD\u6570\u6216\u5176\u53C2\u6570\uFF0C\u5C06\u88AB\u5FFD\u7565",n,{key:e})),null):a==="content"||a==="label"?(t.diagnostics.push(new K("W_SET_INVALID_VALUE_TYPE","@set \u7684\u53C2\u6570 [{key}] \u5185\u5BB9\u548C\u6807\u7B7E\u4E0D\u80FD\u4F5C\u4E3A\u9ED8\u8BA4\u503C\uFF0C\u5C06\u88AB\u5FFD\u7565",n,{key:e})),null):[`${Ze(i)}.${s}`.toLowerCase(),a]}args=new Map;constructor(t,e,n,o=null){super(t,o);for(let[s,i]of e){let a=i;if(typeof s!="string"){n.diagnostics.push(new K("W_SET_POSITIONAL_ARG","\u51FD\u6570 @set \u4E0D\u63A5\u6536\u4F4D\u7F6E\u53C2\u6570, \u4F4D\u7F6E\u53C2\u6570[{key}]\u5C06\u88AB\u5FFD\u7565",a.span,{key:s}));continue}let c=r.resolveTarget(n,s.toLowerCase(),a.nameSpan??a.span);if(c===null)continue;let[l,u]=c,p=n.parseArgWithType(a.valueSpan,u,t.start);if(p===null){n.diagnostics.push(new K("W_SET_INVALID_VALUE","\u51FD\u6570 @set \u7684\u53C2\u6570\u503C\u89E3\u6790\u5931\u8D25, \u53C2\u6570[{key}]\u5C06\u88AB\u5FFD\u7565",a.valueSpan,{key:s}));continue}n.setVariable(l,p),this.args.set(l,p)}}toString(){return`@set(${Array.from(this.args,([t,e])=>{let n=typeof e=="string"?lt(e):e&&typeof e=="object"&&"unit"in e?`${e.value}${e.unit}`:e;return`${t}=${n}`}).join(", ")})`}},$a=Yr;var Wa=256;function yn(r){return r.ast instanceof B&&r.ast.callName==="dash"}function qr(r){return"midi"in r}function hn(r,t=[]){if("host"in r&&W(r.host))return hn(r.host,t);if("members"in r&&Array.isArray(r.members)){for(let e of r.members)hn(e,t);return t}return(typeof r.resolvedMidi=="number"||r.ast.name==="9")&&t.push(r.box.y+r.box.visualAxis),t}function ja(r){let t=hn(r);return(Math.min(...t)+Math.max(...t))/2}function Zr(r,t,e){let n,o=[];for(let s=r.length-1;s>=0;s--){let i=r[s];if(i.origins.at(-1).node.track!==t.track)continue;let a=i.origins.find(c=>c.node===t);if(n){if(a!==n)break}else{if(!a)continue;if(e&&!i.end.equals(e))return[];n=a}if(e&&!i.end.equals(e))return[];o.push(i)}return o}function Su(r){let t=1<<r;return(e,n)=>{let o=[];for(let s of n){let i=s.end.clone().sub(s.start),a=Math.min(Wa,Math.max(2,Math.round(i.toNumber()*t))),c=i.div(a);for(let l=0;l<a;l++){let u=c.clone().mul(l).add(s.start);o.push({...s,start:u,end:u.clone().add(c)})}}return o}}var Qr=class r extends B{static def={name:["tremolo"],description:"\u9707\u97F3\uFF08\u540C\u97F3\u9707\u97F3\u4E0E\u53CC\u97F3\u4EA4\u66FF\u9707\u97F3\uFF09",details:"~~~jpfun\n@tremolo(5, n=3)\n@tremolo({#5,^7, 2^4}, n=3)\n~~~\n- **\u5355\u97F3\u9707\u97F3**\uFF1A\u5185\u5BB9\u4E3A\u5355\u4E2A\u97F3\u7B26\u6216\u548C\u5F26\uFF08\u540E\u53EF\u63A5\u589E\u65F6\u7EBF `-`\uFF09\uFF0C\u659C\u6760\u8BB0\u5728\u6700\u672B\u5143\u7D20\u53F3\u4E0B\u89D2\uFF0C\u64AD\u653E\u65F6\u6309 `1 / 2^n` \u56DB\u5206\u97F3\u7B26\u65F6\u503C\u540C\u97F3\u91CD\u590D\u3002\n- **\u53CC\u97F3\u9707\u97F3**\uFF1A\u5185\u5BB9\u4E3A\u4E24\u4E2A\u540C\u8F68\u3001\u7B49\u65F6\u503C\u7684\u76F8\u90BB\u97F3\u7B26\u6216\u548C\u5F26\uFF0C\u659C\u6760\u8BB0\u5728\u4E24\u97F3\u4E4B\u95F4\uFF0C\u64AD\u653E\u65F6\u5728\u4E24\u97F3\u603B\u65F6\u503C\u5185\u6309 `1 / 2^n` \u56DB\u5206\u97F3\u7B26\u65F6\u503C\u4EA4\u66FF\u53D1\u58F0\u3002",allowExtraArgs:!1,args:[{type:"content",default:null,description:"\u5355\u4E2A\u97F3\u7B26\uFF08\u53EF\u5E26\u589E\u65F6\u7EBF\uFF09\u6216\u4E24\u4E2A\u7B49\u65F6\u503C\u7684\u97F3\u7B26/\u548C\u5F26"},{name:"n",type:"number",default:3,description:"\u659C\u6760\u6570\u91CF\uFF0C\u53D6 1..3 \u7684\u6574\u6570"}]};content;n;get children(){return[this.content]}constructor(t,e,n,o=null){super(t,o);let[s,i]=this.getArgValue(e,n);if(!Number.isSafeInteger(i)||i<1||i>3)throw new k("E_TREMOLO_INVALID_N","@tremolo \u7684\u659C\u6760\u6570 n \u5FC5\u987B\u662F 1 \u5230 3 \u7684\u6574\u6570",t);this.content=s,this.n=i,s.parent=this}loweringEnter(t){for(let n=this.parent;n;n=n.parent)if(n instanceof r)throw new k("E_TREMOLO_CONTENT","@tremolo \u4E0D\u80FD\u5D4C\u5957 @tremolo",this.sourceSpan);let e={nodes:[],onTemporal(n){W(n)&&e.nodes.push(n)}};return t.beginLoweringGroup(this,e),[]}loweringExit(t){let{nodes:e}=t.endLoweringGroup(this),n=e.length>=1&&!yn(e[0])&&e.slice(1).every(yn),o=e.length===2&&!yn(e[0])&&!yn(e[1]);if(!n&&!o||e.some(c=>c.T.compare(0)<=0))throw new k("E_TREMOLO_CONTENT","@tremolo \u7684\u5185\u5BB9\u5FC5\u987B\u662F\u5355\u4E2A\u97F3\u7B26\uFF08\u53EF\u5E26\u589E\u65F6\u7EBF\uFF09\u6216\u4E24\u4E2A\u7B49\u65F6\u503C\u7684\u97F3\u7B26/\u548C\u5F26",this.sourceSpan);if(e.some(c=>c.track!==e[0].track))throw new k("E_TREMOLO_CROSS_TRACK","@tremolo \u7684\u5185\u5BB9\u5FC5\u987B\u4F4D\u4E8E\u540C\u4E00\u97F3\u8F68",this.sourceSpan);let s=new Jr(e,this);t.addAttachment(s),t.deferFinalize(()=>s.finalize());let i=n?e.at(-1):e[0],a=i.prepareHorizontal;return i.prepareHorizontal=c=>{a?.call(i,c),s.registerHorizontal(c)},[]}toString(t){return`@tremolo(${this.content.toString(t)}, n=${this.n})`}},Xa=Qr,Jr=class{constructor(t,e){this.nodes=t;this.owner=e;let n=t.length===1||yn(t[1]);this.endPoints=n?[t.at(-1)]:[t[0],t[1]]}nodes;owner;layer="foreground";endPoints;get sourceSpan(){return this.owner.sourceSpan}finalize(){let{nodes:t,owner:e,endPoints:n}=this,o=n.length===1,s=t[0].layoutLine;if(t.some(l=>l.layoutLine!==s))throw new k("E_TREMOLO_CROSS_LINE","@tremolo \u4E0D\u652F\u6301\u8DE8\u8C31\u9762\u884C",e.sourceSpan);if(hn(t[0]).length===0||!o&&hn(t[1]).length===0)throw new k("E_TREMOLO_CONTENT","@tremolo \u7684\u76EE\u6807\u5FC5\u987B\u5305\u542B\u53D1\u58F0\u97F3\u7B26",e.sourceSpan);if(o){let l=t[0],u=Su(e.n),p=l.emitPlayback;l.emitPlayback=m=>{p?.call(l,m),m.defer(d=>{for(let f of Zr(d.spans,l))qr(f)&&d.transform(f,u)})};return}let[i,a]=t;if(!i.T.equals(a.T))throw new k("E_TREMOLO_DURATION_MISMATCH","@tremolo \u53CC\u97F3\u9707\u97F3\u7684\u4E24\u4E2A\u76EE\u6807\u65F6\u503C\u5FC5\u987B\u76F8\u7B49",e.sourceSpan);let c=a.emitPlayback;a.emitPlayback=l=>{c?.call(a,l);let{start:u,end:p}=l;l.defer(m=>{let d=Zr(m.spans,i,u),f=Zr(m.spans,a);if(d.length===0||f.length===0)return;let x=d.reduce((w,A)=>A.start.compare(w)<0?A.start:w,d[0].start).clone(),y=p.clone().sub(x),h=Math.min(Wa/2,Math.max(2,Math.round(y.toNumber()*(1<<e.n-1)))),g=y.clone().div(h*2),b=(w,A)=>(C,_)=>_.flatMap(E=>{let S=(E.end.compare(p)>0?p:E.end).clone().sub(E.start).div(w),M=[];for(let I=0;I<h;I++){let z=S.clone().mul(2*I).add(E.start),j=A&&I===h-1&&E.end.compare(p)>0?E.end.clone():z.clone().add(S);M.push({...E,start:z,end:j})}return M}),T=b(h*2,!1),L=b(h*2-1,!0);for(let w of d)w.start.copyFrom(x),w.end.copyFrom(p),qr(w)&&m.transform(w,T);for(let w of f)w.start.copyFrom(x).add(g),w.end.copyFrom(p),qr(w)&&m.transform(w,L)})}}registerHorizontal(t){if(this.endPoints.length===1){let c=this.endPoints[0];if(t.columnOf(c)<0)return;let l=c.ast.size,u=c.box.w-c.box.anchor+l*.6;t.registerHorizontalLayoutHook(c,c,({columns:p,start:m})=>{for(let d of p[m])d.box===c.box&&(d.WR=Math.max(d.WR,u))});return}let[e,n]=this.endPoints,o=t.columnOf(e),s=t.columnOf(n);if(o<0||s<0)return;if(s<=o||t.trackIndexOf(n)!==t.trackIndexOf(e)+1)throw new k("E_TREMOLO_ADJACENT","@tremolo \u53CC\u97F3\u9707\u97F3\u7684\u4E24\u4E2A\u7AEF\u70B9\u5FC5\u987B\u5728\u540C\u4E00\u8C31\u9762\u884C\u76F8\u90BB",this.owner.sourceSpan);let i=Math.max(e.ast.size,n.ast.size),a=e.box.w-e.box.anchor+i*.84;t.registerHorizontalLayoutHook(e,n,({columns:c})=>{for(let l of c[o])l.WR=Math.max(l.WR,a)})}createGeometry(){let{n:t}=this.owner,e=this.endPoints[0],n=e.ast.size,o,s,i,a,c;if(this.endPoints.length===1)o=e.box.x+e.box.w+n*.1,s=o+n*.34,i=e.box.y+e.box.visualAxis+n*.14,a=n*.18,c=n*.12;else{let[d,f]=this.endPoints;n=Math.max(d.ast.size,f.ast.size);let x=n*.12,y=d.box.x+d.box.w+x,h=f.box.x-x;if(h<=y)throw new k("E_TREMOLO_SPACE","@tremolo \u7684\u7AEF\u70B9\u4E4B\u95F4\u6CA1\u6709\u53EF\u7528\u7684\u6C34\u5E73\u7ED8\u5236\u7A7A\u95F4",this.owner.sourceSpan);let g=Math.min(h-y,n*1.2),b=(y+h)/2;o=b-g/2,s=b+g/2,i=(ja(d)+ja(f))/2,a=Math.min(n*.26,Math.max(n*.16,g*.32)),c=n*.13}let l=Math.max(1,n*.06),u=wu(t,o,s,i,a,c),p=Gt(u);return{regions:[{x:p.x-l/2,y:p.y-l/2,w:p.w+l,h:p.h+l,line:e.layoutLine,track:e.track}],paint(d){d.drawPath(u,{fill:"none",stroke:"#000",strokeWidth:l})}}}};function wu(r,t,e,n,o,s){let i=[];for(let a=0;a<r;a++){let c=n+(a-(r-1)/2)*s;i.push({op:"M",x:t,y:c+o/2},{op:"L",x:e,y:c-o/2})}return i}var ts=class extends B{static def={name:["volta"],description:"\u53CD\u590D\u7684\u8DF3\u623F\u5B50",details:"~~~jpfun\n|: 1 2 | 3@a 4@b :| 5@c 6@d | 7\n@volta(a, b, 1) @volta(c, d, 2)\n~~~\n- **\u989D\u5916\u4F4D\u7F6E\u53C2\u6570**\uFF1A\u66F4\u591A\u904D\u6570\uFF1B\u4F8B\u5982 `@volta(a, b, 1, 2)` \u8BA9\u524D\u4E24\u904D\u5171\u7528\u4E00\u4E2A\u623F\u5B50\u3002\u904D\u6570\u987A\u5E8F\u4E0D\u9650\uFF0C\u8C31\u9762\u6309\u5347\u5E8F\u663E\u793A\u3002\n\n\u672C\u4F8B\u7B2C\u4E00\u904D\u6F14\u594F `a` \u5230 `b`\uFF0C\u7B2C\u4E8C\u904D\u6F14\u594F `c` \u5230 `d`\u3002\n\u64AD\u653E\u533A\u95F4\u5305\u542B\u7EC8\u70B9\u4E8B\u4EF6\u7684\u5B8C\u6574\u65F6\u503C\uFF0C\u4F46\u4E0D\u5305\u542B\u5176\u7ED3\u675F\u65F6\u523B\u7684\u5C0F\u8282\u7EBF\u6216\u540E\u7EED\u4E8B\u4EF6\u3002",allowExtraArgs:!0,extraArgType:"number",args:[{name:"from",description:"\u533A\u95F4\u8D77\u70B9\u7684\u6807\u7B7E\uFF0C\u533A\u95F4\u5141\u8BB8\u8DE8\u8C31\u9762\u884C",type:"label",default:null},{name:"to",description:"\u533A\u95F4\u7EC8\u70B9\u7684\u6807\u7B7E",type:"label",default:null},{name:"pass",description:"\u8FDB\u5165\u6B64\u533A\u95F4\u7684\u6F14\u594F\u904D\u6570\uFF0C\u987B\u4E3A\u6B63\u6574\u6570",type:"number",default:null}]};from;to;passes;size;font;loweringEnter(t){let e=t.getTemporalNodes(this.from).at(0)?.rootHost,n=t.getTemporalNodes(this.to).at(-1)?.rootHost;return!e||!n?(t.diagnostics.push(Y.warning.UnresolvedEndpoint("volta",this.sourceSpan)),[]):(t.addAttachment(new es(this,e,n)),[])}constructor(t,e,n,o=null){super(t,o);let[s,i,a]=this.getArgValue(e,n);this.font=n.variables.numberfont;let c=new Set([a]);for(let l=3;e.has(l);l++)c.add(e.get(l));if(this.from=s,this.to=i,this.passes=[...c].sort((l,u)=>l-u),this.size=n.variables.fontsize,this.passes.some(l=>!Number.isSafeInteger(l)||l<=0))throw new k("E_VOLTA_INVALID_PASS","@volta \u7684\u904D\u6570\u5FC5\u987B\u662F\u6B63\u6574\u6570",t)}toString(t){let e=n=>n.label??n.toString(t);return`@volta(${e(this.from)}, ${e(this.to)}, ${this.passes.join(", ")})`}},Ka=ts;function Ua(r){if(r?.[0]?.mergeKey===gt)return r[0]}var es=class{constructor(t,e,n){this.ast=t;this.from=e;this.to=n}ast;from;to;layer="foreground";get sourceSpan(){return this.ast.sourceSpan}get endPoints(){return[this.from,this.to]}playbackFlow(t){let e=t(this.from),n=t(this.to);if(e===void 0||n===void 0)return;let o=Math.min(e,n),s=(this.from.t.compare(this.to.t)||this.from.T.compare(this.to.T))>0?this.from:this.to,i=t(s,"end");if(i!==void 0)return{range:[o,i],run:a=>this.ast.passes.includes(di(a,o))?void 0:{kind:"jump",column:i+1}}}createGeometry(t){if(!W(this.from)||!W(this.to))return{regions:[],paint(){}};let e=C=>{let _=t.lines[C.layoutLine];return{line:C.layoutLine,view:_,column:_.columnOf(C)}},[n,o]=[e(this.from),e(this.to)];if((n.line>o.line||n.line===o.line&&n.column>o.column)&&([n,o]=[o,n]),n.column<0||o.column<0)return{regions:[],paint(){}};let s=n.view.columns[n.column][0],i=o.view.columns[o.column][0],a=Ua(n.view.columns[n.column-1]),c=Ua(o.view.columns[o.column+1]),l=s.layoutLine,u=i.layoutLine,p=this.ast.size,m={fontSize:p*.6,fontFamily:this.ast.font,textAlign:"left",fill:"#000"},d=this.ast.passes.map(C=>`${C}.`).join(""),f=t.textMeasurer.measureText(d,m),x=Math.max(1,p*.055),y=x/2,h=f.h*1.2,g=p*.15,b=(h-f.h)/2+f.baseline+2,T=Math.max(x,y+g+f.w),L=Math.max(h+y,b-f.baseline+f.h),w=p*.2,A=Array.from({length:u-l+1},(C,_)=>{let E=l+_,v=s.track,S=1/0,M=E!==l&&E!==u?t.getRangeExtents(E):t.getRangeExtents(E,[s,i]);for(let[R,D]of M){let U=t.getVisualAxis(E,R)+D.top;U<S&&(v=R,S=U)}S===1/0&&(S=t.getVisualAxis(E,v));let I=E!==l?Ut(t,E,v):a?.layoutLine===E?a.box.x+a.box.anchor+5:s.box.x+(s.ports["body.left"]?.x??0),z=E!==u?Kt(t,E):c?.layoutLine===E?c.box.x+c.box.anchor:i.box.x+(i.ports["body.right"]?.x??i.box.w),j=Math.min(I,z),q=Math.max(I,z),et=(R,D,U)=>({x:R,y:-y,w:D,h:U+y,line:E,track:v}),N=[et(j-y,q-j+x,y)];E===l&&N.push(et(j-y,T,L)),E===u&&N.push(et(q-y,x,h+y));let O=1/0;for(let R of N)for(let[D,U]of t.getHorizontalExtents(E,R.x,R.x+R.w))O=Math.min(O,t.getVisualAxis(E,D)+U.top-w-(R.y+R.h));O===1/0&&(O=S-w-y);for(let R of N)R.y+=O;return{left:j,right:q,lineY:O,line:E,parts:N}});return{regions:A.map(({parts:C})=>({...C[0],w:Math.max(...C.map(_=>_.x+_.w))-C[0].x,h:Math.max(...C.map(_=>_.h))})),occupancy:A.flatMap(C=>C.parts),paint(C){let _={stroke:"#000",strokeWidth:x};for(let{left:E,right:v,lineY:S,line:M}of A)C.drawLine(E,S,v,S,_),M===l&&(C.drawLine(E,S,E,S+h,_),C.drawText(d,E+g,S+b,m)),M===u&&C.drawLine(v,S,v,S+h,_)}}}};var Qa=new WeakSet,Ya=new WeakMap;function qa(r,t){let e=Ya.get(r);if(!e){e=new Map;for(let n of r)for(let{node:o}of n.origins){if(!Qa.has(o))continue;let s=e.get(o);s?s.push(n):e.set(o,[n])}Ya.set(r,e)}return e.get(t)??[]}var Za=4/3,Tu=.09,Lu=2.5,Au=.5,Cu=.45,ns=class extends B{static def={name:["tie"],description:"\u8FDE\u97F3\u7EBF",details:"~~~jpfun\n1@a 2 3@b @tie(a, b, height=0.5em)\n~~~\n- **\u4F4D\u7F6E\u53C2\u6570**\uFF1A\u7AEF\u70B9\u6807\u7B7E\uFF0C\u53EF\u4F20\u591A\u4E2A\uFF0C\u6309\u987A\u5E8F\u8FDE\u63A5\uFF1B\u7701\u7565\u65F6\u67E5\u627E\u6700\u8FD1\u7684\u53EF\u6807\u8BB0\u5BF9\u8C61\uFF0C\u5305\u62EC\u589E\u65F6\u7EBF\n- **height**\uFF1A\u4EC5\u547D\u540D\u7684\u5F27\u7EBF\u9AD8\u5EA6\u53C2\u6570\uFF0C\u9ED8\u8BA4 `0`\uFF08\u81EA\u52A8\uFF09\uFF1B\u975E\u6B63\u6570\u6309\u6C34\u5E73\u8DE8\u5EA6\u81EA\u52A8\u8C03\u6574\uFF0C\u5728 `2.5em` \u8DE8\u5EA6\u5904\u5E73\u6ED1\u8FBE\u5230 `0.5em` \u4E0A\u9650\uFF0C\u6B63\u6570\u6307\u5B9A\u56FA\u5B9A\u5F27\u9AD8\u3002em \u76F8\u5BF9\u8C03\u7528\u5904\u5B57\u53F7\uFF1B\u53EF\u7528 `@set(tie.height=0.8em)` \u8BBE\u7F6E\u5C40\u90E8\u9ED8\u8BA4\u503C\uFF0C\u663E\u5F0F\u4F20\u53C2\u4F18\u5148\n\n\u540C\u884C\u7AEF\u70B9\u7528\u4E00\u6761\u5F27\u7EBF\u8FDE\u63A5\uFF0C\u81EA\u52A8\u9AD8\u5EA6\u6309\u6C34\u5E73\u8DE8\u5EA6\u8BA1\u7B97\uFF1B\u8DE8\u884C\u65F6\u81EA\u52A8\u62C6\u6210\u591A\u6BB5\uFF0C\u81EA\u52A8\u6A21\u5F0F\u4E0B\u5404\u6BB5\u7EDF\u4E00\u4F7F\u7528 `0.45em` \u9AD8\u5EA6\u3002\u540C\u8F68\u540C\u97F3\u4E14\u65F6\u95F4\u8FDE\u7EED\u7684\u97F3\u6BB5\u5EFA\u7ACB\u64AD\u653E\u8FDE\u63A5\uFF1A\u672A\u53E6\u52A0\u4FEE\u9970\u7684\u540E\u7EE7\u97F3\u6BB5\u5E76\u5165\u524D\u6BB5\u5171\u540C\u5C55\u5F00\uFF08\u5982 `1 ^ $tr 1 @tie()` \u5168\u7A0B\u98A4\u97F3\uFF09\uFF0C\u5E26\u72EC\u7ACB\u4FEE\u9970\u7684\u540E\u7EE7\u97F3\u6BB5\u4ECE\u81EA\u8EAB\u8D77\u70B9\u751F\u6548\uFF08\u5982 `1 1 ^ $tr @tie()` \u4ECE\u7B2C\u4E8C\u62CD\u5F00\u59CB\u98A4\u97F3\uFF09\u3002\u6D89\u53CA\u589E\u65F6\u7EBF\u7684\u8FDE\u63A5\u4EC5\u7ED8\u5236\uFF0C\u4E0D\u5408\u5E76\u64AD\u653E\u97F3\u7B26\u3002",allowExtraArgs:!0,extraArgType:"label",args:[{name:"height",namedOnly:!0,description:"\u5F27\u7EBF\u9AD8\u5EA6\uFF0C\u652F\u6301 px/em\uFF1Bem \u76F8\u5BF9\u8C03\u7528\u5904\u5B57\u53F7\uFF0C\u975E\u6B63\u6570\u81EA\u52A8\u8C03\u6574\uFF0C\u6700\u9AD8 0.5em",type:"length",default:{value:0,unit:"em"}}]};endPoints=[];height;constructor(t,e,n,o=null){super(t,o);let[s]=this.getArgValue(e,n);for(let[a,c]of e)typeof a=="number"&&this.endPoints.push(c);let i=n.labelableNodes.length-1;for(;this.endPoints.length<2&&i>=0;){let a=n.labelableNodes[i--];!a||this.endPoints.includes(a)||this.endPoints.unshift(a)}if(this.endPoints.length<2)throw new k("E_NOT_ENOUGH_ARGS","@{fn} \u8FDE\u97F3\u7EBF\u9700\u8981\u81F3\u5C11\u4E24\u4E2A\u7AEF\u70B9",t,{fn:"tie"});this.height=Math.max(0,n.length2px(s))}loweringEnter(t){let e=[];for(let n of this.endPoints){let o=t.getTemporalNodes(n).at(-1);!o||!W(o)||e.push(o)}return e.length<2?(t.diagnostics.push(Y.warning.UnresolvedEndpoint("tie",this.sourceSpan)),[]):(t.addAttachment(new os(e,this.height,this.sourceSpan)),[])}toString(t){let e=this.endPoints.map(n=>n.label);return e.some(n=>n===void 0)?t.slice(this.sourceSpan.start,this.sourceSpan.end):`@tie(${e.join(", ")}, height=${this.height}px)`}},Ja=ns,os=class{layer="foreground";sourceSpan;endPoints;height;size;thickness;constructor(t,e,n){this.endPoints=t;for(let o of t)Qa.add(o);this.height=e,this.sourceSpan=n,this.size=t.reduce((o,s)=>Math.max(o,s.ast.size),0),this.thickness=Math.max(1.2,this.size*Tu)}applyPlayback(t){for(let e of qa(t.notes,this.endPoints[0])){let n=e;for(let o=1;o<this.endPoints.length;o++){let s=qa(t.notes,this.endPoints[o]).find(i=>i!==n&&i.track===n.track&&i.midi===n.midi&&i.percussion===n.percussion&&n.end.equals(i.start)&&t.connect(n,i));if(!s)break;n=s}}}createGeometry(t){let e=this.createSegments(t),n=e.map(({commands:s,...i})=>i),o=e.map(s=>{let i=t.getHostExtent(s.line,s.track),a=i?Math.max(s.y,t.getVisualAxis(s.line,s.track)+i.top):s.y+s.h;return{x:s.x,y:s.y,w:s.w,h:a-s.y,line:s.line,track:s.track}});return{regions:n,occupancy:o,paint(s){for(let i of e)s.drawPath(i.commands,{fill:"#000"})}}}tiePort(t){let e=t.ports["tie.top"];return e?{x:t.box.x+e.x,y:t.box.y+e.y}:{x:t.box.x+t.box.anchor,y:St(t,!0).y}}createSegments(t){let e=[];for(let n=1;n<this.endPoints.length;n++){let o=this.endPoints[n-1],s=this.endPoints[n];o.layoutLine>s.layoutLine&&([o,s]=[s,o]);let i=this.tiePort(o),a=this.tiePort(s);if(o.layoutLine===s.layoutLine){let l=this.hostTop(t,o.layoutLine,o.track),u=this.hostTop(t,s.layoutLine,s.track);e.push(this.arcSegment(i,a,o.layoutLine,l<=u?o.track:s.track));continue}let c=this.height>0?this.height:this.size*Cu;e.push(this.openingSegment(i,Kt(t,o.layoutLine),c,o.layoutLine,o.track));for(let l=o.layoutLine+1;l<s.layoutLine;l++)e.push(this.horizontalSegment(Ut(t,l,o.track),Kt(t,l),this.hostTop(t,l,o.track)-c,l,o.track));e.push(this.closingSegment(Ut(t,s.layoutLine,s.track),a,c,s.layoutLine,s.track))}return e}resolveHeight(t){if(this.height>0)return this.height;let e=Math.min(1,t/(this.size*Lu));return this.size*Au*e*(2-e)}hostTop(t,e,n){return t.getVisualAxis(e,n)+(t.getHostExtent(e,n)?.top??0)}arcSegment(t,e,n,o){let s=t,i=e;s.x>i.x&&([s,i]=[i,s]);let a=(i.x-s.x)*.25,c=s.x+a,l=i.x-a,u=this.resolveHeight(i.x-s.x)*Za,p=Math.max(0,u-this.thickness*Za),m=[{op:"M",x:s.x,y:s.y},{op:"C",cx1:c,cy1:s.y-u,cx2:l,cy2:i.y-u,x:i.x,y:i.y},{op:"C",cx1:l,cy1:i.y-p,cx2:c,cy2:s.y-p,x:s.x,y:s.y},{op:"Z"}];return co(m,n,o)}openingSegment(t,e,n,o,s){let i=t.y-n,a=n*1.2;e=Math.max(e,t.x+a);let c=t.x+a,l=t.x+a*.45,u=i+this.thickness;return co([{op:"M",x:t.x,y:t.y},{op:"Q",cx:l,cy:i,x:c,y:i},{op:"L",x:e,y:i},{op:"L",x:e,y:u},{op:"L",x:c,y:u},{op:"Q",cx:l,cy:u,x:t.x,y:t.y},{op:"Z"}],o,s)}closingSegment(t,e,n,o,s){let i=e.y-n,a=n*1.2;t=Math.min(t,e.x-a);let c=e.x-a,l=e.x-a*.45,u=i+this.thickness;return co([{op:"M",x:t,y:i},{op:"L",x:c,y:i},{op:"Q",cx:l,cy:i,x:e.x,y:e.y},{op:"Q",cx:l,cy:u,x:c,y:u},{op:"L",x:t,y:u},{op:"Z"}],o,s)}horizontalSegment(t,e,n,o,s){return co([{op:"M",x:t,y:n},{op:"L",x:e,y:n},{op:"L",x:e,y:n+this.thickness},{op:"L",x:t,y:n+this.thickness},{op:"Z"}],o,s)}};function co(r,t,e){return{commands:r,line:t,track:e,...Gt(r)}}var rs=class extends B{static def={name:["tuplet"],description:"\u591A\u8FDE\u97F3",details:`~~~jpfun
|
|
88
97
|
@tuplet({1/ 2 3}, normal=4)
|
|
89
98
|
~~~
|
|
90
|
-
\u672C\u4F8B\u6700\u77ED\u5355\u4F4D\u4E3A\u516B\u5206\u97F3\u7B26\uFF0C\u539F\u5185\u5BB9\u5360 5 \u4E2A\u5355\u4F4D\uFF0C\u7F29\u653E\u540E\u5360 4 \u4E2A\u5355\u4F4D\uFF1A\u5F62\u6210\u4E94\u8FDE\u97F3\uFF0C\u603B\u65F6\u957F\u4E3A\u4E00\u4E2A\u4E8C\u5206\u97F3\u7B26`,allowExtraArgs:!1,args:[{type:"content",description:"\u8FDE\u97F3\u5185\u5BB9\uFF0C\u5404\u5143\u7D20\u6309\u540C\u4E00\u6BD4\u4F8B\u7F29\u653E\u65F6\u503C",default:null},{name:"normal",description:"\u76EE\u6807\u603B\u65F6\u957F\uFF0C\u4EE5\u5185\u5BB9\u4E2D\u7684\u6700\u77ED\u65F6\u503C\u4E3A\u5355\u4F4D",type:"number",default:null}]};static loweringFinalize=t=>{for(let e of t.attachments)e instanceof Kn&&e.validate()};content;normal;font;get children(){return[this.content]}timeFlowModel(){return{mode:"sequence",children:[this.content]}}loweringEnter(t){let e={nodes:[],attachments:[],onTemporal(n){e.nodes.push(n)},onAttachment(n){e.attachments.push(n)}};return t.beginLoweringGroup(this,e),[]}loweringExit(t,e,n){let o=t.endLoweringGroup(this),i=o.nodes.filter(d=>d.T.compare(0)>0);if(i.length===0)throw new k("E_TUPLET_EMPTY","@tuplet \u7684\u5185\u5BB9\u5FC5\u987B\u4EA7\u751F\u81F3\u5C11\u4E00\u4E2A\u6B63\u65F6\u503C\u4E8B\u4EF6",this.sourceSpan);let r=i[0].track;if(i.some(d=>d.track!==r))throw new k("E_TUPLET_PARALLEL_CONTENT","@tuplet \u7684\u5185\u5BB9\u4E0D\u80FD\u5305\u542B\u5E76\u884C\u97F3\u8F68",this.sourceSpan);let a=i[0].T.clone(),c=new F;for(let d of i)d.T.compare(a)<0&&a.copyFrom(d.T),c.add(d.T);let l=c.div(a),p=l.numerator;if(l.denominator!==1||p<2||!Number.isSafeInteger(p))throw new k("E_TUPLET_NON_INTEGRAL_UNITS","@tuplet \u7684\u603B\u65F6\u503C\u5FC5\u987B\u662F\u6700\u77ED\u6B63\u65F6\u503C\u7684\u6574\u6570\u500D\uFF0C\u4E14\u81F3\u5C11\u5305\u542B2\u4E2A\u5355\u4F4D",this.sourceSpan);if(this.normal===p)throw new k("E_TUPLET_INVALID_RATIO",`@tuplet \u7684 normal \u4E0D\u80FD\u7B49\u4E8E\u63A8\u5BFC\u51FA\u7684 actual (${p})`,this.sourceSpan);let f=o.nodes[0].t;for(let d=1;d<o.nodes.length;d++)o.nodes[d].t.compare(f)<0&&(f=o.nodes[d].t);f=f.clone();let u=new F;for(let d of o.nodes)u.copyFrom(d.t).sub(f).mul(this.normal,p),d.t.copyFrom(f).add(u),d.T.mul(this.normal,p);n.copyFrom(f).add(a.mul(this.normal));let h=i.filter(X);return h.length>=2&&t.addAttachment(new Kn(h,p,this.sourceSpan,this.font,o)),[]}constructor(t,e,n,o=null){super(t,o);let[i,r]=this.getArgValue(e,n);if(this.font=n.variables.numberfont,!Number.isSafeInteger(r)||r<=0)throw new k("E_TUPLET_INVALID_NORMAL","@tuplet \u7684 normal \u5FC5\u987B\u662F\u6B63\u7684\u5B89\u5168\u6574\u6570",t);this.content=i,this.normal=r,i.parent=this}toString(t){return`@tuplet(${this.content.toString(t)}, ${this.normal})`}},aa=$s,Kn=class{content;layer="foreground";endPoints;actual;sourceSpan;style;size;constructor(t,e,n,o,i){this.content=i,this.endPoints=t,this.actual=e,this.sourceSpan=n,this.size=t.reduce((r,a)=>Math.max(r,a.ast.size),0),this.style={fontSize:this.size*.72,fontFamily:o,textAlign:"center",fill:"#000"}}validate(){let t=this.endPoints[0];if(this.endPoints.some(e=>e.layoutLine!==t.layoutLine))throw new k("E_TUPLET_CROSS_LINE","@tuplet \u7684\u5185\u5BB9\u4E0D\u80FD\u8DE8\u8D8A\u8C31\u9762\u884C",this.sourceSpan)}createGeometry(t){let e=this.endPoints[0],n=this.endPoints[this.endPoints.length-1],o=e.ports["body.left"]?.x??0,i=n.ports["body.right"]?.x??n.box.w,r=e.box.x+o,a=n.box.x+i;r>a&&([r,a]=[a,r]);let c=t.textMeasurer.measureText(String(this.actual),this.style),l=(r+a)/2,p=this.size*.12,f=this.size*.18,u=this.size*.14,h=t.getVisualAxis(e.layoutLine,e.track),d=t.getRangeExtents(e.layoutLine,[e,n],e.track),y=t.getContentBounds(this.content),m=Math.min(h+(d?.top??0),y?.y??1/0),g=Math.max(1,this.size*.055),x=m-u-Math.max(f,c.h/2),b=x+f,A=x-c.h/2+c.baseline,E=l-c.w/2-p,S=l+c.w/2+p,v=[];E>r&&v.push([r,x,E,x]),S<a&&v.push([S,x,a,x]),v.push([r,x,r,b],[a,x,a,b]);let L=g/2,I=Math.min(x-c.h/2,x-L),w=Math.max(x+c.h/2,b+L),M=[{x:r-L,y:I,w:a-r+g,h:w-I,line:e.layoutLine,track:e.track}],C=String(this.actual),_=this.style;return{regions:M,paint(P){let W={stroke:"#000",strokeWidth:g};for(let[Z,Q,K,N]of v)P.drawLine(Z,Q,K,N,W);P.drawText(C,l,A,_)}}}};var Ps=[{op:"M",x:2.98438,y:-165.5},{op:"C",cx1:8.9375,cy1:-171.781,cx2:20.5156,cy2:-184.688,x:20.5156,y:-208.531},{op:"C",cx1:20.5156,cy1:-238.641,cx2:7.60938,cy2:-269.094,x:7.60938,y:-287.969},{op:"C",cx1:7.60938,cy1:-308.156,cx2:19.2031,cy2:-327.016,x:19.8594,y:-327.688},{op:"C",cx1:19.8594,cy1:-328.016,cx2:19.8594,cy2:-328.016,x:19.8594,y:-328.344},{op:"C",cx1:19.8594,cy1:-328.672,cx2:19.8594,cy2:-329,x:19.5313,y:-329.344},{op:"C",cx1:19.2031,cy1:-329.344,cx2:18.5313,cy2:-329.344,x:18.2031,y:-328.672},{op:"C",cx1:17.875,cy1:-328.344,cx2:0,cy2:-310.469,x:0,y:-283.328},{op:"C",cx1:0,cy1:-254.203,cx2:11.5781,cy2:-233.688,x:11.5781,y:-195.625},{op:"C",cx1:11.5781,cy1:-188.328,cx2:8.60938,cy2:-176.75,x:.328125,y:-166.484},{op:"C",cx1:0,cy1:-166.484,cx2:0,cy2:-165.828,x:0,y:-165.5},{op:"C",cx1:-.328125,cy1:-165.172,cx2:0,cy2:-164.828,x:.328125,y:-164.5},{op:"C",cx1:8.60938,cy1:-154.25,cx2:11.5781,cy2:-142.656,x:11.5781,y:-135.375},{op:"C",cx1:11.5781,cy1:-97.3125,cx2:0,cy2:-76.7969,x:0,y:-47.6563},{op:"C",cx1:0,cy1:-20.8594,cx2:17.875,cy2:-2.64063,x:18.2031,y:-2.3125},{op:"C",cx1:18.5313,cy1:-1.65625,cx2:19.2031,cy2:-1.32813,x:19.5313,y:-1.65625},{op:"C",cx1:19.8594,cy1:-1.98438,cx2:20.1875,cy2:-2.3125,x:19.8594,y:-2.64063},{op:"C",cx1:19.8594,cy1:-2.64063,cx2:19.8594,cy2:-2.98438,x:19.8594,y:-3.3125},{op:"C",cx1:19.2031,cy1:-3.96875,cx2:7.60938,cy2:-22.8438,x:7.60938,y:-43.0313},{op:"C",cx1:7.60938,cy1:-61.8906,cx2:20.5156,cy2:-92.3438,x:20.5156,y:-122.469},{op:"C",cx1:20.5156,cy1:-146.625,cx2:8.9375,cy2:-159.203,x:2.98438,y:-165.5},{op:"Z"}],an=Bt(Ps),Xt=2.33,se=1.17,xe=.34,Ds=[{op:"M",x:0,y:0},{op:"L",x:0,y:-xe},{op:"C",cx1:Xt*.421,cy1:-xe+se*.077,cx2:Xt*.733,cy2:-xe+se*.346,x:Xt,y:-xe+se},{op:"L",x:Xt*.929,y:-xe+se},{op:"C",cx1:Xt*.696,cy1:-xe+se*.535,cx2:Xt*.328,cy2:-xe+se*.352,x:0,y:0},{op:"Z"}];function Yn(s){return new k("E_VOICES_CONNECT","@voices \u7684 connect \u5FC5\u987B\u662F [\u8D77\u70B9-\u7EC8\u70B9]\u3001{\u8D77\u70B9-\u7EC8\u70B9}\u3001[\u7F16\u53F7] \u6216 {\u7F16\u53F7} \u7684\u7EC4\u5408\uFF1B\u8303\u56F4\u7AEF\u70B9\u53EF\u7701\u7565\uFF0C\u5426\u5219\u987B\u4E3A\u6709\u6548\u58F0\u90E8\u7F16\u53F7\u3002\u7A7A\u5B57\u7B26\u4E32\u8868\u793A\u53EA\u6709\u8FDE\u8C31\u7EBF\u3002",s)}function ca(s,t){let e=s.trim(),n=/\s*([\[{])\s*(?:(?:(\d+)\s*)?-\s*(?:(\d+)\s*)?|(\d+)\s*)([\]}])\s*/y,o=[];for(;n.lastIndex<e.length;){let i=n.exec(e);if(!i||i[5]!==(i[1]==="["?"]":"}"))throw Yn(t);let r=i[4]??i[2],a=i[4]??i[3],c=r?Number(r):void 0,l=a?Number(a):void 0;for(let p of[c,l])if(p!==void 0&&(!Number.isSafeInteger(p)||p<1))throw Yn(t);if(c!==void 0&&l!==void 0&&c>l)throw Yn(t);o.push({kind:i[1]==="["?"bracket":"brace",from:c,to:l})}return o}function la(s,t,e){return s.map(({kind:n,from:o=1,to:i=t})=>{if(o>i||i>t)throw Yn(e);return{kind:n,from:o,to:i}})}function Bs(s){return s.map(({kind:t,from:e,to:n})=>{let o=`${e??""}-${n??""}`;return t==="brace"?`{${o}}`:`[${o}]`}).join("")}var Ol=/\s/,pa=2.5,ua=.3,ha=new Set("\uFF08([\uFF3B\uFF5B\u3008\u300A\u300C\u300E\u3010\u3014\u3016\u3018\u301A\u2018\u201C"),Fs=new Set([...ha,...`\uFF0C\u3002\uFF01\uFF1F\uFF1B\uFF1A\u3001,.!?;:\uFF09)]\uFF3D\uFF5D\u3009\u300B\u300D\u300F\u3011\u3015\u3017\u3019\u301B\u2019\u201D"'\u2026\u2014\u2013`]);function fa(s){let t=0,e=s.length;for(;t<e&&Fs.has(s[t]);)t++;for(;e>t&&Fs.has(s[e-1]);)e--;return{prefix:s.slice(0,t),body:s.slice(t,e)}}function $l(s){let t=s/2;return(e,n)=>{let o=e.map(c=>c&&c.bottom-c.top>1e-6?c:{top:-t,bottom:t}),i=[],r=0;for(let c=0;c<o.length;c++)c>0&&(r+=o[c-1].bottom+n-o[c].top),i.push(r);let a=(i[0]+i[i.length-1])/2;return i.map((c,l)=>({offset:c-a,extent:o[l]}))}}var ye=class s extends ${static def={name:["voice","v"],description:"\u58F0\u90E8",details:`~~~jpfun
|
|
91
|
-
|
|
99
|
+
\u672C\u4F8B\u6700\u77ED\u5355\u4F4D\u4E3A\u516B\u5206\u97F3\u7B26\uFF0C\u539F\u5185\u5BB9\u5360 5 \u4E2A\u5355\u4F4D\uFF0C\u7F29\u653E\u540E\u5360 4 \u4E2A\u5355\u4F4D\uFF1A\u5F62\u6210\u4E94\u8FDE\u97F3\uFF0C\u603B\u65F6\u957F\u4E3A\u4E00\u4E2A\u4E8C\u5206\u97F3\u7B26`,allowExtraArgs:!1,args:[{type:"content",description:"\u8FDE\u97F3\u5185\u5BB9\uFF0C\u5404\u5143\u7D20\u6309\u540C\u4E00\u6BD4\u4F8B\u7F29\u653E\u65F6\u503C",default:null},{name:"normal",description:"\u76EE\u6807\u603B\u65F6\u957F\uFF0C\u4EE5\u5185\u5BB9\u4E2D\u7684\u6700\u77ED\u65F6\u503C\u4E3A\u5355\u4F4D",type:"number",default:null}]};content;normal;font;get children(){return[this.content]}loweringEnter(t){let e={nodes:[],attachments:[],onTemporal(n){e.nodes.push(n)},onAttachment(n){e.attachments.push(n)}};return t.beginLoweringGroup(this,e),[]}loweringExit(t,e,n){let o=t.endLoweringGroup(this),s=o.nodes.filter(f=>f.T.compare(0)>0);if(s.length===0)throw new k("E_TUPLET_EMPTY","@tuplet \u7684\u5185\u5BB9\u5FC5\u987B\u4EA7\u751F\u81F3\u5C11\u4E00\u4E2A\u6B63\u65F6\u503C\u4E8B\u4EF6",this.sourceSpan);let i=s[0].track;if(s.some(f=>f.track!==i))throw new k("E_TUPLET_PARALLEL_CONTENT","@tuplet \u7684\u5185\u5BB9\u4E0D\u80FD\u5305\u542B\u5E76\u884C\u97F3\u8F68",this.sourceSpan);let a=s[0].T.clone(),c=new G;for(let f of s)f.T.compare(a)<0&&a.copyFrom(f.T),c.add(f.T);let l=c.div(a),u=l.numerator;if(l.denominator!==1||u<2||!Number.isSafeInteger(u))throw new k("E_TUPLET_NON_INTEGRAL_UNITS","@tuplet \u7684\u603B\u65F6\u503C\u5FC5\u987B\u662F\u6700\u77ED\u6B63\u65F6\u503C\u7684\u6574\u6570\u500D\uFF0C\u4E14\u81F3\u5C11\u5305\u542B2\u4E2A\u5355\u4F4D",this.sourceSpan);if(this.normal===u)throw new k("E_TUPLET_INVALID_RATIO","@tuplet \u7684 normal \u4E0D\u80FD\u7B49\u4E8E\u63A8\u5BFC\u51FA\u7684 actual ({actual})",this.sourceSpan,{actual:u});let p=o.nodes[0].t;for(let f=1;f<o.nodes.length;f++)o.nodes[f].t.compare(p)<0&&(p=o.nodes[f].t);p=p.clone();let m=new G;for(let f of o.nodes)m.copyFrom(f.t).sub(p).mul(this.normal,u),f.t.copyFrom(p).add(m),f.T.mul(this.normal,u);n.copyFrom(p).add(a.mul(this.normal));let d=s.filter(W);if(d.length>=2){let f=new ss(d,u,this.sourceSpan,this.font,o);t.addAttachment(f),t.deferFinalize(()=>f.validate())}return[]}constructor(t,e,n,o=null){super(t,o);let[s,i]=this.getArgValue(e,n);if(this.font=n.variables.numberfont,!Number.isSafeInteger(i)||i<=0)throw new k("E_TUPLET_INVALID_NORMAL","@tuplet \u7684 normal \u5FC5\u987B\u662F\u6B63\u7684\u5B89\u5168\u6574\u6570",t);this.content=s,this.normal=i,s.parent=this}toString(t){return`@tuplet(${this.content.toString(t)}, ${this.normal})`}},tc=rs,ss=class{constructor(t,e,n,o,s){this.content=s;this.endPoints=t,this.actual=e,this.sourceSpan=n,this.size=t.reduce((i,a)=>Math.max(i,a.ast.size),0),this.style={fontSize:this.size*.72,fontFamily:o,textAlign:"center",fill:"#000"}}content;layer="foreground";endPoints;actual;sourceSpan;style;size;validate(){let t=this.endPoints[0];if(this.endPoints.some(e=>e.layoutLine!==t.layoutLine))throw new k("E_TUPLET_CROSS_LINE","@tuplet \u7684\u5185\u5BB9\u4E0D\u80FD\u8DE8\u8D8A\u8C31\u9762\u884C",this.sourceSpan)}createGeometry(t){let e=this.endPoints[0],n=this.endPoints[this.endPoints.length-1],o=e.ports["body.left"]?.x??0,s=n.ports["body.right"]?.x??n.box.w,i=e.box.x+o,a=n.box.x+s;i>a&&([i,a]=[a,i]);let c=t.textMeasurer.measureText(String(this.actual),this.style),l=(i+a)/2,u=this.size*.12,p=this.size*.18,m=this.size*.14,d=t.getVisualAxis(e.layoutLine,e.track),f=t.getRangeExtents(e.layoutLine,[e,n],e.track),x=t.getContentBounds(this.content),y=Math.min(d+(f?.top??0),x?.y??1/0),h=Math.max(1,this.size*.055),g=y-m-Math.max(p,c.h/2),b=g+p,T=g-c.h/2+c.baseline,L=l-c.w/2-u,w=l+c.w/2+u,A=[];L>i&&A.push([i,g,L,g]),w<a&&A.push([w,g,a,g]),A.push([i,g,i,b],[a,g,a,b]);let C=h/2,_=Math.min(g-c.h/2,g-C),E=Math.max(g+c.h/2,b+C),v=[{x:i-C,y:_,w:a-i+h,h:E-_,line:e.layoutLine,track:e.track}],S=String(this.actual),M=this.style;return{regions:v,paint(I){let z={stroke:"#000",strokeWidth:h};for(let[j,q,et,N]of A)I.drawLine(j,q,et,N,z);I.drawText(S,l,T,M)}}}};var Nu=/\s/,vu=.82,nc=new Set("\uFF08([\uFF3B\uFF5B\u3008\u300A\u300C\u300E\u3010\u3014\u3016\u3018\u301A\u2018\u201C"),is=new Set([...nc,...`\uFF0C\u3002\uFF01\uFF1F\uFF1B\uFF1A\u3001,.!?;:\uFF09)]\uFF3D\uFF5D\u3009\u300B\u300D\u300F\u3011\u3015\u3017\u3019\u301B\u2019\u201D"'\u2026\u2014\u2013`]);function lo(r,t){return{fontFamily:t,fontSize:r*vu,fill:"#000"}}function ec(r,t,e){let n=Yt(r,t,e),o=n.runs.map(c=>c.text).join(""),s=0,i=o.length;for(;s<i&&is.has(o[s]);)s++;for(;i>s&&is.has(o[i-1]);)i--;let a=(c,l)=>{let u=0,p=0;for(let m of n.runs){let d=p+m.text.length,f=Math.max(c,p),x=Math.min(l,d);f<x&&(u+=f===p&&x===d?m.w:e.measureText(m.text.slice(f-p,x-p),m.style).w),p=d}return u};return{richLine:n,prefixWidth:a(0,s),bodyWidth:a(s,i)}}function oc(r){let t=0;for(let c=0;c<r.length;c++)r[c]==="\\"?c++:r[c]==="}"&&t++;let e=[],n=[],o=!1,s=!1,i=(c,l)=>{ne(n,c,l),o=!0},a=(c=!1)=>{!c&&!o||(e.push(n),n=[],o=!1)};if(cn(r,(c,l,u)=>{if(!u&&c==="}"&&t--,s)!u&&c==="}"?(a(!0),s=!1):ne(n,c,l);else if(!u&&c==="{"&&t>0)a(),s=!0;else if(u)i(c,l);else if(Nu.test(c))a();else if(c==="-"){let p=o;i(c,l),p&&a()}else c==="@"?(o&&(i(c,l),a()),e.push([])):nc.has(c)?(a(),ne(n,c,l)):is.has(c)?ne(n.length>0||!e.at(-1)?.length?n:e.at(-1),c,l):c.charCodeAt(0)>127?(a(),i(c,l),a()):i(c,l)},"\\*_{}@-^"),a(),n.length>0)if(e.at(-1)?.length)for(let c of n)ne(e.at(-1),c.text,c.mask);else e.push(n);return e}function rc(r){return lt(r.map(t=>{if(t.length===0)return"@";let e=0,n="";for(let o of t)n+=Gn(e^o.mask)+o.text.replace(/[\\{}@\-*_^]/g,"\\$&"),e=o.mask;return`{${n}${Gn(e)}}`}).join(" "))}var uo=class{constructor(t,e,n){this.nodes=t;this.nameHost=e;this.frames=n}nodes;nameHost;frames;layer="foreground";get sourceSpan(){return this.nameHost.ast.sourceSpan}prepareHorizontal(t,e){let n=this.nodes.filter(c=>c.ports?.lyric);if(n.length===0)return;let{lyrics:o,size:s,font:i}=this.nameHost.ast,a=lo(s,i);for(let c=0;c<n.length;c++){let l=n[c],u=0;for(let p of o){let m=p.tokens[c];m?.length&&(u=Math.max(u,ec(m,a,e.textMeasurer).bodyWidth/2))}u!==0&&t[l.layoutLine]?.registerHorizontalLayoutHook(l,l,({columns:p,start:m})=>{let d=p[m].find(x=>x.time===l);if(!d)return;let f=l.ports.lyric.x-l.box.anchor;d.WL=Math.max(d.WL,u-f),d.WR=Math.max(d.WR,u+f)})}}createGeometry(t){let e=this.prepareGeometry(t);return{regions:e,paint(n){for(let o of e)oe(n,o,o.x,o.y+o.baseline)}}}prepareGeometry(t){let{lyrics:e,size:n,font:o}=this.nameHost.ast,s=[],i=this.nodes.filter(y=>y.ports?.lyric);if(i.length===0)return s;let a=new Map;for(let y of i){let h=a.get(y.layoutLine);h||a.set(y.layoutLine,h=new Map);let g=h.get(y.track)??{bottom:-1/0,owner:y.track},b=St(y),T=b.y+b.h,L=y.track;for(let w of this.frames){let A=t.getAttachmentBox(w);if(A.x+A.w<b.x||A.x>b.x+b.w||A.y+A.h<=T)continue;let C=t.getAttachmentOccupancy(w);if(!C)throw new Error("Layout attachment dependency has not been measured");let _=C.filter(E=>E.line===y.layoutLine);if(!(C.some(E=>E.line!==void 0)&&_.length===0)){T=A.y+A.h;for(let E of _)E.line!==void 0&&t.getVisualAxis(E.line,E.track)>t.getVisualAxis(y.layoutLine,L)&&(L=E.track)}}T>=g.bottom&&(g.owner=L),g.bottom=Math.max(g.bottom,T),h.set(y.track,g)}let c=lo(n,o),l=c.fontSize+n*.24,u=t.textMeasurer.measureText("M",c).baseline+n*.32,p=(y,h)=>y+u+h*l;if(this.frames.length)for(let[y,h]of a){if(h.size<2)continue;let g=new Map;for(let[,b]of[...h].sort(([T],[L])=>t.getVisualAxis(y,T)-t.getVisualAxis(y,L))){let T=g.get(b.owner)??0;b.bottom+=T*e.length*l,g.set(b.owner,T+1)}}let{box:m,layoutLine:d,track:f}=this.nameHost,x=a.get(d)?.get(f);for(let y=0;y<e.length;y++){let h=e[y];for(let b=0;b<h.tokens.length&&b<i.length;b++){let T=h.tokens[b],L=i[b],w=a.get(L.layoutLine)?.get(L.track);if(!T.length||!w)continue;let{richLine:A,prefixWidth:C,bodyWidth:_}=ec(T,c,t.textMeasurer);s.push({...A,x:L.box.x+L.ports.lyric.x-_/2-C,y:p(w.bottom,y)-A.baseline,line:L.layoutLine,track:w.owner})}if(!h.name||!m||!x)continue;let g=Yt(h.name,c,t.textMeasurer);s.push({...g,x:m.x+m.anchor-g.w,y:p(x.bottom,y)-g.baseline,line:d,track:x.owner})}return s}};var cs=[{op:"M",x:2.98438,y:-165.5},{op:"C",cx1:8.9375,cy1:-171.781,cx2:20.5156,cy2:-184.688,x:20.5156,y:-208.531},{op:"C",cx1:20.5156,cy1:-238.641,cx2:7.60938,cy2:-269.094,x:7.60938,y:-287.969},{op:"C",cx1:7.60938,cy1:-308.156,cx2:19.2031,cy2:-327.016,x:19.8594,y:-327.688},{op:"C",cx1:19.8594,cy1:-328.016,cx2:19.8594,cy2:-328.016,x:19.8594,y:-328.344},{op:"C",cx1:19.8594,cy1:-328.672,cx2:19.8594,cy2:-329,x:19.5313,y:-329.344},{op:"C",cx1:19.2031,cy1:-329.344,cx2:18.5313,cy2:-329.344,x:18.2031,y:-328.672},{op:"C",cx1:17.875,cy1:-328.344,cx2:0,cy2:-310.469,x:0,y:-283.328},{op:"C",cx1:0,cy1:-254.203,cx2:11.5781,cy2:-233.688,x:11.5781,y:-195.625},{op:"C",cx1:11.5781,cy1:-188.328,cx2:8.60938,cy2:-176.75,x:.328125,y:-166.484},{op:"C",cx1:0,cy1:-166.484,cx2:0,cy2:-165.828,x:0,y:-165.5},{op:"C",cx1:-.328125,cy1:-165.172,cx2:0,cy2:-164.828,x:.328125,y:-164.5},{op:"C",cx1:8.60938,cy1:-154.25,cx2:11.5781,cy2:-142.656,x:11.5781,y:-135.375},{op:"C",cx1:11.5781,cy1:-97.3125,cx2:0,cy2:-76.7969,x:0,y:-47.6563},{op:"C",cx1:0,cy1:-20.8594,cx2:17.875,cy2:-2.64063,x:18.2031,y:-2.3125},{op:"C",cx1:18.5313,cy1:-1.65625,cx2:19.2031,cy2:-1.32813,x:19.5313,y:-1.65625},{op:"C",cx1:19.8594,cy1:-1.98438,cx2:20.1875,cy2:-2.3125,x:19.8594,y:-2.64063},{op:"C",cx1:19.8594,cy1:-2.64063,cx2:19.8594,cy2:-2.98438,x:19.8594,y:-3.3125},{op:"C",cx1:19.2031,cy1:-3.96875,cx2:7.60938,cy2:-22.8438,x:7.60938,y:-43.0313},{op:"C",cx1:7.60938,cy1:-61.8906,cx2:20.5156,cy2:-92.3438,x:20.5156,y:-122.469},{op:"C",cx1:20.5156,cy1:-146.625,cx2:8.9375,cy2:-159.203,x:2.98438,y:-165.5},{op:"Z"}],gn=Gt(cs),se=2.33,ue=1.17,Te=.34,ls=[{op:"M",x:0,y:0},{op:"L",x:0,y:-Te},{op:"C",cx1:se*.421,cy1:-Te+ue*.077,cx2:se*.733,cy2:-Te+ue*.346,x:se,y:-Te+ue},{op:"L",x:se*.929,y:-Te+ue},{op:"C",cx1:se*.696,cy1:-Te+ue*.535,cx2:se*.328,cy2:-Te+ue*.352,x:0,y:0},{op:"Z"}],as=/\s*([\[{])\s*(?:(?:(\d+)\s*)?-\s*(?:(\d+)\s*)?|(\d+)\s*)/y,sc=/\s/,ic=/[\[\]{}:"\r\n]/;function Le(r){return new k("E_VOICES_CONNECT","@voices \u7684 connect \u5FC5\u987B\u662F [\u8D77\u70B9-\u7EC8\u70B9]\u3001{\u8D77\u70B9-\u7EC8\u70B9}\u3001[\u7F16\u53F7] \u6216 {\u7F16\u53F7}\uFF08\u53EF\u7528 :\u540D\u79F0 \u6307\u5B9A\u5206\u7EC4\u540D\uFF09\u7684\u7EC4\u5408\uFF1B\u8303\u56F4\u7AEF\u70B9\u53EF\u7701\u7565\uFF0C\u5426\u5219\u987B\u4E3A\u6709\u6548\u58F0\u90E8\u7F16\u53F7\u3002\u7A7A\u5B57\u7B26\u4E32\u8868\u793A\u53EA\u6709\u8FDE\u8C31\u7EBF\u3002",r)}function ac(r,t){let e=r.trim(),n=[];for(let o=0;o<e.length;o++){as.lastIndex=o;let s=as.exec(e);if(!s)throw Le(t);o=as.lastIndex;let i=s[1]==="["?"]":"}",a=s[4]??s[2],c=s[4]??s[3],l=a?Number(a):void 0,u=c?Number(c):void 0;for(let m of[l,u])if(m!==void 0&&(!Number.isSafeInteger(m)||m<1))throw Le(t);if(l!==void 0&&u!==void 0&&l>u)throw Le(t);let p;if(e[o]===":"){for(o++;o<e.length&&sc.test(e[o]);)o++;if(e[o]==='"'){let m=$t(e,o,e.length),d=m<0?null:jn(e.slice(o,m+1));if(typeof d!="string"||!d)throw Le(t);for(p=d,o=m+1;o<e.length&&sc.test(e[o]);)o++}else{let m=e.indexOf(i,o),d=m<0?"":e.slice(o,m);if(p=ic.test(d)?"":d.trim(),!p)throw Le(t);o=m}}if(e[o]!==i)throw Le(t);n.push({kind:s[1]==="["?"bracket":"brace",from:l,to:u,...p?{name:p}:{}})}return n}function cc(r,t,e){return r.map(({kind:n,from:o=1,to:s=t,name:i})=>{if(o>s||s>t)throw Le(e);return{kind:n,from:o,to:s,...i?{name:i}:{}}})}function us(r){return r.map(({kind:t,from:e,to:n,name:o})=>{let s=o?`:${ic.test(o)||o.trim()!==o?lt(o):o}`:"",i=`${e??""}-${n??""}${s}`;return t==="brace"?`{${i}}`:`[${i}]`}).join("")}var lc=2.5,uc=.3,ku=.5;function Eu(r,t,e){let n=Object.assign(o=>{let s=n.size/2,i=Math.min(n.gap,n.minGap),a=o.map(p=>p?{top:Math.min(p.top,-s),bottom:Math.max(p.bottom,s)}:{top:-s,bottom:s}),c=[],l=0;for(let p=0;p<a.length;p++)p>0&&(l+=a[p-1].bottom+Math.max(n.gap+s,i-a[p].top)),c.push(l);let u=(c[0]+c[c.length-1])/2;return c.map((p,m)=>({offset:p-u,extent:a[m]}))},{size:r,gap:t,minGap:e});return n}function Pu(r,t,e,n,o){let s=1;for(let i=t;i<e;i++){let a=r[i];if(a==='"'){if(i=$t(r,i,e),i<0)return-1}else{if(a==="\r"||a===`
|
|
100
|
+
`)return-1;if(a===n)s++;else if(a===o&&--s===0)return i}}return-1}var ie=class r extends B{static def={name:["voices","vs"],description:"\u591A\u4E2A\u58F0\u90E8",details:`~~~jpfun
|
|
101
|
+
@voices(
|
|
102
|
+
@voice({1 2 3}, \u53F3\u624B, \u7537=ha ha ha),
|
|
103
|
+
@voice({3 4 5}, \u5DE6\u624B, "la la la"),
|
|
104
|
+
connect="{-:\u94A2\u7434}"
|
|
105
|
+
)
|
|
92
106
|
~~~
|
|
93
|
-
- **\u989D\u5916\u53C2\u6570**\uFF1A\u6BCF\u9879\u4E3A\u4E00\u884C\u6B4C\u8BCD\uFF1B\u547D\u540D\u53C2\u6570\u540C\u65F6\u7ED9\u51FA\u6B4C\u8BCD\u884C\u540D\uFF0C\u4F4D\u7F6E\u53C2\u6570\u8868\u793A\u65E0\u884C\u540D\u3002\u7701\u7565\u58F0\u90E8\u540D\u4F46\u4ECD\u9700\u6B4C\u8BCD\u65F6\uFF0C\u4FDD\u7559\u7A7A\u4F4D\uFF0C\u5982 \`@voice({1 2 3}, , ha ha ha)\`\u3002
|
|
94
107
|
|
|
95
|
-
\
|
|
108
|
+
\u63A5\u6536\u591A\u4E2A \`@voice\`\uFF0C\u6309\u4E66\u5199\u987A\u5E8F\u81EA\u4E0A\u800C\u4E0B\u540C\u65F6\u6F14\u594F\uFF1B\u53EF\u7528 \`@set(voices.connect="...", voices.gap=1em)\` \u9884\u8BBE\u9ED8\u8BA4\u53C2\u6570\u3002
|
|
109
|
+
|
|
110
|
+
**\u7B80\u5199**\uFF1A\u8FDE\u7EED\u7684 \`N:\`\uFF08\u53CA \`L:\`\uFF09\u81EA\u52A8\u5408\u4E3A\u591A\u58F0\u90E8\uFF0C\u7A7A\u884C\u5206\u6BB5\u3002\u53EF\u7528 \`V{\u7EC4\u540D}:\`\uFF08\u82B1\u8FDE\u8C31\u53F7\uFF09\u3001\`V[\u7EC4\u540D]:\`\uFF08\u76F4\u8FDE\u8C31\u53F7\uFF09\u3001\`V|:\`\uFF08\u8FDE\u8C31\u7EBF\uFF09\u6307\u5B9A\u8FDE\u8C31\u53F7\uFF0C\u7EC4\u540D\u53EF\u7701\u4E14\u652F\u6301 \`*\u659C\u4F53*\`\u3001\`**\u7C97\u4F53**\` \u7B49\u6587\u5B57\u6837\u5F0F\uFF1A
|
|
96
111
|
|
|
97
|
-
**\u7B80\u5199**\uFF1A\`N\` \u58F0\u660E\u97F3\u7B26\u884C\uFF0C\`L\` \u58F0\u660E\u6B4C\u8BCD\u884C\uFF0C\u62EC\u53F7\u5185\u7684\u540D\u79F0\u53EF\u7701\u7565\uFF1A
|
|
98
112
|
~~~jpfun
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
\
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
`
|
|
107
|
-
`)
|
|
108
|
-
${e.
|
|
109
|
-
`)}
|
|
110
|
-
)`}},ie=class s extends ${static def={name:["voices","vs"],description:"\u591A\u4E2A\u58F0\u90E8",details:'~~~jpfun\n@voices(\n @voice({1 2 3}, \u94A2\u7434, \u7537=ha ha ha),\n @voice({3 4 5}, , "la la la")\n)\n~~~\n\n\u63A5\u53D7\u591A\u4E2A\u58F0\u90E8\u4F5C\u4E3A\u4F4D\u7F6E\u53C2\u6570\uFF0C\u5C06\u5B83\u4EEC\u6309\u65F6\u95F4\u5BF9\u9F50\u3001\u5206\u884C\u6392\u5E03\uFF1B\u58F0\u90E8\u540D\u79F0\u548C\u6B4C\u8BCD\u7531\u5404\u81EA\u7684 `@voice` \u63D0\u4F9B\n\n**\u89C6\u89C9\u8FDE\u63A5**\uFF1A\u4EC5\u547D\u540D\u53C2\u6570 `connect` \u4F7F\u7528\u5B57\u7B26\u4E32\uFF0C\u5982 `connect="[1-4]{5-7}"`\u3002\n`[]` \u662F\u73B0\u6709\u62EC\u7EBF\uFF0C`{}` \u662F\u5F2F\u66F2\u5927\u62EC\u53F7\uFF1B\u7F16\u53F7\u4ECE 1 \u5F00\u59CB\uFF0C\u7701\u7565\u8D77\u70B9/\u7EC8\u70B9\u8868\u793A\u9996/\u672B\u58F0\u90E8\u3002\n`[3]` \u7B49\u4EF7\u4E8E `[3-3]`\uFF0C`{3}` \u7B49\u4EF7\u4E8E `{3-3}`\uFF0C\u7528\u4E8E\u5355\u4E2A\u58F0\u90E8\u3002\n\u9ED8\u8BA4 `"[-]"` \u8FDE\u63A5\u5168\u90E8\u58F0\u90E8\uFF1B`""` \u53EA\u4FDD\u7559\u516C\u5171\u7EC6\u8FDE\u8C31\u7EBF\u3002\u672A\u6307\u5B9A\u7684\u58F0\u90E8\u4ECD\u6709\u7EC6\u7EBF\uFF0C\u8303\u56F4\u53EF\u4EE5\u91CD\u53E0\uFF0C\u4E0D\u6539\u53D8\u58F0\u90E8\u6216\u64AD\u653E\u5173\u7CFB\u3002\n\u7528 `@set(voices.connect="{1-2}[3-]")` \u8BBE\u7F6E\u540E\u7EED\u591A\u58F0\u90E8\u5757\u7684\u9ED8\u8BA4\u65B9\u6848\uFF0C\u663E\u5F0F\u53C2\u6570\u5199\u5728\u6240\u6709\u58F0\u90E8\u4E4B\u540E\u3002\n\n**\u7B80\u5199**\uFF1A\u8FDE\u7EED\u58F0\u660E\u591A\u4E2A `N:` \u58F0\u90E8\u53CA\u5176 `L:` \u6B4C\u8BCD\uFF0C\u4F1A\u81EA\u52A8\u7EC4\u6210 `voices`\n\n~~~jpfun\nN(\u94A2\u7434): 1 2 3\nL(\u7537): ha ha ha\nN: 3 4 5\nL: la la la\n~~~\n\n\u8FDE\u63A5\u58F0\u660E `V{}:`\u3001`V[]:`\u3001`V|:` \u5206\u522B\u6307\u5B9A\u540E\u7EED\u58F0\u90E8\u7684\u5F2F\u66F2\u5927\u62EC\u53F7\u3001\u73B0\u6709\u62EC\u7EBF\u548C\u4EC5\u7EC6\u7EBF\uFF0C\u540E\u9762\u7684 `N:` \u53EF\u4EE5\u540C\u884C\uFF0C\u4E5F\u53EF\u4EE5\u6362\u884C\u3002\n\u5230\u4E0B\u4E00\u6761 V \u58F0\u660E\u6216\u5F53\u524D\u5757\u672B\u5C3E\u7ED3\u675F\uFF0C\u7EC4\u95F4\u4E0D\u7A7A\u884C\uFF1B\u7A7A\u884C\u7ED3\u675F\u6574\u4E2A\u591A\u58F0\u90E8\u5757\u3002\n\u51FA\u73B0 V \u58F0\u660E\u65F6\uFF0C\u5F53\u524D\u5757\u5B8C\u6574\u66FF\u6362\u9ED8\u8BA4\u8FDE\u63A5\u65B9\u6848\uFF0C\u4E0D\u5F71\u54CD\u540E\u9762\u7684\u5757\u3002V \u4E0D\u521B\u5EFA\u97F3\u8F68\uFF0CL \u4ECD\u5C5E\u4E8E\u524D\u9762\u7684 N\u3002\n\n~~~jpfun\nV{}: N(\u53F3\u624B): 1 2 3\nN(\u5DE6\u624B): 5 6 7\nV[]: N(\u5973\u9AD8): 6 6 5\nL: \u554A \u554A \u554A\nN(\u5973\u4F4E): 1 2 3\n~~~',allowExtraArgs:!0,extraArgType:"content",args:[{name:"connect",namedOnly:!0,type:"string",default:"[-]",description:"\u89C6\u89C9\u8FDE\u63A5\uFF1A[1-4] \u4E3A\u73B0\u6709\u62EC\u7EBF\uFF0C{5-7} \u4E3A\u5F2F\u66F2\u5927\u62EC\u53F7\uFF1B[3]\u3001{3} \u8868\u793A\u5355\u4E2A\u58F0\u90E8\uFF0C\u7701\u7565\u8303\u56F4\u7AEF\u70B9\u8868\u793A\u9996/\u672B\u58F0\u90E8\uFF0C\u7A7A\u5B57\u7B26\u4E32\u53EA\u4FDD\u7559\u516C\u5171\u8FDE\u8C31\u7EBF\u3002"}]};static deSugarAtom(t,e,n){if(t[e]!=="V")return null;let o=/^V(\{\}|\[\]|\|):/.exec(t.slice(e,n));if(!o)return null;let i=e+o[0].length,r={kind:"sugar",data:{class:s,kind:o[1]==="{}"?"brace":o[1]==="[]"?"bracket":"line"},span:{start:e,end:i}};return{next:i,node:r}}static deSugarRelation(t,e,n){let o=e[n];if(typeof o=="number"||o.kind!=="sugar"||o.data?.class!==s)return null;let i=t.nodes.length-1;for(;i>=0&&t.nodes[i]instanceof xt;){let{sourceSpan:h}=t.nodes[i],d=t.source.slice(h.start,h.end);if(d.includes(`
|
|
111
|
-
`)||d.trim())break;i--}let r=t.nodes[i],a=r instanceof ye?[r]:r instanceof s&&r.createdBySugar?[...r.voices]:[],c=a.length>0,l=[],p=n;for(;p<e.length;){let h=e[p];if(typeof h=="number"||h.kind!=="sugar"||h.data?.class!==s)break;p++;let d=e[p];typeof d=="number"&&t.source[d]==="\r"&&p++;let y=e[p];typeof y=="number"&&t.source[y]===`
|
|
112
|
-
`&&p++;let m=new _t(t),g=a.length+1;for(;p<e.length;){let x=e[p];if(typeof x=="number"||x.kind!=="sugar"||x.data?.class!==ye)break;p=ye.deSugarRelation(m,e,p,a)}if(a.length<g)throw new k("E_VOICES_GROUP_EMPTY","V \u58F0\u90E8\u5206\u7EC4\u5FC5\u987B\u81F3\u5C11\u5305\u542B\u4E00\u6761 N: \u58F0\u90E8\u58F0\u660E",h.span);(h.data.kind==="brace"||h.data.kind==="bracket")&&l.push({kind:h.data.kind,from:g,to:a.length})}let f=new Map;a.forEach((h,d)=>f.set(d,h)),f.set("connect",Bs(l));let u=new s({start:c?r.sourceSpan.start:o.span.start,end:a.at(-1).sourceSpan.end},f,t);return u.createdBySugar=!0,c&&(t.nodes.length=i),t.pushNode(u),p}voices;createdBySugar=!1;size;braceSpace;connect;get connectionSpecs(){return ca(this.connect,this.sourceSpan)}measure;get children(){return this.voices}timeFlowModel(){return{children:this.children,mode:"parallel",tracks:{laneKey:`voices/${this.voices.length}`,hostIndex:null,measure:this.measure}}}loweringEnter(t){let e=[];return t.beginLoweringGroup(this,{attachment:new Hs(e,this,la(this.connectionSpecs,this.voices.length,this.sourceSpan)),onTemporal:n=>{n instanceof Xn&&n.ast.parent===this&&e.push(n)}}),[]}loweringExit(t){return t.endLoweringGroup(this),[]}constructor(t,e,n,o=null){super(t,o),this.voices=[],this.size=n.variables.fontsize,this.braceSpace=Math.max(n.variables.fontsize,(pa*(Xt+.5)+.5)/(1-ua)),this.measure=$l(n.variables.fontsize),[this.connect]=this.getArgValue(e,n);for(let[i,r]of e){if(i==="connect")continue;let a=r instanceof Tt?r.sourceSpan:r.valueSpan,c=r instanceof Tt?r:n.parseArgWithType(a,"content",t.start);if(!(c instanceof ye))throw new k("E_VOICES_INVALID_CHILD",`@voices \u7684\u53C2\u6570\u5FC5\u987B\u662F @voice \u51FD\u6570\uFF0C\u4F46\u53D1\u73B0\u4E86\u5176\u4ED6\u7C7B\u578B ${c?.constructor.name}`,a);this.addVoice(c)}if(this.voices.length===0)throw new k("E_VOICES_EMPTY","@voices \u5FC5\u987B\u81F3\u5C11\u5305\u542B\u4E00\u4E2A @voice \u51FD\u6570",t)}addVoice(t){this.voices.push(t),t.parent=this,this.sourceSpan.start=Math.min(t.sourceSpan.start,this.sourceSpan.start),this.sourceSpan.end=Math.max(t.sourceSpan.end,this.sourceSpan.end)}toString(t){let e=this.voices.map(n=>` ${n.toString(t)}`);return e.push(` connect=${ht(Bs(this.connectionSpecs))}`),`@voices(
|
|
113
|
+
V{\u94A2\u7434}:
|
|
114
|
+
N(\u53F3\u624B): 1 2 3
|
|
115
|
+
N(\u5DE6\u624B): 5 6 7
|
|
116
|
+
V[\u5408\u5531]:
|
|
117
|
+
N(\u5973\u9AD8): 6 6 5
|
|
118
|
+
L: \u554A \u554A \u554A
|
|
119
|
+
N(\u5973\u4F4E): 1 2 3
|
|
120
|
+
~~~`,allowExtraArgs:!0,extraArgType:"content",args:[{name:"connect",namedOnly:!0,type:"string",default:"[-]",description:"\u8FDE\u8C31\u53F7\uFF1A`[\u8D77\u70B9-\u7EC8\u70B9]` \u4E3A\u62EC\u7EBF\uFF0C`{\u8D77\u70B9-\u7EC8\u70B9}` \u4E3A\u5927\u62EC\u53F7\uFF0C`[3]`/`{3}` \u8868\u793A\u5355\u58F0\u90E8\uFF1B\u7AEF\u70B9\u53EF\u7701\uFF0C\u540E\u53EF\u63A5 `:\u540D\u79F0` \u6307\u5B9A\u5206\u7EC4\u603B\u540D\u79F0\uFF0C\u7A7A\u4E32\u4EC5\u4FDD\u7559\u516C\u5171\u7EC6\u7EBF\u3002"},{name:"gap",namedOnly:!0,type:"length",default:{value:.75,unit:"em"},description:"\u76F8\u90BB\u58F0\u90E8\u4E3B\u65CB\u5F8B\u4E4B\u95F4\u7684\u6807\u51C6\u95F4\u8DDD"},{name:"minGap",namedOnly:!0,type:"length",default:{value:.35,unit:"em"},description:"\u4E0A\u65B9\u8BB0\u53F7\u501F\u7528\u95F4\u8DDD\u540E\u4FDD\u7559\u7684\u6700\u5C0F\u95F4\u8DDD"}]};static deSugarAtom(t,e,n){if(t[e]!=="V")return null;if(t.startsWith("V|:",e)&&e+3<=n)return{next:e+3,node:{kind:"sugar",data:{class:r,kind:"line"},span:{start:e,end:e+3}}};let o=t[e+1];if(o!=="{"&&o!=="[")return null;let s=Pu(t,e+2,n,o,o==="{"?"}":"]");return s<0||s+1>=n||t[s+1]!==":"?null:{next:s+2,node:{kind:"sugar",data:{class:r,kind:o==="{"?"brace":"bracket",name:{start:e+2,end:s}},span:{start:e,end:s+2}}}}static deSugarRelation(t,e,n){let o=e[n];if(typeof o=="number"||o.kind!=="sugar"||o.data?.class!==r)return null;let s=t.nodes.length-1;for(;s>=0&&t.nodes[s]instanceof kt;){let{sourceSpan:d}=t.nodes[s],f=t.source.slice(d.start,d.end);if(f.includes(`
|
|
121
|
+
`)||f.trim())break;s--}let i=t.nodes[s],a=i instanceof pe?[i]:i instanceof r&&i.createdBySugar?[...i.voices]:[],c=a.length>0,l=[],u=n;for(;u<e.length;){let d=e[u];if(typeof d=="number"||d.kind!=="sugar"||d.data?.class!==r)break;u++;let f=e[u];typeof f=="number"&&t.source[f]==="\r"&&u++;let x=e[u];typeof x=="number"&&t.source[x]===`
|
|
122
|
+
`&&u++;let y=new _t(t),h=a.length+1;for(;u<e.length;){let g=e[u];if(typeof g=="number"||g.kind!=="sugar"||g.data?.class!==pe)break;u=pe.deSugarRelation(y,e,u,a)}if(a.length<h)throw new k("E_VOICES_GROUP_EMPTY","V \u58F0\u90E8\u5206\u7EC4\u5FC5\u987B\u81F3\u5C11\u5305\u542B\u4E00\u6761 N: \u58F0\u90E8\u58F0\u660E",d.span);if(d.data.kind==="brace"||d.data.kind==="bracket"){let g=d.data.name?t.parseArgWithType(d.data.name,"string")??"":"";l.push({kind:d.data.kind,from:h,to:a.length,...g?{name:g}:{}})}}let p=new Map;a.forEach((d,f)=>p.set(f,d)),p.set("connect",us(l));let m=new r({start:c?i.sourceSpan.start:o.span.start,end:a.at(-1).sourceSpan.end},p,t);return m.createdBySugar=!0,c&&(t.nodes.length=s),t.pushNode(m),u}voices;createdBySugar=!1;size;font;gap;minGap;connect;get braceSpace(){return Math.max(this.size,(lc*(se+.5)+.5)/(1-uc))}get connectionSpecs(){return ac(this.connect,this.sourceSpan)}get children(){return this.voices}timeFlowModel(){return{children:this.children,mode:"parallel",tracks:{laneKey:`voices/${this.voices.length}`,hostIndex:null,measure:Eu(this.size,this.gap,this.minGap)}}}loweringExit(t,e){let n=cc(this.connectionSpecs,this.voices.length,this.sourceSpan);if(this.voices.length>=2){let i=this.voices.map(a=>t.getTemporalNodes(a)[0]);t.addAttachment(new ps(i,this,n))}let o=`voices/${this.voices.length}`,s=e.groups.find(i=>i.laneKey===o)?.measure;return s&&(this.voices.length>=2&&(Math.abs(s.gap-this.gap)>1e-6||Math.abs(s.minGap-this.minGap)>1e-6)&&t.diagnostics.push(new K("W_VOICES_GAP_CONFLICT","\u76F8\u540C\u58F0\u90E8\u6570\u7684 @voices \u5171\u7528\u97F3\u8F68\u4F46\u8BBE\u7F6E\u4E86\u4E0D\u540C\u7684\u95F4\u8DDD\uFF0C\u5C06\u53D6\u8F83\u5927\u503C",this.sourceSpan)),s.size=Math.max(s.size,this.size),s.gap=Math.max(s.gap,this.gap),s.minGap=Math.max(s.minGap,this.minGap)),[]}constructor(t,e,n,o=null){super(t,o),this.voices=[],this.size=n.variables.fontsize,this.font=n.variables.font;let[s,i,a]=this.getArgValue(e,n);if(this.connect=s,this.gap=n.length2px(i),this.minGap=n.length2px(a),!Number.isFinite(this.gap)||this.gap<0||!Number.isFinite(this.minGap)||this.minGap<0)throw new k("E_INVALID_VOICES_GAP","@voices \u7684 gap \u548C minGap \u5FC5\u987B\u662F\u975E\u8D1F\u6709\u9650\u957F\u5EA6",t);for(let[c,l]of e)if(typeof c!="string"){if(!(l instanceof pe))throw new k("E_VOICES_INVALID_CHILD","@voices \u7684\u53C2\u6570\u5FC5\u987B\u662F @voice \u51FD\u6570\uFF0C\u4F46\u53D1\u73B0\u4E86\u5176\u4ED6\u7C7B\u578B {actual}",l.sourceSpan,{actual:String(l?.constructor.name)});this.addVoice(l)}if(this.voices.length===0)throw new k("E_VOICES_EMPTY","@voices \u5FC5\u987B\u81F3\u5C11\u5305\u542B\u4E00\u4E2A @voice \u51FD\u6570",t)}addVoice(t){this.voices.push(t),t.parent=this,this.sourceSpan.start=Math.min(t.sourceSpan.start,this.sourceSpan.start),this.sourceSpan.end=Math.max(t.sourceSpan.end,this.sourceSpan.end)}toString(t){let e=this.voices.map(n=>` ${n.toString(t)}`);return e.push(` connect=${lt(us(this.connectionSpecs))}`,` gap=${this.gap}px`,` minGap=${this.minGap}px`),`@voices(
|
|
113
123
|
${e.join(`,
|
|
114
124
|
`)}
|
|
115
|
-
)`}},da=ye,ma=ie,zs=.82,Pl=.6;function xa(s,t){return{fontFamily:t,fontSize:s*zs,fill:"#000",fontWeight:600}}var Xn=class extends tt{braceSpace;textBaselineY=0;constructor(t,e){super(),this.ast=t,this.braceSpace=e,this.mergeKey=-2,(t.name||e>0||t.lyrics.some(n=>n.name))&&this.initLayoutBox()}prepareLayout(t){let e=this.ast.name?t.textMeasurer.measureText(this.ast.name,this.style):{w:0,h:0,baseline:0},n=e.w;for(let i of this.ast.lyrics){if(!i.name)continue;let r=t.textMeasurer.measureText(i.name,xa(this.ast.size,this.ast.font));n=Math.max(n,r.w)}let o=this.braceSpace>0?this.braceSpace:n>0?this.ast.size*Pl:0;this.box.w=n+o,this.box.h=e.h,this.box.anchor=n,this.box.visualAxis=e.h/2,this.textBaselineY=e.baseline,this.springConfig.alpha_R=.45}get style(){return{fontSize:this.ast.size*.85,fontFamily:this.ast.font,fill:"#000",fontWeight:600,textAlign:"right"}}paint(t){this.ast.name&&t.drawText(this.ast.name,this.box.x+this.box.anchor,this.box.y+this.textBaselineY,this.style)}},Hs=class{connections;layer="background";names;ast;get sourceSpan(){return this.ast.sourceSpan}constructor(t,e,n){this.connections=n,this.names=t,this.ast=e}createGeometry(){if(this.names.length<2)return{regions:[],paint(){}};let t=this.names[0].box,e=this.names[this.names.length-1].box,n=this.ast.size,o=t.y+t.visualAxis-n*.5,i=e.y+e.visualAxis+n*.5;if(i-o<1e-6)return{regions:[],paint(){}};let r=Math.max(pa,n*.19),a=r*Xt,c=r*se,l=t.x+t.anchor+this.ast.braceSpace*ua+r/2,p=Math.min(r*.67,n*.25),f={x:l+r*1.33-r*.165,y:o+p,w:r*.33,h:i-o-p*2},u=[],h=[],d=[f];for(let y of this.connections){let m=this.names[y.from-1].box,g=this.names[y.to-1].box,x=m.y+m.visualAxis-n*.5,b=g.y+g.visualAxis+n*.5;if(y.kind==="bracket")u.push({x:l-r/2,y:x,w:r,h:b-x}),h.push({commands:Ds,transform:{x:l,y:x,scaleX:r,scaleY:-r}},{commands:Ds,transform:{x:l,y:b,scaleX:r,scaleY:r}}),d.push({x:l-r/2,y:x-c,w:a+r/2,h:b-x+c*2});else{let A=n*.35,E=f.x-n*.12-A,S=A/an.w,v=(b-x)/an.h;h.push({commands:Ps,transform:{x:E-an.x*S,y:x-an.y*v,scaleX:S,scaleY:v}}),d.push({x:E,y:x,w:A,h:b-x})}}return u.push(f),{regions:d,paint(y){for(let m of u)y.drawRect(m.x,m.y,m.w,m.h,{fill:"#000"});for(let m of h)y.drawPath(m.commands,{fill:"#000"},m.transform)}}}},Ws=class{temporalMembers;nameHost;frames;layer="foreground";get sourceSpan(){return this.nameHost.ast.sourceSpan}constructor(t,e,n){this.temporalMembers=t,this.nameHost=e,this.frames=n}prepareHorizontal(t,e){let n=this.temporalMembers.filter(X).filter(a=>a.ports?.lyric),{lyrics:o,size:i}=this.nameHost.ast;if(n.length===0||o.length===0)return;let r={fontSize:i*zs,fontFamily:this.nameHost.ast.font,fill:"#000"};for(let a=0;a<n.length;a++){let c=n[a],l=0;for(let p of o){let f=p.tokens[a];if(f){let{body:u}=fa(f);u&&(l=Math.max(l,e.textMeasurer.measureText(u,r).w/2))}}l!==0&&t[c.layoutLine]?.registerHorizontalLayoutHook(c,c,({columns:p,start:f})=>{let u=p[f].find(d=>d.time===c);if(!u)return;let h=c.ports.lyric.x-c.box.anchor;u.WL=Math.max(u.WL,l-h),u.WR=Math.max(u.WR,l+h)})}}createGeometry(t){let e=this.prepareGeometry(t);return{regions:e,paint(n){for(let o of e)n.drawText(o.text,o.x,o.y+o.textBaselineY,o.style)}}}prepareGeometry(t){let{lyrics:e,size:n}=this.nameHost.ast,o=[],i=this.temporalMembers.filter(X).filter(x=>x.ports?.lyric);if(i.length===0||e.length===0)return o;let r=new Map;for(let x of i){let b=r.get(x.layoutLine);b||r.set(x.layoutLine,b=new Map);let A=b.get(x.track)??{bottom:-1/0,owner:x.track},E=wt(x),S=E.y+E.h,v=x.track;for(let L of this.frames){let I=t.getAttachmentBox(L);if(I.x+I.w<E.x||I.x>E.x+E.w||I.y+I.h<=S)continue;let w=t.getAttachmentOccupancy(L);if(!w)throw new Error("Layout attachment dependency has not been measured");let M=w.filter(C=>C.line===x.layoutLine);if(!(w.some(C=>C.line!==void 0)&&M.length===0)){S=I.y+I.h;for(let C of M)C.line!==void 0&&t.getVisualAxis(C.line,C.track)>t.getVisualAxis(x.layoutLine,v)&&(v=C.track)}}S>=A.bottom&&(A.owner=v),A.bottom=Math.max(A.bottom,S),b.set(x.track,A)}let a=n*zs,c=n*.24,l=n*.32,p={fontSize:a,fontFamily:this.nameHost.ast.font,fill:"#000"},f=xa(n,this.nameHost.ast.font),u=t.textMeasurer.measureText("M",p).baseline+l,h=(x,b)=>x+u+b*(a+c);if(this.frames.length)for(let[x,b]of r){if(b.size<2)continue;let A=new Map;for(let[,E]of[...b].sort(([S],[v])=>t.getVisualAxis(x,S)-t.getVisualAxis(x,v))){let S=A.get(E.owner)??0;E.bottom+=S*e.length*(a+c),A.set(E.owner,S+1)}}let{box:d,layoutLine:y,track:m}=this.nameHost,g=r.get(y)?.get(m);for(let x=0;x<e.length;x++){let b=e[x];for(let E=0;E<b.tokens.length&&E<i.length;E++){let S=b.tokens[E],v=i[E],L=r.get(v.layoutLine)?.get(v.track);if(!S||!L)continue;let I=t.textMeasurer.measureText(S,p),{prefix:w,body:M}=fa(S),C=M?t.textMeasurer.measureText(M,p).w:0,_=w?t.textMeasurer.measureText(w,p).w:0;o.push({text:S,style:p,textBaselineY:I.baseline,x:v.box.x+v.ports.lyric.x-C/2-_,y:h(L.bottom,x)-I.baseline,w:I.w,h:I.h,line:v.layoutLine,track:L.owner})}if(!b.name||!d||!g)continue;let A=t.textMeasurer.measureText(b.name,f);o.push({text:b.name,style:f,textBaselineY:A.baseline,x:d.x+d.anchor-A.w,y:h(g.bottom,x)-A.baseline,w:A.w,h:A.h,line:y,track:g.owner})}return o}};var qn=[Or,Qi,Pr,Hi,_e,nr,aa,da,ma,Fn,zr,Fr,Nr,Gr,Dr,Br,zi,ar,fr,ra,qi,lr,or,Zi,sa,$r,Ti,na,In,On,$n,Hr,Pn,ea];function Gs(s,t={}){let e=new Map,n=new Set(s);for(let o of n){let i=o.layoutDecorationHandler;if(!i)continue;let r=o.def?.name;if(!r)continue;let a=Array.isArray(r)?r[0]:r;e.set(ce(a),i)}return{textMeasurer:t.textMeasurer??Vo,decorationHandlers:e}}var cn=class s{loweringAugmenters=[];loweringFinalizers=[];cnt=0;usedTracks=new Set;attachments=[];page;astToTemporal=new Map;activeLoweringGroups=[];diagnostics;constructor(t=[]){this.diagnostics=t}registerFunctions(t){let e=this.loweringAugmenters=[],n=this.loweringFinalizers=[];for(let o of t){o.loweringAugment&&e.push(o.loweringAugment);let i=o.loweringFinalize;i&&!n.includes(i)&&n.push(i)}}setPageConfig(t){this.page=t}lowerDocument(t){this.cnt=0,this.usedTracks.clear(),this.attachments=[],this.page=void 0,this.astToTemporal=new Map,this.activeLoweringGroups=[];let e=new pe,n=new F,o=this.trackedEvents(t,n,e);return this.solidifyColumns(o,n),this.postprocessResult({diagnostics:this.diagnostics,columns:o,attachments:this.attachments,astToTemporal:this.astToTemporal,duration:n,rootTrack:e,tracks:[...this.usedTracks],page:this.page})}solidifyColumns(t,e){let n=0;for(let u of t){let h=0;for(let d of u){let y=d.addon?.breakBefore??0;y>h&&(h=y)}n+=h,u.layoutLine=n}let o={bpm:Jt,velocity:Le,keySignature:Ue,program:gn},i=new Map,r=new Map,a=u=>i.get(u)??(u.parent?a(u.parent):Le),c=u=>r.get(u)??(u.parent?c(u.parent):gn),l=new F;for(let u of t){l.isZero()||u.shiftTime(l);let h;for(let d of u){o.currentEvent=d,o.velocity=a(d.track),o.program=c(d.track);let y=d.onTimeState?.(o);y&&!y.isZero()&&(!h||y.compare(h)>0)&&(h??=new F).copyFrom(y),i.set(d.track,o.velocity),r.set(d.track,o.program)}h&&l.add(h)}if(l.isZero())return;let p=new Set(r.keys()),f=new F;e.set(0);for(let u=t.length-1;u>=0&&p.size>0;u--){let h=t[u];for(let d=h.length-1;d>=0;d--){let y=h[d];if(!p.delete(y.track))continue;let m=y.T;f.copyFrom(y.t),m.isZero()||f.add(m),f.compare(e)>0&&e.copyFrom(f)}}}beginLoweringGroup(t,e){this.activeLoweringGroups.push({owner:t,group:e})}endLoweringGroup(t){let e=this.activeLoweringGroups.pop();if(!e)throw new Error("No active lowering group to end");if(e.owner!==t)throw new Error("Lowering groups must end in reverse order");return e.group.attachment&&this.addAttachment(e.group.attachment),e.group}postprocessResult(t){if(this.activeLoweringGroups.length>0)throw new Error("Lowering groups must be closed before post-processing");let e=[];for(let n of this.loweringAugmenters)for(let o of n(t))e.push(o);for(let n of e)this.addAttachment(n);for(let n of this.loweringFinalizers)n(t);return t}addAttachment(t){this.attachments.push(t);for(let e=this.activeLoweringGroups.length-1;e>=0;e--)this.activeLoweringGroups[e].group.onAttachment?.(t)}getTemporalNodes(t){return this.astToTemporal.get(t)??[]}isolateFromLoweringGroups(t){let e=this.activeLoweringGroups;this.activeLoweringGroups=[];try{return t()}finally{this.activeLoweringGroups=e}}initEvent(t,e,n,o){t.t.add(n),this.usedTracks.add(o),t.track=o,t.ast??=e,t.order=this.cnt++,t.mergeKey??=t.order}trackedEvents(t,e,n){let o=[];this.appendEvents(t.loweringEnter(this,n),t,e,n,o);let i=t.timeFlowModel(this);if(i)switch(i.mode){case"sequence":for(let r of i.children)for(let a of this.trackedEvents(r,e,n))o.push(a);break;case"parallel":{let r=i.tracks,a=i.children,c=r.hostIndex===void 0?0:r.hostIndex,l=n.group(r,c===null?a.length:a.length-1),p=[];for(let h=0;h<a.length;h++){let d=a[h],y=h===c?n:l.members[c===null||h<c?h:h-1],m=e.clone(),g=this.trackedEvents(d,m,y);g.length===0&&this.diagnostics.push(H.warning.ZeroTimeTrack(d.sourceSpan,h+1)),p.push(g)}let f=o.length;for(let h of s.anchorAlign(p))o.push(h);let u=new F;for(let h=f;h<o.length;h++)for(let d of o[h])u.copyFrom(d.t).add(d.T),u.compare(e)>0&&e.copyFrom(u)}break}return this.appendEvents(t.loweringExit(this,n,e),t,e,n,o),o}appendEvents(t,e,n,o,i){let r;for(let a of t){this.initEvent(a,e,n,o),this.indexTemporal(a);for(let l=this.activeLoweringGroups.length-1;l>=0;l--)this.activeLoweringGroups[l].group.onTemporal?.(a);let c=(r??=new F).copyFrom(a.t).add(a.T);c.compare(n)>0&&n.copyFrom(c),i.push(new Us(a))}}indexTemporal(t){let e=this.astToTemporal.get(t.ast);e?e.push(t):this.astToTemporal.set(t.ast,[t])}static anchorAlign(t){for(let l=t.length-1;l>=0;l--)t[l].length===0&&t.splice(l,1);let e=t.length;if(e===0)return[];if(e===1)return t[0];let n=[],o=new Uint16Array(e),i=Array.from({length:e},()=>new F),r=[],a=new js(e);for(let l=0;l<e;l++)a.push({e:t[l][0],i:l});let c=l=>{let p=t[l][++o[l]];p&&(i[l].isZero()||p.shiftTime(i[l]),a.push({e:p,i:l}))};for(;;){let l=a.pop();if(l===void 0){if(r.length===0)break;let f=r[0],u=f.e,h=u.t;for(let d=1;d<r.length;d++)r[d].e.t.compare(h)>0&&(h=r[d].e.t);i[f.i].add(h).sub(u.t),c(f.i);for(let d=1;d<r.length;d++){let y=r[d];u.push(...y.e),i[y.i].add(h).sub(y.e.t),c(y.i)}r.length=0,u.t=h,u.sort((d,y)=>d.order-y.order),n.push(u);continue}if(l.e.mergeKey===mt){r.push(l);continue}let p=[l.i];for(;;){let f=a.front();if(!f||!f.e.t.equals(l.e.t)||f.e.mergeKey!==l.e.mergeKey)break;a.pop(),l.e.push(...f.e),p.push(f.i)}n.push(l.e);for(let f of p)c(f)}return n}},Us=class extends Array{static get[Symbol.species](){return Array}mergeKey;constructor(t){super(1),this.mergeKey=t.mergeKey,this[0]=t}get t(){return this[0].t}set t(t){for(let e of this)e.t.copyFrom(t)}shiftTime(t){for(let e of this)e.t.add(t)}set layoutLine(t){for(let e of this)e.layoutLine=t}};function Vs(s,t){let e=s.e.t.compare(t.e.t);return e!==0?e:s.e.mergeKey!==t.e.mergeKey?s.e.mergeKey<t.e.mergeKey?-1:1:s.i-t.i}var js=class extends Array{validLen=0;constructor(t){super(t)}front(){if(this.validLen!==0)return this[0]}push(t){return this[this.validLen]=t,this.up(this.validLen++),this.validLen}pop(){if(this.validLen===0)return;let t=this[0];return this[0]=this[--this.validLen],this[this.validLen]=void 0,this.down(0),t}up(t){let e=this[t];for(;t>0;){let n=t-1>>1;if(Vs(e,this[n])>=0)break;this[t]=this[n],t=n}this[t]=e}down(t){let e=this[t];for(;;){let n=(t<<1)+1,o=n+1;if(n>=this.validLen)break;let i=n;if(o<this.validLen&&Vs(this[o],this[n])<0&&(i=o),Vs(this[i],e)>=0)break;this[t]=this[i],t=i}this[t]=e}};function Ks(s,t={}){let{functions:e=qn,textMeasurer:n,variables:o,...i}=t,{maskedSource:r,lineStarts:a}=Pe(s),c=new _t({source:r,variables:o});c.registerFunctions(e);let l=new dt({start:0,end:s.length},c.parse()),p=new cn(c.diagnostics);p.registerFunctions(e);let f=p.lowerDocument(l),u=Gs(e,{textMeasurer:n}),h=bo(f,u,i);return{lineStarts:a,maskedSource:r,diagnostics:c.diagnostics,ast:l,lowering:f,layout:h}}function Dl(s,t=qn){let{maskedSource:e,commentSpans:n}=Pe(s),o=new _t({source:e,commentSpans:n});return o.registerFunctions(t),{syntax:o.parseSyntax(),diagnostics:o.diagnostics}}function Ys(s){return typeof s.applyPlayback=="function"}function Zn(s,t){let e=Math.max(0,t),n=0,o=0,i=Jt;for(let r of s){if(r.kind!=="tempo")continue;let a=r.at.toNumber();if(a>e)break;a>o&&(n+=(a-o)*60/i),o=a,i=r.bpm}return n+(e-o)*60/i}function ya(s,t){let e=Math.max(0,t),n=0,o=Jt;for(let i of s){if(i.kind!=="tempo")continue;let r=i.at.toNumber(),a=(r-n)*60/o;if(e<a)return n+e*o/60;e-=a,n=r,o=i.bpm}return n+e*o/60}function ga(s,t){let e=Math.max(0,t),n=e;for(let o of s){let i=o.performance.toNumber();if(i>e)break;n=o.score.toNumber()+e-i}return n}function ba(s,t){let e=Math.max(0,t),n;for(let o=0;o<s.length;o++){let i=s[o],r=i.score.toNumber();if(r>e){(!n||r<n.score.toNumber())&&(n=i);continue}let a=s[o+1],c=a?a.performance.toNumber()-i.performance.toNumber():1/0;if(!(e-r>=c))return i.performance.toNumber()+(e-r)}return n?.performance.toNumber()??e}function Bl(s,t){let e=Math.min(ya(s.events,t),s.performanceDuration.toNumber());return ga(s.scoreMap,e)}function Fl(s,t){let e=Math.min(ba(s.scoreMap,t),s.performanceDuration.toNumber());return Zn(s.events,e)}var wa={tempo:0,"time-signature":1,"program-change":2,"note-off":3,"note-on":4};function Sa(s,t){return s.at.compare(t.at)||wa[s.kind]-wa[t.kind]||s.order-t.order}function Aa(s,t){let e=new Map,n=new Map;for(let a of s)if(a.kind==="note-on"){if(e.has(a.noteId))throw new Error(`Duplicate NoteOn ${a.noteId}`);e.set(a.noteId,a)}else if(a.kind==="note-off"){if(n.has(a.noteId))throw new Error(`Duplicate NoteOff ${a.noteId}`);n.set(a.noteId,a)}for(let[a,c]of e){let l=n.get(a);if(!l)throw new Error(`Note ${a} has no NoteOff`);if(l.at.compare(c.at)<=0)throw new Error(`Note ${a} has a non-positive duration`);if(c.origins.length===0||l.origins.length===0)throw new Error(`Note ${a} has no origin`)}for(let a of n.keys())if(!e.has(a))throw new Error(`NoteOff ${a} has no NoteOn`);let o=new Set;for(let a of e.values())o.add(a.track);let i=new Map;for(let a of t)o.has(a)&&i.set(a,i.size);for(let a of o)i.has(a)||i.set(a,i.size);let r=[];for(let a of s){if(a.kind==="tempo"){r.push({kind:"tempo",at:a.at,bpm:a.bpm});continue}if(a.kind==="time-signature"){r.push({kind:"time-signature",at:a.at,numerator:a.numerator,denominator:a.denominator});continue}if(a.kind==="program-change"){let p=i.get(a.track);p!==void 0&&r.push({kind:"program-change",at:a.at,track:p,program:a.program});continue}let c=a.kind==="note-on"?a:e.get(a.noteId),l=i.get(c.track);if(a.kind==="note-on"){r.push({kind:"note-on",at:a.at,noteId:a.noteId,track:l,midi:a.midi,velocity:a.velocity,...a.percussion?{percussion:!0}:{},sourceSpans:a.sourceSpans});continue}r.push({kind:"note-off",at:a.at,noteId:a.noteId,track:l,midi:c.midi})}return{events:r,tracks:[...i.keys()]}}function zl(s,t,e){let n=s.columns,o=new Map;for(let m=0;m<n.length;m++)for(let g of n[m])o.set(g,m);let i=(m,g)=>{for(let x=m;x;x=x.foldedInto){let b=o.get(x);if(b===void 0)continue;if(g!=="end"||x.T.compare(0)<=0)return b;let A=x.t.clone().add(x.T),E=b;for(;E+1<n.length&&n[E+1][0].t.compare(A)<0;)E++;return E}},r=new Map,a=new Map,c=(m,g)=>{let x=m.playbackFlow?.(i);if(!x)return;let[b,A]=x.range??[0,n.length-1];if(x.range&&(!Number.isSafeInteger(b)||!Number.isSafeInteger(A)||b<0||A<b||A>=n.length))throw new k("E_PLAYBACK_FLOW_RANGE",`\u64AD\u653E\u63A7\u5236\u6D41\u8303\u56F4 [${b}, ${A}] \u8D85\u51FA\u65F6\u95F4\u5217\u8FB9\u754C`,g);let E={hook:x,sourceSpan:g};for(let S=b;S<=A;S++){let v=a.get(S);v?v.push(E):a.set(S,[E])}};for(let m of s.astToTemporal.values())for(let g of m){c(g,g.ast.sourceSpan);let x=g.playbackMarks?.();if(!x)continue;let b=i(g);if(b!==void 0)for(let A of x){let E=r.get(A);E?E.push(b):r.set(A,[b])}}for(let m of s.attachments)c(m,m.sourceSpan??{start:0,end:0});if(a.size===0)return n.map((m,g)=>g);for(let m of r.values())m.sort((g,x)=>g-x);let l=new Array(n.length).fill(0),p=0,f={get column(){return p},visits:m=>l[m]??0,seek(m,g,x){let b=r.get(m);if(b){if(x>0)return b.find(A=>A>g);for(let A=b.length-1;A>=0;A--)if(b[A]<g)return b[A]}}},u=[],h=0;for(;p<n.length;){if(++h>e)throw new k("E_PLAYBACK_FLOW_LIMIT",`\u64AD\u653E\u63A7\u5236\u6D41\u8BBF\u95EE\u8D85\u8FC7 ${e} \u6B65\uFF1B\u53EF\u901A\u8FC7 maxFlowSteps \u63D0\u9AD8\u5C55\u5F00\u9884\u7B97`,n[p][0].ast.sourceSpan);l[p]++;let m;for(let g of a.get(p)??[]){let b=g.hook.run(f);if(b){if(b.kind==="stop")return u;if(!Number.isSafeInteger(b.column)||b.column<0||b.column>n.length)throw new k("E_PLAYBACK_FLOW_JUMP",`\u64AD\u653E\u63A7\u5236\u6D41\u8DF3\u8F6C\u76EE\u6807 ${b.column} \u8D85\u51FA\u65F6\u95F4\u5217\u8FB9\u754C`,g.sourceSpan);m=Math.min(m??1/0,b.column)}}m!==void 0?p=m:(u.push(p),p++)}let d=new Set(u),y=!1;for(let m=0;m<n.length;m++){let g=!d.has(m);g&&!y&&t.push(new q("W_PLAYBACK_COLUMN_NEVER_PLAYED","\u8FD9\u91CC\u5728\u4EFB\u4F55\u4E00\u904D\u91CC\u90FD\u4E0D\u4F1A\u6F14\u594F",n[m][0].ast.sourceSpan)),y=g}return u}function Hl(s,t){let e=t?.maxFlowSteps??65536;if(!Number.isSafeInteger(e)||e<=0)throw new k("E_PLAYBACK_FLOW_LIMIT","maxFlowSteps \u5FC5\u987B\u662F\u6B63\u5B89\u5168\u6574\u6570",s.columns[0]?.[0]?.ast.sourceSpan??{start:0,end:0});let n=[],o=[],i=[],r=[],a=new Map,c=new Map,l=0,p=0,f=[{kind:"initial",at:new F,origins:[]}],u=new Map,h=new Map,d={spans:i,notes:r,diagnostics:n},y=(T,D,z)=>{if(!Number.isFinite(T.toNumber())||T.compare(0)<0)throw new k("E_PLAYBACK_CONTROL_TIME","\u7CFB\u7EDF\u63A7\u5236\u65F6\u523B\u5FC5\u987B\u662F\u975E\u8D1F\u6709\u9650\u503C",D.at(-1).node.ast.sourceSpan);f.push({kind:"control",at:T.clone(),origins:D,apply:z})};function m(T,D,z,Y,V,et=[],gt=T.track){let rt=[...et,{node:T}],bt=[...D],Mt=[...D],It=[...z],qt=[...z],Gt=[];function Rt(U){let pt={...U,start:U.start.clone(),end:U.end.clone(),track:gt,origins:rt,sourceSpans:[{...T.ast.sourceSpan}]};return i.push(pt),qt.length&&h.set(pt,qt),pt}let Ut=T.playbackState?.program;Ut!==void 0&&c.get(gt)!==Ut&&(c.set(gt,Ut),o.push({kind:"program-change",at:Y.clone(),order:l++,origins:rt,track:gt,program:Ut}));let J=T.playbackState?.bpm;J!==void 0&&y(Y,rt,U=>{U.bpm=J}),T.emitPlayback?.({start:Y,end:Y.clone().add(V),track:gt,span(U){Rt(U)},note(U){let pt=Rt(U);r.push(pt),Mt.length&&a.set(pt,Mt)},extend(U){if(!i.includes(U)||!U.end.equals(Y)||V.compare(0)<=0)throw new k("E_PLAYBACK_EXTEND_RANGE","\u6269\u5C55\u5FC5\u987B\u63A5\u7EED\u5F53\u524D\u8BA1\u5212\u5185\u7684\u533A\u95F4\u4E14\u65F6\u503C\u4E3A\u6B63",T.ast.sourceSpan);let pt=U.end.clone().sub(U.start),Nt=pt.clone().add(V),At=(h.get(U)??[]).map(ut=>ut.startRatio?{...ut,startRatio:ut.startRatio.clone().mul(pt).div(Nt)}:ut);for(let ut of qt)At.push({...ut,startRatio:pt.clone().div(Nt)});At.length&&h.set(U,At),U.end.add(V)},emit:U=>o.push({...U,at:U.at.clone(),order:l++,origins:rt}),control:(U,pt)=>y(U,rt,pt),scaleFollowingBpm(U,pt,Nt=1,At){if(!Number.isSafeInteger(pt)||!Number.isSafeInteger(Nt)||pt<=0||Nt<=0)throw new k("E_PLAYBACK_BPM_SCALE","\u901F\u5EA6\u6BD4\u4F8B\u5FC5\u987B\u662F\u6B63\u6709\u7406\u6570",T.ast.sourceSpan);let ut=new F(pt,Nt),$t=u.get(U);if($t&&!$t.equals(ut))throw new k("E_PLAYBACK_BPM_SCALE","\u540C\u4E00\u901F\u5EA6\u6548\u679C key \u5FC5\u987B\u4F7F\u7528\u56FA\u5B9A\u6BD4\u4F8B",T.ast.sourceSpan);u.set(U,ut),z.push({key:U,factor:ut,followConnections:At?.followConnections??!1,origins:rt})},affectFollowing:U=>D.push(U),defer:U=>Gt.push(U),play:(U,pt,Nt)=>m(U,bt,It,pt??Y,Nt??V,rt,gt)});for(let U of Gt)U(d)}let g=zl(s,n,e),x=s.columns[g[0]]?.[0]?.t.clone()??new F,b=[{performance:new F,score:x}],A=new F().sub(x),E=new F;for(let T=0;T<g.length;T++){let D=g[T];for(let rt of s.columns[D])m(rt,[],[],rt.t.clone().add(A),rt.T.clone());let z=s.columns[D+1]?.[0]?.t??s.duration;E.copyFrom(z).add(A);let Y=g[T+1];if(Y===void 0||Y===D+1)continue;let V=s.columns[Y][0]?.t.clone()??new F;A.add(z).sub(V);let et={performance:E.clone(),score:V};b[b.length-1].performance.equals(et.performance)?b[b.length-1]=et:b.push(et)}for(let T of i){if(!Number.isFinite(T.start.toNumber())||!Number.isFinite(T.end.toNumber())||T.start.compare(0)<0||T.end.compare(T.start)<=0)throw new k("E_PLAYBACK_NOTE_RANGE","\u97F3\u6BB5\u5FC5\u987B\u5177\u6709\u975E\u8D1F\u8D77\u70B9\u548C\u6B63\u65F6\u503C",T.sourceSpans[0]);T.end.compare(E)>0&&E.copyFrom(T.end),Object.freeze(T.start),Object.freeze(T.end);for(let D of T.origins)Object.freeze(D);for(let D of T.sourceSpans)Object.freeze(D);Object.freeze(T.origins),Object.freeze(T.sourceSpans),Object.freeze(T)}let S=new Set(r),v=new Map,L=new Map,I={notes:r,diagnostics:n,connect(T,D){if(!S.has(T)||!S.has(D)||!T.end.equals(D.start))throw new k("E_PLAYBACK_CONNECTION","\u97F3\u6BB5\u8FDE\u63A5\u5FC5\u987B\u5C5E\u4E8E\u5F53\u524D\u8BA1\u5212\u4E14\u65F6\u95F4\u76F8\u63A5",T.sourceSpans[0]);return v.has(T)&&v.get(T)!==D||L.has(D)&&L.get(D)!==T?!1:(v.set(T,D),L.set(D,T),!0)}};for(let T of s.attachments)Ys(T)&&T.applyPlayback(I);let w=[...r].sort((T,D)=>D.start.compare(T.start)),M=new Map;for(let T of w){let D=v.get(T),z=D?M.get(D):T.end;M.set(T,z)}for(let T of i){let D=M.get(T)??T.end;for(let z of h.get(T)??[]){let Y=z.startRatio?T.start.clone().add(T.end.clone().sub(T.start).mul(z.startRatio)):T.start;f.push({kind:"scale",at:Y,origins:z.origins,scale:z,delta:1},{kind:"scale",at:z.followConnections?D:T.end,origins:z.origins,scale:z,delta:-1})}}let C={bpm:Jt,bpmScale:new F(1)},_=new Map,P=new F(1),W=[];f.sort((T,D)=>T.at.compare(D.at));let Z=0,Q;for(;Z<f.length;){let T=f[Z].at,D=new Set;for(;Z<f.length&&f[Z].at.equals(T);){let et=f[Z++];for(let gt of et.origins)D.add(gt);if(et.kind==="control")et.apply(C);else if(et.kind==="scale"){let{key:gt,factor:rt}=et.scale,bt=_.get(gt)??0,Mt=bt+et.delta;_.set(gt,Mt),bt===0&&Mt>0?P.mul(rt):bt>0&&Mt===0&&P.div(rt)}}let z=C.bpmScale.clone().mul(P),Y={bpm:C.bpm,bpmScale:z,effectiveBpm:C.bpm*z.toNumber()};if(!Number.isFinite(Y.effectiveBpm)||Y.effectiveBpm<=0)throw new k("E_PLAYBACK_BPM","\u7CFB\u7EDF\u63A7\u5236\u4EA7\u751F\u4E86\u65E0\u6548\u901F\u5EA6",[...D].at(-1)?.node.ast.sourceSpan??{start:0,end:0});let V=W.at(-1)?.state;(!V||V.bpm!==Y.bpm||!V.bpmScale.equals(z))&&W.push({at:T.clone(),state:Y}),Q!==Y.effectiveBpm&&(Q=Y.effectiveBpm,o.push({kind:"tempo",at:T.clone(),bpm:Y.effectiveBpm,order:l++,origins:[...D]}))}let K={diagnostics:n,stateAt(T){let D=0,z=W.length;for(;D<z;){let V=D+z>>>1;W[V].at.compare(T)<=0?D=V+1:z=V}let Y=W[Math.max(0,D-1)].state;return{...Y,bpmScale:Y.bpmScale.clone()}}},N=new Map;for(let T of r){let D=[{...T,start:T.start.clone(),end:T.end.clone()}];for(let V of a.get(T)??[])D=V(K,D)??D;let z,Y;for(let V of D){if(!Number.isFinite(V.start.toNumber())||!Number.isFinite(V.end.toNumber())||V.start.compare(T.start)<0||V.end.compare(T.end)>0||V.end.compare(V.start)<=0)throw new k("E_PLAYBACK_TRANSFORM_RANGE","\u58F0\u97F3\u5C55\u5F00\u5FC5\u987B\u4F4D\u4E8E\u539F\u97F3\u6BB5\u533A\u95F4\u5185\u4E14\u65F6\u503C\u4E3A\u6B63",T.sourceSpans[0]);(!z||V.start.compare(z)<0)&&(z=V.start),(!Y||V.end.compare(Y)>0)&&(Y=V.end)}if(!z?.equals(T.start)||!Y?.equals(T.end))throw new k("E_PLAYBACK_TRANSFORM_RANGE","\u58F0\u97F3\u5C55\u5F00\u5FC5\u987B\u4FDD\u6301\u539F\u97F3\u6BB5\u7684\u8D77\u6B62\u8FB9\u754C",T.sourceSpans[0]);N.set(T,D.map(V=>{let{start:et,end:gt,track:rt,midi:bt,velocity:Mt,percussion:It,origins:qt,sourceSpans:Gt}=V,Rt=p++,Ut={kind:"note-on",at:et.clone(),noteId:Rt,order:l++,track:rt,midi:bt,velocity:Mt,percussion:It,origins:[...qt],sourceSpans:Gt.map(U=>({...U}))},J={kind:"note-off",at:gt.clone(),noteId:Rt,order:l++,origins:[...qt]};return o.push(Ut,J),{on:Ut,off:J}}))}let R=new Set,O=new Map;for(let T of w){let D=v.get(T);if(D)for(let z of N.get(T)){if(!z.off.at.equals(T.end))continue;let Y=N.get(D).find(V=>!R.has(V.on)&&V.on.at.equals(D.start)&&V.on.track===z.on.track&&V.on.midi===z.on.midi&&V.on.percussion===z.on.percussion);Y&&(z.off.at.copyFrom(Y.off.at),O.set(z.on,Y.on),R.add(Y.on),R.add(Y.off))}}for(let T of O.keys())if(!R.has(T))for(let D=O.get(T);D;D=O.get(D))T.sourceSpans.push(...D.sourceSpans);let j=(R.size?o.filter(T=>!R.has(T)):o).sort(Sa),B=Aa(j,s.tracks),G=j.at(-1)?.at;return G&&G.compare(E)>0&&E.copyFrom(G),{events:B.events,scoreMap:b,tracks:B.tracks,performanceDuration:E,durationSeconds:Zn(B.events,E.toNumber()),diagnostics:n}}function ge(s){return s.pages.length>0?s.pages.map(t=>t.bounds):[s.bounds]}function qs(s,t){for(let e of s.attachments)e.layer==="background"&&e.paint(t);for(let e of s.objects){e.paint(t);for(let n of e.decorations)n.paint?.(t)}for(let e of s.attachments)e.layer==="foreground"&&e.paint(t)}var Xs=class{pages;painters;constructor(t,e){this.pages=t,this.painters=e}route(t,e,n){let o=0,i=this.pages.length;for(;o<i;){let r=o+i>>>1,a=this.pages[r];a.y+a.h<t?o=r+1:i=r}for(let r=o;r<this.pages.length&&this.pages[r].y<=e;r++)n(this.painters[r])}drawText(t,e,n,o){this.route(n,n,i=>i.drawText(t,e,n,o))}drawLine(t,e,n,o,i){let r=(i?.strokeWidth??1)/2;this.route(Math.min(e,o)-r,Math.max(e,o)+r,a=>a.drawLine(t,e,n,o,i))}drawRect(t,e,n,o,i){let r=i?.stroke?(i.strokeWidth??1)/2:0;this.route(e-r,e+Math.max(0,o)+r,a=>{a.drawRect(t,e,n,o,i)})}drawCircle(t,e,n,o){let i=o?.stroke?(o.strokeWidth??1)/2:0,r=Math.max(0,n)+i;this.route(e-r,e+r,a=>a.drawCircle(t,e,n,o))}drawPath(t,e,n){if(t.length===0)return;let o=n?l=>n.y+l*n.scaleY:l=>l,i=1/0,r=-1/0,a=l=>{let p=o(l);i=Math.min(i,p),r=Math.max(r,p)};for(let l of t)l.op!=="Z"&&(l.op==="Q"&&a(l.cy),l.op==="C"&&(a(l.cy1),a(l.cy2)),a(l.y));if(!Number.isFinite(i))return;let c=e?.stroke?(e.strokeWidth??1)/2:0;this.route(i-c,r+c,l=>{l.drawPath(t,e,n)})}};function ze(s,t){let e=ge(s);if(t.length!==e.length)throw new Error(`Expected ${e.length} page painters, got ${t.length}`);qs(s,new Xs(e,t))}var Zs=class{commands=[];replay(t){for(let e of this.commands)switch(e.kind){case"text":t.drawText(e.text,e.x,e.y,e.style);break;case"line":t.drawLine(e.x1,e.y1,e.x2,e.y2,e.style);break;case"rect":t.drawRect(e.x,e.y,e.w,e.h,e.style);break;case"circle":t.drawCircle(e.cx,e.cy,e.r,e.style);break;case"path":t.drawPath(e.commands,e.style);break}}drawText(t,e,n,o){this.commands.push({kind:"text",text:t,x:e,y:n,style:o})}drawLine(t,e,n,o,i){this.commands.push({kind:"line",x1:t,y1:e,x2:n,y2:o,style:i})}drawRect(t,e,n,o,i){this.commands.push({kind:"rect",x:t,y:e,w:n,h:o,style:i})}drawCircle(t,e,n,o){this.commands.push({kind:"circle",cx:t,cy:e,r:n,style:o})}drawPath(t,e,n){this.commands.push({kind:"path",commands:t.map(o=>Wl(o,n)),style:e})}};function Wl(s,t){if(!t||s.op==="Z")return{...s};let e=o=>t.x+o*t.scaleX,n=o=>t.y+o*t.scaleY;return s.op==="M"||s.op==="L"?{op:s.op,x:e(s.x),y:n(s.y)}:s.op==="Q"?{op:"Q",cx:e(s.cx),cy:n(s.cy),x:e(s.x),y:n(s.y)}:s.op==="C"?{op:"C",cx1:e(s.cx1),cy1:n(s.cy1),cx2:e(s.cx2),cy2:n(s.cy2),x:e(s.x),y:n(s.y)}:{...s}}function st(s){return Number.isFinite(s)?String(Math.round(s*1e3)/1e3):"0"}function Ot(s){return s.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Gl(s,t){let e=[],n=t?i=>st(t.x+i*t.scaleX):st,o=t?i=>st(t.y+i*t.scaleY):st;for(let i of s){if(i.op==="Z"){e.push("Z");continue}if(i.op==="M"||i.op==="L"){e.push(`${i.op}${n(i.x)} ${o(i.y)}`);continue}if(i.op==="Q"){e.push(`Q${n(i.cx)} ${o(i.cy)} ${n(i.x)} ${o(i.y)}`);continue}"cx1"in i&&e.push(`C${n(i.cx1)} ${o(i.cy1)} ${n(i.cx2)} ${o(i.cy2)} ${n(i.x)} ${o(i.y)}`)}return e.join(" ")}function ln(s){return s?.opacity===void 0?"":` opacity="${st(s.opacity)}"`}var Qn=class{body=[];drawText(t,e,n,o){let i=o.fontFamily??Oe,r=o.fontWeight??"normal",a=o.fill??"#000",c=o.textAlign==="center"?"middle":o.textAlign==="right"?"end":"start";this.body.push(`<text x="${st(e)}" y="${st(n)}" font-family="${Ot(i)}" font-size="${st(o.fontSize)}" font-weight="${Ot(String(r))}" text-anchor="${c}" `+(o.fontStyle?`font-style="${Ot(o.fontStyle)}" `:"")+`fill="${Ot(a)}" xml:space="preserve"${ln(o)}>${Ot(t)}</text>`)}drawLine(t,e,n,o,i){let r=i?.stroke??i?.fill??"#000",a=i?.strokeWidth??1;this.body.push(`<line x1="${st(t)}" y1="${st(e)}" x2="${st(n)}" y2="${st(o)}" stroke="${Ot(r)}" stroke-width="${st(a)}" stroke-linecap="round"${ln(i)} />`)}drawRect(t,e,n,o,i){let r=i?.fill??"none",a=i?.stroke??"none",c=i?.strokeWidth??1;this.body.push(`<rect x="${st(t)}" y="${st(e)}" width="${st(Math.max(0,n))}" height="${st(Math.max(0,o))}" fill="${Ot(r)}" stroke="${Ot(a)}" stroke-width="${st(c)}"${ln(i)} />`)}drawCircle(t,e,n,o){let i=o?.fill??"#000",r=o?.stroke??"none",a=o?.strokeWidth??1;this.body.push(`<circle cx="${st(t)}" cy="${st(e)}" r="${st(Math.max(0,n))}" fill="${Ot(i)}" stroke="${Ot(r)}" stroke-width="${st(a)}"${ln(o)} />`)}drawPath(t,e,n){if(t.length===0)return;let o=Gl(t,n),i=e?.fill??"none",r=e?.stroke??"none",a=e?.strokeWidth??1;this.body.push(`<path d="${o}" fill="${Ot(i)}" stroke="${Ot(r)}" stroke-width="${st(a)}" stroke-linecap="round" stroke-linejoin="round"${ln(e)} />`)}toSvg(t,e={}){let n=Math.max(0,e.padding??0),o=t.x-n,i=t.y-n,r=Math.max(1,t.w+n*2),a=Math.max(1,t.h+n*2),c=e.background?`<rect x="${st(o)}" y="${st(i)}" width="${st(r)}" height="${st(a)}" fill="${Ot(e.background)}" />`:"";return`<svg xmlns="http://www.w3.org/2000/svg" width="${st(r)}" height="${st(a)}" viewBox="${st(o)} ${st(i)} ${st(r)} ${st(a)}">${c}${this.body.join("")}</svg>`}};function Vl(s,t={}){let e=ge(s),n=e.map(()=>new Qn);return ze(s,n),n.map((o,i)=>o.toSvg(e[i],t))}function Ul(s,t,e=0,n=0,o=1,i=1){s.beginPath();for(let r of t){if(r.op==="Z"){s.closePath();continue}if(r.op==="M"){s.moveTo(e+r.x*o,n+r.y*i);continue}if(r.op==="L"){s.lineTo(e+r.x*o,n+r.y*i);continue}if(r.op==="Q"){s.quadraticCurveTo(e+r.cx*o,n+r.cy*i,e+r.x*o,n+r.y*i);continue}"cx1"in r&&s.bezierCurveTo(e+r.cx1*o,n+r.cy1*i,e+r.cx2*o,n+r.cy2*i,e+r.x*o,n+r.y*i)}}function fn(s,t){t?.opacity!==void 0&&(s.globalAlpha*=t.opacity)}var Jn=class{context;constructor(t){this.context=t}drawText(t,e,n,o){this.context.save(),fn(this.context,o),this.context.fillStyle=o.fill??"#000",this.context.font=Cn(o),this.context.textAlign=o.textAlign??"left",this.context.textBaseline="alphabetic",this.context.fillText(t,e,n),this.context.restore()}drawLine(t,e,n,o,i){this.context.save(),fn(this.context,i),this.context.beginPath(),this.context.moveTo(t,e),this.context.lineTo(n,o),this.context.strokeStyle=i?.stroke??i?.fill??"#000",this.context.lineWidth=i?.strokeWidth??1,this.context.lineCap="round",this.context.stroke(),this.context.restore()}drawRect(t,e,n,o,i){n<0||o<0||(this.context.save(),fn(this.context,i),i?.fill&&(this.context.fillStyle=i.fill,this.context.fillRect(t,e,n,o)),i?.stroke&&(this.context.strokeStyle=i.stroke,this.context.lineWidth=i.strokeWidth??1,this.context.strokeRect(t,e,n,o)),this.context.restore())}drawCircle(t,e,n,o){n<0||(this.context.save(),fn(this.context,o),this.context.beginPath(),this.context.arc(t,e,n,0,Math.PI*2),(o?.fill??!0)&&(this.context.fillStyle=o?.fill??"#000",this.context.fill()),o?.stroke&&(this.context.strokeStyle=o.stroke,this.context.lineWidth=o.strokeWidth??1,this.context.stroke()),this.context.restore())}drawPath(t,e,n){t.length!==0&&(this.context.save(),fn(this.context,e),Ul(this.context,t,n?.x,n?.y,n?.scaleX,n?.scaleY),e?.fill&&(this.context.fillStyle=e.fill,this.context.fill()),e?.stroke&&(this.context.strokeStyle=e.stroke,this.context.lineWidth=e.strokeWidth??1,this.context.lineCap="round",this.context.lineJoin="round",this.context.stroke()),this.context.restore())}};function jl(s,t){let e=ge(s);if(t.length!==e.length)throw new Error(`Expected ${e.length} page contexts, got ${t.length}`);for(let[n,o]of t.entries())o.save(),o.translate(-e[n].x,-e[n].y);try{ze(s,t.map(n=>new Jn(n)))}finally{for(let n of t)n.restore()}}function Qs(s,t,e){let n=0,o=s.length;for(;n<o;){let i=Math.floor((n+o)/2);e(s[i])<t?n=i+1:o=i}return n}function Ea(s,t,e){let n=Math.max(1,Math.round(t/48)),o=[],i=[...e].sort((a,c)=>a-c);for(let a of s){let c=[...a.notes].sort((l,p)=>l.ticks-p.ticks);for(let l of[t/2,t,t*2]){let p=l/3,f=Math.min(n,p/8),u=l/2,h=new Set(c.map(d=>Math.round(d.ticks/u)*u).filter((d,y)=>Math.abs(c[y].ticks-d)<=f));for(let d of h){let y=d+l,m=Qs(i,d,S=>S);for(;i[m]===d;)m++;if(i[m]<y)continue;let g=[0,1,2].map(S=>{let v=d+S*p,L=Qs(c,v-f,w=>w.ticks),I=Qs(c,v+f+1,w=>w.ticks);return c.slice(L,I).filter(w=>Math.abs(w.ticks-v)<=f&&Math.abs(w.durationTicks-p)<=f)});if(g.some(S=>S.length===0))continue;let x=g.map(S=>S.reduce((v,L)=>v+L.ticks,0)/S.length),b=x.reduce((S,v,L)=>S+Math.abs(v-(d+L*p)),0)/3,A=l/4,E=x.reduce((S,v)=>S+Math.abs(v-(d+Math.round((v-d)/A)*A)),0)/3;E-b>=f&&o.push({notes:g,start:d,span:l,advantage:E-b})}}}o.sort((a,c)=>c.advantage-a.advantage);let r=0;for(let a of o)if(!a.notes.some(c=>c.some(l=>l.triplet))){for(let c=0;c<3;c++)for(let l of a.notes[c])l.triplet={group:r,slot:c,startTicks:a.start,spanTicks:a.span};r++}return r>0}var Kl={title:"size=2em, align=center",subtitle:"size=0.85em, align=center",author:"size=0.8em, align=right"};function He(s,t){for(let e=t.length-1;e>=0;e--)s=`{${s} ^ ${t[e]}}`;return s}function to(s,t,e=""){if(t==="absolute")return s.octave===0?`@note(${s.name}, ${s.accidental}, 0)${e}`:`${s.name}${s.accidental}${s.octave}${e}`;let n=s.octave>0?"'".repeat(s.octave):",".repeat(-s.octave);return`${s.accidental}${s.name}${n}${e}`}function Js(s,t){return t.trim()!==t||/[\r\n%]/.test(t)||/^\s*[@{]/.test(t)||t.endsWith("\\")?`H.${s}: @text(${ht(t)}, ${Kl[s]})`:`H.${s}: ${t}`}function eo(s){let[t,e]=s.meter,n=[];return s.title&&n.push(Js("title",s.title)),s.subtitle&&n.push(Js("subtitle",s.subtitle)),s.author&&n.push(Js("author",s.author)),n.push(`H.signature: 1=${s.key} ${t}/${e}`),n.push(`H.tempo: ${s.tempo}`),n.join(`
|
|
116
|
-
|
|
125
|
+
)`}},ps=class{constructor(t,e,n){this.names=t;this.ast=e;this.connections=n;let o=t[0],s=t.at(-1),i=s.prepareLayout;s.prepareLayout=c=>{i.call(s,c),this.prepareLabels(c)};let a=o.prepareHorizontal;o.prepareHorizontal=c=>{a?.call(o,c),!(this.leftWidth<=0)&&c.registerHorizontalLayoutHook(o,o,({columns:l,start:u})=>{for(let p of l[u])p.WL=Math.max(p.WL,this.leftWidth)})}}names;ast;connections;layer="background";leftWidth=0;measuredLabels=[];get sourceSpan(){return this.ast.sourceSpan}prepareLabels(t){let e=ds(this.ast.size,this.ast.font),n=this.ast.size*ku,o=0;this.measuredLabels=this.connections.map(s=>{if(!s.name)return;let i=Yt(s.name,e,t.textMeasurer),a=0;for(let l=s.from-1;l<s.to;l++)a=Math.max(a,this.names[l].box.anchor);let c=(a>0?a+n:0)+i.w;return o=Math.max(o,c),{richLine:i,leftWidth:c}}),this.leftWidth=o}createGeometry(){let t=this.names[0].box,e=this.ast.size,n=h=>{let{y:g,visualAxis:b}=this.names[h].box;return g+b},o=n(0)-e*.5,s=n(this.names.length-1)+e*.5;if(s-o<1e-6)return{regions:[],paint(){}};let i=Math.max(lc,e*.19),a=i*se,c=i*ue,l=t.x+t.anchor,u=l+this.ast.braceSpace*uc+i/2,p=Math.min(i*.67,e*.25),m={x:u+i*1.33-i*.165,y:o+p,w:i*.33,h:s-o-p*2},d=[],f=[],x=[],y=[m];for(let h=0;h<this.connections.length;h++){let g=this.connections[h],b=n(g.from-1)-e*.5,T=n(g.to-1)+e*.5;if(g.kind==="bracket")d.push({x:u-i/2,y:b,w:i,h:T-b}),f.push({commands:ls,transform:{x:u,y:b,scaleX:i,scaleY:-i}},{commands:ls,transform:{x:u,y:T,scaleX:i,scaleY:i}}),y.push({x:u-i/2,y:b-c,w:a+i/2,h:T-b+c*2});else{let w=e*.35,A=m.x-e*.12-w,C=w/gn.w,_=(T-b)/gn.h;f.push({commands:cs,transform:{x:A-gn.x*C,y:b-gn.y*_,scaleX:C,scaleY:_}}),y.push({x:A,y:b,w,h:T-b})}let L=this.measuredLabels[h];L&&x.push({...L.richLine,x:l-L.leftWidth,y:(b+T-L.richLine.h)/2})}return d.push(m),this.names[0].ports["bar.number"]={x:u+i*1.33-t.x,y:Math.min(o,...y.map(h=>h.y))-t.y},y.push(...x),{regions:y,paint(h){for(let g of d)h.drawRect(g.x,g.y,g.w,g.h,{fill:"#000"});for(let g of f)h.drawPath(g.commands,{fill:"#000"},g.transform);for(let g of x)oe(h,g,g.x+g.w,g.y+g.baseline)}}}},ms=ie;var Mu=.6;function ds(r,t){return{fontFamily:t,fontSize:r*.85,fill:"#000",textAlign:"right"}}var pe=class r extends B{static def={name:["voice","v"],description:"\u58F0\u90E8",details:"~~~jpfun\n@voice({1 2 3}, \u94A2\u7434, \u7537=ha ha ha, \u5973=la la la)\n~~~\n- **\u989D\u5916\u53C2\u6570**\uFF1A\u6BCF\u9879\u4E3A\u4E00\u884C\u6B4C\u8BCD\uFF1B\u547D\u540D\u53C2\u6570\u540C\u65F6\u7ED9\u51FA\u6B4C\u8BCD\u884C\u540D\uFF0C\u4F4D\u7F6E\u53C2\u6570\u8868\u793A\u65E0\u884C\u540D\u3002\u7701\u7565\u58F0\u90E8\u540D\u4F46\u4ECD\u9700\u6B4C\u8BCD\u65F6\uFF0C\u4FDD\u7559\u7A7A\u4F4D\uFF0C\u5982 `@voice({1 2 3}, , ha ha ha)`\u3002\n\n\u6B4C\u8BCD\u53EF\u7528\u5F15\u53F7\u5305\u88F9\uFF1B\u8C03\u7528 `@voice` \u65F6\u6B4C\u8BCD\u82E5\u542B\u9017\u53F7\u987B\u52A0\u5F15\u53F7\u3002\u82F1\u6587\u7528\u7A7A\u683C\u6216\u8FDE\u5B57\u7B26 `-` \u5206\u8BCD\uFF0C\u7528 `@` \u7559\u7A7A\u3002\u540D\u79F0\u4E0E\u6B4C\u8BCD\u5747\u652F\u6301 `*\u659C\u4F53*`\u3001`**\u7C97\u4F53**`\u3001`_\u4E0B\u5212\u7EBF_`\u3001`^\u4E0A\u6807^`\uFF08\u53EF\u8DE8\u591A\u4E2A\u97F3\u7B26\uFF0C\u5982 `*\u6625\u7720\u4E0D\u89C9\u6653*`\uFF09\u3002\n\n**\u7B80\u5199**\uFF1A`N` \u58F0\u660E\u97F3\u7B26\u884C\uFF0C`L` \u58F0\u660E\u6B4C\u8BCD\u884C\uFF0C\u62EC\u53F7\u5185\u7684\u540D\u79F0\u53EF\u7701\u7565\uFF1A\n~~~jpfun\nN(\u94A2\u7434): 1 2 3\nL(\u7537): ha ha ha\nL: la la la\n~~~\n\u6362\u884C\u7ED3\u675F\u5F53\u524D\u884C\uFF0C\u884C\u672B\u52A0 `\\` \u53EF\u7EED\u884C\uFF1B`L:` \u4E2D\u53EF\u76F4\u63A5\u4F7F\u7528\u9017\u53F7\u3002",allowExtraArgs:!0,extraArgType:"string",args:[{type:"content",description:"\u58F0\u90E8\u7684\u97F3\u7B26\u5185\u5BB9",default:null},{name:"name",description:"\u663E\u793A\u5728\u5DE6\u4FA7\u7684\u58F0\u90E8\u540D\u79F0\uFF0C\u7A7A\u503C\u9690\u85CF\u540D\u79F0",type:"string",default:""}]};static deSugarAtom(t,e,n){if(t[e]!=="N"&&t[e]!=="L")return null;let o=e+1,s={start:o,end:o};if(t[o]==="("){let c=Gi(t,o+1,n);if(c<0)return null;s={start:o+1,end:c},o=c+1}if(t[o++]!==":")return null;if(t[e]==="N")return{next:o,node:{kind:"sugar",data:{class:r,name:s},span:{start:e,end:o}}};if(o=re(t,o,n),o>=n)return null;let i;if(t[o]==='"'){let c=$t(t,o,n);if(c<0)return null;i={start:o,end:c+1},o=c+1}else{let c=o;for(;o<n&&t[o]!==`
|
|
126
|
+
`;)o++;i={start:c,end:o}}return{next:o,node:{kind:"sugar",data:{class:r,lyric:i,name:s},span:{start:e,end:o}}}}static deSugarRelation(t,e,n,o){let s=e[n++];if(s.data?.class!==r)return null;let i=g=>t.parseArgWithType(g,"string")??"";if(s.data?.lyric!==void 0){let g=null,b=t.nodes.length-1;for(;b>=0;b--){let T=t.nodes[b];if(T instanceof kt){if(!t.variables.strict)continue;throw new k("E_LYRICS_WITHOUT_VOICE_NOTES","strict \u6A21\u5F0F\u4E0B\uFF0C\u8BED\u6CD5\u7CD6 'L:' \u6216 'L(name)' \u5FC5\u987B\u8DDF\u5728 @voice \u7684\u97F3\u7B26\u4E4B\u540E\uFF0C\u4F46\u5728\u5176\u524D\u9762\u53D1\u73B0\u4E86\u672A\u77E5\u6587\u672C",T.sourceSpan)}T instanceof r?g=T:T instanceof ie&&(g=T.voices.at(-1)??null);break}if(g===null)throw new k("E_LYRICS_WITHOUT_VOICE_NOTES","\u8BED\u6CD5\u7CD6 'L:' \u6216 'L(name):' \u5FC5\u987B\u8DDF\u5728 @voice\uFF08\u6216 N:\uFF09\u4E4B\u540E\uFF0C\u4F46\u6CA1\u6709\u627E\u5230\u7B26\u5408\u8981\u6C42\u7684 voice\uFF1B\u8BF7\u68C0\u67E5\u8BED\u6CD5\u6216\u76F4\u63A5\u4F7F\u7528 @voice \u51FD\u6570",s.span);return g.addLyric(i(s.data.name),i(s.data.lyric),s.span,t),t.nodes.length=b+1,n<e.length&&typeof e[n]=="number"&&t.source[e[n]]===`
|
|
127
|
+
`&&n++,n}let a=i(s.data.name),c=n,l=0;for(;c<e.length;c++){let g=e[c];if(typeof g=="number"){if(t.source[g]===`
|
|
128
|
+
`){l=1;break}}else if(g.kind==="sugar"&&(g.data?.class===r||g.data?.class===ie))break}let u=new _t(t),p=e.slice(n,c);if(c+=l,u.makeNodes(p),u.nodes.length===0)throw Y.error.EmptyContent("voice","content",s.span);let m={start:s.span.start,end:u.nodes.at(-1).sourceSpan.end},d=new Map;u.nodes.length===1&&u.nodes[0]instanceof Nt?d.set(0,u.nodes[0]):d.set(0,new Nt({...m},u.nodes)),d.set("name",a);let f=new r(m,d,t,null);if(o)return t.pushNode(f),o.push(f),c;let x=null,y=t.nodes.length-1,h=null;t:for(;y>=0;y--){let g=t.nodes[y];if(g instanceof kt){if(t.variables.strict)break;for(let b=g.sourceSpan.start;b<g.sourceSpan.end;b++)if(t.source[b]===`
|
|
129
|
+
`)break t;h=g;continue}if(g instanceof ie){if(!g.createdBySugar)break;x=g}else if(g instanceof r){let b=new Map;b.set(0,g),x=new ie({start:g.sourceSpan.start,end:g.sourceSpan.end},b,t,null),x.createdBySugar=!0}break}return x?(t.nodes[y]=x,x.addVoice(f),h&&(t.nodes.length=y+1,t.diagnostics.push(new K("W_VOICES_TEXT_BETWEEN","\u4E24\u4E2A @voice \u4E4B\u95F4\u6709\u672A\u77E5\u6587\u672C\u3002\u5F53\u524D\u5904\u4E8E\u975E strict \u6A21\u5F0F\uFF0C\u4F1A\u5FFD\u7565\u8BE5\u5185\u5BB9\u3001\u5408\u5E76\u4E3A\u4E00\u4E2A @voices",h.sourceSpan)))):t.pushNode(f),c}content;name;size;font;lyrics;get children(){return[this.content]}loweringEnter(t){let e=this.parent,n=e instanceof ie&&e.voices.length>1?e.braceSpace:0,o=new fs(this,n);if(this.lyrics.length>0){let s={nameHost:o,nodes:[],frames:[],onTemporal(i){W(i)&&s.nodes.push(i)},onAttachment(i){Xt(i)&&i.layer==="background"&&s.frames.push(i)}};t.beginLoweringGroup(this,s)}return[o]}loweringExit(t){if(this.lyrics.length>0){let{nodes:e,nameHost:n,frames:o}=t.endLoweringGroup(this);t.addAttachment(new uo(e,n,o))}return[]}constructor(t,e,n,o=null){super(t,o),this.size=n.variables.fontsize,[this.content,this.name]=this.getArgValue(e,n),this.content.parent=this,this.font=n.variables.font,e.delete(0),e.delete("name"),e.delete(1),this.lyrics=[];for(let[s,i]of e){if(typeof i=="string"){this.addLyric(s,i);continue}let a=i,c=n.parseArgWithType(a.valueSpan,"string",t.start);c===null?n.diagnostics.push(new K("W_VOICE_INVALID_LYRIC","@voice \u7684\u6B4C\u8BCD\u53C2\u6570\u503C\u89E3\u6790\u5931\u8D25, \u53C2\u6570[{key}]\u5C06\u88AB\u5FFD\u7565",a.valueSpan,{key:s})):this.addLyric(s,c)}}addLyric(t,e,n=null,o=null){typeof t=="number"&&(t="");let s=oc(e);if(s.length===0&&o&&n&&o.diagnostics.push(new K("W_EMPTY_LYRIC","@voice\u7684\u6B4C\u8BCD{name}\u662F\u7A7A\u7684",n,{name:t})),this.lyrics.push({name:t,tokens:s}),n)for(let i=this;i;i=i.parent)i.sourceSpan.start=Math.min(n.start,i.sourceSpan.start),i.sourceSpan.end=Math.max(n.end,i.sourceSpan.end)}toString(t){let e=[`${this.content.toString(t)},${lt(this.name)}`];for(let n of this.lyrics){let o=rc(n.tokens);e.push(n.name?`${n.name}=${o}`:o)}return`@voice(
|
|
130
|
+
${e.join(`,
|
|
131
|
+
`)}
|
|
132
|
+
)`}},fs=class extends tt{braceSpace;preparedName=null;constructor(t,e){super(),this.ast=t,this.braceSpace=e,this.mergeKey=-2,(t.name||e>0||t.lyrics.some(n=>n.name))&&this.initLayoutBox()}prepareLayout(t){this.preparedName=this.ast.name?Yt(this.ast.name,ds(this.ast.size,this.ast.font),t.textMeasurer):null;let e=this.preparedName?.w??0,n=lo(this.ast.size,this.ast.font);for(let s of this.ast.lyrics)s.name&&(e=Math.max(e,Yt(s.name,n,t.textMeasurer).w));let o=this.braceSpace>0?this.braceSpace:e>0?this.ast.size*Mu:0;this.box.w=e+o,this.box.h=this.preparedName?.h??0,this.box.anchor=e,this.box.visualAxis=this.box.h/2,this.springConfig.alpha_R=.45}paint(t){this.preparedName&&oe(t,this.preparedName,this.box.x+this.box.anchor,this.box.y+this.preparedName.baseline)}},ys=pe;var po=[pa,Ei,da,mi,Ci,_i,tc,Xa,ys,ms,eo,ba,xa,sa,Ta,ha,ga,ui,Bi,Hi,Ja,vi,Vi,Fi,ki,Ka,ma,Ys,$a,qn,Bn,Zn,Sa,Qn,Ga];function hs(r,t={}){let e=new Map,n=new Set(r);for(let o of n){let s=o.layoutDecorationHandler;if(!s)continue;let i=o.def?.name;if(!i)continue;let a=Array.isArray(i)?i[0]:i;e.set(fe(a),s)}return{textMeasurer:t.textMeasurer??ur,decorationHandlers:e}}var xn=class r{activeFinalizers=new Map;cnt=0;usedTracks=new Set;attachments=[];page;astToTemporal=new Map;activeLoweringGroups=[];diagnostics=[];setPageConfig(t){this.page=t}lowerDocument(t,e=[]){this.cnt=0,this.usedTracks.clear(),this.activeFinalizers.clear(),this.attachments=[],this.page=void 0,this.astToTemporal=new Map,this.activeLoweringGroups=[],this.diagnostics=e;let n=new ge,o=new G,s=this.trackedEvents(t,o,n);return this.solidifyColumns(s,o),this.postprocessResult({diagnostics:this.diagnostics,columns:s,attachments:this.attachments,astToTemporal:this.astToTemporal,duration:o,rootTrack:n,tracks:[...this.usedTracks],page:this.page})}solidifyColumns(t,e){let n=0;for(let m of t){let d=0;for(let f of m){let x=f.addon?.breakBefore??0;x>d&&(d=x)}n+=d,m.layoutLine=n}let o={bpm:Zt,velocity:Me,keySignature:Qe,program:kn},s=new Map,i=new Map,a=m=>s.get(m)??(m.parent?a(m.parent):Me),c=m=>i.get(m)??(m.parent?c(m.parent):kn),l=new G;for(let m of t){l.isZero()||m.shiftTime(l);let d;for(let f of m){o.velocity=a(f.track),o.program=c(f.track);let x=f.onTimeState?.(o);x&&!x.isZero()&&(!d||x.compare(d)>0)&&(d??=new G).copyFrom(x),s.set(f.track,o.velocity),i.set(f.track,o.program)}d&&l.add(d)}if(l.isZero())return;let u=new Set(i.keys()),p=new G;e.set(0);for(let m=t.length-1;m>=0&&u.size>0;m--){let d=t[m];for(let f=d.length-1;f>=0;f--){let x=d[f];if(!u.delete(x.track))continue;let y=x.T;p.copyFrom(x.t),y.isZero()||p.add(y),p.compare(e)>0&&e.copyFrom(p)}}}beginLoweringGroup(t,e){this.activeLoweringGroups.push({owner:t,group:e})}endLoweringGroup(t){let e=this.activeLoweringGroups.pop();if(!e)throw new Error("No active lowering group to end");if(e.owner!==t)throw new Error("Lowering groups must end in reverse order");return e.group}postprocessResult(t){if(this.activeLoweringGroups.length>0)throw new Error("Lowering groups must be closed before post-processing");let e=this.activeFinalizers.size;if(e===0)return t;if(e===1)return this.activeFinalizers.keys().next().value(t),t;let n=[...this.activeFinalizers.entries()].sort((o,s)=>o[1]-s[1]);for(let[o]of n)o(t);return t}deferFinalize(t,e=0){let n=this.activeFinalizers.get(t);(n===void 0||e<n)&&this.activeFinalizers.set(t,e)}addAttachment(t){this.attachments.push(t);for(let e=this.activeLoweringGroups.length-1;e>=0;e--)this.activeLoweringGroups[e].group.onAttachment?.(t)}getTemporalNodes(t){return this.astToTemporal.get(t)??[]}isolateFromLoweringGroups(t){let e=this.activeLoweringGroups;this.activeLoweringGroups=[];try{return t()}finally{this.activeLoweringGroups=e}}initEvent(t,e,n,o){t.t.add(n),this.usedTracks.add(o),t.track=o,t.ast??=e,t.order=this.cnt++,t.mergeKey??=t.order}trackedEvents(t,e,n,o=[]){this.appendEvents(t.loweringEnter(this,n),t,e,n,o);let s=t.timeFlowModel(this);if(s)switch(s.mode){case"sequence":for(let i of s.children)this.trackedEvents(i,e,n,o);break;case"parallel":{let i=s.tracks,a=s.children,c=i.hostIndex===void 0?0:i.hostIndex,l=n.group(i,c===null?a.length:a.length-1),u=[];for(let d=0;d<a.length;d++){let f=a[d],x=d===c?n:l.members[c===null||d<c?d:d-1],y=e.clone(),h=this.trackedEvents(f,y,x);h.length===0&&this.diagnostics.push(Y.warning.ZeroTimeTrack(f.sourceSpan,d+1)),u.push(h)}let p=o.length;for(let d of r.anchorAlign(u))o.push(d);let m=new G;for(let d=p;d<o.length;d++)for(let f of o[d])m.copyFrom(f.t).add(f.T),m.compare(e)>0&&e.copyFrom(m)}break}return this.appendEvents(t.loweringExit(this,n,e),t,e,n,o),o}appendEvents(t,e,n,o,s){let i;for(let a of t){this.initEvent(a,e,n,o),this.indexTemporal(a);for(let l=this.activeLoweringGroups.length-1;l>=0;l--)this.activeLoweringGroups[l].group.onTemporal?.(a);let c=(i??=new G).copyFrom(a.t).add(a.T);c.compare(n)>0&&n.copyFrom(c),s.push(new xs(a))}}indexTemporal(t){let e=this.astToTemporal.get(t.ast);e?e.push(t):this.astToTemporal.set(t.ast,[t])}static anchorAlign(t){for(let l=t.length-1;l>=0;l--)t[l].length===0&&t.splice(l,1);let e=t.length;if(e===0)return[];if(e===1)return t[0];let n=[],o=new Uint32Array(e),s=Array.from({length:e},()=>new G),i=[],a=new bs(e);for(let l=0;l<e;l++)a.push({e:t[l][0],i:l});let c=l=>{let u=t[l][++o[l]];u&&(s[l].isZero()||u.shiftTime(s[l]),a.push({e:u,i:l}))};for(;;){let l=a.pop();if(l===void 0){if(i.length===0)break;let p=i[0],m=p.e,d=m.t;for(let f=1;f<i.length;f++)i[f].e.t.compare(d)>0&&(d=i[f].e.t);s[p.i].add(d).sub(m.t),c(p.i);for(let f=1;f<i.length;f++){let x=i[f];m.push(...x.e),s[x.i].add(d).sub(x.e.t),c(x.i)}i.length=0,m.t=d,m.sort((f,x)=>f.order-x.order),n.push(m);continue}if(l.e.mergeKey===gt){i.push(l);continue}let u=[l.i];for(;;){let p=a.front();if(!p||!p.e.t.equals(l.e.t)||p.e.mergeKey!==l.e.mergeKey)break;a.pop(),l.e.push(...p.e),u.push(p.i)}n.push(l.e);for(let p of u)c(p)}return n}},xs=class extends Array{static get[Symbol.species](){return Array}mergeKey;constructor(t){super(1),this.mergeKey=t.mergeKey,this[0]=t}get t(){return this[0].t}set t(t){for(let e of this)e.t.copyFrom(t)}shiftTime(t){for(let e of this)e.t.add(t)}set layoutLine(t){for(let e of this)e.layoutLine=t}};function gs(r,t){let e=r.e.t.compare(t.e.t);return e!==0?e:r.e.mergeKey!==t.e.mergeKey?r.e.mergeKey<t.e.mergeKey?-1:1:r.i-t.i}var bs=class extends Array{validLen=0;constructor(t){super(t)}front(){if(this.validLen!==0)return this[0]}push(t){return this[this.validLen]=t,this.up(this.validLen++),this.validLen}pop(){if(this.validLen===0)return;let t=this[0];return this[0]=this[--this.validLen],this[this.validLen]=void 0,this.down(0),t}up(t){let e=this[t];for(;t>0;){let n=t-1>>1;if(gs(e,this[n])>=0)break;this[t]=this[n],t=n}this[t]=e}down(t){let e=this[t];for(;;){let n=(t<<1)+1,o=n+1;if(n>=this.validLen)break;let s=n;if(o<this.validLen&&gs(this[o],this[n])<0&&(s=o),gs(this[s],e)>=0)break;this[t]=this[s],t=s}this[t]=e}};function Ss(r,t={}){let{functions:e=po,textMeasurer:n,variables:o,...s}=t,{maskedSource:i,lineStarts:a}=ze(r),c=new _t({source:i,variables:o});c.registerFunctions(e);let l=new Nt({start:0,end:r.length},c.parse()),p=new xn().lowerDocument(l,c.diagnostics),m=hs(e,{textMeasurer:n}),d=Oo(p,m,s);return{lineStarts:a,maskedSource:i,diagnostics:c.diagnostics,ast:l,lowering:p,layout:d}}function Ru(r,t=po){let{maskedSource:e,commentSpans:n}=ze(r),o=new _t({source:e,commentSpans:n});return o.registerFunctions(t),{syntax:o.parseSyntax(),diagnostics:o.diagnostics}}function ws(r){return typeof r.applyPlayback=="function"}var pc=new WeakMap;function mc(r){let t=pc.get(r);if(t)return t;let e=[{performance:0,seconds:0,bpm:Zt}],n=0,o=0,s=Zt;for(let i of r){if(i.kind!=="tempo")continue;let a=i.at.toNumber();a>o&&(n+=(a-o)*60/s,o=a),s=i.bpm;let c=e[e.length-1];c.performance===o?c.bpm=s:e.push({performance:o,seconds:n,bpm:s})}return pc.set(r,e),e}function Ts(r,t,e){let n=0,o=r.length;for(;n<o;){let s=n+o>>>1;e(r[s])<=t?n=s+1:o=s}return r[Math.max(0,n-1)]}function mo(r,t){let e=Math.max(0,t),n=Ts(mc(r),e,o=>o.performance);return n.seconds+(e-n.performance)*60/n.bpm}function dc(r,t){let e=Math.max(0,t),n=Ts(mc(r),e,o=>o.seconds);return n.performance+(e-n.seconds)*n.bpm/60}function fc(r,t){let e=Math.max(0,t),n=Ts(r,e,o=>o.performance.toNumber());return n&&n.performance.toNumber()<=e?n.score.toNumber()+e-n.performance.toNumber():e}function yc(r,t){let e=Math.max(0,t),n;for(let o=0;o<r.length;o++){let s=r[o],i=s.score.toNumber();if(i>e){(!n||i<n.score.toNumber())&&(n=s);continue}let a=r[o+1],c=a?a.performance.toNumber()-s.performance.toNumber():1/0;if(!(e-i>=c))return s.performance.toNumber()+(e-i)}return n?.performance.toNumber()??e}function _u(r,t){let e=Math.min(dc(r.events,t),r.performanceDuration.toNumber());return fc(r.scoreMap,e)}function Fu(r,t){let e=Math.min(yc(r.scoreMap,t),r.performanceDuration.toNumber());return mo(r.events,e)}var hc={tempo:0,"time-signature":1,"program-change":2,"note-off":3,"note-on":4};function gc(r,t){return r.at.compare(t.at)||hc[r.kind]-hc[t.kind]||r.order-t.order}function xc(r,t,e){let n=new Map;for(let s of t)e.has(s)&&n.set(s,n.size);for(let s of e)n.has(s)||n.set(s,n.size);let o=[];for(let s of r){if(s.kind==="tempo"){o.push({kind:"tempo",at:s.at,bpm:s.bpm});continue}if(s.kind==="time-signature"){o.push({kind:"time-signature",at:s.at,numerator:s.numerator,denominator:s.denominator});continue}let i=n.get(s.track);if(i!==void 0){if(s.kind==="program-change"){o.push({kind:"program-change",at:s.at,track:i,program:s.program});continue}if(s.kind==="note-on"){o.push({kind:"note-on",at:s.at,noteId:s.noteId,track:i,midi:s.midi,velocity:s.velocity,...s.percussion?{percussion:!0}:{},sourceSpans:s.sourceSpans});continue}o.push({kind:"note-off",at:s.at,noteId:s.noteId,track:i,midi:s.midi})}}return{events:o,tracks:[...n.keys()]}}function Ou(r,t,e){let n=r.columns,o,s=(y,h)=>{if(!o){o=new Map;for(let g=0;g<n.length;g++)for(let b of n[g])o.set(b,g)}for(let g=y;g;g=g.foldedInto){let b=o.get(g);if(b===void 0)continue;if(h!=="end"||g.T.compare(0)<=0)return b;let T=g.t.clone().add(g.T),L=b;for(;L+1<n.length&&n[L+1][0].t.compare(T)<0;)L++;return L}},i=new Map,a=new Map,c=(y,h)=>{let g=y.playbackFlow?.(s);if(!g)return;let[b,T]=g.range??[0,n.length-1];if(g.range&&(!Number.isSafeInteger(b)||!Number.isSafeInteger(T)||b<0||T<b||T>=n.length))throw new k("E_PLAYBACK_FLOW_RANGE","\u64AD\u653E\u63A7\u5236\u6D41\u8303\u56F4 [{from}, {to}] \u8D85\u51FA\u65F6\u95F4\u5217\u8FB9\u754C",h,{from:b,to:T});let L={hook:g,sourceSpan:h};for(let w=b;w<=T;w++){let A=a.get(w);A?A.push(L):a.set(w,[L])}};for(let y of r.astToTemporal.values())for(let h of y){c(h,h.ast.sourceSpan);let g=h.playbackMarks?.();if(!g?.length)continue;let b=s(h);if(b!==void 0)for(let T of g){let L=i.get(T);L?L.push(b):i.set(T,[b])}}for(let y of r.attachments)c(y,y.sourceSpan??{start:0,end:0});if(a.size===0)return n.map((y,h)=>h);for(let y of i.values())y.sort((h,g)=>h-g);let l=new Array(n.length).fill(0),u=0,p={get column(){return u},visits:y=>l[y]??0,seek(y,h,g){let b=i.get(y);if(b){if(g>0)return b.find(T=>T>h);for(let T=b.length-1;T>=0;T--)if(b[T]<h)return b[T]}}},m=[],d=0;for(;u<n.length;){if(++d>e)throw new k("E_PLAYBACK_FLOW_LIMIT","\u64AD\u653E\u63A7\u5236\u6D41\u8BBF\u95EE\u8D85\u8FC7 {maxFlowSteps} \u6B65\uFF1B\u53EF\u901A\u8FC7 maxFlowSteps \u63D0\u9AD8\u5C55\u5F00\u9884\u7B97",n[u][0].ast.sourceSpan,{maxFlowSteps:e});l[u]++;let y;for(let h of a.get(u)??[]){let b=h.hook.run(p);if(b){if(b.kind==="stop")return m;if(!Number.isSafeInteger(b.column)||b.column<0||b.column>n.length)throw new k("E_PLAYBACK_FLOW_JUMP","\u64AD\u653E\u63A7\u5236\u6D41\u8DF3\u8F6C\u76EE\u6807 {column} \u8D85\u51FA\u65F6\u95F4\u5217\u8FB9\u754C",h.sourceSpan,{column:b.column});y=Math.min(y??1/0,b.column)}}y!==void 0?u=y:(m.push(u),u++)}let f=new Set(m),x=!1;for(let y=0;y<n.length;y++){let h=!f.has(y)&&n[y].some(g=>!g.T.isZero());h&&!x&&t.push(new K("W_PLAYBACK_COLUMN_NEVER_PLAYED","\u8FD9\u91CC\u5728\u4EFB\u4F55\u4E00\u904D\u91CC\u90FD\u4E0D\u4F1A\u6F14\u594F",n[y][0].ast.sourceSpan)),x=h}return m}function Iu(r,t){let e=t?.maxFlowSteps??65536;if(!Number.isSafeInteger(e)||e<=0)throw new k("E_PLAYBACK_FLOW_LIMIT","maxFlowSteps \u5FC5\u987B\u662F\u6B63\u5B89\u5168\u6574\u6570",r.columns[0]?.[0]?.ast.sourceSpan??{start:0,end:0});let n=[],o=[],s=[],i=[],a=new Map,c=new Map,l=0,u=0,p=[{kind:"initial",at:new G,origins:[]}],m=new Map,d=new Map,f={spans:s,notes:i,diagnostics:n,transform(P,F){if(i.lastIndexOf(P)<0)throw new k("E_PLAYBACK_TRANSFORM_TARGET","\u58F0\u97F3\u53D8\u6362\u76EE\u6807\u5FC5\u987B\u5C5E\u4E8E\u5F53\u524D\u8BA1\u5212\u7684\u5DF2\u53D1\u5E03\u97F3\u6BB5",P.sourceSpans?.[0]??{start:0,end:0});let $=a.get(P);a.set(P,$?[...$,F]:[F])}},x=(P,F,$)=>{if(!Number.isFinite(P.toNumber())||P.compare(0)<0)throw new k("E_PLAYBACK_CONTROL_TIME","\u7CFB\u7EDF\u63A7\u5236\u65F6\u523B\u5FC5\u987B\u662F\u975E\u8D1F\u6709\u9650\u503C",F.at(-1).node.ast.sourceSpan);p.push({kind:"control",at:P.clone(),origins:F,apply:$})};function y(P,F,$,H,X,ot=[],rt=P.track){if(!P.playbackState&&!P.emitPlayback)return;let ht=[...ot,{node:P}],dt=F.length?[...F]:void 0,at=$.length?[...$]:void 0,Pt,xt,me;function Bt(V){let J={...V,start:V.start.clone(),end:V.end.clone(),track:rt,origins:ht,sourceSpans:[{...P.ast.sourceSpan}]};return s.push(J),at&&d.set(J,at),J}let Mt=P.playbackState?.program;Mt!==void 0&&c.get(rt)!==Mt&&(c.set(rt,Mt),o.push({kind:"program-change",at:H.clone(),order:l++,track:rt,program:Mt}));let Ce=P.playbackState?.bpm;if(Ce!==void 0&&x(H,ht,V=>{V.bpm=Ce}),P.emitPlayback?.({start:H,end:H.clone().add(X),track:rt,span(V){Bt(V)},note(V){let J=Bt(V);i.push(J),dt&&a.set(J,dt)},extend(V){if(s.lastIndexOf(V)<0||!V.end.equals(H)||X.compare(0)<=0)throw new k("E_PLAYBACK_EXTEND_RANGE","\u6269\u5C55\u5FC5\u987B\u63A5\u7EED\u5F53\u524D\u8BA1\u5212\u5185\u7684\u533A\u95F4\u4E14\u65F6\u503C\u4E3A\u6B63",P.ast.sourceSpan);let J=V.end.clone().sub(V.start),At=J.clone().add(X),Rt=(d.get(V)??[]).map(ft=>ft.startRatio?{...ft,startRatio:ft.startRatio.clone().mul(J).div(At)}:ft);if(at)for(let ft of at)Rt.push({...ft,startRatio:J.clone().div(At)});Rt.length&&d.set(V,Rt),V.end.add(X)},emit:V=>o.push({...V,at:V.at.clone(),order:l++}),control:(V,J)=>x(V,ht,J),scaleFollowingBpm(V,J,At=1,Rt){if(!Number.isSafeInteger(J)||!Number.isSafeInteger(At)||J<=0||At<=0)throw new k("E_PLAYBACK_BPM_SCALE","\u901F\u5EA6\u6BD4\u4F8B\u5FC5\u987B\u662F\u6B63\u6709\u7406\u6570",P.ast.sourceSpan);let ft=new G(J,At),vt=m.get(V);if(vt&&!vt.equals(ft))throw new k("E_PLAYBACK_BPM_SCALE","\u540C\u4E00\u901F\u5EA6\u6548\u679C key \u5FC5\u987B\u4F7F\u7528\u56FA\u5B9A\u6BD4\u4F8B",P.ast.sourceSpan);m.set(V,ft),$.push({key:V,factor:ft,followConnections:Rt?.followConnections??!1,origins:ht})},affectFollowing:V=>F.push(V),defer:V=>(me??=[]).push(V),play:(V,J,At)=>y(V,Pt??=[...F],xt??=[...$],J??H,At??X,ht,rt)}),me)for(let V of me)V(f)}let h=Ou(r,n,e),g=r.columns[h[0]]?.[0]?.t.clone()??new G,b=[{performance:new G,score:g}],T=new G().sub(g),L=new G;for(let P=0;P<h.length;P++){let F=h[P];for(let ht of r.columns[F])!ht.playbackState&&!ht.emitPlayback||y(ht,[],[],ht.t.clone().add(T),ht.T.clone());let $=r.columns[F+1]?.[0]?.t??r.duration;L.copyFrom($).add(T);let H=h[P+1];if(H===void 0||H===F+1)continue;let X=r.columns[H][0]?.t.clone()??new G;T.add($).sub(X);let ot={performance:L.clone(),score:X};b[b.length-1].performance.equals(ot.performance)?b[b.length-1]=ot:b.push(ot)}for(let P of s){if(!Number.isFinite(P.start.toNumber())||!Number.isFinite(P.end.toNumber())||P.start.compare(0)<0||P.end.compare(P.start)<=0)throw new k("E_PLAYBACK_NOTE_RANGE","\u97F3\u6BB5\u5FC5\u987B\u5177\u6709\u975E\u8D1F\u8D77\u70B9\u548C\u6B63\u65F6\u503C",P.sourceSpans[0]);P.end.compare(L)>0&&L.copyFrom(P.end),Object.freeze(P.start),Object.freeze(P.end);for(let F of P.origins)Object.freeze(F);for(let F of P.sourceSpans)Object.freeze(F);Object.freeze(P.origins),Object.freeze(P.sourceSpans),Object.freeze(P)}let w,A=new Map,C=new Map,_={notes:i,diagnostics:n,connect(P,F){if(w??=new Set(i),!w.has(P)||!w.has(F)||!P.end.equals(F.start))throw new k("E_PLAYBACK_CONNECTION","\u97F3\u6BB5\u8FDE\u63A5\u5FC5\u987B\u5C5E\u4E8E\u5F53\u524D\u8BA1\u5212\u4E14\u65F6\u95F4\u76F8\u63A5",P.sourceSpans[0]);return A.has(P)&&A.get(P)!==F||C.has(F)&&C.get(F)!==P?!1:(A.set(P,F),C.set(F,P),!0)}};for(let P of r.attachments)ws(P)&&P.applyPlayback(_);for(let[P,F]of d){let $=P;if(F.some(H=>H.followConnections))for(;A.has($);)$=A.get($);for(let H of F){let X=H.startRatio?P.start.clone().add(P.end.clone().sub(P.start).mul(H.startRatio)):P.start;p.push({kind:"scale",at:X,origins:H.origins,scale:H,delta:1},{kind:"scale",at:H.followConnections?$.end:P.end,origins:H.origins,scale:H,delta:-1})}}let E={bpm:Zt,bpmScale:new G(1)},v=new Map,S=new G(1),M=[];p.sort((P,F)=>P.at.compare(F.at));let I=0,z;for(;I<p.length;){let P=p[I].at,F;for(;I<p.length&&p[I].at.equals(P);){let ot=p[I++];if(F=ot.origins.at(-1)??F,ot.kind==="control")ot.apply(E);else if(ot.kind==="scale"){let{key:rt,factor:ht}=ot.scale,dt=v.get(rt)??0,at=dt+ot.delta;v.set(rt,at),dt===0&&at>0?S.mul(ht):dt>0&&at===0&&S.div(ht)}}let $=E.bpmScale.clone().mul(S),H={bpm:E.bpm,bpmScale:$,effectiveBpm:E.bpm*$.toNumber()};if(!Number.isFinite(H.effectiveBpm)||H.effectiveBpm<=0)throw new k("E_PLAYBACK_BPM","\u7CFB\u7EDF\u63A7\u5236\u4EA7\u751F\u4E86\u65E0\u6548\u901F\u5EA6",F?.node.ast.sourceSpan??{start:0,end:0});let X=M.at(-1)?.state;(!X||X.bpm!==H.bpm||!X.bpmScale.equals($))&&M.push({at:P.clone(),state:H}),z!==H.effectiveBpm&&(z=H.effectiveBpm,o.push({kind:"tempo",at:P.clone(),bpm:H.effectiveBpm,order:l++}))}let j={diagnostics:n,stateAt(P){let F=0,$=M.length;for(;F<$;){let X=F+$>>>1;M[X].at.compare(P)<=0?F=X+1:$=X}let H=M[Math.max(0,F-1)].state;return{...H,bpmScale:H.bpmScale.clone()}}},q=(P,F)=>!a.has(F)&&P.track===F.track&&P.midi===F.midi&&P.percussion===F.percussion,et=new Set,N=new Map;for(let P of i){let F=C.get(P);if(F&&q(F,P))continue;let $=P,H=A.get($),X;for(;H&&q($,H);)A.delete($),X??=[...P.sourceSpans],X.push(...H.sourceSpans),$=H,H=A.get($);$!==P&&(A.delete($),H&&A.set(P,H));let ot=$.end,rt=X?Object.freeze(X):P.sourceSpans,ht=a.get(P),dt;if(ht){dt=[{...P,start:P.start.clone(),end:ot.clone(),sourceSpans:rt}];for(let xt of ht)dt=xt(j,dt)??dt;let Pt;for(let xt of dt){if(!Number.isFinite(xt.start.toNumber())||!Number.isFinite(xt.end.toNumber())||xt.start.compare(P.start)<0||xt.end.compare(ot)>0||xt.end.compare(xt.start)<=0)throw new k("E_PLAYBACK_TRANSFORM_RANGE","\u58F0\u97F3\u5C55\u5F00\u5FC5\u987B\u4F4D\u4E8E\u539F\u97F3\u6BB5\u533A\u95F4\u5185\u4E14\u65F6\u503C\u4E3A\u6B63",P.sourceSpans[0]);(!Pt||xt.start.compare(Pt)<0)&&(Pt=xt.start)}if(!Pt?.equals(P.start))throw new k("E_PLAYBACK_TRANSFORM_RANGE","\u58F0\u97F3\u5C55\u5F00\u5FC5\u987B\u4FDD\u6301\u539F\u97F3\u6BB5\u7684\u8D77\u70B9",P.sourceSpans[0])}else dt=[$===P?P:{...P,end:ot,sourceSpans:rt}];let at=H!==void 0||F!==void 0?[]:void 0;for(let Pt of dt){let{start:xt,end:me,track:Bt,midi:Mt,velocity:Ce,percussion:V,sourceSpans:J}=Pt,At=u++,Rt={kind:"note-on",at:xt.clone(),noteId:At,order:l++,track:Bt,midi:Mt,velocity:Ce,percussion:V,sourceSpans:[...J]},ft={kind:"note-off",at:me.clone(),noteId:At,order:l++,track:Bt,midi:Mt};et.add(Bt),o.push(Rt,ft),at?.push({on:Rt,off:ft})}at&&N.set(P,at)}let O=new Set,R=new Map,D=A.size>1?[...A.keys()].sort((P,F)=>F.start.compare(P.start)):A.keys();for(let P of D){let F=A.get(P);for(let $ of N.get(P)){if(!$.off.at.equals(F.start))continue;let H=N.get(F).find(X=>!O.has(X.on)&&X.on.at.equals(F.start)&&X.on.track===$.on.track&&X.on.midi===$.on.midi&&X.on.percussion===$.on.percussion);H&&($.off.at.copyFrom(H.off.at),R.set($.on,H.on),O.add(H.on),O.add(H.off))}}for(let P of R.keys())if(!O.has(P))for(let F=R.get(P);F;F=R.get(F))P.sourceSpans.push(...F.sourceSpans);let U=(O.size?o.filter(P=>!O.has(P)):o).sort(gc),Q=xc(U,r.tracks,et),Z=U.at(-1)?.at;return Z&&Z.compare(L)>0&&L.copyFrom(Z),{events:Q.events,scoreMap:b,tracks:Q.tracks,performanceDuration:L,durationSeconds:mo(Q.events,L.toNumber()),diagnostics:n}}function Ae(r){return r.pages.length>0?r.pages.map(t=>t.bounds):[r.bounds]}function As(r,t){for(let e of r.attachments)e.layer==="background"&&e.paint(t);for(let e of r.objects){e.paint(t);for(let n of e.decorations)n.paint?.(t)}for(let e of r.attachments)e.layer==="foreground"&&e.paint(t)}var Ls=class{constructor(t,e){this.pages=t;this.painters=e}pages;painters;route(t,e,n){let o=0,s=this.pages.length;for(;o<s;){let i=o+s>>>1,a=this.pages[i];a.y+a.h<t?o=i+1:s=i}for(let i=o;i<this.pages.length&&this.pages[i].y<=e;i++)n(this.painters[i])}drawText(t,e,n,o){this.route(n,n,s=>s.drawText(t,e,n,o))}drawLine(t,e,n,o,s){let i=(s?.strokeWidth??1)/2;this.route(Math.min(e,o)-i,Math.max(e,o)+i,a=>a.drawLine(t,e,n,o,s))}drawRect(t,e,n,o,s){let i=s?.stroke?(s.strokeWidth??1)/2:0;this.route(e-i,e+Math.max(0,o)+i,a=>{a.drawRect(t,e,n,o,s)})}drawCircle(t,e,n,o){let s=o?.stroke?(o.strokeWidth??1)/2:0,i=Math.max(0,n)+s;this.route(e-i,e+i,a=>a.drawCircle(t,e,n,o))}drawPath(t,e,n){if(t.length===0)return;let o=n?l=>n.y+l*n.scaleY:l=>l,s=1/0,i=-1/0,a=l=>{let u=o(l);s=Math.min(s,u),i=Math.max(i,u)};for(let l of t)l.op!=="Z"&&(l.op==="Q"&&a(l.cy),l.op==="C"&&(a(l.cy1),a(l.cy2)),a(l.y));if(!Number.isFinite(s))return;let c=e?.stroke?(e.strokeWidth??1)/2:0;this.route(s-c,i+c,l=>{l.drawPath(t,e,n)})}};function Ue(r,t){let e=Ae(r);if(t.length!==e.length)throw new Error(`Expected ${e.length} page painters, got ${t.length}`);As(r,new Ls(e,t))}var Cs=class{commands=[];replay(t){for(let e of this.commands)switch(e.kind){case"text":t.drawText(e.text,e.x,e.y,e.style);break;case"line":t.drawLine(e.x1,e.y1,e.x2,e.y2,e.style);break;case"rect":t.drawRect(e.x,e.y,e.w,e.h,e.style);break;case"circle":t.drawCircle(e.cx,e.cy,e.r,e.style);break;case"path":t.drawPath(e.commands,e.style);break}}drawText(t,e,n,o){this.commands.push({kind:"text",text:t,x:e,y:n,style:o})}drawLine(t,e,n,o,s){this.commands.push({kind:"line",x1:t,y1:e,x2:n,y2:o,style:s})}drawRect(t,e,n,o,s){this.commands.push({kind:"rect",x:t,y:e,w:n,h:o,style:s})}drawCircle(t,e,n,o){this.commands.push({kind:"circle",cx:t,cy:e,r:n,style:o})}drawPath(t,e,n){this.commands.push({kind:"path",commands:t.map(o=>Bu(o,n)),style:e})}};function Bu(r,t){if(!t||r.op==="Z")return{...r};let e=o=>t.x+o*t.scaleX,n=o=>t.y+o*t.scaleY;return r.op==="Q"?{op:"Q",cx:e(r.cx),cy:n(r.cy),x:e(r.x),y:n(r.y)}:r.op==="C"?{op:"C",cx1:e(r.cx1),cy1:n(r.cy1),cx2:e(r.cx2),cy2:n(r.cy2),x:e(r.x),y:n(r.y)}:{op:r.op,x:e(r.x),y:n(r.y)}}function it(r){return Number.isFinite(r)?String(Math.round(r*1e3)/1e3):"0"}function Ot(r){return r.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}var Du=Ot(Ve);function Vu(r,t){let e=[],n=t?s=>it(t.x+s*t.scaleX):it,o=t?s=>it(t.y+s*t.scaleY):it;for(let s of r){if(s.op==="Z"){e.push("Z");continue}if(s.op==="M"||s.op==="L"){e.push(`${s.op}${n(s.x)} ${o(s.y)}`);continue}if(s.op==="Q"){e.push(`Q${n(s.cx)} ${o(s.cy)} ${n(s.x)} ${o(s.y)}`);continue}"cx1"in s&&e.push(`C${n(s.cx1)} ${o(s.cy1)} ${n(s.cx2)} ${o(s.cy2)} ${n(s.x)} ${o(s.y)}`)}return e.join(" ")}var fo=class{body=[];drawText(t,e,n,o){let s=o.fontFamily??De,i=o.fontWeight??"normal",a=o.fill??"#000",c=o.textAlign==="center"?"middle":o.textAlign==="right"?"end":"start";this.body.push(`<text x="${it(e)}" y="${it(n)}"`+(s!==Ve?` font-family="${Ot(s)}"`:"")+` font-size="${it(o.fontSize)}"`+(i!=="normal"?` font-weight="${Ot(String(i))}"`:"")+(c!=="start"?` text-anchor="${c}"`:"")+(o.fontStyle&&o.fontStyle!=="normal"?` font-style="${Ot(o.fontStyle)}"`:"")+(a!=="#000"?` fill="${Ot(a)}"`:"")+(/\s/.test(t)?' xml:space="preserve"':"")+`>${Ot(t)}</text>`)}drawLine(t,e,n,o,s){let i=s?.stroke??s?.fill??"#000",a=s?.strokeWidth??1;this.body.push(`<line x1="${it(t)}" y1="${it(e)}" x2="${it(n)}" y2="${it(o)}" stroke="${Ot(i)}" stroke-width="${it(a)}" stroke-linecap="round" />`)}drawRect(t,e,n,o,s){let i=s?.fill??"none",a=s?.stroke??"none",c=s?.strokeWidth??1;this.body.push(`<rect x="${it(t)}" y="${it(e)}" width="${it(Math.max(0,n))}" height="${it(Math.max(0,o))}"`+(i!=="#000"?` fill="${Ot(i)}"`:"")+(a!=="none"?` stroke="${Ot(a)}" stroke-width="${it(c)}"`:"")+" />")}drawCircle(t,e,n,o){let s=o?.fill??"#000",i=o?.stroke??"none",a=o?.strokeWidth??1;this.body.push(`<circle cx="${it(t)}" cy="${it(e)}" r="${it(Math.max(0,n))}"`+(s!=="#000"?` fill="${Ot(s)}"`:"")+(i!=="none"?` stroke="${Ot(i)}" stroke-width="${it(a)}"`:"")+" />")}drawPath(t,e,n){if(t.length===0)return;let o=Vu(t,n),s=e?.fill??"none",i=e?.stroke??"none",a=e?.strokeWidth??1;this.body.push(`<path d="${o}"`+(s!=="#000"?` fill="${Ot(s)}"`:"")+(i!=="none"?` stroke="${Ot(i)}" stroke-width="${it(a)}" stroke-linecap="round" stroke-linejoin="round"`:"")+" />")}toSvg(t,e={}){let n=t.x,o=t.y,s=Math.max(1,t.w),i=Math.max(1,t.h),a=e.background?`<rect x="${it(n)}" y="${it(o)}" width="${it(s)}" height="${it(i)}" fill="${Ot(e.background)}" />`:"";return`<svg xmlns="http://www.w3.org/2000/svg" width="${it(s)}" height="${it(i)}" viewBox="${it(n)} ${it(o)} ${it(s)} ${it(i)}" font-family="${Du}" font-weight="normal" fill="#000">${a}${this.body.join("")}</svg>`}};function Hu(r,t={}){let e=Ae(r),n=e.map(()=>new fo);return Ue(r,n),n.map((o,s)=>o.toSvg(e[s],t))}function zu(r,t,e=0,n=0,o=1,s=1){r.beginPath();for(let i of t){if(i.op==="Z"){r.closePath();continue}if(i.op==="M"){r.moveTo(e+i.x*o,n+i.y*s);continue}if(i.op==="L"){r.lineTo(e+i.x*o,n+i.y*s);continue}if(i.op==="Q"){r.quadraticCurveTo(e+i.cx*o,n+i.cy*s,e+i.x*o,n+i.y*s);continue}"cx1"in i&&r.bezierCurveTo(e+i.cx1*o,n+i.cy1*s,e+i.cx2*o,n+i.cy2*s,e+i.x*o,n+i.y*s)}}var yo=class{constructor(t){this.context=t}context;drawText(t,e,n,o){this.context.fillStyle=o.fill??"#000",this.context.font=$n(o),this.context.textAlign=o.textAlign??"left",this.context.textBaseline="alphabetic",this.context.fillText(t,e,n)}drawLine(t,e,n,o,s){this.context.beginPath(),this.context.moveTo(t,e),this.context.lineTo(n,o),this.context.strokeStyle=s?.stroke??s?.fill??"#000",this.context.lineWidth=s?.strokeWidth??1,this.context.lineCap="round",this.context.stroke()}drawRect(t,e,n,o,s){n<0||o<0||(s?.fill&&(this.context.fillStyle=s.fill,this.context.fillRect(t,e,n,o)),s?.stroke&&(this.context.strokeStyle=s.stroke,this.context.lineWidth=s.strokeWidth??1,this.context.lineJoin="miter",this.context.strokeRect(t,e,n,o)))}drawCircle(t,e,n,o){if(n<0)return;this.context.beginPath(),this.context.arc(t,e,n,0,Math.PI*2);let s=o?.fill??"#000";s&&s!=="none"&&(this.context.fillStyle=s,this.context.fill()),o?.stroke&&(this.context.strokeStyle=o.stroke,this.context.lineWidth=o.strokeWidth??1,this.context.stroke())}drawPath(t,e,n){t.length!==0&&(zu(this.context,t,n?.x,n?.y,n?.scaleX,n?.scaleY),e?.fill&&(this.context.fillStyle=e.fill,this.context.fill()),e?.stroke&&(this.context.strokeStyle=e.stroke,this.context.lineWidth=e.strokeWidth??1,this.context.lineCap="round",this.context.lineJoin="round",this.context.stroke()))}};function Gu(r,t){let e=Ae(r);if(t.length!==e.length)throw new Error(`Expected ${e.length} page contexts, got ${t.length}`);for(let[n,o]of t.entries())o.save(),o.translate(-e[n].x,-e[n].y);try{Ue(r,t.map(n=>new yo(n)))}finally{for(let n of t)n.restore()}}function Ns(r,t,e){let n=0,o=r.length;for(;n<o;){let s=Math.floor((n+o)/2);e(r[s])<t?n=s+1:o=s}return n}function bc(r,t,e){let n=Math.max(1,Math.round(t/48)),o=[],s=[...e].sort((a,c)=>a-c);for(let a of r){let c=[...a.notes].sort((l,u)=>l.ticks-u.ticks);for(let l of[t/2,t,t*2]){let u=l/3,p=Math.min(n,u/8),m=l/2,d=new Set(c.map(f=>Math.round(f.ticks/m)*m).filter((f,x)=>Math.abs(c[x].ticks-f)<=p));for(let f of d){let x=f+l,y=Ns(s,f,w=>w);for(;s[y]===f;)y++;if(s[y]<x)continue;let h=[0,1,2].map(w=>{let A=f+w*u,C=Ns(c,A-p,E=>E.ticks),_=Ns(c,A+p+1,E=>E.ticks);return c.slice(C,_).filter(E=>Math.abs(E.ticks-A)<=p&&Math.abs(E.durationTicks-u)<=p)});if(h.some(w=>w.length===0))continue;let g=h.map(w=>w.reduce((A,C)=>A+C.ticks,0)/w.length),b=g.reduce((w,A,C)=>w+Math.abs(A-(f+C*u)),0)/3,T=l/4,L=g.reduce((w,A)=>w+Math.abs(A-(f+Math.round((A-f)/T)*T)),0)/3;L-b>=p&&o.push({notes:h,start:f,span:l,advantage:L-b})}}}o.sort((a,c)=>c.advantage-a.advantage);let i=0;for(let a of o)if(!a.notes.some(c=>c.some(l=>l.triplet))){for(let c=0;c<3;c++)for(let l of a.notes[c])l.triplet={group:i,slot:c,startTicks:a.start,spanTicks:a.span};i++}return i>0}var $u={title:"size=2em, align=center",subtitle:"size=0.85em, align=center",author:"size=0.8em, align=right"},ju=["1","#1","2","#2","3","4","#4","5","#5","6","#6","7"];function Ke(r,t){for(let e=t.length-1;e>=0;e--)r=`{${r} ^ ${t[e]}}`;return r}function ho(r){let t=(r%12+12)%12,e=Math.floor(r/12),n=e>0?"'".repeat(e):",".repeat(-e);return`${ju[t]}${n}`}function go(r,t,e){return e===0?`@note(${r}, ${t}, 0)`:`${r}${t}${e}`}function vs(r,t){return t.trim()!==t||/[\r\n%]/.test(t)||/^\s*[@{]/.test(t)||t.endsWith("\\")?`H.${r}: @text(${lt(t)}, ${$u[r]})`:`H.${r}: ${t}`}function xo(r){let[t,e]=r.meter,n=[];return r.title&&n.push(vs("title",r.title)),r.subtitle&&n.push(vs("subtitle",r.subtitle)),r.author&&n.push(vs("author",r.author)),n.push(`H.signature: 1=${r.key} ${t}/${e}`),n.push(`H.tempo: ${r.tempo}`),n.join(`
|
|
133
|
+
`)}function bo(r){let t=Math.max(0,...r.map(e=>e.length));return Array.from({length:t},(e,n)=>r.map(o=>o[n]).filter(Boolean).join(`
|
|
117
134
|
`)).join(`
|
|
118
135
|
|
|
119
|
-
`)}var
|
|
120
|
-
${
|
|
136
|
+
`)}var Wu=[4,4],Xu=1.03,Uu=1.25,Ku=4,Yu=8;function jt(r,t,e=0,n=Number.MAX_SAFE_INTEGER){if(!Number.isSafeInteger(r)||r<e||r>n)throw new RangeError(`${t} must be an integer in ${e}..${n}`)}function bn(r,t){if(!Array.isArray(r))throw new TypeError(`${t} must be an array`)}function qu(r,t,e){let n=1;for(;t*e>r*2**n;)n++;return n}function Zu(r){let t=new Map;for(let e of r)t.set(e.at,e);return[...t.values()]}function Sc(r,t){if(t==="relative")return ho(r-60);let e=He[r%12];return go(e[0],e.slice(1),Math.floor(r/12)-1)}function ks(r,t){return r.numerator*4*t/r.denominator}function Lc(r,t){let e=0,n=r.length-1;for(;e<n;){let o=Math.ceil((e+n)/2);r[o].at<=t?e=o:n=o-1}return r[e]}function wc(r,t,e,n){let o=Lc(e,r),s=ks(o,n),i=Math.max(0,Math.floor((r-o.at)/s)),a=o.at+i*s,c=n/2**t;return a+Math.round((r-a)/c)*c}function Qu(r,t){let e=new Map;for(let o of r)e.set(o.ticks,o);let n=[];for(let o of e.values()){let s=n.at(-1);if(!s){n.push(o);continue}let i=s.numerator*4*t/s.denominator,a=Math.max(0,Math.round((o.ticks-s.ticks)/i)),c={...o,ticks:s.ticks+a*i};c.ticks===s.ticks?n[n.length-1]=c:n.push(c)}return n}function Ju(r,t,e){let n=[];for(let o=0;o<r.length;o++){let s=r[o],i=r[o+1]?.ticks??t,a=s.numerator*4*e/s.denominator;for(let c=s.ticks+a;c<i&&c<t;c+=a)n.push(c)}return n}function tp(r){let t=new Map;for(let n of r){let o=`${n.start}:${n.end}`,s=t.get(o);s?s.notes.push(n):t.set(o,{start:n.start,end:n.end,notes:[n],triplet:n.triplet})}let e=[...t.values()];for(let n of e)n.notes.sort((o,s)=>o.midi-s.midi);return e.sort((n,o)=>n.start-o.start||n.end-o.end)}function ep(r){let t=new Map,e=[];for(let n of r)if(n.triplet){let o=t.get(n.triplet.group)??[];o.push(n),t.set(n.triplet.group,o)}else e.push(n);for(let n of t.values())n.sort((o,s)=>o.triplet.slot-s.triplet.slot),e.push({start:n[0].start,end:n.at(-1).end,members:n});return e.sort((n,o)=>n.start-o.start||n.end-o.end)}function np(r){let t=[];for(let n of r){let o=t.find(s=>s.items.at(-1).end<=n.start);o||t.push(o={items:[]}),o.items.push(n)}let e=n=>{let o=0,s=0;for(let i of n.items){let a="members"in i?i.members:[i];for(let c of a)for(let l of c.notes)o+=l.midi,s++}return o/s};return t.map(n=>({lane:n,averagePitch:e(n)})).sort((n,o)=>n.averagePitch-o.averagePitch).map(n=>n.lane)}function op(r){let t=[],e=[],n=0,o=()=>{e.length!==0&&(t.push({start:e[0].start,end:n,lanes:np(e)}),e=[])};for(let s of r)e.length>0&&s.start>=n&&o(),e.push(s),n=Math.max(n,s.end);return o(),t}function So(r,t){let e=[],n=r,o=!0;for(;n>0;){let s=2**Math.floor(Math.log2(Math.min(n,t)));n-=s;let i=0;if(o&&n<t)for(let c=s/2;c>=1&&n>=c;c/=2)n-=c,i++;let a=Math.log2(t/s);e.push("/".repeat(a)+".".repeat(i)),o=!1}return e}function rp(r,t,e,n){let s=`@page(width=${Math.max(1e6,r.length*64)}px, height=0px, top=0px, bottom=0px, left=0px, right=0px)
|
|
137
|
+
${r}`,i=n.compileScore(s,{horizontalOnly:!0}).layout,a=t.map(()=>({left:1/0,right:-1/0}));for(let d of i.objects){if(d.box.w<=0)continue;let f=Math.round(d.t.toNumber()*e),x=0,y=t.length;for(;x<y;){let b=x+y>>>1,T=t[b];f<T||f===T&&d.mergeKey===n.anchorKey?y=b:x=b+1}let h=x;h>=t.length&&(h=t.length-1);let g=a[h];g.left=Math.min(g.left,d.box.x),g.right=Math.max(g.right,d.box.x+d.box.w)}let c=n.page.width-n.page.marginLeft-n.page.marginRight,l=c*Xu,u=c*Uu,p=[{imbalance:0,previous:-1}];for(let d=1;d<=t.length;d++){let f;for(let x=d-1;x>=Math.max(0,d-Yu);x--){let y=1/0,h=-1/0;for(let w=x;w<d;w++)y=Math.min(y,a[w].left),h=Math.max(h,a[w].right);let g=h-y;if(g>u&&x<d-1)continue;let b=p[x];if(!b)continue;let T=g-l,L={imbalance:b.imbalance+T**2*(g<c?Ku:1),previous:x};(!f||L.imbalance<f.imbalance)&&(f=L)}p[d]=f}let m=new Set;for(let d=t.length;p[d].previous>0;d=p[d].previous)m.add(t[p[d].previous-1]);return m}function Tc(r,t,e="",n){let o=s=>n?`@${n[s]}`:"";return r.notes.length===1?`${Sc(r.notes[0].midi,t)}${e}${o(0)}`:`{${r.notes.map((s,i)=>`${Sc(s.midi,t)}${i===0?e:""}${o(i)}`).join(" ^ ")}}`}function sp(r,t,e,n,o,s,i,a,c,l,u,p,m){let d=new Set([t,e]);for(let w of r.items)d.add(w.start),d.add(w.end);for(let w of c)d.add(w);if(u)for(let w of u.keys())w>=t&&w<e&&d.add(w);for(let w of p.keys())w>=t&&w<e&&d.add(w);let f=[...d].sort((w,A)=>w-A),x=new Map(f.map((w,A)=>[w,A])),y=new Map,h=w=>w.map(A=>{let C=m();return A.push(C),C});if(m)for(let w of r.items){if("members"in w)continue;let A=x.get(w.start);for(let C=A;f[C]<w.end;C++){let _=So((f[C+1]-f[C])/s,o);if(f[C]>w.start&&a.has(f[C])||_.some((E,v)=>(f[C]>w.start||v>0)&&E.includes("/"))){y.set(w,w.notes.map(()=>[]));break}}}let g=Array.from({length:n},()=>[]),b=0,T=0,L;if(m&&p.size){L=0;let w=-1/0;for(let[A,C]of p)A<=t&&A>=w&&(L=C,w=A)}for(let w=0;w<f.length;w++){let A=f[w];for(;T<r.items.length&&r.items[T].end<=A;)T++;A>t&&A<e&&a.has(A)&&g[b].push("|"),A>t&&A<e&&l.has(A)&&b++;let C=f[w+1];if(C===void 0)continue;if(m){let v=A===t?L:p.get(A);v!==void 0&&g[b].push(`@program(${v})`)}let _=u?.get(A)??[],E=r.items[T];if(E&&E.start<=A&&E.end>=C){if("members"in E&&A===E.start){let S=(E.members[0].end-E.members[0].start)*3/(2*s),M=So(S,o).join(""),I=E.members.map(z=>Tc(z,i,M)).join(" ");g[b].push(Ke(`@tuplet({${I}}, 2)`,_)),w=x.get(E.end)-1;continue}if("members"in E)throw new Error("MIDI triplet rendering must start at its first slot");let v=So((C-A)/s,o);for(let S=0;S<v.length;S++){let M=v[S],I=A>E.start||S>0,z=y.get(E),j=!I||S===0&&a.has(A)||M.includes("/")?Tc(E,i,M,z&&h(z)):`-${M}`;g[b].push(S===0?Ke(j,_):j),z&&C===E.end&&S===v.length-1&&g[b].push(...z.map(q=>`@tie(${q.join(", ")})`))}}else g[b].push(...So((C-A)/s,o).map((v,S)=>S===0?Ke(`0${v}`,_):`0${v}`))}return g.map(w=>w.join(" "))}function ip(r,t,e,n,o,s,i){let a=o.size+1,c=Array.from({length:a},()=>[]),l=[],u=0;for(let d of r.regions)u<d.start&&l.push({start:u,end:d.start,lanes:[{items:[]}]}),l.push(d),u=d.end;u<t&&l.push({start:u,end:t,lanes:[{items:[]}]});let p=0,m=0;for(let d of l){for(d.start>0&&e.has(d.start)&&(c[m].push("|"),o.has(d.start)&&m++);p<n.length&&n[p]<=d.start;)p++;let f=p,x=m;for(;p<n.length&&n[p]<d.end;)o.has(n[p])&&x++,p++;let y=n.slice(f,p),h=x-m+1,g=d.lanes.map(b=>s(d,b,y,h));for(let b=0;b<h;b++){if(!g.some(L=>L[b]))continue;let T=g.length===1?g[0][b]:`@stack(${g.map(L=>`{ ${L[b]} }`).join(", ")})`;c[m+b].push(T)}m=x}return e.has(t)&&c[a-1].push("|"),c.map((d,f)=>`N${i&&f===0&&r.source.name?`(${lt(r.source.name)})`:""}: { ${d.join(" ")} }`)}function Ac(r,t={},e){if(!r||typeof r!="object"||!r.header||typeof r.header!="object")throw new TypeError("MIDI JSON must contain a header");if(bn(r.tracks,"tracks"),bn(r.header.tempos,"header.tempos"),bn(r.header.timeSignatures,"header.timeSignatures"),typeof r.header.name!="string")throw new TypeError("header.name must be a string");let n=r.header.tick;jt(n,"header.tick",1,32767);let o=t.alignRate??4;jt(o,"alignRate",2,16);let s=t.barsPerLine??0;if(!Number.isSafeInteger(s))throw new RangeError("barsPerLine must be an integer");let i=t.pitchMode??"absolute";if(i!=="relative"&&i!=="absolute")throw new TypeError("pitchMode must be relative or absolute");let a=t.title??r.header.name;if(typeof a!="string")throw new TypeError("title must be a string");let c=[],l=0,u=1;for(let[N,O]of r.tracks.entries()){if(!O||typeof O!="object"||typeof O.name!="string")throw new TypeError(`tracks[${N}] must contain a string name`);if(jt(O.channel,`tracks[${N}].channel`,0,15),O.channel===9)continue;bn(O.notes,`tracks[${N}].notes`),bn(O.instruments,`tracks[${N}].instruments`);let R=O.instruments.map((U,Q)=>(jt(U.ticks,`tracks[${N}].instruments[${Q}].ticks`),jt(U.number,`tracks[${N}].instruments[${Q}].number`,0,127),{...U})),D=O.notes.map((U,Q)=>{jt(U.ticks,`tracks[${N}].notes[${Q}].ticks`),jt(U.durationTicks,`tracks[${N}].notes[${Q}].durationTicks`,1),jt(U.midi,`tracks[${N}].notes[${Q}].midi`,0,127),l=Math.max(l,U.ticks+U.durationTicks);let Z=qu(U.durationTicks,n,o);return u=Math.max(u,Z),{...U,divisions:Z}});D.length>0&&c.push({source:O,notes:D,programs:R})}let p=Qu([{ticks:0,timeSignature:Wu},...r.header.timeSignatures].filter(N=>N.ticks===0||N.ticks<l).map((N,O)=>{jt(N.ticks,`header.timeSignatures[${O}].ticks`);let[R,D]=N.timeSignature;jt(R,`header.timeSignatures[${O}].numerator`,1,255),jt(D,`header.timeSignatures[${O}].denominator`,1,32768);let U=Math.log2(D);if(!Number.isInteger(U))throw new RangeError("MIDI time-signature denominator must be a power of two");return u=Math.max(u,U-2),{ticks:N.ticks,numerator:R,denominator:D}}).sort((N,O)=>N.ticks-O.ticks),n),m=[{ticks:0,bpm:Zt},...r.header.tempos.map((N,O)=>{if(jt(N.ticks,`header.tempos[${O}].ticks`),!Number.isFinite(N.bpm)||N.bpm<=0)throw new RangeError(`header.tempos[${O}].bpm must be positive and finite`);return N})].filter(N=>N.ticks===0||N.ticks<l).sort((N,O)=>N.ticks-O.ticks),d=2**u,f=bc(c,n,[...p.slice(1).map(N=>N.ticks),...m.slice(1).map(N=>N.ticks),...c.flatMap(N=>N.programs.map(O=>O.ticks)),...Ju(p,l,n)])?3:1,x=d*f,y=N=>{if(!Number.isSafeInteger(N*x))throw new RangeError("MIDI timeline is too large to quantize exactly");return N*x/n},h=N=>{if(!Number.isSafeInteger(N*d))throw new RangeError("MIDI timeline is too large to quantize exactly");return Math.round(N*d/n)*f},g=p.map(N=>({at:h(N.ticks),numerator:N.numerator,denominator:N.denominator})),b=[],T=new Map;for(let N of c)for(let O of N.notes)T.set(O.ticks,Math.max(T.get(O.ticks)??1,O.divisions));let L=0;for(let N of c){let O=N.notes.map(R=>{let D=R.triplet?Math.round(y(R.triplet.spanTicks)/3):0,U=R.triplet?Math.round(y(R.triplet.startTicks))+R.triplet.slot*D:wc(y(R.ticks),T.get(R.ticks),g,x),Q=R.triplet?U+D:wc(y(R.ticks+R.durationTicks),R.divisions,g,x),Z=x/2**R.divisions;return Q<=U&&(Q=U+Z),L=Math.max(L,Q),{...R,start:U,end:Q}});b.push({source:N.source,regions:op(ep(tp(O))),programs:new Map(N.programs.filter(R=>R.ticks===0||R.ticks<l).map(R=>[h(R.ticks),R.number]))})}let w=Lc(g,L),A=ks(w,x),C=L===0?0:w.at+Math.ceil((L-w.at)/A)*A,_=Zu(m.map(N=>({at:h(N.ticks),bpm:N.bpm}))).filter(N=>N.at===0||N.at<L),E=g.filter(N=>N.at===0||N.at<L),v=new Set;for(let N=0;N<E.length;N++){let O=E[N],R=E[N+1]?.at??C;O.at>0&&v.add(O.at);let D=ks(O,x);for(let U=O.at+D;U<=R&&U<=C;U+=D)v.add(U)}C>0&&v.add(C);let S=[...v].sort((N,O)=>N-O),M=new Map,I=(N,O)=>{let R=M.get(N)??[];R.push(O),M.set(N,R)};for(let N of E.slice(1))I(N.at,`@meter(${N.numerator}, ${N.denominator})`);for(let N of _.slice(1))I(N.at,`@tempo(${N.bpm})`);let z=E[0],j=xo({title:a,key:"C4",meter:[z.numerator,z.denominator],tempo:_[0].bpm});if(b.length===0)return j;let q=N=>{let O=0,R=N?()=>`mt${O++}`:void 0,D=N??new Set,U=b.map((Z,P)=>ip(Z,C,v,S,D,(F,$,H,X)=>sp($,F.start,F.end,X,d,f,i,v,H,D,P===0&&$===F.lanes.at(-1)?M:void 0,Z.programs,R),b.length>1)),Q=bo(U);return N?`${j}
|
|
121
138
|
|
|
122
|
-
${G}`:G},K=i<=0?ff(Q(),C,y,e):new Set(C.filter((N,R)=>(R+1)%i===0&&N<L));return Q(K)}function hf(s,t={}){return ka(s,t,{compileScore:Ks,anchorKey:mt,page:Ct})}function kt(s){return s.localName||s.tagName.split(":").at(-1)}function at(s,t){let e=[];for(let n=0;n<s.childNodes.length;n++){let o=s.childNodes[n];if(o.nodeType!==1)continue;let i=o;(t===void 0||kt(i)===t)&&e.push(i)}return e}function nt(s,t){for(let e=0;e<s.childNodes.length;e++){let n=s.childNodes[e];if(n.nodeType===1&&kt(n)===t)return n}}function ei(s,t){for(let e of at(s)){if(kt(e)===t)return e;let n=ei(e,t);if(n)return n}}function ni(s,t){let e=[];for(let n of at(s))kt(n)===t&&e.push(n),e.push(...ni(n,t));return e}function yt(s,t){return(t===void 0?s:s&&nt(s,t))?.textContent?.trim()??""}function ft(s,t,e){let n=yt(s,t);if(n===""){if(e!==void 0)return e;throw new RangeError(`MusicXML <${t}> must contain a finite number`)}let o=Number(n);if(Number.isFinite(o))return o;throw new RangeError(`MusicXML <${t}> must contain a finite number`)}var df=new Set(["ppp","pp","p","mp","mf","f","ff","fff"]),_a=256,mf={percussion:["PERCUSSION_SKIPPED","MIDI channel 10 percussion note was omitted."],displayPitch:["APPROXIMATED","Unpitched note was converted to a melodic note using its display pitch."],afterGrace:["APPROXIMATED","After-grace note has no preceding event and was treated as a before-grace note."],wedge:["APPROXIMATED","Wedge was mapped to note onsets with a fixed velocity change of {value}."],unsupported:["UNSUPPORTED_ELEMENT","MusicXML <{value}> was omitted."],gracePitch:["UNATTACHED_CONTENT","Grace note without a pitch was omitted."],graceHost:["UNATTACHED_CONTENT","Before-grace note has no following event and was omitted."],dynamicHost:["UNATTACHED_CONTENT","Dynamic {value} has no target voice and was omitted."],directionOutput:["UNATTACHED_CONTENT","Direction mark has no generated output position and was omitted."],tempoReplaced:["UNATTACHED_CONTENT","Tempo {value} was replaced by a different tempo at the same time and was omitted."],arpeggioOutput:["UNSUPPORTED_ELEMENT","Arpeggiate mark requires at least two pitches in one event and was omitted."],multipleRest:["APPROXIMATED","Multiple-rest grouping could not be preserved without discarding musical content; individual rests were retained."],textHost:["UNATTACHED_CONTENT","Text {value} has no target event and was omitted."],wedgeStart:["UNRESOLVED_RELATION","Wedge stop has no matching start and was omitted."],wedgeReplaced:["UNRESOLVED_RELATION","Wedge start was replaced before a matching stop and was omitted."],wedgeStop:["UNRESOLVED_RELATION","Wedge start has no matching stop and was omitted."],wedgeVoice:["UNRESOLVED_RELATION","Wedge has no target voice and was omitted."],wedgeEndpoints:["UNRESOLVED_RELATION","Wedge has no two distinct note onsets to use as endpoints and was omitted."],endingStart:["UNRESOLVED_RELATION","Ending stop has no matching start and was omitted."],endingReplaced:["UNRESOLVED_RELATION","Ending start was replaced before a matching stop and was omitted."],endingStop:["UNRESOLVED_RELATION","Ending start has no matching stop and was omitted."],endingEndpoints:["UNRESOLVED_RELATION","Ending has no event endpoints in its interval and was omitted."],tieStart:["UNRESOLVED_RELATION","Tie stop has no matching start and was omitted."],tieStop:["UNRESOLVED_RELATION","Tie start has no matching stop in any ending branch and was omitted."],glissStart:["UNRESOLVED_RELATION","Glissando stop has no matching start and was omitted."],glissStop:["UNRESOLVED_RELATION","Glissando start has no matching stop and was omitted."],glissReplaced:["UNRESOLVED_RELATION","Glissando start was replaced before a matching stop and was omitted."],glissEndpoints:["UNRESOLVED_RELATION","Glissando endpoints are simultaneous or cross a score line and were omitted."],glissStyle:["APPROXIMATED","MusicXML <{value}> was converted to a straight glissando arrow."]};function ot(s,t,e,n=""){let[o,i]=mf[t];s.push({code:`W_MUSICXML_${o}`,severity:"warning",message:i.replace("{value}",()=>String(n)),location:e})}var un=class{roots;accepted=[];constructor(t){this.roots=t}read(t,e=!1,n){for(let o of n?[n]:this.roots){let i=e?ei(o,t):nt(o,t);if(i)return i}}readAll(t,e=!1){return this.roots.flatMap(n=>e?ni(n,t):at(n,t))}accept(t){t&&this.accepted.push(t)}report(t,e,n){for(let o of n?[n]:this.roots)for(let i of at(o)){if(this.accepted.includes(i))continue;let r=kt(i);ot(t,"unsupported",{...e,element:r},r)}}};function oi(s,t){let e=s.getAttribute("placement");return e==="above"||e==="below"?e:t}function Ia(s){let t=new Map,e=kt(s);if(e==="score-partwise"){for(let n of at(s,"part"))t.set(n.getAttribute("id")??"",at(n,"measure").map(o=>({body:o,container:o})));return t}if(e==="score-timewise"){for(let n of at(s,"measure"))for(let o of at(n,"part")){let i=o.getAttribute("id")??"",r=t.get(i)??[];r.push({body:o,container:n}),t.set(i,r)}return t}throw new TypeError(`Unsupported MusicXML root <${e}>`)}function si(s){let t={};if(nt(s,"midi-channel")&&(t.channel=ft(s,"midi-channel"),!Number.isSafeInteger(t.channel)||t.channel<1||t.channel>16))throw new RangeError("MusicXML midi-channel must be an integer in 1..16");if(nt(s,"midi-program")&&(t.program=ft(s,"midi-program")-1,!Number.isSafeInteger(t.program)||t.program<0||t.program>127))throw new RangeError("MusicXML midi-program must be an integer in 1..128");return t}function Ra(s){let t=at(s,"credit"),e=f=>{let u=t.find(h=>yt(h,"credit-type")===f);return u?yt(u,"credit-words"):""},n=yt(nt(s,"work"),"work-title"),o=yt(s,"movement-title")||(n!=="Untitled Score"&&n!=="\u672A\u547D\u540D\u4E50\u8C31"?n:"")||e("title"),i=e("subtitle"),r=e("composer")||(()=>{let f=nt(s,"identification"),u=f?at(f,"creator"):[];return yt(u.find(h=>h.getAttribute("type")==="composer")??u[0])})(),a,c=nt(s,"defaults"),l=c&&nt(c,"scaling"),p=c&&nt(c,"page-layout");if(l&&p&&nt(p,"page-width")&&nt(p,"page-height")){let f=ft(l,"millimeters")/ft(l,"tenths")*96/25.4,u=at(p,"page-margins"),h=u.find(d=>d.getAttribute("type")==="odd")??u[0];Number.isFinite(f)&&f>0&&(a={width:ft(p,"page-width")*f,height:ft(p,"page-height")*f,top:h?ft(h,"top-margin",48/f)*f:48,bottom:h?ft(h,"bottom-margin",48/f)*f:48,left:h?ft(h,"left-margin",40/f)*f:40,right:h?ft(h,"right-margin",40/f)*f:40})}return{title:o,subtitle:i,creator:r,page:a}}function Oa(s,t,e){let n=e?.readAll("tied"),o=nt(s,"pitch"),i=o??nt(s,"unpitched");if(!i)return null;let r=yt(i,o?"step":"display-step").toUpperCase(),a=o?ft(i,"alter",0):0,c=ft(i,o?"octave":"display-octave");if(!/^[A-G]$/.test(r)||!Number.isInteger(a)||!Number.isInteger(c))throw new RangeError("jpFun requires MusicXML pitches with integer step alterations and octaves");let l=new Set,p=at(s,"tie");for(let f of p)l.add(f.getAttribute("type")??"");if(n)for(let f of n){let u=f.getAttribute("type")??"";l.add(u),(u==="start"||u==="stop"||u==="continue")&&e?.accept(f)}return{location:{...t,element:p.length?"tie":n?.length?"tied":kt(s)},step:r,alter:a,octave:c,tieStart:l.has("start")||l.has("continue"),tieStop:l.has("stop")||l.has("continue")}}function $a(s,t,e,n){let o=(s.octave+1)*12+vt[s.step]+s.alter+t+n*12;if(e===void 0){let i=ee[(o%12+12)%12];s.step=i[0],s.alter=i.length-1,s.octave=Math.floor(o/12)-1}else{let i="CDEFGAB",r=s.octave*7+i.indexOf(s.step)+e+n*7;s.step=i[(r%7+7)%7],s.octave=Math.floor(r/7),s.alter=o-(s.octave+1)*12-vt[s.step]}}function Pa(s,t,e){let n=[],o=[];if(!s)return{modifiers:n,slides:o};let i=s.read("fermata");i&&(n.push({name:"fermata",placement:oi(i,i.getAttribute("type")==="inverted"?"below":"above")}),s.accept(i));let r=s.read("articulations");if(r){let c=s.read("accent",!1,r);c&&(n.push({name:"accent",placement:oi(c,"above")}),s.accept(c));for(let[l,p,f]of[["scoop","pre","up"],["plop","pre","down"],["doit","post","up"],["falloff","post","down"]])for(let u of at(r,l))o.push({side:p,direction:f}),s.accept(u),(u.getAttribute("line-shape")==="curved"||u.getAttribute("line-type")==="wavy")&&ot(t,"glissStyle",{...e,element:l},l);s.report(t,e,r),s.accept(r)}let a=s.read("ornaments");if(a){let c=[["trill-mark","tr"],["mordent","mordent"],["inverted-mordent","prall"]];for(let[l,p]of c){let f=s.read(l,!1,a);f&&(n.push({name:p,placement:oi(f,"above")}),s.accept(f))}s.report(t,e,a),s.accept(a)}return{modifiers:n,slides:o}}function Da(s,t,e){if(!(!s||!t))for(let n of["slide","glissando"])for(let o of s.readAll(n)){let i=o.getAttribute("type");i!=="start"&&i!=="stop"||((t.glissandi??=[]).push({kind:n,type:i,number:o.getAttribute("number")||"1"}),s.accept(o),i==="start"&&(n==="glissando"&&o.getAttribute("line-type")!=="solid"||o.getAttribute("line-type")==="wavy"||yt(o))&&ot(e,"glissStyle",{...t.location,element:n},n))}}function ii(s,t){if(!t||t.direction==="none")return s??t;if(s&&s.direction!=="none"&&s.direction!==t.direction)throw new RangeError("Conflicting MusicXML arpeggiate directions in one chord");return t}function Ba(s,t){if(!s)return;let e;for(let n of s.readAll("arpeggiate")){let o=n.getAttribute("direction")||"none";if(o!=="none"&&o!=="up"&&o!=="down")throw new RangeError(`Unsupported MusicXML arpeggiate direction: ${o}`);e=ii(e,{direction:o,location:{...t,element:"arpeggiate"}}),s.accept(n)}return e}function Fa(s,t){let e=nt(s,"time-modification");if(!e)return;let n=ft(e,"actual-notes"),o=ft(e,"normal-notes");if(!Number.isSafeInteger(n)||n<2||!Number.isSafeInteger(o)||o<=0)throw new RangeError("MusicXML time-modification requires positive integer actual-notes and normal-notes");return{actual:n,normal:o,start:t?.some(i=>i.getAttribute("type")==="start")??!1,stop:t?.some(i=>i.getAttribute("type")==="stop")??!1}}function za(s,t,e){if(!(!s||!t||!e))for(let n of t){let o=n.getAttribute("type");(o==="start"||o==="stop")&&e[o]&&s.accept(n)}}function Ha(s){let t=new Map;for(let e of at(s,"lyric")){let n=e.getAttribute("number")||e.getAttribute("name")||"1",o=at(e).filter(r=>["text","elision"].includes(kt(r))).map(r=>kt(r)==="elision"?"~":yt(r)).join(""),i=yt(e,"syllabic");t.set(n,o&&(i==="begin"||i==="middle")?`${o}-`:o)}return t}function Wa(s,t,e){if(!s)return;let n;for(let o of at(s)){let i=kt(o);!n&&df.has(i)?n=i:ot(t,"unsupported",{...e,element:i},i)}return n}function Ga(s){let t=[];for(let e of["rehearsal","words"])for(let n of s.readAll(e,!0)){let o=n.textContent?.trim();o&&t.push({text:o,boxed:e==="rehearsal"}),s.accept(n)}return t}function Va(s){if(!s)return;let t=Number(yt(s,"per-minute")),e=yt(s,"beat-unit"),o={maxima:32,long:16,breve:8,whole:4,half:2,quarter:1,eighth:.5,"16th":.25,"32nd":.125,"64th":.0625,"128th":.03125,"256th":.015625,"512th":.0078125,"1024th":.00390625}[e];if(!Number.isFinite(t)||o===void 0)return;let i=o/2;for(let r of at(s,"beat-unit-dot"))o+=i,i/=2;return t*o}function Ua(s){let t=[],e;for(let r of at(s)){let a=kt(r);a==="beats"?e=yt(r).split("+").reduce((c,l)=>c+Number(l),0):a==="beat-type"&&e!==void 0&&(t.push({beats:e,beatType:Number(yt(r))}),e=void 0)}if(t.length===0||t.some(r=>!Number.isSafeInteger(r.beats)||r.beats<=0||!Number.isSafeInteger(r.beatType)||r.beatType<=0))throw new RangeError("MusicXML time signature must contain positive integer beats/beat-type pairs");let n=(r,a)=>a===0?r:n(a,r%a),o=t.reduce((r,a)=>r/n(r,a.beatType)*a.beatType,1),i=t.reduce((r,a)=>r+a.beats*o/a.beatType,0);if(!Number.isSafeInteger(i)||!Number.isSafeInteger(o))throw new RangeError("MusicXML time signature exceeds the supported integer range");return{numerator:i,denominator:o}}function ja(s){let t=new Set;for(let e of s.split(/\s*,\s*/)){let n=e.match(/^(\d+)(?:\s*-\s*(\d+))?$/);if(!n)throw new RangeError("MusicXML ending number must contain positive integers or ascending ranges");let o=Number(n[1]),i=Number(n[2]??n[1]);if(!Number.isSafeInteger(o)||!Number.isSafeInteger(i)||o<1||i<o||i>_a)throw new RangeError(`MusicXML ending passes must be ascending integers in 1..${_a}`);for(let r=o;r<=i;r++)t.add(r)}return[...t].sort((e,n)=>e-n)}function ri(s){return s.start.clone().add(s.duration)}function ai(s,{partId:t,staff:e,voice:n}){return s.filter(o=>o.partId===t&&o.staff===e&&(!n||o.voice===n))}function Ka(s,t,e){let n=[],o=new Map;for(let a of s.sort((c,l)=>c.at.compare(l.at))){let{partId:c,staff:l,voice:p=""}=a.location,f=`${c}\0${l}\0${p}\0${a.number}`;if(a.type==="stop"){let u=o.get(f);u?n.push({from:u,end:a.at}):ot(e,"wedgeStart",a.location),o.delete(f)}else{let u=o.get(f);u&&ot(e,"wedgeReplaced",u.location),o.set(f,a)}}for(let a of o.values())ot(e,"wedgeStop",a.location);let i=[],r;for(let a of t.sort((c,l)=>c.at.compare(l.at)))a.type==="start"?(r&&ot(e,"endingReplaced",r.location),r=a):r?(i.push({from:r,end:a.at}),r=void 0):ot(e,"endingStart",a.location);return r&&ot(e,"endingStop",r.location),{wedges:n,endings:i}}function xf(s,t,e,n,o){let i=s[0];if(i)for(let r of t){if(r.from.at.compare(r.end)>=0)continue;let a=e.find(u=>u.at.compare(r.from.at)>=0&&u.at.compare(r.end)<0),c=a?.location.partId??i.partId,l=a?.location.staff??i.staff,p=s.filter(u=>u.partId===c&&u.staff===l);if(p.some(u=>u.events.some(h=>h.start.compare(r.from.at)>=0&&h.start.compare(r.end)<0)))continue;let f=p.find(u=>!u.events.some(h=>h.start.compare(r.end)<0&&ri(h).compare(r.from.at)>0));if(!f){let u=p.map(h=>Number(h.voice)).filter(Number.isFinite);f={partId:c,partName:o.get(c)??c,staff:l,voice:String(Math.max(0,...u)+1),events:[]},s.push(f)}f.events.push({start:r.from.at.clone(),duration:r.end.clone().sub(r.from.at),pitches:[],rest:!0,order:n++,modifiers:[],annotations:[],preGraces:[],postGraces:[],lyrics:new Map}),f.events.sort((u,h)=>u.start.compare(h.start)||u.order-h.order)}}function yf(s,t,e){for(let n of t){let o=ai(s,n.location);if(n.dynamic&&o.length===0&&ot(e,"dynamicHost",{...n.location,element:"dynamics"},n.dynamic),n.dynamic){let r={at:n.at,name:n.dynamic,placement:n.placement,location:{...n.location,element:"dynamics"}};for(let a of o)(a.dynamics??=[]).push(r)}if(n.texts.length===0)continue;let i;t:for(let r of o)for(let a of r.events){let c=a.start.compare(n.at);if(c<0&&ri(a).compare(n.at)>0){i=a;break t}(!i||i.start.compare(n.at)<0||c>=0&&(a.start.compare(i.start)<0||a.start.equals(i.start)&&a.order<i.order))&&(i=a)}for(let r of n.texts)i?i.annotations.push({...r,placement:n.placement}):ot(e,"textHost",{...n.location,element:r.boxed?"rehearsal":"words"},ht(r.text))}}function gf(s){return s.flatMap(t=>{let e=[];for(let n of[...t.events].sort((o,i)=>o.start.compare(i.start)||o.order-i.order)){let o=e.find(i=>ri(i.events.at(-1)).compare(n.start)<=0);o?o.events.push(n):e.push({...t,events:[n]})}return e.length?e:[t]})}function Ya(s,t,e,n,o,i){return xf(s,t,e,n,o),yf(s,e,i),gf(s)}var Xa=["Cb","Gb","Db","Ab","Eb","Bb","F","C","G","D","A","E","B","F#","C#"],bf=["Ab","Eb","Bb","F","C","G","D","A","E","B","F#","C#","G#","D#","A#"],qa=["1","1#","2","2#","3","4","4#","5","5#","6","6#","7"];function zt(s,t){return s.clone().add(t)}function ct(s){return s.toString()}function We(s){let[t,e="1"]=s.split("/");return new F(Number(t),Number(e))}function Vt(s,t,e){let n=0,o=s.length;for(;n<o;){let i=n+o>>1;e(s[i]).compare(t)<0?n=i+1:o=i}return n}function ci(s,t){let e=s[Vt(s,t,n=>n.start)-1];return!!e&&e.end.compare(t)>0}function wf(s){let t=s.endsWith("-"),e=t?s.slice(0,-1):s,n=e.replace(/[\\{}@-]/g,"\\$&")+(t?"-":""),o=[...e].some(i=>i.codePointAt(0)>127);return/\s/.test(e)||o&&([...e].length>1||e.length>1||t)?`{${n}}`:n}function hn(s,t,e){let n=ct(t),o=s.get(n);if(!o||o==="|"){s.set(n,e);return}o==="|:"&&e.startsWith(":|")?s.set(n,e===":|"?":|:":`${e} |:`):e==="|:"&&o.includes(":|")?s.set(n,o===":|"?":|:":`${o} |:`):e==="|||"&&!o.includes("|:")&&!o.includes(":|")&&s.set(n,e)}function Sf(s,t){let e=new Map,n=new Map,o=nt(s,"part-list");if(o)for(let w of at(o,"score-part")){let M=w.getAttribute("id")??"";e.set(M,yt(w,"part-name"));let C=new Map,_;for(let P of at(w,"midi-instrument")){let W=si(P);_??=W,C.set(P.getAttribute("id")??"",W)}n.set(M,{fallback:_,byId:C})}let i=Ra(s),r=new Map,a=new Map,c=new Map,l=new Map,p=[],f=[],u=new Map,h=new Map,d=new Set,y=new Set,m=[],g=new F,x=0,b=Ia(s),A=new Map([...b.keys()].map((w,M)=>[w,M])),E=b.keys().next().value,S=[];for(let[w,M]of b){let C=n.get(w),_=1,P=new F,W={numerator:4,denominator:4},Z=new Map,Q=new Map,K=[],N=[],R=[],O=new Map,j=[],B=m.length,G=(T,D)=>{let z={...C?.byId.get(T)??C?.fallback};for(let Y of R)Y.id===T&&Y.at.compare(D)<=0&&Object.assign(z,Y.instrument);return z};for(let T=0;T<M.length;T++){j.push(P.clone());let{body:D,container:z}=M[T],Y={partId:w,measureIndex:T+1,measureNumber:z.getAttribute("number")??void 0},V=new F,et=new F,gt;z.getAttribute("implicit")!=="yes"&&T>0&&(hn(h,P,"|"),w===E&&d.add(ct(P)));let rt=nt(D,"print")??(z===D?void 0:nt(z,"print"));(rt?.getAttribute("new-system")==="yes"||rt?.getAttribute("new-page")==="yes")&&(P.isZero()||y.add(ct(P)));let bt=at(D),Mt=(J,U)=>{let pt=nt(J,"repeat"),Nt=pt?.getAttribute("direction");if(Nt==="forward")hn(h,U,"|:");else if(Nt==="backward"){let $t=pt?.getAttribute("times"),be=$t?Number($t):2;if(!Number.isSafeInteger(be)||be<2)throw new RangeError("MusicXML repeat times must be an integer of at least 2");hn(h,U,new Array(be-1).fill(":|").join(" "))}else yt(J,"bar-style")==="light-heavy"&&hn(h,U,"|||");let At=nt(J,"ending"),ut=At?.getAttribute("type");if(At&&(ut==="start"||ut==="stop"||ut==="discontinue")){let $t=ja(At.getAttribute("number")??"");$t.length>0&&u.set(`${ct(U)}\0${ut}\0${$t.join(",")}`,{location:{...Y,element:"ending"},at:U.clone(),type:ut,passes:$t})}};for(let J of bt){let U=kt(J);if(U==="attributes"){let it=zt(P,V);for(let Et of at(J,"transpose")){let St=ft(Et,"chromatic"),Se=nt(Et,"diatonic")?ft(Et,"diatonic"):void 0,Ae=ft(Et,"octave-change",0);if(![St,Ae,Se??0].every(Number.isSafeInteger)||nt(Et,"double"))throw new RangeError("jpFun requires integer MusicXML transposition without octave doubling");K.push({at:it.clone(),staff:Et.getAttribute("number")??"",chromatic:St,diatonic:Se,octaves:Ae})}if(nt(J,"divisions")&&(_=ft(J,"divisions")),!Number.isSafeInteger(_)||_<=0)throw new RangeError("MusicXML divisions must be a positive integer");let lt=nt(J,"time");if(lt){let{numerator:Et,denominator:St}=Ua(lt);W={numerator:Et,denominator:St},a.set(ct(it),{at:it,numerator:Et,denominator:St})}let ae=nt(J,"key");if(ae){let Et=ft(ae,"fifths",0);if(!Number.isSafeInteger(Et))throw new RangeError("MusicXML fifths must be an integer");c.set(ct(it),{at:it,fifths:Et,mode:yt(ae,"mode")||"major"})}for(let Et of at(J,"measure-style")){if(!nt(Et,"multiple-rest"))continue;let St=ft(Et,"multiple-rest");if(!Number.isSafeInteger(St)||St<=0||St>4294967295)throw new RangeError("MusicXML multiple-rest must be a positive integer in 1..4294967295");m.push({location:{...Y,element:"multiple-rest",staff:Et.getAttribute("number")||void 0},start:it.clone(),count:St})}continue}if(U==="backup"||U==="forward"){gt=void 0;let it=new F(ft(J,"duration"),_);if(U==="backup"?V.sub(it):V.add(it),V.compare(0)<0)throw new RangeError("MusicXML backup moves before the measure start");et=et.compare(V)<0?V.clone():et;continue}if(U==="direction"||U==="sound"){let it=new F(U==="direction"?ft(J,"offset",0):0,_),lt=zt(zt(P,V),it),ae=U==="sound"?J:nt(J,"sound");if(ae){for(let jt of at(ae,"midi-instrument"))R.push({at:lt,id:jt.getAttribute("id")??"",instrument:si(jt)});R.sort((jt,Ee)=>jt.at.compare(Ee.at))}let Et=ae?.getAttribute("tempo"),St=U==="direction"?new un([J]):void 0,Se=St?.read("metronome",!0),Ae=Va(Se),Qt=Et?Number(Et):Ae;if(Qt!==void 0){if(!Number.isFinite(Qt)||Qt<=0)throw new RangeError("MusicXML tempo must be positive and finite");let jt=ct(lt),Ee=l.get(jt);Ee?.location&&Ee.bpm!==Qt&&ot(t,"tempoReplaced",Ee.location,Ee.bpm),l.set(jt,{at:lt,bpm:Qt,location:{...Y,element:Se&&Ae===Qt?"metronome":"sound"}})}if(!St)continue;Qt!==void 0&&Ae===Qt&&St.accept(Se);let Qa=yt(J,"staff")||"1",Ja=yt(J,"voice"),xn={...Y,element:U,staff:Qa,voice:Ja||void 0},wi=St.read("dynamics",!0),Si=Wa(wi,t,xn);St.accept(wi);let Ai=Ga(St);(Si||Ai.length>0)&&p.push({location:xn,at:lt,placement:J.getAttribute("placement")==="below"?"below":"above",dynamic:Si,texts:Ai});let ao=St.read("wedge",!0),yn=ao?.getAttribute("type");(yn==="crescendo"||yn==="diminuendo"||yn==="stop")&&(f.push({location:{...xn,element:"wedge"},at:lt,number:ao?.getAttribute("number")||"1",type:yn}),St.accept(ao));for(let jt of at(J,"direction-type"))St.report(t,xn,jt);continue}if(U==="barline"&&J.getAttribute("location")==="middle"){Mt(J,zt(P,V));continue}if(U!=="note"){U==="harmony"&&ot(t,"unsupported",{...Y,element:U},U);continue}let pt=yt(J,"voice")||"1",Nt=yt(J,"staff")||"1",At={...Y,element:"note",staff:Nt,voice:pt},ut=`${w}\0${Nt}\0${pt}`,$t=nt(J,"instrument")?.getAttribute("id")||C?.byId.keys().next().value||"",be=at(J,"notations"),Zt=be.length?new un(be):void 0,Pt=Oa(J,At,Zt);Da(Zt,Pt,t);let hi=nt(J,"rest")!==void 0;if(!Pt&&!hi)throw new TypeError("MusicXML note must contain pitch, unpitched, or rest");let re=nt(J,"chord")!==void 0,dn=nt(J,"grace"),we=re&>?gt.clone():zt(P,V);if(!re&&!dn&&(gt=we.clone()),Pt&&nt(J,"pitch")&&N.push({pitch:Pt,at:we}),G($t,we).channel===10){if(ot(t,"percussion",At),dn)continue;let it=new F(ft(J,"duration"),_);if(it.compare(0)<=0)throw new RangeError("MusicXML non-grace notes require a positive duration");re||V.add(it),et.compare(V)<0&&(et=V.clone());continue}Pt&&!nt(J,"pitch")&&ot(t,"displayPitch",{...At,element:"unpitched"});let mn=r.get(ut);mn||(mn={partId:w,partName:e.get(w)??w,staff:Nt,voice:pt,events:[]},r.set(ut,mn));let ro=Z.get(ut);if(dn){if(!Pt){ot(t,"gracePitch",{...At,element:"grace"});continue}Zt?.report(t,At);let it=dn.getAttribute("steal-time-previous");if(it!==null&&it!==""&&ro){let lt=ro.postGraces;re&<.length>0?lt.at(-1).push(Pt):lt.push([Pt])}else{it!==null&&it!==""&&ot(t,"afterGrace",{...At,element:"grace"});let lt=Q.get(ut)??[];re&<.length>0?lt.at(-1).push(Pt):lt.push([Pt]),Q.set(ut,lt)}continue}let Ge=new F(ft(J,"duration"),_);if(Ge.compare(0)<=0)throw new RangeError("MusicXML non-grace notes require a positive duration");let Lt=re?ro:void 0,di=Ha(J),{modifiers:mi,slides:xi}=Pa(Zt,t,At),yi=Ba(Zt,At),gi=Zt?.readAll("tuplet");if(!Lt||!Lt.start.equals(we)||!Lt.duration.equals(Ge)||Lt.rest)Lt={start:we,duration:Ge,pitches:[],rest:hi,order:x++,modifiers:mi,annotations:[],preGraces:Q.get(ut)??[],postGraces:[],lyrics:di,arpeggio:yi,slides:xi,timeModification:Fa(J,gi)},Q.delete(ut),mn.events.push(Lt),O.set(Lt,$t),Z.set(ut,Lt);else{Lt.arpeggio=ii(Lt.arpeggio,yi);for(let it of xi)Lt.slides?.some(lt=>lt.side===it.side&<.direction===it.direction)||(Lt.slides??=[]).push(it);for(let it of mi)Lt.modifiers.some(lt=>lt.name===it.name&<.placement===it.placement)||Lt.modifiers.push(it)}za(Zt,gi,Lt.timeModification),Zt?.report(t,At),Pt&&Lt.pitches.push(Pt);for(let[it,lt]of di)lt&&!Lt.lyrics.has(it)&&Lt.lyrics.set(it,lt);re||V.add(Ge);let bi=zt(we,Ge).sub(P);et.compare(bi)<0&&(et=bi)}let It=new F(W.numerator*4,W.denominator),Gt=z.getAttribute("implicit")==="yes"||T===0&&et.compare(It)<0||et.compare(It)>0?et:It,Rt=Gt;if(w===E)S[T]=Gt.clone();else if(S[T]&&(Rt=S[T].clone(),et.compare(Rt)>0))throw new RangeError(`MusicXML part ${w} exceeds the controlling measure duration`);let Ut=zt(P,Rt);for(let J of bt.filter(U=>kt(U)==="barline")){let U=J.getAttribute("location");U!=="middle"&&Mt(J,U==="left"?P:Ut)}P.add(Rt),g.compare(P)<0&&(g=P.clone())}j.push(P.clone());for(let T of m.slice(B))T.end=j[T.location.measureIndex-1+T.count];for(let T of Q.values())for(let D of T)for(let z of D)ot(t,"graceHost",{...z.location,element:"grace"});K.sort((T,D)=>T.at.compare(D.at)).reverse();for(let{pitch:T,at:D}of N){let z=K.find(Y=>(!Y.staff||Y.staff===T.location.staff)&&Y.at.compare(D)<=0);z&&$a(T,z.chromatic,z.diatonic,z.octaves)}for(let[T,D]of O)T.program=G(D,T.start).program;hn(h,P,"|||")}let v=[...r.values()],{wedges:L,endings:I}=Ka(f,[...u.values()],t);return I.length>0&&v.length===0&&E!==void 0&&v.push({partId:E,partName:e.get(E)??E,staff:"1",voice:"1",events:[]}),{...i,lanes:Ya(v,I,p,x,e,t).sort((w,M)=>A.get(w.partId)-A.get(M.partId)||Number(w.staff)-Number(M.staff)||Number(w.voice)-Number(M.voice)),meters:[...a.values()].sort((w,M)=>w.at.compare(M.at)),keys:[...c.values()].sort((w,M)=>w.at.compare(M.at)),tempos:[...l.values()].sort((w,M)=>w.at.compare(M.at)),wedges:L,endings:I,bars:h,measureBoundaries:d,lineBreaks:y,multipleRests:m,end:g}}function li(s){if(!Number.isSafeInteger(s.fifths)||s.fifths<-7||s.fifths>7)throw new RangeError("jpFun supports MusicXML key signatures from -7 to 7 fifths");let t=s.mode.toLowerCase();if(t==="minor"||t==="aeolian")return bf[s.fifths+7];if(t==="major"||t==="ionian")return Xa[s.fifths+7];let n={dorian:[1,2],phrygian:[2,4],lydian:[3,5],mixolydian:[4,7],locrian:[6,11]}[t];if(!n)throw new RangeError(`Unsupported MusicXML mode ${s.mode}`);let o=Xa[s.fifths+7],i="CDEFGAB",r=i[(i.indexOf(o[0])+n[0])%i.length],l=(((vt[o[0]]+(o[1]==="#"?1:o[1]==="b"?-1:0)+n[1])%12+12)%12-vt[r]+18)%12-6;if(l<-1||l>1)throw new RangeError(`MusicXML mode ${s.mode} requires an unsupported tonic spelling`);return r+(l===1?"#":l===-1?"b":"")}function fi(s,t){let e=Vt(s,t,n=>n.at);return e<s.length&&s[e].at.equals(t)?s[e]:s[Math.max(0,e-1)]}function so(s,t,e,n,o=""){let i,r,a;if(t==="absolute")i=s.step,r=s.alter>0?"#".repeat(s.alter):"b".repeat(-s.alter),a=s.octave;else{let l=(s.octave+1)*12+vt[s.step]+s.alter,p=li(e),f=p[1]==="#"?1:p[1]==="b"?-1:0,u=l-60-vt[p[0]]-f,h=(u%12+12)%12;i=qa[h][0],r=qa[h].slice(1),a=Math.floor(u/12)}let c=n.labels.get(s);return to({name:i,accidental:r,octave:a},t,o)+(c?`@${c}`:"")}function Za(s,t,e,n,o,i=""){let r;s.rest||s.pitches.length===0?r=`0${i}`:s.pitches.length===1?r=so(s.pitches[0],t,e,n,i):r=`{${s.pitches.map((l,p)=>so(l,t,e,n,p===0?i:"")).join(" ^ ")}}`,s.arpeggio&&(s.pitches.length>=2?r=s.arpeggio.direction==="none"?`@arp(${r})`:`@arp(${r}, direction=${s.arpeggio.direction})`:ot(o,"arpeggioOutput",s.arpeggio.location));for(let l of s.slides??[])r=`@slide(${r}, side=${l.side}, direction=${l.direction})`;let a=l=>l.map(p=>p.length===1?so(p[0],t,e,n):`{${p.map(f=>so(f,t,e,n)).join(" ^ ")}}`);s.preGraces.length>0&&(r=`{{${a(s.preGraces).join(" ")}} > ${r}}`),s.postGraces.length>0&&(r=`{${r} < {${a(s.postGraces).join(" ")}}}`);for(let l of s.modifiers)r=`{${r} ${l.placement==="below"?"_":"^"} $${l.name}}`;for(let l of s.annotations){let p=ht(l.text);r=`{${r} ${l.placement==="below"?"_":"^"} ${l.boxed?`@box(${p})`:p}}`}let c=n.labels.get(s);return c&&s.pitches.length!==1&&(r+=`@${c}`),r}function Af(s){return s>0&&Number.isInteger(Math.log2(s))}function io(s,t){s=He(s,t?.sources??[]);for(let e of t?.below??[])s=`{${s} _ ${e}}`;return t&&(t.pendingLocations.length=0),s}function Ef(s,t){let e="/".repeat(t),n=s.match(/@mx\d+$/)?.[0];return n?s.slice(0,-n.length)+e+n:s+e}function Tf(s){let t=[],e=s.numerator;for(let n=Math.floor(Math.log2(e));n>=0;n--){let o=2**n;if(e<o)continue;e-=o;let i=Math.log2(s.denominator)-n,r=0;if(t.length===0&&i>=0)for(let a=n-1;a>=0&&e>=2**a;a--)e-=2**a,r++;t.push({fractionPower:i,dots:r})}return t}function pi(s,t,e){if(!Af(e.denominator))throw new RangeError(`MusicXML duration ${e} requires a tuplet that jpFun cannot infer`);let n=[],o=Tf(e);for(let[a,{fractionPower:c,dots:l}]of o.entries()){let p=a===0,f=`${"/".repeat(Math.max(0,c))}${".".repeat(l)}`,u=p&&typeof s=="function",h;if(u?h=s(f):h=p?s:t,!u&&c>0&&(h=Ef(h,c)),!u&&l>0)h+=".".repeat(l);else if(c<0){let d=2**-c;n.push(h,...new Array(d-1).fill(t));continue}n.push(h)}let i=o.at(-1),r=i.fractionPower<0?new F(1):new F(2**(i.dots+1)-1,2**(i.fractionPower+i.dots));return{source:n.join(" "),tailDuration:r,slotCount:n.length}}function Lf(s,t,e,n,o,i,r,a){let c=[],l=[...o.values()].sort((p,f)=>p.at.compare(f.at));for(let p=0;p<s.events.length;){let f=s.events[p],u=f.timeModification;if(!u){c.push({start:f.start,end:zt(f.start,f.duration),event:f}),p++;continue}let h=[f],d=u.start;for(;++p<s.events.length;){let L=h.at(-1);if(L.timeModification?.stop)break;let I=s.events[p],w=I.timeModification;if(!w||w.actual!==u.actual||w.normal!==u.normal||!zt(L.start,L.duration).equals(I.start)||!d&&h.length>=u.actual)break;h.push(I)}if(h.length<2)throw new RangeError("MusicXML tuplet group must contain at least two consecutive events");let y=h.map(L=>{let I=zt(L.start,L.duration),w=Vt(l,L.start,_=>_.at);l[w]?.at.equals(L.start)&&w++;let M=Vt(l,I,_=>_.at),C=[L.start,...l.slice(w,M).map(_=>_.at),I];return C.slice(0,-1).map((_,P)=>({at:_,end:C[P+1],duration:C[P+1].clone().sub(_).mul(u.actual,u.normal)}))}),m=y.flatMap(L=>L.map(I=>I.duration)),g=m.reduce((L,I)=>L.compare(I)<=0?L:I),b=m.reduce((L,I)=>L.add(I),new F).div(g),A=b.clone().mul(u.normal,u.actual);if(b.denominator!==1||A.denominator!==1)throw new RangeError("MusicXML tuplet ratio cannot be represented by jpFun");let E=[],S=h.map((L,I)=>{let w=fi(n,L.start),M=[],C=i.get(ct(L.start));if(C!==void 0&&M.push(`@program(${C})`),I>0){let W=e.bars.get(ct(L.start));W&&M.push(W)}let _=L.rest?"0":"-",P=L.rest?0:1;for(let[W,{at:Z,end:Q,duration:K}]of y[I].entries()){let N=o.get(ct(Z)),O=pi(W===0||N?j=>io(W===0?Za(L,t,w,r,a,j):`${_}${j}`,N):_,_,K);O.tailDuration.mul(u.normal,u.actual),M.push(r.labelEnding(O,Q)),L.rest&&(P+=O.slotCount)}return E.push({event:L,slotCount:P}),M.push(...r.afterSources.get(L)??[]),M.join(" ")}),v=zt(h.at(-1).start,h.at(-1).duration);c.push({start:h[0].start,end:v,source:`@tuplet({${S.join(" ")}}, ${A.numerator})`,lyricEvents:E})}return c}function Cf(s,t){let e=0,n=[],o=new Map,i={labels:new Map,afterSources:new Map,labelEnding({source:x,tailDuration:b},A){let E=o.get(ct(A));if(!E)return x;let S=A.clone().sub(b);return S.compare(E.at)<=0?x:(E.at=S,E.label=`mx${e++}`,`${x}@${E.label}`)},labelRest(x,b,A){let E=b.find(L=>i.labels.has(L)),S=o.get(ct(A));if(!E&&!S)return x;let v=r(E??b[0]);for(let L of b)i.labels.has(L)&&i.labels.set(L,v);return S&&(S.at=b[0].start,S.label=v),`${x}@${v}`}},r=x=>{let b=i.labels.get(x)??`mx${e++}`;return i.labels.set(x,b),b},a=(x,b)=>{let A=i.afterSources.get(x);A||i.afterSources.set(x,A=[]),A.push(b)},c=new Map,l=[...s.lineBreaks].map(We),p=[],f=new Map,u=new Set,h=new Map,d=[...s.endings].sort((x,b)=>x.from.at.compare(b.from.at)),y=x=>{let b=Vt(d,x,E=>E.from.at),A=d[b]?.from.at.equals(x)?d[b]:d[b-1];return A&&x.compare(A.end)<0?A:void 0};for(let x of s.lanes)for(let b of x.events){let A=y(b.start),E=A?h.get(A)??new Map:f;A&&h.set(A,E);let S=[...b.preGraces.flat(),...b.pitches,...b.postGraces.flat()];for(let v of S){v.glissandi?.length&&p.push({event:b,pitch:v});let L=`${x.partId}\0${x.staff}\0${x.voice}\0${v.step}\0${v.alter}\0${v.octave}`,I=E.get(L)??(A?f.get(L):void 0);v.tieStop&&I?(u.delete(I),a(b,`@tie(${r(I)}, ${r(v)})`)):v.tieStop&&ot(t,"tieStart",v.location),v.tieStart?(E.set(L,v),u.add(v)):v.tieStop&&E.delete(L)}}for(let x of u)ot(t,"tieStop",x.location);for(let{event:x,pitch:b}of p.sort((A,E)=>A.event.start.compare(E.event.start)||A.event.order-E.event.order))for(let A of b.glissandi??[]){let E=`${b.location.partId}\0${A.kind}\0${A.number}`,S=c.get(E);if(A.type==="start"){S&&ot(t,"glissReplaced",S.pitch.location),c.set(E,{pitch:b,event:x});continue}c.delete(E),S?S.event.start.equals(x.start)||l.some(v=>v.compare(S.event.start)>0&&v.compare(x.start)<=0)?ot(t,"glissEndpoints",b.location):a(x,`@gliss(${r(S.pitch)}, ${r(b)})`):ot(t,"glissStart",b.location)}for(let{pitch:x}of c.values())ot(t,"glissStop",x.location);let m=x=>r(x.pitches.length===1?x.pitches[0]:x);for(let x of s.wedges){let b=ai(s.lanes,x.from.location);b.length===0&&ot(t,"wedgeVoice",x.from.location);for(let A of b){let E={...x.from.location,staff:A.staff,voice:A.voice},S=A.events.filter(M=>!M.rest&&M.pitches.length>0),v=S.find(M=>M.start.compare(x.from.at)<=0&&zt(M.start,M.duration).compare(x.from.at)>0)??S.find(M=>M.start.compare(x.from.at)>=0),L;for(let M of S){if(M.start.compare(x.end)>=0)break;L=M}if(!v||!L||v.start.compare(L.start)>=0){ot(t,"wedgeEndpoints",E);continue}let I=x.from.type==="crescendo"?24:-24;ot(t,"wedge",E,I);let w=`@dyn(${m(v)}, ${m(L)}, ${I})`;n.push(()=>w)}}let g=s.lanes.flatMap(x=>x.events).sort((x,b)=>x.start.compare(b.start)||x.order-b.order);for(let x of d){let b=Vt(g,x.from.at,L=>L.start),A=Vt(g,x.end,L=>L.start);if(b>=A){ot(t,"endingEndpoints",x.from.location);continue}let E=g[b],S=g[A-1];m(E);let v=o.get(ct(x.end))??{at:S.start,label:m(S)};o.set(ct(x.end),v),n.push(()=>`@volta(${m(E)}, ${v.label}, ${x.from.passes.join(", ")})`)}return{relations:n,metadata:i}}function vf(s,t,e){let n=t.pitchMode??"absolute";if(n!=="relative"&&n!=="absolute")throw new TypeError("pitchMode must be relative or absolute");let o=t.barsPerLine??4;if(!Number.isSafeInteger(o)||o<=0)throw new RangeError("barsPerLine must be a positive integer");let i=s.meters.length===0||!s.meters[0].at.isZero()?[{at:new F,numerator:4,denominator:4},...s.meters]:s.meters,r=s.keys.length===0||!s.keys[0].at.isZero()?[{at:new F,fifths:0,mode:"major"},...s.keys]:s.keys,a=s.tempos.length===0||!s.tempos[0].at.isZero()?[{at:new F,bpm:120},...s.tempos]:s.tempos,c=new Map,l=(w,M,C,_,P="above")=>{let W=ct(M),Z=w.get(W)??{at:M,sources:[],pendingLocations:[]};P==="below"?(Z.below??=[]).push(C):Z.sources.push(C),_&&Z.pendingLocations.push(_),w.set(W,Z)};for(let w of r.slice(1))l(c,w.at,`@1(${li(w)}4)`);for(let w of i.slice(1))l(c,w.at,`@meter(${w.numerator}, ${w.denominator})`);for(let w of a.slice(1))l(c,w.at,`@tempo(${w.bpm})`,w.location);let p=s.lanes.map((w,M)=>{let C=M===0?c:new Map;for(let _ of w.dynamics??[])l(C,_.at,`$${_.name}`,_.location,_.placement);return C}),f=s.lanes.map(w=>{let M=new Map,C;for(let _ of w.events)_.program!==void 0&&_.program!==C&&(C=_.program,M.set(ct(_.start),C));return M}),u=[...s.bars.keys()].map(We).sort((w,M)=>w.compare(M)),h=[...s.measureBoundaries].map(We).sort((w,M)=>w.compare(M));if(s.lineBreaks.size===0){let w=0;for(let M of h)++w===o&&(s.lineBreaks.add(ct(M)),w=0)}let{relations:d,metadata:y}=Cf(s,e),m=s.page?`@page(width=${s.page.width}px, height=${s.page.height}px, top=${s.page.top}px, bottom=${s.page.bottom}px, left=${s.page.left}px, right=${s.page.right}px)
|
|
123
|
-
`:"",g=
|
|
124
|
-
`);return`N${
|
|
125
|
-
${
|
|
139
|
+
${Q}`:Q},et=s<=0?rp(q(),S,x,e):new Set(S.filter((N,O)=>(O+1)%s===0&&N<C));return q(et)}function ap(r,t={}){return Ac(r,t,{compileScore:Ss,anchorKey:gt,page:Lt})}function Ft(r){return r.localName||r.tagName.split(":").at(-1)}function mt(r,t){let e=[];for(let n=0;n<r.childNodes.length;n++){let o=r.childNodes[n];if(o.nodeType!==1)continue;let s=o;(t===void 0||Ft(s)===t)&&e.push(s)}return e}function st(r,t){for(let e=0;e<r.childNodes.length;e++){let n=r.childNodes[e];if(n.nodeType===1&&Ft(n)===t)return n}}function Es(r,t){for(let e of mt(r)){if(Ft(e)===t)return e;let n=Es(e,t);if(n)return n}}function Ps(r,t){let e=[];for(let n of mt(r))Ft(n)===t&&e.push(n),e.push(...Ps(n,t));return e}function bt(r,t){return(t===void 0?r:r&&st(r,t))?.textContent?.trim()??""}function yt(r,t,e){let n=bt(r,t);if(n===""){if(e!==void 0)return e;throw new RangeError(`MusicXML <${t}> must contain a finite number`)}let o=Number(n);if(Number.isFinite(o))return o;throw new RangeError(`MusicXML <${t}> must contain a finite number`)}var cp=/^(?:p+|f+|mp|mf)$/,Cc=256,lp=[["segno","segno"],["coda","coda"],["dacapo","dc"],["dalsegno","ds"],["fine","fine"],["tocoda","tocoda"]];function up(r){let t=r.trim().replace(/\s+/g," ");if(/^(?:d\.\s*c\.?|da\s+capo)(?:\s+al\s+(?:fine|coda)\.?)?$/i.test(t))return"dc";if(/^(?:d\.\s*s\.?|dal\s+segno)(?:\s+al\s+(?:fine|coda)\.?)?$/i.test(t))return"ds";if(/^fine\.?$/i.test(t))return"fine";if(/^(?:to\s+coda|al\s+coda)\.?$/i.test(t))return"tocoda"}var pp={percussion:["PERCUSSION_SKIPPED","MIDI channel 10 percussion note was omitted."],displayPitch:["APPROXIMATED","Unpitched note was converted to a melodic note using its display pitch."],afterGrace:["APPROXIMATED","After-grace note has no preceding event and was treated as a before-grace note."],wedge:["APPROXIMATED","Wedge was mapped to note onsets with a fixed velocity change of {value}."],unsupported:["UNSUPPORTED_ELEMENT","MusicXML <{value}> was omitted."],gracePitch:["UNATTACHED_CONTENT","Grace note without a pitch was omitted."],graceHost:["UNATTACHED_CONTENT","Before-grace note has no following event and was omitted."],dynamicHost:["UNATTACHED_CONTENT","Dynamic {value} has no target voice and was omitted."],directionOutput:["UNATTACHED_CONTENT","Direction mark has no generated output position and was omitted."],tempoReplaced:["UNATTACHED_CONTENT","Tempo {value} was replaced by a different tempo at the same time and was omitted."],arpeggioOutput:["UNSUPPORTED_ELEMENT","Arpeggiate mark requires at least two pitches in one event and was omitted."],multipleRest:["APPROXIMATED","Multiple-rest grouping could not be preserved without discarding musical content; individual rests were retained."],textHost:["UNATTACHED_CONTENT","Text {value} has no target event and was omitted."],wedgeStart:["UNRESOLVED_RELATION","Wedge stop has no matching start and was omitted."],wedgeReplaced:["UNRESOLVED_RELATION","Wedge start was replaced before a matching stop and was omitted."],wedgeStop:["UNRESOLVED_RELATION","Wedge start has no matching stop and was omitted."],wedgeVoice:["UNRESOLVED_RELATION","Wedge has no target voice and was omitted."],wedgeEndpoints:["UNRESOLVED_RELATION","Wedge has no two distinct note onsets to use as endpoints and was omitted."],endingStart:["UNRESOLVED_RELATION","Ending stop has no matching start and was omitted."],endingReplaced:["UNRESOLVED_RELATION","Ending start was replaced before a matching stop and was omitted."],endingStop:["UNRESOLVED_RELATION","Ending start has no matching stop and was omitted."],endingEndpoints:["UNRESOLVED_RELATION","Ending has no event endpoints in its interval and was omitted."],tieStart:["UNRESOLVED_RELATION","Tie stop has no matching start and was omitted."],tieStop:["UNRESOLVED_RELATION","Tie start has no matching stop in any ending branch and was omitted."],glissStart:["UNRESOLVED_RELATION","Glissando stop has no matching start and was omitted."],glissStop:["UNRESOLVED_RELATION","Glissando start has no matching stop and was omitted."],glissReplaced:["UNRESOLVED_RELATION","Glissando start was replaced before a matching stop and was omitted."],glissEndpoints:["UNRESOLVED_RELATION","Glissando endpoints are simultaneous and were omitted."],glissStyle:["APPROXIMATED","MusicXML <{value}> was converted to a straight glissando arrow."],symbolStyle:["APPROXIMATED","MusicXML <{value}> was mapped to the default symbol shape."]};function nt(r,t,e,n=""){let[o,s]=pp[t];r.push({code:`W_MUSICXML_${o}`,severity:"warning",message:s.replace("{value}",()=>String(n)),location:e})}var wn=class{constructor(t){this.roots=t}roots;accepted=[];read(t,e=!1,n){for(let o of n?[n]:this.roots){let s=e?Es(o,t):st(o,t);if(s)return s}}readAll(t,e=!1){return this.roots.flatMap(n=>e?Ps(n,t):mt(n,t))}accept(t){t&&this.accepted.push(t)}report(t,e,n){for(let o of n?[n]:this.roots)for(let s of mt(o)){if(this.accepted.includes(s))continue;let i=Ft(s);nt(t,"unsupported",{...e,element:i},i)}}};function Sn(r,t){let e=r.getAttribute("placement");return e==="above"||e==="below"?e:t}function Nc(r){let t=new Map,e=Ft(r);if(e==="score-partwise"){for(let n of mt(r,"part"))t.set(n.getAttribute("id")??"",mt(n,"measure").map(o=>({body:o,container:o})));return t}if(e==="score-timewise"){for(let n of mt(r,"measure"))for(let o of mt(n,"part")){let s=o.getAttribute("id")??"",i=t.get(s)??[];i.push({body:o,container:n}),t.set(s,i)}return t}throw new TypeError(`Unsupported MusicXML root <${e}>`)}function Ms(r){let t={};if(st(r,"midi-channel")&&(t.channel=yt(r,"midi-channel"),!Number.isSafeInteger(t.channel)||t.channel<1||t.channel>16))throw new RangeError("MusicXML midi-channel must be an integer in 1..16");if(st(r,"midi-program")&&(t.program=yt(r,"midi-program")-1,!Number.isSafeInteger(t.program)||t.program<0||t.program>127))throw new RangeError("MusicXML midi-program must be an integer in 1..128");return t}function vc(r){let t=mt(r,"credit"),e=p=>{let m=t.find(d=>bt(d,"credit-type")===p);return m?bt(m,"credit-words"):""},n=bt(st(r,"work"),"work-title"),o=bt(r,"movement-title")||(n!=="Untitled Score"&&n!=="\u672A\u547D\u540D\u4E50\u8C31"?n:"")||e("title"),s=e("subtitle"),i=e("composer")||(()=>{let p=st(r,"identification"),m=p?mt(p,"creator"):[];return bt(m.find(d=>d.getAttribute("type")==="composer")??m[0])})(),a,c=st(r,"defaults"),l=c&&st(c,"scaling"),u=c&&st(c,"page-layout");if(l&&u&&st(u,"page-width")&&st(u,"page-height")){let p=yt(l,"millimeters")/yt(l,"tenths")*96/25.4,m=mt(u,"page-margins"),d=m.find(f=>f.getAttribute("type")==="odd")??m[0];Number.isFinite(p)&&p>0&&(a={width:yt(u,"page-width")*p,height:yt(u,"page-height")*p,top:d?yt(d,"top-margin",48/p)*p:48,bottom:d?yt(d,"bottom-margin",48/p)*p:48,left:d?yt(d,"left-margin",40/p)*p:40,right:d?yt(d,"right-margin",40/p)*p:40})}return{title:o,subtitle:s,creator:i,page:a}}function kc(r,t,e){let n=e?.readAll("tied"),o=st(r,"pitch"),s=o??st(r,"unpitched");if(!s)return null;let i=bt(s,o?"step":"display-step").toUpperCase(),a=o?yt(s,"alter",0):0,c=yt(s,o?"octave":"display-octave");if(!/^[A-G]$/.test(i)||!Number.isInteger(a)||!Number.isInteger(c))throw new RangeError("jpFun requires MusicXML pitches with integer step alterations and octaves");let l=new Set,u=mt(r,"tie");for(let p of u)l.add(p.getAttribute("type")??"");if(n)for(let p of n){let m=p.getAttribute("type")??"";l.add(m),(m==="start"||m==="stop"||m==="continue")&&e?.accept(p)}return{location:{...t,element:u.length?"tie":n?.length?"tied":Ft(r)},step:i,alter:a,octave:c,tieStart:l.has("start")||l.has("continue"),tieStop:l.has("stop")||l.has("continue")}}function Ec(r,t,e,n){let o=(r.octave+1)*12+Et[r.step]+r.alter+t+n*12;if(e===void 0){let s=He[(o%12+12)%12];r.step=s[0],r.alter=s.length-1,r.octave=Math.floor(o/12)-1}else{let s="CDEFGAB",i=r.octave*7+s.indexOf(r.step)+e+n*7;r.step=s[(i%7+7)%7],r.octave=Math.floor(i/7),r.alter=o-(r.octave+1)*12-Et[r.step]}}function Pc(r,t,e){let n=[],o=[];if(!r)return{modifiers:n,slides:o};let s=r.read("fermata");s&&(n.push({name:"fermata",placement:Sn(s,s.getAttribute("type")==="inverted"?"below":"above")}),r.accept(s));let i=r.read("articulations");if(i){for(let[c,l]of[["accent","accent"],["staccato","staccato"],["tenuto","tenuto"],["strong-accent","marcato"],["staccatissimo","staccato"]]){let u=r.read(c,!1,i);u&&(n.push({name:l,placement:Sn(u,"above")}),r.accept(u),c==="strong-accent"&&u.getAttribute("type")==="down"&&nt(t,"symbolStyle",{...e,element:c},c))}for(let[c,l,u]of[["scoop","pre","up"],["plop","pre","down"],["doit","post","up"],["falloff","post","down"]])for(let p of mt(i,c))o.push({side:l,direction:u}),r.accept(p),(p.getAttribute("line-shape")==="curved"||p.getAttribute("line-type")==="wavy")&&nt(t,"glissStyle",{...e,element:c},c);r.report(t,e,i),r.accept(i)}let a=r.read("ornaments");if(a){for(let[c,l]of[["trill-mark","tr"],["mordent","mordent"],["inverted-mordent","prall"],["turn","turn"],["inverted-turn","iturn"]]){let u=r.read(c,!1,a);u&&(n.push({name:l,placement:Sn(u,"above")}),r.accept(u),(c==="turn"||c==="inverted-turn")&&u.getAttribute("slash")==="yes"&&nt(t,"symbolStyle",{...e,element:c},c))}r.report(t,e,a),r.accept(a)}return{modifiers:n,slides:o}}function Mc(r,t,e){if(!(!r||!t))for(let n of["slide","glissando"])for(let o of r.readAll(n)){let s=o.getAttribute("type");s!=="start"&&s!=="stop"||((t.glissandi??=[]).push({kind:n,type:s,number:o.getAttribute("number")||"1"}),r.accept(o),s==="start"&&(n==="glissando"&&o.getAttribute("line-type")!=="solid"||o.getAttribute("line-type")==="wavy"||bt(o))&&nt(e,"glissStyle",{...t.location,element:n},n))}}function Rs(r,t){if(!t||t.direction==="none")return r??t;if(r&&r.direction!=="none"&&r.direction!==t.direction)throw new RangeError("Conflicting MusicXML arpeggiate directions in one chord");return t}function Rc(r,t){if(!r)return;let e;for(let n of r.readAll("arpeggiate")){let o=n.getAttribute("direction")||"none";if(o!=="none"&&o!=="up"&&o!=="down")throw new RangeError(`Unsupported MusicXML arpeggiate direction: ${o}`);e=Rs(e,{direction:o,location:{...t,element:"arpeggiate"}}),r.accept(n)}return e}function _c(r,t){let e=st(r,"time-modification");if(!e)return;let n=yt(e,"actual-notes"),o=yt(e,"normal-notes");if(!Number.isSafeInteger(n)||n<2||!Number.isSafeInteger(o)||o<=0)throw new RangeError("MusicXML time-modification requires positive integer actual-notes and normal-notes");return{actual:n,normal:o,start:t?.some(s=>s.getAttribute("type")==="start")??!1,stop:t?.some(s=>s.getAttribute("type")==="stop")??!1}}function Fc(r,t,e){if(!(!r||!t||!e))for(let n of t){let o=n.getAttribute("type");(o==="start"||o==="stop")&&e[o]&&r.accept(n)}}function Oc(r){let t=new Map;for(let e of mt(r,"lyric")){let n=e.getAttribute("number")||e.getAttribute("name")||"1",o=mt(e).filter(i=>["text","elision"].includes(Ft(i))).map(i=>Ft(i)==="elision"?"~":bt(i)).join(""),s=bt(e,"syllabic");t.set(n,o&&(s==="begin"||s==="middle")?`${o}-`:o)}return t}function Ic(r,t,e){if(!r)return;let n;for(let o of mt(r)){let s=Ft(o);!n&&cp.test(s)?n=s:nt(t,"unsupported",{...e,element:s},s)}return n}function Bc(r,t="above",e){let n=[],o=[];for(let s of["segno","coda"])for(let i of r.readAll(s,!0))o.push({symbol:s,placement:Sn(i,t),location:{...e??{element:s},element:s}}),r.accept(i);for(let s of["rehearsal","words"])for(let i of r.readAll(s,!0)){let a=i.textContent?.trim();if(a){let c=s==="words"?up(a):void 0;c?o.push({symbol:c,placement:Sn(i,t),location:{...e??{element:s},element:s}}):n.push({text:a,boxed:s==="rehearsal"})}r.accept(i)}return{texts:n,repeats:o}}function Dc(r,t,e){if(!r)return[];let n=[];for(let[o,s]of lp){let i=r.getAttribute(o)?.trim().toLowerCase();i&&i!=="no"&&n.push({symbol:s,placement:t,location:{...e,element:"sound"}})}return n}function Vc(r){if(!r)return;let t=Number(bt(r,"per-minute")),e=bt(r,"beat-unit"),o={maxima:32,long:16,breve:8,whole:4,half:2,quarter:1,eighth:.5,"16th":.25,"32nd":.125,"64th":.0625,"128th":.03125,"256th":.015625,"512th":.0078125,"1024th":.00390625}[e];if(!Number.isFinite(t)||o===void 0)return;let s=o/2;for(let i of mt(r,"beat-unit-dot"))o+=s,s/=2;return t*o}function Hc(r){let t=[],e;for(let i of mt(r)){let a=Ft(i);a==="beats"?e=bt(i).split("+").reduce((c,l)=>c+Number(l),0):a==="beat-type"&&e!==void 0&&(t.push({beats:e,beatType:Number(bt(i))}),e=void 0)}if(t.length===0||t.some(i=>!Number.isSafeInteger(i.beats)||i.beats<=0||!Number.isSafeInteger(i.beatType)||i.beatType<=0))throw new RangeError("MusicXML time signature must contain positive integer beats/beat-type pairs");let n=(i,a)=>a===0?i:n(a,i%a),o=t.reduce((i,a)=>i/n(i,a.beatType)*a.beatType,1),s=t.reduce((i,a)=>i+a.beats*o/a.beatType,0);if(!Number.isSafeInteger(s)||!Number.isSafeInteger(o))throw new RangeError("MusicXML time signature exceeds the supported integer range");return{numerator:s,denominator:o}}function zc(r){let t=new Set;for(let e of r.split(/\s*,\s*/)){let n=e.match(/^(\d+)(?:\s*-\s*(\d+))?$/);if(!n)throw new RangeError("MusicXML ending number must contain positive integers or ascending ranges");let o=Number(n[1]),s=Number(n[2]??n[1]);if(!Number.isSafeInteger(o)||!Number.isSafeInteger(s)||o<1||s<o||s>Cc)throw new RangeError(`MusicXML ending passes must be ascending integers in 1..${Cc}`);for(let i=o;i<=s;i++)t.add(i)}return[...t].sort((e,n)=>e-n)}function _s(r){return r.start.clone().add(r.duration)}function Fs(r,{partId:t,staff:e,voice:n}){return r.filter(o=>o.partId===t&&o.staff===e&&(!n||o.voice===n))}function Gc(r,t,e){let n=[],o=new Map;for(let a of r.sort((c,l)=>c.at.compare(l.at))){let{partId:c,staff:l,voice:u=""}=a.location,p=`${c}\0${l}\0${u}\0${a.number}`;if(a.type==="stop"){let m=o.get(p);m?n.push({from:m,end:a.at}):nt(e,"wedgeStart",a.location),o.delete(p)}else{let m=o.get(p);m&&nt(e,"wedgeReplaced",m.location),o.set(p,a)}}for(let a of o.values())nt(e,"wedgeStop",a.location);let s=[],i;for(let a of t.sort((c,l)=>c.at.compare(l.at)))a.type==="start"?(i&&nt(e,"endingReplaced",i.location),i=a):i?(s.push({from:i,end:a.at}),i=void 0):nt(e,"endingStart",a.location);return i&&nt(e,"endingStop",i.location),{wedges:n,endings:s}}function mp(r,t,e,n,o){let s=r[0];if(s)for(let i of t){if(i.from.at.compare(i.end)>=0)continue;let a=e.find(m=>m.at.compare(i.from.at)>=0&&m.at.compare(i.end)<0),c=a?.location.partId??s.partId,l=a?.location.staff??s.staff,u=r.filter(m=>m.partId===c&&m.staff===l);if(u.some(m=>m.events.some(d=>d.start.compare(i.from.at)>=0&&d.start.compare(i.end)<0)))continue;let p=u.find(m=>!m.events.some(d=>d.start.compare(i.end)<0&&_s(d).compare(i.from.at)>0));if(!p){let m=u.map(d=>Number(d.voice)).filter(Number.isFinite);p={partId:c,partName:o.get(c)??c,staff:l,voice:String(Math.max(0,...m)+1),events:[]},r.push(p)}p.events.push({start:i.from.at.clone(),duration:i.end.clone().sub(i.from.at),pitches:[],rest:!0,order:n++,modifiers:[],annotations:[],preGraces:[],postGraces:[],lyrics:new Map}),p.events.sort((m,d)=>m.start.compare(d.start)||m.order-d.order)}}function dp(r,t,e){for(let n of t){let o=Fs(r,n.location);if(n.dynamic&&o.length===0&&nt(e,"dynamicHost",{...n.location,element:"dynamics"},n.dynamic),n.dynamic){let i={at:n.at,name:n.dynamic,placement:n.placement,location:{...n.location,element:"dynamics"}};for(let a of o)(a.dynamics??=[]).push(i)}if(n.texts.length===0)continue;let s;t:for(let i of o)for(let a of i.events){let c=a.start.compare(n.at);if(c<0&&_s(a).compare(n.at)>0){s=a;break t}(!s||s.start.compare(n.at)<0||c>=0&&(a.start.compare(s.start)<0||a.start.equals(s.start)&&a.order<s.order))&&(s=a)}for(let i of n.texts)s?s.annotations.push({...i,placement:n.placement}):nt(e,"textHost",{...n.location,element:i.boxed?"rehearsal":"words"},lt(i.text))}}function fp(r){return r.flatMap(t=>{let e=[];for(let n of[...t.events].sort((o,s)=>o.start.compare(s.start)||o.order-s.order)){let o=e.find(s=>_s(s.events.at(-1)).compare(n.start)<=0);o?o.events.push(n):e.push({...t,events:[n]})}return e.length?e:[t]})}function $c(r,t,e,n,o,s){return mp(r,t,e,n,o),dp(r,e,s),fp(r)}var jc=["Cb","Gb","Db","Ab","Eb","Bb","F","C","G","D","A","E","B","F#","C#"],yp=["Ab","Eb","Bb","F","C","G","D","A","E","B","F#","C#","G#","D#","A#"];function Wt(r,t){return r.clone().add(t)}function ut(r){return r.toString()}function Tn(r){let[t,e="1"]=r.split("/");return new G(Number(t),Number(e))}function Qt(r,t,e){let n=0,o=r.length;for(;n<o;){let s=n+o>>1;e(r[s]).compare(t)<0?n=s+1:o=s}return n}function wo(r,t){let e=r[Qt(r,t,n=>n.start)-1];return!!e&&e.end.compare(t)>0}function hp(r){let t=r.endsWith("-"),e=t?r.slice(0,-1):r,n=e.replace(/[\\{}@\-*_^]/g,"\\$&")+(t?"-":""),o=[...e].some(s=>s.codePointAt(0)>127);return/\s/.test(e)||o&&([...e].length>1||e.length>1||t)?`{${n}}`:n}function Ln(r,t,e){let n=ut(t),o=r.get(n);if(!o||o==="|"){r.set(n,e);return}o==="|:"&&e.startsWith(":|")?r.set(n,e===":|"?":|:":`${e} |:`):e==="|:"&&o.includes(":|")?r.set(n,o===":|"?":|:":`${o} |:`):e==="|||"&&!o.includes("|:")&&!o.includes(":|")&&r.set(n,e)}function gp(r,t){let e=new Map,n=new Map,o=st(r,"part-list");if(o)for(let S of mt(o,"score-part")){let M=S.getAttribute("id")??"";e.set(M,bt(S,"part-name"));let I=new Map,z;for(let j of mt(S,"midi-instrument")){let q=Ms(j);z??=q,I.set(j.getAttribute("id")??"",q)}n.set(M,{fallback:z,byId:I})}let s=vc(r),i=new Map,a=new Map,c=new Map,l=new Map,u=new Map,p=[],m=[],d=new Map,f=new Map,x=new Set,y=new Set,h=[],g=new G,b=0,T=S=>{let M=`${ut(S.at)}\0${S.symbol}`;u.has(M)||u.set(M,S)},L=Nc(r),w=new Map([...L.keys()].map((S,M)=>[S,M])),A=L.keys().next().value,C=[];for(let[S,M]of L){let I=n.get(S),z=1,j=new G,q={numerator:4,denominator:4},et=new Map,N=new Map,O=[],R=[],D=[],U=new Map,Q=[],Z=h.length,P=(F,$)=>{let H={...I?.byId.get(F)??I?.fallback};for(let X of D)X.id===F&&X.at.compare($)<=0&&Object.assign(H,X.instrument);return H};for(let F=0;F<M.length;F++){Q.push(j.clone());let{body:$,container:H}=M[F],X={partId:S,measureIndex:F+1,measureNumber:H.getAttribute("number")??void 0},ot=new G,rt=new G,ht;H.getAttribute("implicit")!=="yes"&&F>0&&(Ln(f,j,"|"),S===A&&x.add(ut(j)));let dt=st($,"print")??(H===$?void 0:st(H,"print"));(dt?.getAttribute("new-system")==="yes"||dt?.getAttribute("new-page")==="yes")&&(j.isZero()||y.add(ut(j)));let at=mt($),Pt=(V,J)=>{let At=st(V,"repeat"),Rt=At?.getAttribute("direction");if(Rt==="forward")Ln(f,J,"|:");else if(Rt==="backward"){let It=At?.getAttribute("times"),Jt=It?Number(It):2;if(!Number.isSafeInteger(Jt)||Jt<2)throw new RangeError("MusicXML repeat times must be an integer of at least 2");Ln(f,J,new Array(Jt-1).fill(":|").join(" "))}else bt(V,"bar-style")==="light-heavy"&&Ln(f,J,"|||");let ft=st(V,"ending"),vt=ft?.getAttribute("type");if(ft&&(vt==="start"||vt==="stop"||vt==="discontinue")){let It=zc(ft.getAttribute("number")??"");It.length>0&&d.set(`${ut(J)}\0${vt}\0${It.join(",")}`,{location:{...X,element:"ending"},at:J.clone(),type:vt,passes:It})}for(let It of["segno","coda"]){let Jt=st(V,It);Jt&&T({at:J.clone(),symbol:It,placement:Jt.getAttribute("placement")==="below"?"below":"above",location:{...X,element:It}})}};for(let V of at){let J=Ft(V);if(J==="attributes"){let ct=Wt(j,ot);for(let Tt of mt(V,"transpose")){let wt=yt(Tt,"chromatic"),ve=st(Tt,"diatonic")?yt(Tt,"diatonic"):void 0,ke=yt(Tt,"octave-change",0);if(![wt,ke,ve??0].every(Number.isSafeInteger)||st(Tt,"double"))throw new RangeError("jpFun requires integer MusicXML transposition without octave doubling");O.push({at:ct.clone(),staff:Tt.getAttribute("number")??"",chromatic:wt,diatonic:ve,octaves:ke})}if(st(V,"divisions")&&(z=yt(V,"divisions")),!Number.isSafeInteger(z)||z<=0)throw new RangeError("MusicXML divisions must be a positive integer");let pt=st(V,"time");if(pt){let{numerator:Tt,denominator:wt}=Hc(pt);q={numerator:Tt,denominator:wt},a.set(ut(ct),{at:ct,numerator:Tt,denominator:wt})}let ce=st(V,"key");if(ce){let Tt=yt(ce,"fifths",0);if(!Number.isSafeInteger(Tt))throw new RangeError("MusicXML fifths must be an integer");c.set(ut(ct),{at:ct,fifths:Tt,mode:bt(ce,"mode")||"major"})}for(let Tt of mt(V,"measure-style")){if(!st(Tt,"multiple-rest"))continue;let wt=yt(Tt,"multiple-rest");if(!Number.isSafeInteger(wt)||wt<=0||wt>4294967295)throw new RangeError("MusicXML multiple-rest must be a positive integer in 1..4294967295");h.push({location:{...X,element:"multiple-rest",staff:Tt.getAttribute("number")||void 0},start:ct.clone(),count:wt})}continue}if(J==="backup"||J==="forward"){ht=void 0;let ct=new G(yt(V,"duration"),z);if(J==="backup"?ot.sub(ct):ot.add(ct),ot.compare(0)<0)throw new RangeError("MusicXML backup moves before the measure start");rt=rt.compare(ot)<0?ot.clone():rt;continue}if(J==="direction"||J==="sound"){let ct=new G(J==="direction"?yt(V,"offset",0):0,z),pt=Wt(Wt(j,ot),ct),ce=J==="sound"?V:st(V,"sound");if(ce){for(let Vt of mt(ce,"midi-instrument"))D.push({at:pt,id:Vt.getAttribute("id")??"",instrument:Ms(Vt)});D.sort((Vt,te)=>Vt.at.compare(te.at))}let Tt=ce?.getAttribute("tempo"),wt=J==="direction"?new wn([V]):void 0,ve=wt?.read("metronome",!0),ke=Vc(ve),le=Tt?Number(Tt):ke;if(le!==void 0){if(!Number.isFinite(le)||le<=0)throw new RangeError("MusicXML tempo must be positive and finite");let Vt=ut(pt),te=l.get(Vt);te?.location&&te.bpm!==le&&nt(t,"tempoReplaced",te.location,te.bpm),l.set(Vt,{at:pt,bpm:le,location:{...X,element:ve&&ke===le?"metronome":"sound"}})}let Ao=V.getAttribute("placement")==="below"?"below":"above",Xc=bt(V,"staff")||"1",Uc=bt(V,"voice"),qe={...X,element:J,staff:Xc,voice:Uc||void 0};if(wt){le!==void 0&&ke===le&&wt.accept(ve);let Vt=wt.read("dynamics",!0),te=Ic(Vt,t,qe);wt.accept(Vt);let{texts:Xs,repeats:Kc}=Bc(wt,Ao,qe);for(let No of Kc)T({...No,at:pt.clone()});(te||Xs.length>0)&&p.push({location:qe,at:pt,placement:Ao,dynamic:te,texts:Xs});let Co=wt.read("wedge",!0),vn=Co?.getAttribute("type");(vn==="crescendo"||vn==="diminuendo"||vn==="stop")&&(m.push({location:{...qe,element:"wedge"},at:pt,number:Co?.getAttribute("number")||"1",type:vn}),wt.accept(Co));for(let No of mt(V,"direction-type"))wt.report(t,qe,No)}for(let Vt of Dc(ce,Ao,{...X,element:"sound"}))T({...Vt,at:pt.clone()});continue}if(J==="barline"&&V.getAttribute("location")==="middle"){Pt(V,Wt(j,ot));continue}if(J!=="note"){J==="harmony"&&nt(t,"unsupported",{...X,element:J},J);continue}let At=bt(V,"voice")||"1",Rt=bt(V,"staff")||"1",ft={...X,element:"note",staff:Rt,voice:At},vt=`${S}\0${Rt}\0${At}`,It=st(V,"instrument")?.getAttribute("id")||I?.byId.keys().next().value||"",Jt=mt(V,"notations"),ae=Jt.length?new wn(Jt):void 0,Dt=kc(V,ft,ae);Mc(ae,Dt,t);let Vs=st(V,"rest")!==void 0;if(!Dt&&!Vs)throw new TypeError("MusicXML note must contain pitch, unpitched, or rest");let de=st(V,"chord")!==void 0,Cn=st(V,"grace"),Ne=de&&ht?ht.clone():Wt(j,ot);if(!de&&!Cn&&(ht=Ne.clone()),Dt&&st(V,"pitch")&&R.push({pitch:Dt,at:Ne}),P(It,Ne).channel===10){if(nt(t,"percussion",ft),Cn)continue;let ct=new G(yt(V,"duration"),z);if(ct.compare(0)<=0)throw new RangeError("MusicXML non-grace notes require a positive duration");de||ot.add(ct),rt.compare(ot)<0&&(rt=ot.clone());continue}Dt&&!st(V,"pitch")&&nt(t,"displayPitch",{...ft,element:"unpitched"});let Nn=i.get(vt);Nn||(Nn={partId:S,partName:e.get(S)??S,staff:Rt,voice:At,events:[]},i.set(vt,Nn));let Lo=et.get(vt);if(Cn){if(!Dt){nt(t,"gracePitch",{...ft,element:"grace"});continue}ae?.report(t,ft);let ct=Cn.getAttribute("steal-time-previous");if(ct!==null&&ct!==""&&Lo){let pt=Lo.postGraces;de&&pt.length>0?pt.at(-1).push(Dt):pt.push([Dt])}else{ct!==null&&ct!==""&&nt(t,"afterGrace",{...ft,element:"grace"});let pt=N.get(vt)??[];de&&pt.length>0?pt.at(-1).push(Dt):pt.push([Dt]),N.set(vt,pt)}continue}let Ye=new G(yt(V,"duration"),z);if(Ye.compare(0)<=0)throw new RangeError("MusicXML non-grace notes require a positive duration");let Ct=de?Lo:void 0,Hs=Oc(V),{modifiers:zs,slides:Gs}=Pc(ae,t,ft),$s=Rc(ae,ft),js=ae?.readAll("tuplet");if(!Ct||!Ct.start.equals(Ne)||!Ct.duration.equals(Ye)||Ct.rest)Ct={start:Ne,duration:Ye,pitches:[],rest:Vs,order:b++,modifiers:zs,annotations:[],preGraces:N.get(vt)??[],postGraces:[],lyrics:Hs,arpeggio:$s,slides:Gs,timeModification:_c(V,js)},N.delete(vt),Nn.events.push(Ct),U.set(Ct,It),et.set(vt,Ct);else{Ct.arpeggio=Rs(Ct.arpeggio,$s);for(let ct of Gs)Ct.slides?.some(pt=>pt.side===ct.side&&pt.direction===ct.direction)||(Ct.slides??=[]).push(ct);for(let ct of zs)Ct.modifiers.some(pt=>pt.name===ct.name&&pt.placement===ct.placement)||Ct.modifiers.push(ct)}Fc(ae,js,Ct.timeModification),ae?.report(t,ft),Dt&&Ct.pitches.push(Dt);for(let[ct,pt]of Hs)pt&&!Ct.lyrics.has(ct)&&Ct.lyrics.set(ct,pt);de||ot.add(Ye);let Ws=Wt(Ne,Ye).sub(j);rt.compare(Ws)<0&&(rt=Ws)}let xt=new G(q.numerator*4,q.denominator),Bt=H.getAttribute("implicit")==="yes"||F===0&&rt.compare(xt)<0||rt.compare(xt)>0?rt:xt,Mt=Bt;if(S===A)C[F]=Bt.clone();else if(C[F]&&(Mt=C[F].clone(),rt.compare(Mt)>0))throw new RangeError(`MusicXML part ${S} exceeds the controlling measure duration`);let Ce=Wt(j,Mt);for(let V of at.filter(J=>Ft(J)==="barline")){let J=V.getAttribute("location");J!=="middle"&&Pt(V,J==="left"?j:Ce)}j.add(Mt),g.compare(j)<0&&(g=j.clone())}Q.push(j.clone());for(let F of h.slice(Z))F.end=Q[F.location.measureIndex-1+F.count];for(let F of N.values())for(let $ of F)for(let H of $)nt(t,"graceHost",{...H.location,element:"grace"});O.sort((F,$)=>F.at.compare($.at)).reverse();for(let{pitch:F,at:$}of R){let H=O.find(X=>(!X.staff||X.staff===F.location.staff)&&X.at.compare($)<=0);H&&Ec(F,H.chromatic,H.diatonic,H.octaves)}for(let[F,$]of U)F.program=P($,F.start).program;Ln(f,j,"|||")}let _=[...i.values()],{wedges:E,endings:v}=Gc(m,[...d.values()],t);return v.length>0&&_.length===0&&A!==void 0&&_.push({partId:A,partName:e.get(A)??A,staff:"1",voice:"1",events:[]}),{...s,lanes:$c(_,v,p,b,e,t).sort((S,M)=>w.get(S.partId)-w.get(M.partId)||Number(S.staff)-Number(M.staff)||Number(S.voice)-Number(M.voice)),meters:[...a.values()].sort((S,M)=>S.at.compare(M.at)),keys:[...c.values()].sort((S,M)=>S.at.compare(M.at)),tempos:[...l.values()].sort((S,M)=>S.at.compare(M.at)),repeats:[...u.values()].sort((S,M)=>S.at.compare(M.at)),wedges:E,endings:v,bars:f,measureBoundaries:x,lineBreaks:y,multipleRests:h,end:g}}function Os(r){if(!Number.isSafeInteger(r.fifths)||r.fifths<-7||r.fifths>7)throw new RangeError("jpFun supports MusicXML key signatures from -7 to 7 fifths");let t=r.mode.toLowerCase();if(t==="minor"||t==="aeolian")return yp[r.fifths+7];if(t==="major"||t==="ionian")return jc[r.fifths+7];let n={dorian:[1,2],phrygian:[2,4],lydian:[3,5],mixolydian:[4,7],locrian:[6,11]}[t];if(!n)throw new RangeError(`Unsupported MusicXML mode ${r.mode}`);let o=jc[r.fifths+7],s="CDEFGAB",i=s[(s.indexOf(o[0])+n[0])%s.length],l=(((Et[o[0]]+(o[1]==="#"?1:o[1]==="b"?-1:0)+n[1])%12+12)%12-Et[i]+18)%12-6;if(l<-1||l>1)throw new RangeError(`MusicXML mode ${r.mode} requires an unsupported tonic spelling`);return i+(l===1?"#":l===-1?"b":"")}function Is(r,t){let e=Qt(r,t,n=>n.at);return e<r.length&&r[e].at.equals(t)?r[e]:r[Math.max(0,e-1)]}function To(r,t,e,n,o=""){let s;if(t==="absolute"){let a=r.alter>0?"#".repeat(r.alter):"b".repeat(-r.alter);s=go(r.step,a,r.octave)}else{let a=(r.octave+1)*12+Et[r.step]+r.alter,c=Os(e),l=c[1]==="#"?1:c[1]==="b"?-1:0;s=ho(a-60-Et[c[0]]-l)}let i=n.labels.get(r);return`${s}${o}${i?`@${i}`:""}`}function Wc(r,t,e,n,o,s=""){let i;r.rest||r.pitches.length===0?i=`0${s}`:r.pitches.length===1?i=To(r.pitches[0],t,e,n,s):i=`{${r.pitches.map((l,u)=>To(l,t,e,n,u===0?s:"")).join(" ^ ")}}`,r.arpeggio&&(r.pitches.length>=2?i=r.arpeggio.direction==="none"?`@arp(${i})`:`@arp(${i}, direction=${r.arpeggio.direction})`:nt(o,"arpeggioOutput",r.arpeggio.location));for(let l of r.slides??[])i=`@slide(${i}, side=${l.side}, direction=${l.direction})`;let a=l=>l.map(u=>u.length===1?To(u[0],t,e,n):`{${u.map(p=>To(p,t,e,n)).join(" ^ ")}}`);r.preGraces.length>0&&(i=`{{${a(r.preGraces).join(" ")}} > ${i}}`),r.postGraces.length>0&&(i=`{${i} < {${a(r.postGraces).join(" ")}}}`);for(let l of r.modifiers)i=`{${i} ${l.placement==="below"?"_":"^"} $${l.name}}`;for(let l of r.annotations){let u=lt(l.text);i=`{${i} ${l.placement==="below"?"_":"^"} ${l.boxed?`@box(${u})`:u}}`}let c=n.labels.get(r);return c&&r.pitches.length!==1&&(i+=`@${c}`),i}function xp(r){return r>0&&Number.isInteger(Math.log2(r))}function An(r,t){r=Ke(r,t?.sources??[]);for(let e of t?.below??[])r=`{${r} _ ${e}}`;return t&&(t.pendingLocations.length=0),r}function bp(r,t){let e="/".repeat(t),n=r.match(/@mx\d+$/)?.[0];return n?r.slice(0,-n.length)+e+n:r+e}function Sp(r){let t=[],e=r.numerator;for(let n=Math.floor(Math.log2(e));n>=0;n--){let o=2**n;if(e<o)continue;e-=o;let s=Math.log2(r.denominator)-n,i=0;if(t.length===0&&s>=0)for(let a=n-1;a>=0&&e>=2**a;a--)e-=2**a,i++;t.push({fractionPower:s,dots:i})}return t}function Bs(r,t,e){if(!xp(e.denominator))throw new RangeError(`MusicXML duration ${e} requires a tuplet that jpFun cannot infer`);let n=[],o=Sp(e);for(let[a,{fractionPower:c,dots:l}]of o.entries()){let u=a===0,p=`${"/".repeat(Math.max(0,c))}${".".repeat(l)}`,m=u&&typeof r=="function",d;if(m?d=r(p):d=u?r:t,!m&&c>0&&(d=bp(d,c)),!m&&l>0)d+=".".repeat(l);else if(c<0){let f=2**-c;n.push(d,...new Array(f-1).fill(t));continue}n.push(d)}let s=o.at(-1),i=s.fractionPower<0?new G(1):new G(2**(s.dots+1)-1,2**(s.fractionPower+s.dots));return{source:n.join(" "),tailDuration:i,slotCount:n.length}}function wp(r,t,e,n,o,s,i,a){let c=[],l=[...o.values()].sort((u,p)=>u.at.compare(p.at));for(let u=0;u<r.events.length;){let p=r.events[u],m=p.timeModification;if(!m){c.push({start:p.start,end:Wt(p.start,p.duration),event:p}),u++;continue}let d=[p],f=m.start;for(;++u<r.events.length;){let C=d.at(-1);if(C.timeModification?.stop)break;let _=r.events[u],E=_.timeModification;if(!E||E.actual!==m.actual||E.normal!==m.normal||!Wt(C.start,C.duration).equals(_.start)||!f&&d.length>=m.actual)break;d.push(_)}if(d.length<2)throw new RangeError("MusicXML tuplet group must contain at least two consecutive events");let x=d.map(C=>{let _=Wt(C.start,C.duration),E=Qt(l,C.start,M=>M.at);l[E]?.at.equals(C.start)&&E++;let v=Qt(l,_,M=>M.at),S=[C.start,...l.slice(E,v).map(M=>M.at),_];return S.slice(0,-1).map((M,I)=>({at:M,end:S[I+1],duration:S[I+1].clone().sub(M).mul(m.actual,m.normal)}))}),y=x.flatMap(C=>C.map(_=>_.duration)),h=y.reduce((C,_)=>C.compare(_)<=0?C:_),b=y.reduce((C,_)=>C.add(_),new G).div(h),T=b.clone().mul(m.normal,m.actual);if(b.denominator!==1||T.denominator!==1)throw new RangeError("MusicXML tuplet ratio cannot be represented by jpFun");let L=[],w=d.map((C,_)=>{let E=Is(n,C.start),v=[],S=s.get(ut(C.start));if(S!==void 0&&v.push(`@program(${S})`),_>0){let z=e.bars.get(ut(C.start));z&&v.push(z)}let M=C.rest?"0":"-",I=C.rest?0:1;for(let[z,{at:j,end:q,duration:et}]of x[_].entries()){let N=o.get(ut(j)),R=Bs(z===0||N?D=>An(z===0?Wc(C,t,E,i,a,D):`${M}${D}`,N):M,M,et);R.tailDuration.mul(m.normal,m.actual),v.push(i.labelEnding(R,q)),C.rest&&(I+=R.slotCount)}return L.push({event:C,slotCount:I}),v.push(...i.afterSources.get(C)??[]),v.join(" ")}),A=Wt(d.at(-1).start,d.at(-1).duration);c.push({start:d[0].start,end:A,source:`@tuplet({${w.join(" ")}}, ${T.numerator})`,lyricEvents:L})}return c}function Tp(r,t){let e=0,n=[],o=new Map,s={labels:new Map,afterSources:new Map,labelEnding({source:h,tailDuration:g},b){let T=o.get(ut(b));if(!T)return h;let L=b.clone().sub(g);return L.compare(T.at)<=0?h:(T.at=L,T.label=`mx${e++}`,`${h}@${T.label}`)},labelRest(h,g,b){let T=g.find(A=>s.labels.has(A)),L=o.get(ut(b));if(!T&&!L)return h;let w=i(T??g[0]);for(let A of g)s.labels.has(A)&&s.labels.set(A,w);return L&&(L.at=g[0].start,L.label=w),`${h}@${w}`}},i=h=>{let g=s.labels.get(h)??`mx${e++}`;return s.labels.set(h,g),g},a=(h,g)=>{let b=s.afterSources.get(h);b||s.afterSources.set(h,b=[]),b.push(g)},c=new Map,l=[],u=new Map,p=new Set,m=new Map,d=[...r.endings].sort((h,g)=>h.from.at.compare(g.from.at)),f=h=>{let g=Qt(d,h,T=>T.from.at),b=d[g]?.from.at.equals(h)?d[g]:d[g-1];return b&&h.compare(b.end)<0?b:void 0};for(let h of r.lanes)for(let g of h.events){let b=f(g.start),T=b?m.get(b)??new Map:u;b&&m.set(b,T);let L=[...g.preGraces.flat(),...g.pitches,...g.postGraces.flat()];for(let w of L){w.glissandi?.length&&l.push({event:g,pitch:w});let A=`${h.partId}\0${h.staff}\0${h.voice}\0${w.step}\0${w.alter}\0${w.octave}`,C=T.get(A)??(b?u.get(A):void 0);w.tieStop&&C?(p.delete(C),a(g,`@tie(${i(C)}, ${i(w)})`)):w.tieStop&&nt(t,"tieStart",w.location),w.tieStart?(T.set(A,w),p.add(w)):w.tieStop&&T.delete(A)}}for(let h of p)nt(t,"tieStop",h.location);for(let{event:h,pitch:g}of l.sort((b,T)=>b.event.start.compare(T.event.start)||b.event.order-T.event.order))for(let b of g.glissandi??[]){let T=`${g.location.partId}\0${b.kind}\0${b.number}`,L=c.get(T);if(b.type==="start"){L&&nt(t,"glissReplaced",L.pitch.location),c.set(T,{pitch:g,event:h});continue}c.delete(T),L?L.event.start.equals(h.start)?nt(t,"glissEndpoints",g.location):a(h,`@gliss(${i(L.pitch)}, ${i(g)})`):nt(t,"glissStart",g.location)}for(let{pitch:h}of c.values())nt(t,"glissStop",h.location);let x=h=>i(h.pitches.length===1?h.pitches[0]:h);for(let h of r.wedges){let g=Fs(r.lanes,h.from.location);g.length===0&&nt(t,"wedgeVoice",h.from.location);for(let b of g){let T={...h.from.location,staff:b.staff,voice:b.voice},L=b.events.filter(E=>!E.rest&&E.pitches.length>0),w=L.find(E=>E.start.compare(h.from.at)<=0&&Wt(E.start,E.duration).compare(h.from.at)>0)??L.find(E=>E.start.compare(h.from.at)>=0),A;for(let E of L){if(E.start.compare(h.end)>=0)break;A=E}if(!w||!A||w.start.compare(A.start)>=0){nt(t,"wedgeEndpoints",T);continue}let C=h.from.type==="crescendo"?24:-24;nt(t,"wedge",T,C);let _=`@dyn(${x(w)}, ${x(A)}, ${C})`;n.push(()=>_)}}let y=r.lanes.flatMap(h=>h.events).sort((h,g)=>h.start.compare(g.start)||h.order-g.order);for(let h of d){let g=Qt(y,h.from.at,A=>A.start),b=Qt(y,h.end,A=>A.start);if(g>=b){nt(t,"endingEndpoints",h.from.location);continue}let T=y[g],L=y[b-1];x(T);let w=o.get(ut(h.end))??{at:L.start,label:x(L)};o.set(ut(h.end),w),n.push(()=>`@volta(${x(T)}, ${w.label}, ${h.from.passes.join(", ")})`)}return{relations:n,metadata:s}}function Lp(r,t,e){let n=t.pitchMode??"absolute";if(n!=="relative"&&n!=="absolute")throw new TypeError("pitchMode must be relative or absolute");let o=t.barsPerLine??4;if(!Number.isSafeInteger(o)||o<=0)throw new RangeError("barsPerLine must be a positive integer");let s=r.meters.length===0||!r.meters[0].at.isZero()?[{at:new G,numerator:4,denominator:4},...r.meters]:r.meters,i=r.keys.length===0||!r.keys[0].at.isZero()?[{at:new G,fifths:0,mode:"major"},...r.keys]:r.keys,a=r.tempos.length===0||!r.tempos[0].at.isZero()?[{at:new G,bpm:120},...r.tempos]:r.tempos,c=new Map,l=new Map,u=(v,S,M,I,z="above")=>{let j=ut(S),q=v.get(j)??{at:S,sources:[],pendingLocations:[]};z==="below"?(q.below??=[]).push(M):q.sources.push(M),I&&q.pendingLocations.push(I),v.set(j,q)};for(let v of i.slice(1))u(c,v.at,`@1(${Os(v)}4)`);for(let v of s.slice(1))u(c,v.at,`@meter(${v.numerator}, ${v.denominator})`);for(let v of a.slice(1))u(c,v.at,`@tempo(${v.bpm})`,v.location);for(let v of r.repeats){let S=v.symbol==="segno"||v.symbol==="coda"?c:l;u(S,v.at,`$${v.symbol}`,v.location,v.placement)}let p=r.lanes.map((v,S)=>{let M=S===0?c:new Map;for(let I of v.dynamics??[])u(M,I.at,`$${I.name}`,I.location,I.placement);return M}),m=r.lanes.map(v=>{let S=new Map,M;for(let I of v.events)I.program!==void 0&&I.program!==M&&(M=I.program,S.set(ut(I.start),M));return S}),d=[...r.bars.keys()].map(Tn).sort((v,S)=>v.compare(S)),f=[...r.measureBoundaries].map(Tn).sort((v,S)=>v.compare(S));if(r.lineBreaks.size===0){let v=0;for(let S of f)++v===o&&(r.lineBreaks.add(ut(S)),v=0)}let{relations:x,metadata:y}=Tp(r,e),h=r.page?`@page(width=${r.page.width}px, height=${r.page.height}px, top=${r.page.top}px, bottom=${r.page.bottom}px, left=${r.page.left}px, right=${r.page.right}px)
|
|
140
|
+
`:"",g=r.lanes.map((v,S)=>wp(v,n,r,i,p[S],m[S],y,e)),b=new Set;for(let v of r.multipleRests){let{start:S,end:M,count:I}=v,z=`${S}:${M}:${I}`;if(b.has(z))continue;let j=R=>!!M&&R.compare(S)>0&&R.compare(M)<0,q=Is(s,S),et=new G(q.numerator*4,q.denominator),N=g.map(R=>R.slice(Qt(R,S,D=>D.start),Qt(R,M??S,D=>D.start)));if(!(M&&M.clone().sub(S).equals(et.clone().mul(I))&&!s.some(R=>j(R.at))&&![...r.bars].some(([R,D])=>j(Tn(R))&&D!=="|")&&!r.endings.some(R=>j(R.from.at)||j(R.end))&&![...l.values()].some(R=>j(R.at))&&p.every(R=>![...R.values()].some(D=>j(D.at)))&&m.every(R=>![...R.keys()].some(D=>j(Tn(D))))&&N.length>0&&N.every(R=>R.length===I&&R.every((D,U)=>{let Q=D.event;return Q?.rest&&Q.pitches.length===0&&!Q.arpeggio&&!Q.slides?.length&&Q.modifiers.length===0&&Q.annotations.length===0&&Q.preGraces.length===0&&Q.postGraces.length===0&&Q.lyrics.size===0&&!y.afterSources.has(Q)&&D.start.equals(S.clone().add(et.clone().mul(U)))&&D.end.clone().sub(D.start).equals(et)})))||!M){nt(e,"multipleRest",v.location);continue}b.add(z);for(let[R,D]of g.entries()){let U=m[R].get(ut(S)),Q=N[R].map(P=>P.event),Z=(U===void 0?"":`@program(${U}) `)+An(y.labelRest(`@rest(${I})`,Q,M),p[R].get(ut(S)));D.splice(Qt(D,S,P=>P.start),I,{start:S,end:M,source:Z})}}let T=g.flatMap(v=>v.filter(S=>S.source).map(S=>({start:S.start,end:S.end}))).sort((v,S)=>v.start.compare(S.start)||v.end.compare(S.end)),L=[];for(let v of T){let S=L.at(-1);S&&v.start.compare(S.end)<0?v.end.compare(S.end)>0&&(S.end=v.end):L.push(v)}let w=new Map([...r.lineBreaks].map(v=>[v,Tn(v)]).filter(([,v])=>!wo(L,v))),A=r.lanes.map((v,S)=>{let M=new Set;for(let Z of v.events)for(let P of Z.lyrics.keys())M.add(P);let I=[...M].sort((Z,P)=>Z.localeCompare(P,void 0,{numeric:!0})),z=[[]],j=[new Map(I.map(Z=>[Z,[]]))],q=(Z,P)=>{for(let F of I){let $=j.at(-1).get(F);for(let H=0;H<P;H++){let X=H===0&&Z?Z.lyrics.get(F):void 0;$.push(X?hp(X):"@")}}},et=g[S],N=et.filter(Z=>Z.source),O=new Map;O.set("0",new G),O.set(ut(r.end),r.end);for(let Z of et)O.set(ut(Z.start),Z.start),O.set(ut(Z.end),Z.end);for(let Z of d)wo(N,Z)||O.set(ut(Z),Z);for(let[Z,P]of w)O.set(Z,P);let R=p[S];for(let[Z,P]of R)wo(N,P.at)||O.set(Z,P.at);if(S===0)for(let[Z,P]of l)wo(N,P.at)||O.set(Z,P.at);let D=[...O.values()].sort((Z,P)=>Z.compare(P)),U=0;for(let Z=0;Z<D.length;Z++){let P=D[Z];for(;U<et.length&&et[U].end.compare(P)<=0;)U++;let F=r.bars.get(ut(P)),$=S===0?l.get(ut(P)):void 0;if(F&&(!P.isZero()||F!=="|"))if($){let at=F.split(" ");at[0]=An(at[0],$),z.at(-1).push(at.join(" "))}else z.at(-1).push(F);else $&&P.compare(r.end)<=0&&(z.at(-1).push(...$.sources,...$.below??[]),$.pendingLocations.length=0);w.has(ut(P))&&(z.push([]),j.push(new Map(I.map(at=>[at,[]]))));let H=D[Z+1];if(!H)continue;let X=H.clone().sub(P);if(X.isZero())continue;let ot=R.get(ut(P)),rt=et[U];if(rt?.source){if(!rt.start.equals(P)||!rt.end.equals(H))throw new RangeError("MusicXML atomic block cannot cross a barline or state change");z.at(-1).push(rt.source);for(let at of rt.lyricEvents??[])q(at.event,at.slotCount);continue}let ht=m[S].get(ut(P));ht!==void 0&&z.at(-1).push(`@program(${ht})`);let dt=rt?.event;if(dt&&rt.start.compare(P)<=0&&rt.end.compare(H)>=0){let at=dt.start.equals(P),Pt=Is(i,dt.start),xt=dt.rest?"0":"-",Bt=Bs(at||ot?Mt=>An(at?Wc(dt,n,Pt,y,e,Mt):`${xt}${Mt}`,ot):xt,xt,X);z.at(-1).push(y.labelEnding(Bt,H)),at&&z.at(-1).push(...y.afterSources.get(dt)??[]),dt.rest?q(at?dt:void 0,Bt.slotCount):at&&q(dt,1)}else{let Pt=Bs(ot?xt=>An(`0${xt}`,ot):"0","0",X);z.at(-1).push(y.labelEnding(Pt,H)),q(void 0,Pt.slotCount)}}let Q=v.partName&&(!r.lanes[S-1]||r.lanes[S-1].partId!==v.partId)?v.partName:"";return z.map((Z,P)=>{let $=I.map(X=>lt(j[P].get(X).join(" "))).map(X=>`L: ${X}`).join(`
|
|
141
|
+
`);return`N${P===0&&Q?`(${lt(Q)})`:""}: { ${Z.join(" ")} }${$?`
|
|
142
|
+
${$}`:""}`})}),C=new Set;for(let v of[c,l,...p])for(let S of v.values())for(let M of S.pendingLocations)C.add(M);for(let v of C)nt(e,"directionOutput",v);let _=xo({title:r.title,subtitle:r.subtitle,author:r.creator,key:`${Os(i[0])}4`,meter:[s[0].numerator,s[0].denominator],tempo:a[0].bpm}),E=bo(A);return`${h}${_}
|
|
126
143
|
|
|
127
|
-
${
|
|
128
|
-
${
|
|
144
|
+
${E}${x.length>0?`
|
|
145
|
+
${x.map(v=>v()).join(" ")}`:""}`}function Ap(r,t={}){if(!r||r.nodeType!==1)throw new TypeError("MusicXML root must be an element");let e=[];return{script:Lp(gp(r,e),t,e),diagnostics:e}}var Cp=globalThis;Object.assign(Cp.jpfun??={},Ds);})();
|