Home
last modified time | relevance | path

Searched refs:stack (Results 326 – 350 of 388) sorted by relevance

1...<<111213141516

/plugin/authgooglesheets/vendor/guzzlehttp/guzzle/
H A DCHANGELOG.md302 * Reduced the number of stack frames needed to send requests.
635 …ation to ExceptionCollection exceptions so that users have more context, including a stack trace of
/plugin/ckgdoku/ckeditor/
H A Dckeditor.js1162stack=[]};k.prototype={push:function(a){a=this.stack.push({keyCode:a,inputs:0});return this.stack[…
1163 …;else for(a=this.stack.length;a--;)this.stack[a].inputs=0},getTotalInputs:function(){for(var a=thi…
/plugin/prosemirror/lib/
H A Dbundle.js1 !function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=27)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=o,t.svgIcon=function(e){var t=document.createElement("span");return t.innerHTML=o(e),t};var r={"alert-circle-outline":"M11,15H13V17H11V15M11,7H13V13H11V7M12,2C6.47,2 2,6.5 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M12,20A8,8 0 0,1 4,12A8,8 0 0,1 12,4A8,8 0 0,1 20,12A8,8 0 0,1 12,20Z","chevron-down":"M7.41,8.58L12,13.17L16.59,8.58L18,10L12,16L6,10L7.41,8.58Z","file-image-outline":"M14,2L20,8V20A2,2 0 0,1 18,22H6A2,2 0 0,1 4,20V4A2,2 0 0,1 6,2H14M18,20V9H13V4H6V20H18M17,13V19H7L12,14L14,16M10,10.5A1.5,1.5 0 0,1 8.5,12A1.5,1.5 0 0,1 7,10.5A1.5,1.5 0 0,1 8.5,9A1.5,1.5 0 0,1 10,10.5Z","format-bold":"M13.5,15.5H10V12.5H13.5A1.5,1.5 0 0,1 15,14A1.5,1.5 0 0,1 13.5,15.5M10,6.5H13A1.5,1.5 0 0,1 14.5,8A1.5,1.5 0 0,1 13,9.5H10M15.6,10.79C16.57,10.11 17.25,9 17.25,8C17.25,5.74 15.5,4 13.25,4H7V18H14.04C16.14,18 17.75,16.3 17.75,14.21C17.75,12.69 16.89,11.39 15.6,10.79Z","format-header-pound":"M3,4H5V10H9V4H11V18H9V12H5V18H3V4M13,8H15.31L15.63,5H17.63L17.31,8H19.31L19.63,5H21.63L21.31,8H23V10H21.1L20.9,12H23V14H20.69L20.37,17H18.37L18.69,14H16.69L16.37,17H14.37L14.69,14H13V12H14.9L15.1,10H13V8M17.1,10L16.9,12H18.9L19.1,10H17.1Z","format-header-1":"M3,4H5V10H9V4H11V18H9V12H5V18H3V4M14,18V16H16V6.31L13.5,7.75V5.44L16,4H18V16H20V18H14Z","format-header-2":"M3,4H5V10H9V4H11V18H9V12H5V18H3V4M21,18H15A2,2 0 0,1 13,16C13,15.47 13.2,15 13.54,14.64L18.41,9.41C18.78,9.05 19,8.55 19,8A2,2 0 0,0 17,6A2,2 0 0,0 15,8H13A4,4 0 0,1 17,4A4,4 0 0,1 21,8C21,9.1 20.55,10.1 19.83,10.83L15,16H21V18Z","format-header-3":"M3,4H5V10H9V4H11V18H9V12H5V18H3V4M15,4H19A2,2 0 0,1 21,6V16A2,2 0 0,1 19,18H15A2,2 0 0,1 13,16V15H15V16H19V12H15V10H19V6H15V7H13V6A2,2 0 0,1 15,4Z","format-header-4":"M3,4H5V10H9V4H11V18H9V12H5V18H3V4M18,18V13H13V11L18,4H20V11H21V13H20V18H18M18,11V7.42L15.45,11H18Z","format-header-5":"M3,4H5V10H9V4H11V18H9V12H5V18H3V4M15,4H20V6H15V10H17A4,4 0 0,1 21,14A4,4 0 0,1 17,18H15A2,2 0 0,1 13,16V15H15V16H17A2,2 0 0,0 19,14A2,2 0 0,0 17,12H15A2,2 0 0,1 13,10V6A2,2 0 0,1 15,4Z","format-header-6":"M3,4H5V10H9V4H11V18H9V12H5V18H3V4M15,4H19A2,2 0 0,1 21,6V7H19V6H15V10H19A2,2 0 0,1 21,12V16A2,2 0 0,1 19,18H15A2,2 0 0,1 13,16V6A2,2 0 0,1 15,4M15,12V16H19V12H15Z","format-header-decrease":"M4,4H6V10H10V4H12V18H10V12H6V18H4V4M20.42,7.41L16.83,11L20.42,14.59L19,16L14,11L19,6L20.42,7.41Z","format-header-equal":"M4,4H6V10H10V4H12V18H10V12H6V18H4V4M14,10V8H21V10H14M14,12H21V14H14V12Z","format-header-increase":"M4,4H6V10H10V4H12V18H10V12H6V18H4V4M14.59,7.41L18.17,11L14.59,14.59L16,16L21,11L16,6L14.59,7.41Z","format-text":"M18.5,4L19.66,8.35L18.7,8.61C18.25,7.74 17.79,6.87 17.26,6.43C16.73,6 16.11,6 15.5,6H13V16.5C13,17 13,17.5 13.33,17.75C13.67,18 14.33,18 15,18V19H9V18C9.67,18 10.33,18 10.67,17.75C11,17.5 11,17 11,16.5V6H8.5C7.89,6 7.27,6 6.74,6.43C6.21,6.87 5.75,7.74 5.3,8.61L4.34,8.35L5.5,4H18.5Z","format-italic":"M10,4V7H12.21L8.79,15H6V18H14V15H11.79L15.21,7H18V4H10Z","format-list-bulleted":"M7,5H21V7H7V5M7,13V11H21V13H7M4,4.5A1.5,1.5 0 0,1 5.5,6A1.5,1.5 0 0,1 4,7.5A1.5,1.5 0 0,1 2.5,6A1.5,1.5 0 0,1 4,4.5M4,10.5A1.5,1.5 0 0,1 5.5,12A1.5,1.5 0 0,1 4,13.5A1.5,1.5 0 0,1 2.5,12A1.5,1.5 0 0,1 4,10.5M7,19V17H21V19H7M4,16.5A1.5,1.5 0 0,1 5.5,18A1.5,1.5 0 0,1 4,19.5A1.5,1.5 0 0,1 2.5,18A1.5,1.5 0 0,1 4,16.5Z","format-list-numbers":"M7,13H21V11H7M7,19H21V17H7M7,7H21V5H7M2,11H3.8L2,13.1V14H5V13H3.2L5,10.9V10H2M3,8H4V4H2V5H3M2,17H4V17.5H3V18.5H4V19H2V20H5V16H2V17Z","format-paragraph":"M13,4A4,4 0 0,1 17,8A4,4 0 0,1 13,12H11V18H9V4H13M13,10A2,2 0 0,0 15,8A2,2 0 0,0 13,6H11V10H13Z","format-strikethrough":"M3,14H21V12H3M5,4V7H10V10H14V7H19V4M10,19H14V16H10V19Z","format-superscript":"M16,7.41L11.41,12L16,16.59L14.59,18L10,13.41L5.41,18L4,16.59L8.59,12L4,7.41L5.41,6L10,10.59L14.59,6L16,7.41M21.85,9H16.97V8L17.86,7.18C18.62,6.54 19.18,6 19.56,5.55C19.93,5.11 20.12,4.7 20.13,4.32C20.14,4.04 20.05,3.8 19.86,3.62C19.68,3.43 19.39,3.34 19,3.33C18.69,3.34 18.42,3.4 18.16,3.5L17.5,3.89L17.05,2.72C17.32,2.5 17.64,2.33 18.03,2.19C18.42,2.05 18.85,2 19.32,2C20.1,2 20.7,2.2 21.1,2.61C21.5,3 21.72,3.54 21.72,4.18C21.71,4.74 21.53,5.26 21.18,5.73C20.84,6.21 20.42,6.66 19.91,7.09L19.27,7.61V7.63H21.85V9Z","format-subscript":"M16,7.41L11.41,12L16,16.59L14.59,18L10,13.41L5.41,18L4,16.59L8.59,12L4,7.41L5.41,6L10,10.59L14.59,6L16,7.41M21.85,21.03H16.97V20.03L17.86,19.23C18.62,18.58 19.18,18.04 19.56,17.6C19.93,17.16 20.12,16.75 20.13,16.36C20.14,16.08 20.05,15.85 19.86,15.66C19.68,15.5 19.39,15.38 19,15.38C18.69,15.38 18.42,15.44 18.16,15.56L17.5,15.94L17.05,14.77C17.32,14.56 17.64,14.38 18.03,14.24C18.42,14.1 18.85,14 19.32,14C20.1,14.04 20.7,14.25 21.1,14.66C21.5,15.07 21.72,15.59 21.72,16.23C21.71,16.79 21.53,17.31 21.18,17.78C20.84,18.25 20.42,18.7 19.91,19.14L19.27,19.66V19.68H21.85V21.03Z","format-underline":"M5,21H19V19H5V21M12,17A6,6 0 0,0 18,11V3H15.5V11A3.5,3.5 0 0,1 12,14.5A3.5,3.5 0 0,1 8.5,11V3H6V11A6,6 0 0,0 12,17Z","format-quote-close":"M14,17H17L19,13V7H13V13H16M6,17H9L11,13V7H5V13H8L6,17Z","console-line":"M13,19V16H21V19H13M8.5,13L2.47,7H6.71L11.67,11.95C12.25,12.54 12.25,13.5 11.67,14.07L6.74,19H2.5L8.5,13Z","translate-off":"M12.17,5.81C11.87,6.69 11.47,7.55 11,8.39L12.35,9.74C13.11,8.5 13.71,7.18 14.13,5.81H17.16V3.75H9.94V1.69H7.87V3.75H6.37L8.43,5.81H12.17M15.53,12.91L17.03,14.41L17.67,12.69L19.08,16.47L22.39,19.77L18.7,9.94H16.64L15.53,12.91M1.31,1.31L0,2.62L1.13,3.75H0.65V5.81H3.19L5.26,7.88H4.46C5.21,9.56 6.24,11.15 7.53,12.58L2.28,17.76L3.75,19.22L8.91,14.07L12.11,17.27L12.8,15.43L14.1,16.72L12,22.31H14.06L15.22,19.22H16.6L21.38,24L22.69,22.69L1.31,1.31Z","link-variant":"M10.59,13.41C11,13.8 11,14.44 10.59,14.83C10.2,15.22 9.56,15.22 9.17,14.83C7.22,12.88 7.22,9.71 9.17,7.76V7.76L12.71,4.22C14.66,2.27 17.83,2.27 19.78,4.22C21.73,6.17 21.73,9.34 19.78,11.29L18.29,12.78C18.3,11.96 18.17,11.14 17.89,10.36L18.36,9.88C19.54,8.71 19.54,6.81 18.36,5.64C17.19,4.46 15.29,4.46 14.12,5.64L10.59,9.17C9.41,10.34 9.41,12.24 10.59,13.41M13.41,9.17C13.8,8.78 14.44,8.78 14.83,9.17C16.78,11.12 16.78,14.29 14.83,16.24V16.24L11.29,19.78C9.34,21.73 6.17,21.73 4.22,19.78C2.27,17.83 2.27,14.66 4.22,12.71L5.71,11.22C5.7,12.04 5.83,12.86 6.11,13.65L5.64,14.12C4.46,15.29 4.46,17.19 5.64,18.36C6.81,19.54 8.71,19.54 9.88,18.36L13.41,14.83C14.59,13.66 14.59,11.76 13.41,10.59C13,10.2 13,9.56 13.41,9.17Z",image:"M8.5,13.5L11,16.5L14.5,12L19,18H5M21,19V5C21,3.89 20.1,3 19,3H5A2,2 0 0,0 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19Z","arrow-expand-left":"M20,22H22V2H20V11H5.83L11.33,5.5L9.92,4.08L2,12L9.92,19.92L11.33,18.5L5.83,13H20V22Z","arrow-expand-right":"M4,2H2V22H4V13H18.17L12.67,18.5L14.08,19.92L22,12L14.08,4.08L12.67,5.5L18.17,11H4V2Z",puzzle:"M20.5,11H19V7C19,5.89 18.1,5 17,5H13V3.5A2.5,2.5 0 0,0 10.5,1A2.5,2.5 0 0,0 8,3.5V5H4A2,2 0 0,0 2,7V10.8H3.5C5,10.8 6.2,12 6.2,13.5C6.2,15 5,16.2 3.5,16.2H2V20A2,2 0 0,0 4,22H7.8V20.5C7.8,19 9,17.8 10.5,17.8C12,17.8 13.2,19 13.2,20.5V22H17A2,2 0 0,0 19,20V16H20.5A2.5,2.5 0 0,0 23,13.5A2.5,2.5 0 0,0 20.5,11Z","puzzle-outline":"M22,13.5C22,15.26 20.7,16.72 19,16.96V20A2,2 0 0,1 17,22H13.2V21.7A2.7,2.7 0 0,0 10.5,19C9,19 7.8,20.21 7.8,21.7V22H4A2,2 0 0,1 2,20V16.2H2.3C3.79,16.2 5,15 5,13.5C5,12 3.79,10.8 2.3,10.8H2V7A2,2 0 0,1 4,5H7.04C7.28,3.3 8.74,2 10.5,2C12.26,2 13.72,3.3 13.96,5H17A2,2 0 0,1 19,7V10.04C20.7,10.28 22,11.74 22,13.5M17,15H18.5A1.5,1.5 0 0,0 20,13.5A1.5,1.5 0 0,0 18.5,12H17V7H12V5.5A1.5,1.5 0 0,0 10.5,4A1.5,1.5 0 0,0 9,5.5V7H4V9.12C5.76,9.8 7,11.5 7,13.5C7,15.5 5.75,17.2 4,17.88V20H6.12C6.8,18.25 8.5,17 10.5,17C12.5,17 14.2,18.25 14.88,20H17V15Z","code-braces":"M8,3A2,2 0 0,0 6,5V9A2,2 0 0,1 4,11H3V13H4A2,2 0 0,1 6,15V19A2,2 0 0,0 8,21H10V19H8V14A2,2 0 0,0 6,12A2,2 0 0,0 8,10V5H10V3M16,3A2,2 0 0,1 18,5V9A2,2 0 0,0 20,11H21V13H20A2,2 0 0,0 18,15V19A2,2 0 0,1 16,21H14V19H16V14A2,2 0 0,1 18,12A2,2 0 0,1 16,10V5H14V3H16Z",rss:"M6.18,15.64A2.18,2.18 0 0,1 8.36,17.82C8.36,19 7.38,20 6.18,20C5,20 4,19 4,17.82A2.18,2.18 0 0,1 6.18,15.64M4,4.44A15.56,15.56 0 0,1 19.56,20H16.73A12.73,12.73 0 0,0 4,7.27V4.44M4,10.1A9.9,9.9 0 0,1 13.9,20H11.07A7.07,7.07 0 0,0 4,12.93V10.1Z",emoticon:"M12,17.5C14.33,17.5 16.3,16.04 17.11,14H6.89C7.69,16.04 9.67,17.5 12,17.5M8.5,11A1.5,1.5 0 0,0 10,9.5A1.5,1.5 0 0,0 8.5,8A1.5,1.5 0 0,0 7,9.5A1.5,1.5 0 0,0 8.5,11M15.5,11A1.5,1.5 0 0,0 17,9.5A1.5,1.5 0 0,0 15.5,8A1.5,1.5 0 0,0 14,9.5A1.5,1.5 0 0,0 15.5,11M12,20A8,8 0 0,1 4,12A8,8 0 0,1 12,4A8,8 0 0,1 20,12A8,8 0 0,1 12,20M12,2C6.47,2 2,6.5 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2Z","note-plus-outline":"M15,10H20.5L15,4.5V10M4,3H16L22,9V19A2,2 0 0,1 20,21H4C2.89,21 2,20.1 2,19V5C2,3.89 2.89,3 4,3M4,5V19H20V12H13V5H4M8,17V15H6V13H8V11H10V13H12V15H10V17H8Z","table-plus":"M18,14H20V17H23V19H20V22H18V19H15V17H18V14M4,3H18A2,2 0 0,1 20,5V12.08C18.45,11.82 16.92,12.18 15.68,13H12V17H13.08C12.97,17.68 12.97,18.35 13.08,19H4A2,2 0 0,1 2,17V5A2,2 0 0,1 4,3M4,7V11H10V7H4M12,7V11H18V7H12M4,13V17H10V13H4Z","table-edit":"M21.7,13.35L20.7,14.35L18.65,12.3L19.65,11.3C19.86,11.08 20.21,11.08 20.42,11.3L21.7,12.58C21.92,12.79 21.92,13.14 21.7,13.35M12,18.94L18.07,12.88L20.12,14.93L14.06,21H12V18.94M4,2H18A2,2 0 0,1 20,4V8.17L16.17,12H12V16.17L10.17,18H4A2,2 0 0,1 2,16V4A2,2 0 0,1 4,2M4,6V10H10V6H4M12,6V10H18V6H12M4,12V16H10V12H4Z","table-row-plus-before":"M22,14A2,2 0 0,0 20,12H4A2,2 0 0,0 2,14V21H4V19H8V21H10V19H14V21H16V19H20V21H22V14M4,14H8V17H4V14M10,14H14V17H10V14M20,14V17H16V14H20M11,10H13V7H16V5H13V2H11V5H8V7H11V10Z","table-row-plus-after":"M22,10A2,2 0 0,1 20,12H4A2,2 0 0,1 2,10V3H4V5H8V3H10V5H14V3H16V5H20V3H22V10M4,10H8V7H4V10M10,10H14V7H10V10M20,10V7H16V10H20M11,14H13V17H16V19H13V22H11V19H8V17H11V14Z","table-row-remove":"M9.41,13L12,15.59L14.59,13L16,14.41L13.41,17L16,19.59L14.59,21L12,18.41L9.41,21L8,19.59L10.59,17L8,14.41L9.41,13M22,9A2,2 0 0,1 20,11H4A2,2 0 0,1 2,9V6A2,2 0 0,1 4,4H20A2,2 0 0,1 22,6V9M4,9H8V6H4V9M10,9H14V6H10V9M16,9H20V6H16V9Z","table-column-plus-before":"M13,2A2,2 0 0,0 11,4V20A2,2 0 0,0 13,22H22V2H13M20,10V14H13V10H20M20,16V20H13V16H20M20,4V8H13V4H20M9,11H6V8H4V11H1V13H4V16H6V13H9V11Z","table-column-plus-after":"M11,2A2,2 0 0,1 13,4V20A2,2 0 0,1 11,22H2V2H11M4,10V14H11V10H4M4,16V20H11V16H4M4,4V8H11V4H4M15,11H18V8H20V11H23V13H20V16H18V13H15V11Z","table-column-remove":"M4,2H11A2,2 0 0,1 13,4V20A2,2 0 0,1 11,22H4A2,2 0 0,1 2,20V4A2,2 0 0,1 4,2M4,10V14H11V10H4M4,16V20H11V16H4M4,4V8H11V4H4M17.59,12L15,9.41L16.41,8L19,10.59L21.59,8L23,9.41L20.41,12L23,14.59L21.59,16L19,13.41L16.41,16L15,14.59L17.59,12Z","table-border":"M21,19A1,1 0 0,1 20,20H19V18H21V19M15,20V18H17V20H15M11,20V18H13V20H11M7,20V18H9V20H7M4,20A1,1 0 0,1 3,19V18H5V20H4M19,4H5A2,2 0 0,0 3,6V8H5L11,8H13L19,8H21V6C21,4.89 20.11,4 19,4M5,14H3V16H5V14M5,10H3V12H5V10M21,10H19V12H21V10M21,14H19V16H21V14M11,16V14H13V16H11M11,12V10H13V12H11","format-align-left":"M3,3H21V5H3V3M3,7H15V9H3V7M3,11H21V13H3V11M3,15H15V17H3V15M3,19H21V21H3V19Z","format-align-center":"M3,3H21V5H3V3M7,7H17V9H7V7M3,11H21V13H3V11M7,15H17V17H7V15M3,19H21V21H3V19Z","format-align-right":"M3,3H21V5H3V3M9,7H21V9H9V7M3,11H21V13H3V11M9,15H21V17H9V15M3,19H21V21H3V19Z","table-merge-cells":"M5,10H3V6A2,2 0 0,1 5,4H11V6H5V10M19,18H13V20H19A2,2 0 0,0 21,18V14H19V18M5,18V14H3V18A2,2 0 0,0 5,20H11V18H5M19,4H13V6H19V10H21V6A2,2 0 0,0 19,4M8,13V15L11,12L8,9V11H3V13H8M16,11V9L13,12L16,15V13H21V11H16Z","arrow-split-vertical":"M18,16V13H15V22H13V2H15V11H18V8L22,12L18,16M2,12L6,16V13H9V22H11V2H9V11H6V8L2,12Z","table-remove":"M15.46,15.88L16.88,14.46L19,16.59L21.12,14.46L22.54,15.88L20.41,18L22.54,20.12L21.12,21.54L19,19.41L16.88,21.54L15.46,20.12L17.59,18L15.46,15.88M4,3H18A2,2 0 0,1 20,5V12.08C18.45,11.82 16.92,12.18 15.68,13H12V17H13.08C12.97,17.68 12.97,18.35 13.08,19H4A2,2 0 0,1 2,17V5A2,2 0 0,1 4,3M4,7V11H10V7H4M12,7V11H18V7H12M4,13V17H10V13H4Z","settings-outline":"M19.43,12.97L21.54,14.63C21.73,14.78 21.78,15.05 21.66,15.27L19.66,18.73C19.54,18.95 19.27,19.03 19.05,18.95L16.56,17.94C16.04,18.34 15.5,18.67 14.87,18.93L14.5,21.58C14.46,21.82 14.25,22 14,22H10C9.75,22 9.54,21.82 9.5,21.58L9.13,18.93C8.5,18.68 7.96,18.34 7.44,17.94L4.95,18.95C4.73,19.03 4.46,18.95 4.34,18.73L2.34,15.27C2.21,15.05 2.27,14.78 2.46,14.63L4.57,12.97L4.5,12L4.57,11L2.46,9.37C2.27,9.22 2.21,8.95 2.34,8.73L4.34,5.27C4.46,5.05 4.73,4.96 4.95,5.05L7.44,6.05C7.96,5.66 8.5,5.32 9.13,5.07L9.5,2.42C9.54,2.18 9.75,2 10,2H14C14.25,2 14.46,2.18 14.5,2.42L14.87,5.07C15.5,5.32 16.04,5.66 16.56,6.05L19.05,5.05C19.27,4.96 19.54,5.05 19.66,5.27L21.66,8.73C21.78,8.95 21.73,9.22 21.54,9.37L19.43,11L19.5,12L19.43,12.97M6.5,12C6.5,12.58 6.59,13.13 6.75,13.66L4.68,15.36L5.43,16.66L7.95,15.72C8.69,16.53 9.68,17.12 10.8,17.37L11.24,20H12.74L13.18,17.37C14.3,17.13 15.3,16.54 16.05,15.73L18.56,16.67L19.31,15.37L17.24,13.67C17.41,13.14 17.5,12.58 17.5,12C17.5,11.43 17.41,10.87 17.25,10.35L19.31,8.66L18.56,7.36L16.06,8.29C15.31,7.47 14.31,6.88 13.19,6.63L12.75,4H11.25L10.81,6.63C9.69,6.88 8.69,7.47 7.94,8.29L5.44,7.35L4.69,8.65L6.75,10.35C6.59,10.87 6.5,11.43 6.5,12M12,8.5A3.5,3.5 0 0,1 15.5,12A3.5,3.5 0 0,1 12,15.5A3.5,3.5 0 0,1 8.5,12A3.5,3.5 0 0,1 12,8.5M12,10.5A1.5,1.5 0 0,0 10.5,12A1.5,1.5 0 0,0 12,13.5A1.5,1.5 0 0,0 13.5,12A1.5,1.5 0 0,0 12,10.5Z","checkbox-blank-outline":"M19,3H5C3.89,3 3,3.89 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5C21,3.89 20.1,3 19,3M19,5V19H5V5H19Z","checkbox-marked-outline":"M19,19H5V5H15V3H5C3.89,3 3,3.89 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V11H19M7.91,10.08L6.5,11.5L11,16L21,6L19.59,4.58L11,13.17L7.91,10.08Z",undo:"M12.5,8C9.85,8 7.45,9 5.6,10.6L2,7V16H11L7.38,12.38C8.77,11.22 10.54,10.5 12.5,10.5C16.04,10.5 19.05,12.81 20.1,16L22.47,15.22C21.08,11.03 17.15,8 12.5,8Z",redo:"M18.4,10.6C16.55,9 14.15,8 11.5,8C6.85,8 2.92,11.03 1.54,15.22L3.9,16C4.95,12.81 7.95,10.5 11.5,10.5C13.45,10.5 15.23,11.22 16.62,12.38L13,16H22V7L18.4,10.6Z"};function o(e){var t=r["alert-circle-outline"];return void 0!==r[e]?t=r[e]:console.error("SVG icon "+e+" does not exist"),'<svg viewBox="0 0 24 24"><path d="'+t+'" /></svg>'}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(o(this,e),"function"!=typeof t.command)throw new TypeError("command is not a function!");this.options=t,"function"==typeof t.isActive&&(this.isActive=t.isActive)}return r(e,[{key:"isActive",value:function(e){return!1}}]),r(e,[{key:"render",value:function(e){var t=this,n=this.renderDOM(e);if(!n)throw new Error("Could not generate dom for "+this.options.label+" "+JSON.stringify(this.options));return n.addEventListener("mousedown",(function(n){n.preventDefault(),t.options.command(e.state,e.dispatch,e)})),this.dom=n,n}},{key:"renderDOM",value:function(t){var n=void 0;return"function"==typeof this.options.render?n=this.options.render(t):(n=jQuery("<span>").addClass("menuitem"),this.options.icon instanceof Element&&n.append(e.renderSVGIcon(this.options.icon,this.options.label)),"string"==typeof this.options.label&&n.append(jQuery("<span>").addClass("menulabel").attr("title",this.options.label).text(this.options.label).get(0)),n=n.get(0)),n}},{key:"update",value:function(e){"function"==typeof this.options.update&&this.options.update(e,this.dom),this.isActive(e.state)?this.dom.classList.add("is-active"):this.dom.classList.remove("is-active"),this.options.command(e.state,null,e)?this.dom.classList.remove("is-disabled"):this.dom.classList.add("is-disabled")}}],[{key:"renderSVGIcon",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return jQuery(e).addClass("menuicon").attr("title",t)}}]),e}();t.default=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();var o=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return r(e,null,[{key:"isAvailable",value:function(e){throw new Error("isAvailable is not implemented!")}},{key:"getMenuItem",value:function(e){throw new Error("getMenuItem is not implemented!")}}]),e}();t.default=o},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r,o,i=n(4),a=n(13),s=n(5),l=n(6),c=n(16);if("undefined"!=typeof WeakMap){var u=new WeakMap;r=function(e){return u.get(e)},o=function(e,t){return u.set(e,t),t}}else{var f=[],p=0;r=function(e){for(var t=0;t<f.length;t+=2)if(f[t]==e)return f[t+1]},o=function(e,t){return 10==p&&(p=0),f[p++]=e,f[p++]=t}}var d=function(e,t,n,r){this.left=e,this.top=t,this.right=n,this.bottom=r},h=function(e,t,n,r){this.width=e,this.height=t,this.map=n,this.problems=r};function v(e){if(e.colwidth)return e.colwidth.slice();for(var t=[],n=0;n<e.colspan;n++)t.push(0);return t}h.prototype.findCell=function(e){for(var t=0;t<this.map.length;t++){var n=this.map[t];if(n==e){for(var r=t%this.width,o=t/this.width|0,i=r+1,a=o+1,s=1;i<this.width&&this.map[t+s]==n;s++)i++;for(var l=1;a<this.height&&this.map[t+this.width*l]==n;l++)a++;return new d(r,o,i,a)}}throw new RangeError("No cell with offset "+e+" found")},h.prototype.colCount=function(e){for(var t=0;t<this.map.length;t++)if(this.map[t]==e)return t%this.width;throw new RangeError("No cell with offset "+e+" found")},h.prototype.nextCell=function(e,t,n){var r=this.findCell(e),o=r.left,i=r.right,a=r.top,s=r.bottom;return"horiz"==t?(n<0?0==o:i==this.width)?null:this.map[a*this.width+(n<0?o-1:i)]:(n<0?0==a:s==this.height)?null:this.map[o+this.width*(n<0?a-1:s)]},h.prototype.rectBetween=function(e,t){var n=this.findCell(e),r=n.left,o=n.right,i=n.top,a=n.bottom,s=this.findCell(t),l=s.left,c=s.right,u=s.top,f=s.bottom;return new d(Math.min(r,l),Math.min(i,u),Math.max(o,c),Math.max(a,f))},h.prototype.cellsInRect=function(e){for(var t=[],n={},r=e.top;r<e.bottom;r++)for(var o=e.left;o<e.right;o++){var i=r*this.width+o,a=this.map[i];n[a]||(n[a]=!0,o==e.left&&o&&this.map[i-1]==a||r==e.top&&r&&this.map[i-this.width]==a||t.push(a))}return t},h.prototype.positionAt=function(e,t,n){for(var r=0,o=0;;r++){var i=o+n.child(r).nodeSize;if(r==e){for(var a=t+e*this.width,s=(e+1)*this.width;a<s&&this.map[a]<o;)a++;return a==s?i-1:this.map[a]}o=i}},h.get=function(e){return r(e)||o(e,function(e){if("table"!=e.type.spec.tableRole)throw new RangeError("Not a table node: "+e.type.name);for(var t=function(e){for(var t=-1,n=!1,r=0;r<e.childCount;r++){var o=e.child(r),i=0;if(n)for(var a=0;a<r;a++)for(var s=e.child(a),l=0;l<s.childCount;l++){var c=s.child(l);a+c.attrs.rowspan>r&&(i+=c.attrs.colspan)}for(var u=0;u<o.childCount;u++){var f=o.child(u);i+=f.attrs.colspan,f.attrs.rowspan>1&&(n=!0)}-1==t?t=i:t!=i&&(t=Math.max(t,i))}return t}(e),n=e.childCount,r=[],o=0,i=null,a=[],s=0,l=t*n;s<l;s++)r[s]=0;for(var c=0,u=0;c<n;c++){var f=e.child(c);u++;for(var p=0;;p++){for(;o<r.length&&0!=r[o];)o++;if(p==f.childCount)break;for(var d=f.child(p),m=d.attrs,y=m.colspan,g=m.rowspan,b=m.colwidth,w=0;w<g;w++){if(w+c>=n){(i||(i=[])).push({type:"overlong_rowspan",pos:u,n:g-w});break}for(var k=o+w*t,O=0;O<y;O++){0==r[k+O]?r[k+O]=u:(i||(i=[])).push({type:"collision",row:c,pos:u,n:y-O});var M=b&&b[O];if(M){var S=(k+O)%t*2,_=a[S];null==_||_!=M&&1==a[S+1]?(a[S]=M,a[S+1]=1):_==M&&a[S+1]++}}}o+=y,u+=d.nodeSize}for(var C=(c+1)*t,x=0;o<C;)0==r[o++]&&x++;x&&(i||(i=[])).push({type:"missing",row:c,n:x}),u++}for(var A=new h(t,n,r,i),T=!1,V=0;!T&&V<a.length;V+=2)null!=a[V]&&a[V+1]<n&&(T=!0);T&&function(e,t,n){e.problems||(e.problems=[]);for(var r=0,o={};r<e.map.length;r++){var i=e.map[r];if(!o[i]){o[i]=!0;for(var a=n.nodeAt(i),s=null,l=0;l<a.attrs.colspan;l++){var c=(r+l)%e.width,u=t[2*c];null==u||a.attrs.colwidth&&a.attrs.colwidth[l]==u||((s||(s=v(a.attrs)))[l]=u)}s&&e.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:s})}}}(A,a,e);return A}(e))};var m=new i.PluginKey("selectingCells");function y(e){for(var t=e.depth-1;t>0;t--)if("row"==e.node(t).type.spec.tableRole)return e.node(0).resolve(e.before(t+1));return null}function g(e){for(var t=e.selection.$head,n=t.depth;n>0;n--)if("row"==t.node(n).type.spec.tableRole)return!0;return!1}function b(e){var t=e.selection;return t.$anchorCell?t.$anchorCell.pos>t.$headCell.pos?t.$anchorCell:t.$headCell:t.node&&"cell"==t.node.type.spec.tableRole?t.$anchor:y(t.$head)||function(e){for(var t=e.nodeAfter,n=e.pos;t;t=t.firstChild,n++){var r=t.type.spec.tableRole;if("cell"==r||"header_cell"==r)return e.doc.resolve(n)}for(var o=e.nodeBefore,i=e.pos;o;o=o.lastChild,i--){var a=o.type.spec.tableRole;if("cell"==a||"header_cell"==a)return e.doc.resolve(i-o.nodeSize)}}(t.$head)}function w(e){return"row"==e.parent.type.spec.tableRole&&e.nodeAfter}function k(e){return e.node(0).resolve(e.pos+e.nodeAfter.nodeSize)}function O(e,t){return e.depth==t.depth&&e.pos>=t.start(-1)&&e.pos<=t.end(-1)}function M(e,t,n){var r=e.start(-1),o=h.get(e.node(-1)).nextCell(e.pos-r,t,n);return null==o?null:e.node(0).resolve(r+o)}function S(e,t,n){var r={};for(var o in e)r[o]=e[o];return r[t]=n,r}function _(e,t,n){void 0===n&&(n=1);var r=S(e,"colspan",e.colspan-n);return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(t,n),r.colwidth.some((function(e){return e>0}))||(r.colwidth=null)),r}function C(e,t,n){void 0===n&&(n=1);var r=S(e,"colspan",e.colspan+n);if(r.colwidth){r.colwidth=r.colwidth.slice();for(var o=0;o<n;o++)r.colwidth.splice(t,0,0)}return r}var x=function(e){function t(t,n){void 0===n&&(n=t);var r=t.node(-1),o=h.get(r),a=t.start(-1),s=o.rectBetween(t.pos-a,n.pos-a),l=t.node(0),c=o.cellsInRect(s).filter((function(e){return e!=n.pos-a}));c.unshift(n.pos-a);var u=c.map((function(e){var t=r.nodeAt(e),n=e+a+1;return new i.SelectionRange(l.resolve(n),l.resolve(n+t.content.size))}));e.call(this,u[0].$from,u[0].$to,u),this.$anchorCell=t,this.$headCell=n}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.map=function(e,n){var r=e.resolve(n.map(this.$anchorCell.pos)),o=e.resolve(n.map(this.$headCell.pos));if(w(r)&&w(o)&&O(r,o)){var a=this.$anchorCell.node(-1)!=r.node(-1);return a&&this.isRowSelection()?t.rowSelection(r,o):a&&this.isColSelection()?t.colSelection(r,o):new t(r,o)}return i.TextSelection.between(r,o)},t.prototype.content=function(){for(var e=this.$anchorCell.node(-1),t=h.get(e),n=this.$anchorCell.start(-1),r=t.rectBetween(this.$anchorCell.pos-n,this.$headCell.pos-n),o={},i=[],a=r.top;a<r.bottom;a++){for(var l=[],c=a*t.width+r.left,u=r.left;u<r.right;u++,c++){var f=t.map[c];if(!o[f]){o[f]=!0;var p=t.findCell(f),d=e.nodeAt(f),v=r.left-p.left,m=p.right-r.right;if(v>0||m>0){var y=d.attrs;v>0&&(y=_(y,0,v)),m>0&&(y=_(y,y.colspan-m,m)),d=p.left<r.left?d.type.createAndFill(y):d.type.create(y,d.content)}if(p.top<r.top||p.bottom>r.bottom){var g=S(d.attrs,"rowspan",Math.min(p.bottom,r.bottom)-Math.max(p.top,r.top));d=p.top<r.top?d.type.createAndFill(g):d.type.create(g,d.content)}l.push(d)}}i.push(e.child(a).copy(s.Fragment.from(l)))}var b=this.isColSelection()&&this.isRowSelection()?e:i;return new s.Slice(s.Fragment.from(b),1,1)},t.prototype.replace=function(t,n){void 0===n&&(n=s.Slice.empty);for(var r=t.steps.length,o=this.ranges,i=0;i<o.length;i++){var a=o[i],l=a.$from,c=a.$to,u=t.mapping.slice(r);t.replace(u.map(l.pos),u.map(c.pos),i?s.Slice.empty:n)}var f=e.findFrom(t.doc.resolve(t.mapping.slice(r).map(this.to)),-1);f&&t.setSelection(f)},t.prototype.replaceWith=function(e,t){this.replace(e,new s.Slice(s.Fragment.from(t),0,0))},t.prototype.forEachCell=function(e){for(var t=this.$anchorCell.node(-1),n=h.get(t),r=this.$anchorCell.start(-1),o=n.cellsInRect(n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r)),i=0;i<o.length;i++)e(t.nodeAt(o[i]),r+o[i])},t.prototype.isColSelection=function(){var e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;var n=e+this.$anchorCell.nodeAfter.attrs.rowspan,r=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(n,r)==this.$headCell.node(-1).childCount},t.colSelection=function(e,n){void 0===n&&(n=e);var r=h.get(e.node(-1)),o=e.start(-1),i=r.findCell(e.pos-o),a=r.findCell(n.pos-o),s=e.node(0);return i.top<=a.top?(i.top>0&&(e=s.resolve(o+r.map[i.left])),a.bottom<r.height&&(n=s.resolve(o+r.map[r.width*(r.height-1)+a.right-1]))):(a.top>0&&(n=s.resolve(o+r.map[a.left])),i.bottom<r.height&&(e=s.resolve(o+r.map[r.width*(r.height-1)+i.right-1]))),new t(e,n)},t.prototype.isRowSelection=function(){var e=h.get(this.$anchorCell.node(-1)),t=this.$anchorCell.start(-1),n=e.colCount(this.$anchorCell.pos-t),r=e.colCount(this.$headCell.pos-t);if(Math.min(n,r)>0)return!1;var o=n+this.$anchorCell.nodeAfter.attrs.colspan,i=r+this.$headCell.nodeAfter.attrs.colspan;return Math.max(o,i)==e.width},t.prototype.eq=function(e){return e instanceof t&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos},t.rowSelection=function(e,n){void 0===n&&(n=e);var r=h.get(e.node(-1)),o=e.start(-1),i=r.findCell(e.pos-o),a=r.findCell(n.pos-o),s=e.node(0);return i.left<=a.left?(i.left>0&&(e=s.resolve(o+r.map[i.top*r.width])),a.right<r.width&&(n=s.resolve(o+r.map[r.width*(a.top+1)-1]))):(a.left>0&&(n=s.resolve(o+r.map[a.top*r.width])),i.right<r.width&&(e=s.resolve(o+r.map[r.width*(i.top+1)-1]))),new t(e,n)},t.prototype.toJSON=function(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}},t.fromJSON=function(e,n){return new t(e.resolve(n.anchor),e.resolve(n.head))},t.create=function(e,n,r){return void 0===r&&(r=n),new t(e.resolve(n),e.resolve(r))},t.prototype.getBookmark=function(){return new A(this.$anchorCell.pos,this.$headCell.pos)},t}(i.Selection);x.prototype.visible=!1,i.Selection.jsonID("cell",x);var A=function(e,t){this.anchor=e,this.head=t};function T(e){if(!(e.selection instanceof x))return null;var t=[];return e.selection.forEachCell((function(e,n){t.push(a.Decoration.node(n,n+e.nodeSize,{class:"selectedCell"}))})),a.DecorationSet.create(e.doc,t)}function V(e,t){var n=e.getAttribute("data-colwidth"),r=n&&/^\d+(,\d+)*$/.test(n)?n.split(",").map((function(e){return Number(e)})):null,o=Number(e.getAttribute("colspan")||1),i={colspan:o,rowspan:Number(e.getAttribute("rowspan")||1),colwidth:r&&r.length==o?r:null};for(var a in t){var s=t[a].getFromDOM,l=s&&s(e);null!=l&&(i[a]=l)}return i}function j(e,t){var n={};for(var r in 1!=e.attrs.colspan&&(n.colspan=e.attrs.colspan),1!=e.attrs.rowspan&&(n.rowspan=e.attrs.rowspan),e.attrs.colwidth&&(n["data-colwidth"]=e.attrs.colwidth.join(",")),t){var o=t[r].setDOMAttr;o&&o(e.attrs[r],n)}return n}function E(e){var t=e.cached.tableNodeTypes;if(!t)for(var n in t=e.cached.tableNodeTypes={},e.nodes){var r=e.nodes[n],o=r.spec.tableRole;o&&(t[o]=r)}return t}function P(e){if(!e.size)return null;for(var t=e.content,n=e.openStart,r=e.openEnd;1==t.childCount&&(n>0&&r>0||"table"==t.firstChild.type.spec.tableRole);)n--,r--,t=t.firstChild.content;var o=t.firstChild,i=o.type.spec.tableRole,a=o.type.schema,l=[];if("row"==i)for(var c=0;c<t.childCount;c++){var u=t.child(c).content,f=c?0:Math.max(0,n-1),p=c<t.childCount-1?0:Math.max(0,r-1);(f||p)&&(u=N(E(a).row,new s.Slice(u,f,p)).content),l.push(u)}else{if("cell"!=i&&"header_cell"!=i)return null;l.push(n||r?N(E(a).row,new s.Slice(t,n,r)).content:t)}return function(e,t){for(var n=[],r=0;r<t.length;r++)for(var o=t[r],i=o.childCount-1;i>=0;i--)for(var a=o.child(i).attrs,l=a.rowspan,c=a.colspan,u=r;u<r+l;u++)n[u]=(n[u]||0)+c;for(var f=0,p=0;p<n.length;p++)f=Math.max(f,n[p]);for(var d=0;d<n.length;d++)if(d>=t.length&&t.push(s.Fragment.empty),n[d]<f){for(var h=E(e).cell.createAndFill(),v=[],m=n[d];m<f;m++)v.push(h);t[d]=t[d].append(s.Fragment.from(v))}return{height:t.length,width:f,rows:t}}(a,l)}function N(e,t){var n=e.createAndFill();return new l.Transform(n).replace(0,n.content.size,t).doc}function H(e,t,n){var r=e.width,o=e.height,i=e.rows;if(r!=t){for(var a=[],l=[],c=0;c<i.length;c++){for(var u=i[c],f=[],p=a[c]||0,d=0;p<t;d++){var h=u.child(d%u.childCount);p+h.attrs.colspan>t&&(h=h.type.create(_(h.attrs,h.attrs.colspan,p+h.attrs.colspan-t),h.content)),f.push(h),p+=h.attrs.colspan;for(var v=1;v<h.attrs.rowspan;v++)a[c+v]=(a[c+v]||0)+h.attrs.colspan}l.push(s.Fragment.from(f))}i=l,r=t}if(o!=n){for(var m=[],y=0,g=0;y<n;y++,g++){for(var b=[],w=i[g%o],k=0;k<w.childCount;k++){var O=w.child(k);y+O.attrs.rowspan>n&&(O=O.type.create(S(O.attrs,"rowspan",n-O.attrs.rowspan),O.content)),b.push(O)}m.push(s.Fragment.from(b))}i=m,o=n}return{width:r,height:o,rows:i}}function L(e,t,n,r,o,i,a,s){if(0==a||a==t.height)return!1;for(var l=!1,c=o;c<i;c++){var u=a*t.width+c,f=t.map[u];if(t.map[u-t.width]==f){l=!0;var p=n.nodeAt(f),d=t.findCell(f),h=d.top,v=d.left;e.setNodeMarkup(e.mapping.slice(s).map(f+r),null,S(p.attrs,"rowspan",a-h)),e.insert(e.mapping.slice(s).map(t.positionAt(a,v,n)),p.type.createAndFill(S(p.attrs,"rowspan",h+p.attrs.rowspan-a))),c+=p.attrs.colspan-1}}return l}function D(e,t,n,r,o,i,a,s){if(0==a||a==t.width)return!1;for(var l=!1,c=o;c<i;c++){var u=c*t.width+a,f=t.map[u];if(t.map[u-1]==f){l=!0;var p=n.nodeAt(f),d=t.colCount(f),h=e.mapping.slice(s).map(f+r);e.setNodeMarkup(h,null,_(p.attrs,a-d,p.attrs.colspan-(a-d))),e.insert(h+p.nodeSize,p.type.createAndFill(_(p.attrs,0,a-d))),c+=p.attrs.rowspan-1}}return l}function I(e,t,n,r,o){var i=n?e.doc.nodeAt(n-1):e.doc,a=h.get(i),l=r.top,c=r.left,u=c+o.width,f=l+o.height,p=e.tr,d=0;function v(){i=n?p.doc.nodeAt(n-1):p.doc,a=h.get(i),d=p.mapping.maps.length}(function(e,t,n,r,o,i,a){var l,c,u=E(e.doc.type.schema);if(o>t.width)for(var f=0,p=0;f<t.height;f++){var d=n.child(f);p+=d.nodeSize;var h=[],v=void 0;v=null==d.lastChild||d.lastChild.type==u.cell?l||(l=u.cell.createAndFill()):c||(c=u.header_cell.createAndFill());for(var m=t.width;m<o;m++)h.push(v);e.insert(e.mapping.slice(a).map(p-1+r),h)}if(i>t.height){for(var y=[],g=0,b=(t.height-1)*t.width;g<Math.max(t.width,o);g++){var w=!(g>=t.width)&&n.nodeAt(t.map[b+g]).type==u.header_cell;y.push(w?c||(c=u.header_cell.createAndFill()):l||(l=u.cell.createAndFill()))}for(var k=u.row.create(null,s.Fragment.from(y)),O=[],M=t.height;M<i;M++)O.push(k);e.insert(e.mapping.slice(a).map(r+n.nodeSize-2),O)}return!(!l&&!c)})(p,a,i,n,u,f,d)&&v(),L(p,a,i,n,c,u,l,d)&&v(),L(p,a,i,n,c,u,f,d)&&v(),D(p,a,i,n,l,f,c,d)&&v(),D(p,a,i,n,l,f,u,d)&&v();for(var m=l;m<f;m++){var y=a.positionAt(m,c,i),g=a.positionAt(m,u,i);p.replace(p.mapping.slice(d).map(y+n),p.mapping.slice(d).map(g+n),new s.Slice(o.rows[m-l],0,0))}v(),p.setSelection(new x(p.doc.resolve(n+a.positionAt(l,c,i)),p.doc.resolve(n+a.positionAt(f-1,u-1,i)))),t(p)}A.prototype.map=function(e){return new A(e.map(this.anchor),e.map(this.head))},A.prototype.resolve=function(e){var t=e.resolve(this.anchor),n=e.resolve(this.head);return"row"==t.parent.type.spec.tableRole&&"row"==n.parent.type.spec.tableRole&&t.index()<t.parent.childCount&&n.index()<n.parent.childCount&&O(t,n)?new x(t,n):i.Selection.near(n,1)};var R=c.keydownHandler({ArrowLeft:F("horiz",-1),ArrowRight:F("horiz",1),ArrowUp:F("vert",-1),ArrowDown:F("vert",1),"Shift-ArrowLeft":z("horiz",-1),"Shift-ArrowRight":z("horiz",1),"Shift-ArrowUp":z("vert",-1),"Shift-ArrowDown":z("vert",1),Backspace:B,"Mod-Backspace":B,Delete:B,"Mod-Delete":B});function $(e,t,n){return!n.eq(e.selection)&&(t&&t(e.tr.setSelection(n).scrollIntoView()),!0)}function F(e,t){return function(n,r,o){var a=n.selection;if(a instanceof x)return $(n,r,i.Selection.near(a.$headCell,t));if("horiz"!=e&&!a.empty)return!1;var s=K(o,e,t);if(null==s)return!1;if("horiz"==e)return $(n,r,i.Selection.near(n.doc.resolve(a.head+t),t));var l,c=n.doc.resolve(s),u=M(c,e,t);return l=u?i.Selection.near(u,1):t<0?i.Selection.near(n.doc.resolve(c.before(-1)),-1):i.Selection.near(n.doc.resolve(c.after(-1)),1),$(n,r,l)}}function z(e,t){return function(n,r,o){var i=n.selection;if(!(i instanceof x)){var a=K(o,e,t);if(null==a)return!1;i=new x(n.doc.resolve(a))}var s=M(i.$headCell,e,t);return!!s&&$(n,r,new x(i.$anchorCell,s))}}function B(e,t){var n=e.selection;if(!(n instanceof x))return!1;if(t){var r=e.tr,o=E(e.schema).cell.createAndFill().content;n.forEachCell((function(e,t){e.content.eq(o)||r.replace(r.mapping.map(t+1),r.mapping.map(t+e.nodeSize-1),new s.Slice(o,0,0))})),r.docChanged&&t(r)}return!0}function J(e,t){var n=y(e.state.doc.resolve(t));return!!n&&(e.dispatch(e.state.tr.setSelection(new x(n))),!0)}function W(e,t,n){if(!g(e.state))return!1;var r=P(n),o=e.state.selection;if(o instanceof x){r||(r={width:1,height:1,rows:[s.Fragment.from(N(E(e.state.schema).cell,n))]});var i=o.$anchorCell.node(-1),a=o.$anchorCell.start(-1),l=h.get(i).rectBetween(o.$anchorCell.pos-a,o.$headCell.pos-a);return r=H(r,l.right-l.left,l.bottom-l.top),I(e.state,e.dispatch,a,l,r),!0}if(r){var c=b(e.state),u=c.start(-1);return I(e.state,e.dispatch,u,h.get(c.node(-1)).findCell(c.pos-u),r),!0}return!1}function q(e,t){if(!t.ctrlKey&&!t.metaKey){var n,r=G(e,t.target);if(t.shiftKey&&e.state.selection instanceof x)o(e.state.selection.$anchorCell,t),t.preventDefault();else if(t.shiftKey&&r&&null!=(n=y(e.state.selection.$anchor))&&Q(e,t).pos!=n.pos)o(n,t),t.preventDefault();else if(!r)return;e.root.addEventListener("mouseup",i),e.root.addEventListener("dragstart",i),e.root.addEventListener("mousemove",a)}function o(t,n){var r=Q(e,n),o=null==m.getState(e.state);if(!r||!O(t,r)){if(!o)return;r=t}var i=new x(t,r);if(o||!e.state.selection.eq(i)){var a=e.state.tr.setSelection(i);o&&a.setMeta(m,t.pos),e.dispatch(a)}}function i(){e.root.removeEventListener("mouseup",i),e.root.removeEventListener("dragstart",i),e.root.removeEventListener("mousemove",a),null!=m.getState(e.state)&&e.dispatch(e.state.tr.setMeta(m,-1))}function a(n){var a,s=m.getState(e.state);if(null!=s)a=e.state.doc.resolve(s);else if(G(e,n.target)!=r&&!(a=Q(e,t)))return i();a&&o(a,n)}}function K(e,t,n){if(!(e.state.selection instanceof i.TextSelection))return null;for(var r=e.state.selection.$head,o=r.depth-1;o>=0;o--){var a=r.node(o);if((n<0?r.index(o):r.indexAfter(o))!=(n<0?0:a.childCount))return null;if("cell"==a.type.spec.tableRole||"header_cell"==a.type.spec.tableRole){var s=r.before(o),l="vert"==t?n>0?"down":"up":n>0?"right":"left";return e.endOfTextblock(l)?s:null}}return null}function G(e,t){for(;t&&t!=e.dom;t=t.parentNode)if("TD"==t.nodeName||"TH"==t.nodeName)return t}function Q(e,t){var n=e.posAtCoords({left:t.clientX,top:t.clientY});return n&&n?y(e.state.doc.resolve(n.pos)):null}function Z(e,t){var n,r=function(t,r){"table"==t.type.spec.tableRole&&(n=function(e,t,n,r){var o=h.get(t);if(!o.problems)return r;r||(r=e.tr);for(var i,a,s=[],l=0;l<o.height;l++)s.push(0);for(var c=0;c<o.problems.length;c++){var u=o.problems[c];if("collision"==u.type){for(var f=t.nodeAt(u.pos),p=0;p<f.attrs.rowspan;p++)s[u.row+p]+=u.n;r.setNodeMarkup(r.mapping.map(n+1+u.pos),null,_(f.attrs,f.attrs.colspan-u.n,u.n))}else if("missing"==u.type)s[u.row]+=u.n;else if("overlong_rowspan"==u.type){var d=t.nodeAt(u.pos);r.setNodeMarkup(r.mapping.map(n+1+u.pos),null,S(d.attrs,"rowspan",d.attrs.rowspan-u.n))}else if("colwidth mismatch"==u.type){var v=t.nodeAt(u.pos);r.setNodeMarkup(r.mapping.map(n+1+u.pos),null,S(v.attrs,"colwidth",u.colwidth))}}for(var m=0;m<s.length;m++)s[m]&&(null==i&&(i=m),a=m);for(var y=0,g=n+1;y<o.height;y++){var b=t.child(y),w=g+b.nodeSize,k=s[y];if(k>0){var O="cell";b.firstChild&&(O=b.firstChild.type.spec.tableRole);for(var M=[],C=0;C<k;C++)M.push(E(e.schema)[O].createAndFill());var x=0!=y&&i!=y-1||a!=y?w-1:g+1;r.insert(r.mapping.map(x),M)}g=w}return r}(e,t,r,n))};return t?t.doc!=e.doc&&function e(t,n,r,o){var i=t.childCount,a=n.childCount;e:for(var s=0,l=0;s<a;s++){for(var c=n.child(s),u=l,f=Math.min(i,s+3);u<f;u++)if(t.child(u)==c){l=u+1,r+=c.nodeSize;continue e}o(c,r),l<i&&t.child(l).sameMarkup(c)?e(t.child(l),c,r+1,o):c.nodesBetween(0,c.content.size,o,r+1),r+=c.nodeSize}}(t.doc,e.doc,0,r):e.doc.descendants(r),n}function U(e){var t,n=e.selection,r=b(e),o=r.node(-1),i=r.start(-1),a=h.get(o);return(t=n instanceof x?a.rectBetween(n.$anchorCell.pos-i,n.$headCell.pos-i):a.findCell(r.pos-i)).tableStart=i,t.map=a,t.table=o,t}function X(e,t,n){var r=t.map,o=t.tableStart,i=t.table,a=n>0?-1:0;(function(e,t,n){for(var r=E(t.type.schema).header_cell,o=0;o<e.height;o++)if(t.nodeAt(e.map[n+o*e.width]).type!=r)return!1;return!0})(r,i,n+a)&&(a=0==n||n==r.width?null:0);for(var s=0;s<r.height;s++){var l=s*r.width+n;if(n>0&&n<r.width&&r.map[l-1]==r.map[l]){var c=r.map[l],u=i.nodeAt(c);e.setNodeMarkup(e.mapping.map(o+c),null,C(u.attrs,n-r.colCount(c))),s+=u.attrs.rowspan-1}else{var f=null==a?E(i.type.schema).cell:i.nodeAt(r.map[l+a]).type,p=r.positionAt(s,n,i);e.insert(e.mapping.map(o+p),f.createAndFill())}}return e}function Y(e,t,n){for(var r=t.map,o=t.table,i=t.tableStart,a=e.mapping.maps.length,s=0;s<r.height;){var l=s*r.width+n,c=r.map[l],u=o.nodeAt(c);if(n>0&&r.map[l-1]==c||n<r.width-1&&r.map[l+1]==c)e.setNodeMarkup(e.mapping.slice(a).map(i+c),null,_(u.attrs,n-r.colCount(c)));else{var f=e.mapping.slice(a).map(i+c);e.delete(f,f+u.nodeSize)}s+=u.attrs.rowspan}}function ee(e,t,n){for(var r=t.map,o=t.tableStart,i=t.table,a=o,s=0;s<n;s++)a+=i.child(s).nodeSize;var l=[],c=n>0?-1:0;(function(e,t,n){for(var r=E(t.type.schema).header_cell,o=0;o<e.width;o++)if(t.nodeAt(e.map[o+n*e.width]).type!=r)return!1;return!0})(r,i,n+c)&&(c=0==n||n==r.height?null:0);for(var u=0,f=r.width*n;u<r.width;u++,f++)if(n>0&&n<r.height&&r.map[f]==r.map[f-r.width]){var p=r.map[f],d=i.nodeAt(p).attrs;e.setNodeMarkup(o+p,null,S(d,"rowspan",d.rowspan+1)),u+=d.colspan-1}else{var h=null==c?E(i.type.schema).cell:i.nodeAt(r.map[f+c*r.width]).type;l.push(h.createAndFill())}return e.insert(a,E(i.type.schema).row.create(null,l)),e}function te(e,t,n){for(var r=t.map,o=t.table,i=t.tableStart,a=0,s=0;s<n;s++)a+=o.child(s).nodeSize;var l=a+o.child(n).nodeSize,c=e.mapping.maps.length;e.delete(a+i,l+i);for(var u=0,f=n*r.width;u<r.width;u++,f++){var p=r.map[f];if(n>0&&p==r.map[f-r.width]){var d=o.nodeAt(p).attrs;e.setNodeMarkup(e.mapping.slice(c).map(p+i),null,S(d,"rowspan",d.rowspan-1)),u+=d.colspan-1}else if(n<r.width&&p==r.map[f+r.width]){var h=o.nodeAt(p),v=h.type.create(S(h.attrs,"rowspan",h.attrs.rowspan-1),h.content),m=r.positionAt(n+1,u,o);e.insert(e.mapping.slice(c).map(i+m),v),u+=h.attrs.colspan-1}}}function ne(e){var t=e.content;return 1==t.childCount&&t.firstChild.isTextblock&&0==t.firstChild.childCount}function re(e,t,n){for(var r=t.map.cellsInRect({left:0,top:0,right:"row"==e?t.map.width:1,bottom:"column"==e?t.map.height:1}),o=0;o<r.length;o++){var i=t.table.nodeAt(r[o]);if(i&&i.type!==n.header_cell)return!1}return!0}function oe(e,t){return(t=t||{useDeprecatedLogic:!1}).useDeprecatedLogic?function(e){return function(t,n){if(!g(t))return!1;if(n){for(var r=E(t.schema),o=U(t),i=t.tr,a=o.map.cellsInRect("column"==e?new d(o.left,0,o.right,o.map.height):"row"==e?new d(0,o.top,o.map.width,o.bottom):o),s=a.map((function(e){return o.table.nodeAt(e)})),l=0;l<a.length;l++)s[l].type==r.header_cell&&i.setNodeMarkup(o.tableStart+a[l],r.cell,s[l].attrs);if(0==i.steps.length)for(var c=0;c<a.length;c++)i.setNodeMarkup(o.tableStart+a[c],r.header_cell,s[c].attrs);n(i)}return!0}}(e):function(t,n){if(!g(t))return!1;if(n){var r=E(t.schema),o=U(t),i=t.tr,a=re("row",o,r),s=re("column",o,r),l=("column"===e?a:"row"===e&&s)?1:0,c="column"==e?new d(0,l,1,o.map.height):"row"==e?new d(l,0,o.map.width,1):o,u="column"==e?s?r.cell:r.header_cell:"row"==e?a?r.cell:r.header_cell:r.cell;o.map.cellsInRect(c).forEach((function(e){var t=e+o.tableStart,n=i.doc.nodeAt(t);n&&i.setNodeMarkup(t,u,n.attrs)})),n(i)}return!0}}var ie=oe("row",{useDeprecatedLogic:!0}),ae=oe("column",{useDeprecatedLogic:!0}),se=oe("cell",{useDeprecatedLogic:!0});var le=function(e,t){this.node=e,this.cellMinWidth=t,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.colgroup=this.table.appendChild(document.createElement("colgroup")),ce(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))};function ce(e,t,n,r,o,i){for(var a=0,s=!0,l=t.firstChild,c=e.firstChild,u=0,f=0;u<c.childCount;u++)for(var p=c.child(u).attrs,d=p.colspan,h=p.colwidth,v=0;v<d;v++,f++){var m=o==f?i:h&&h[v],y=m?m+"px":"";a+=m||r,m||(s=!1),l?(l.style.width!=y&&(l.style.width=y),l=l.nextSibling):t.appendChild(document.createElement("col")).style.width=y}for(;l;){var g=l.nextSibling;l.parentNode.removeChild(l),l=g}s?(n.style.width=a+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=a+"px")}le.prototype.update=function(e){return e.type==this.node.type&&(this.node=e,ce(e,this.colgroup,this.table,this.cellMinWidth),!0)},le.prototype.ignoreMutation=function(e){return"attributes"==e.type&&(e.target==this.table||this.colgroup.contains(e.target))};var ue=new i.PluginKey("tableColumnResizing");var fe=function(e,t){this.activeHandle=e,this.dragging=t};function pe(e,t,n){var r=e.posAtCoords({left:t.clientX,top:t.clientY}).pos,o=y(e.state.doc.resolve(r));if(!o)return-1;if("right"==n)return o.pos;var i=h.get(o.node(-1)),a=o.start(-1),s=i.map.indexOf(o.pos-a);return s%i.width==0?-1:a+i.map[s-1]}function de(e,t,n){var r=t.clientX-e.startX;return Math.max(n,e.startWidth+r)}function he(e,t){e.dispatch(e.state.tr.setMeta(ue,{setHandle:t}))}function ve(e){for(var t=[],n=0;n<e;n++)t.push(0);return t}fe.prototype.apply=function(e){var t=this,n=e.getMeta(ue);if(n&&null!=n.setHandle)return new fe(n.setHandle,null);if(n&&void 0!==n.setDragging)return new fe(t.activeHandle,n.setDragging);if(t.activeHandle>-1&&e.docChanged){var r=e.mapping.map(t.activeHandle,-1);w(e.doc.resolve(r))||(r=null),t=new fe(r,t.dragging)}return t},t.tableEditing=function(e){void 0===e&&(e={});var t=e.allowTableNodeSelection;return void 0===t&&(t=!1),new i.Plugin({key:m,state:{init:function(){return null},apply:function(e,t){var n=e.getMeta(m);if(null!=n)return-1==n?null:n;if(null==t||!e.docChanged)return t;var r=e.mapping.mapResult(t),o=r.deleted,i=r.pos;return o?null:i}},props:{decorations:T,handleDOMEvents:{mousedown:q},createSelectionBetween:function(e){if(null!=m.getState(e.state))return e.state.selection},handleTripleClick:J,handleKeyDown:R,handlePaste:W},appendTransaction:function(e,n,r){return function(e,t,n){var r,o,a=(t||e).selection,s=(t||e).doc;if(a instanceof i.NodeSelection&&(o=a.node.type.spec.tableRole)){if("cell"==o||"header_cell"==o)r=x.create(s,a.from);else if("row"==o){var l=s.resolve(a.from+1);r=x.rowSelection(l,l)}else if(!n){var c=h.get(a.node),u=a.from+1,f=u+c.map[c.width*c.height-1];r=x.create(s,u+1,f)}}else a instanceof i.TextSelection&&function(e){var t=e.$from,n=e.$to;if(t.pos==n.pos||t.pos<t.pos-6)return!1;for(var r=t.pos,o=n.pos,i=t.depth;i>=0&&!(t.after(i+1)<t.end(i));i--,r++);for(var a=n.depth;a>=0&&!(n.before(a+1)>n.start(a));a--,o--);return r==o&&/row|table/.test(t.node(i).type.spec.tableRole)}(a)?r=i.TextSelection.create(s,a.from):a instanceof i.TextSelection&&function(e){for(var t,n,r=e.$from,o=e.$to,i=r.depth;i>0;i--){var a=r.node(i);if("cell"===a.type.spec.tableRole||"header_cell"===a.type.spec.tableRole){t=a;break}}for(var s=o.depth;s>0;s--){var l=o.node(s);if("cell"===l.type.spec.tableRole||"header_cell"===l.type.spec.tableRole){n=l;break}}return t!==n&&0===o.parentOffset}(a)&&(r=i.TextSelection.create(s,a.$from.start(),a.$from.end()));return r&&(t||(t=e.tr)).setSelection(r),t}(r,Z(r,n),t)}})},t.fixTables=Z,t.handlePaste=W,t.cellAround=y,t.isInTable=g,t.selectionCell=b,t.moveCellForward=k,t.inSameTable=O,t.findCell=function(e){return h.get(e.node(-1)).findCell(e.pos-e.start(-1))},t.colCount=function(e){return h.get(e.node(-1)).colCount(e.pos-e.start(-1))},t.nextCell=M,t.tableNodes=function(e){var t=e.cellAttributes||{},n={colspan:{default:1},rowspan:{default:1},colwidth:{default:null}};for(var r in t)n[r]={default:t[r].default};return{table:{content:"table_row+",tableRole:"table",isolating:!0,group:e.tableGroup,parseDOM:[{tag:"table"}],toDOM:function(){return["table",["tbody",0]]}},table_row:{content:"(table_cell | table_header)*",tableRole:"row",parseDOM:[{tag:"tr"}],toDOM:function(){return["tr",0]}},table_cell:{content:e.cellContent,attrs:n,tableRole:"cell",isolating:!0,parseDOM:[{tag:"td",getAttrs:function(e){return V(e,t)}}],toDOM:function(e){return["td",j(e,t),0]}},table_header:{content:e.cellContent,attrs:n,tableRole:"header_cell",isolating:!0,parseDOM:[{tag:"th",getAttrs:function(e){return V(e,t)}}],toDOM:function(e){return["th",j(e,t),0]}}}},t.CellSelection=x,t.TableMap=h,t.columnResizing=function(e){void 0===e&&(e={});var t=e.handleWidth;void 0===t&&(t=5);var n=e.cellMinWidth;void 0===n&&(n=25);var r=e.View;void 0===r&&(r=le);var o=e.lastColumnResizable;return void 0===o&&(o=!0),new i.Plugin({key:ue,state:{init:function(e,t){return this.spec.props.nodeViews[E(t.schema).table.name]=function(e,t){return new r(e,n,t)},new fe(-1,!1)},apply:function(e,t){return t.apply(e)}},props:{attributes:function(e){return ue.getState(e).activeHandle>-1?{class:"resize-cursor"}:null},handleDOMEvents:{mousemove:function(e,n){!function(e,t,n,r,o){var i=ue.getState(e.state);if(!i.dragging){var a=function(e){for(;e&&"TD"!=e.nodeName&&"TH"!=e.nodeName;)e=e.classList.contains("ProseMirror")?null:e.parentNode;return e}(t.target),s=-1;if(a){var l=a.getBoundingClientRect(),c=l.left,u=l.right;t.clientX-c<=n?s=pe(e,t,"left"):u-t.clientX<=n&&(s=pe(e,t,"right"))}if(s!=i.activeHandle){if(!o&&-1!==s){var f=e.state.doc.resolve(s),p=f.node(-1),d=h.get(p),v=f.start(-1);if(d.colCount(f.pos-v)+f.nodeAfter.attrs.colspan-1==d.width-1)return}he(e,s)}}}(e,n,t,0,o)},mouseleave:function(e){!function(e){var t=ue.getState(e.state);t.activeHandle>-1&&!t.dragging&&he(e,-1)}(e)},mousedown:function(e,t){!function(e,t,n){var r=ue.getState(e.state);if(-1==r.activeHandle||r.dragging)return!1;var o=e.state.doc.nodeAt(r.activeHandle),i=function(e,t,n){var r=n.colspan,o=n.colwidth,i=o&&o[o.length-1];if(i)return i;var a=e.domAtPos(t),s=a.node.childNodes[a.offset].offsetWidth,l=r;if(o)for(var c=0;c<r;c++)o[c]&&(s-=o[c],l--);return s/l}(e,r.activeHandle,o.attrs);function a(t){window.removeEventListener("mouseup",a),window.removeEventListener("mousemove",s);var r=ue.getState(e.state);r.dragging&&(!function(e,t,n){for(var r=e.state.doc.resolve(t),o=r.node(-1),i=h.get(o),a=r.start(-1),s=i.colCount(r.pos-a)+r.nodeAfter.attrs.colspan-1,l=e.state.tr,c=0;c<i.height;c++){var u=c*i.width+s;if(!c||i.map[u]!=i.map[u-i.width]){var f=i.map[u],p=o.nodeAt(f).attrs,d=1==p.colspan?0:s-i.colCount(f);if(!p.colwidth||p.colwidth[d]!=n){var v=p.colwidth?p.colwidth.slice():ve(p.colspan);v[d]=n,l.setNodeMarkup(a+f,null,S(p,"colwidth",v))}}}l.docChanged&&e.dispatch(l)}(e,r.activeHandle,de(r.dragging,t,n)),e.dispatch(e.state.tr.setMeta(ue,{setDragging:null})))}function s(t){if(!t.which)return a(t);var r=ue.getState(e.state),o=de(r.dragging,t,n);!function(e,t,n,r){var o=e.state.doc.resolve(t),i=o.node(-1),a=o.start(-1),s=h.get(i).colCount(o.pos-a)+o.nodeAfter.attrs.colspan-1,l=e.domAtPos(o.start(-1)).node;for(;"TABLE"!=l.nodeName;)l=l.parentNode;ce(i,l.firstChild,l,r,s,n)}(e,r.activeHandle,o,n)}e.dispatch(e.state.tr.setMeta(ue,{setDragging:{startX:t.clientX,startWidth:i}})),window.addEventListener("mouseup",a),window.addEventListener("mousemove",s),t.preventDefault()}(e,t,n)}},decorations:function(e){var t=ue.getState(e);if(t.activeHandle>-1)return function(e,t){for(var n=[],r=e.doc.resolve(t),o=r.node(-1),i=h.get(o),s=r.start(-1),l=i.colCount(r.pos-s)+r.nodeAfter.attrs.colspan,c=0;c<i.height;c++){var u=l+c*i.width-1;if(!(l!=i.width&&i.map[u]==i.map[u+1]||0!=c&&i.map[u-1]==i.map[u-1-i.width])){var f=i.map[u],p=s+f+o.nodeAt(f).nodeSize-1,d=document.createElement("div");d.className="column-resize-handle",n.push(a.Decoration.widget(p,d))}}return a.DecorationSet.create(e.doc,n)}(e,t.activeHandle)},nodeViews:{}}})},t.columnResizingPluginKey=ue,t.updateColumnsOnResize=ce,t.__pastedCells=P,t.__insertCells=I,t.__clipCells=H,t.addColumn=X,t.addColumnBefore=function(e,t){if(!g(e))return!1;if(t){var n=U(e);t(X(e.tr,n,n.left))}return!0},t.addColumnAfter=function(e,t){if(!g(e))return!1;if(t){var n=U(e);t(X(e.tr,n,n.right))}return!0},t.removeColumn=Y,t.deleteColumn=function(e,t){if(!g(e))return!1;if(t){var n=U(e),r=e.tr;if(0==n.left&&n.right==n.map.width)return!1;for(var o=n.right-1;Y(r,n,o),o!=n.left;o--)n.table=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc,n.map=h.get(n.table);t(r)}return!0},t.addRow=ee,t.addRowBefore=function(e,t){if(!g(e))return!1;if(t){var n=U(e);t(ee(e.tr,n,n.top))}return!0},t.addRowAfter=function(e,t){if(!g(e))return!1;if(t){var n=U(e);t(ee(e.tr,n,n.bottom))}return!0},t.removeRow=te,t.deleteRow=function(e,t){if(!g(e))return!1;if(t){var n=U(e),r=e.tr;if(0==n.top&&n.bottom==n.map.height)return!1;for(var o=n.bottom-1;te(r,n,o),o!=n.top;o--)n.table=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc,n.map=h.get(n.table);t(r)}return!0},t.mergeCells=function(e,t){var n=e.selection;if(!(n instanceof x)||n.$anchorCell.pos==n.$headCell.pos)return!1;var r=U(e),o=r.map;if(function(e,t){for(var n=e.width,r=e.height,o=e.map,i=t.top*n+t.left,a=i,s=(t.bottom-1)*n+t.left,l=i+(t.right-t.left-1),c=t.top;c<t.bottom;c++){if(t.left>0&&o[a]==o[a-1]||t.right<n&&o[l]==o[l+1])return!0;a+=n,l+=n}for(var u=t.left;u<t.right;u++){if(t.top>0&&o[i]==o[i-n]||t.bottom<r&&o[s]==o[s+n])return!0;i++,s++}return!1}(o,r))return!1;if(t){for(var i,a,l=e.tr,c={},u=s.Fragment.empty,f=r.top;f<r.bottom;f++)for(var p=r.left;p<r.right;p++){var d=o.map[f*o.width+p],h=r.table.nodeAt(d);if(!c[d])if(c[d]=!0,null==i)i=d,a=h;else{ne(h)||(u=u.append(h.content));var v=l.mapping.map(d+r.tableStart);l.delete(v,v+h.nodeSize)}}if(l.setNodeMarkup(i+r.tableStart,null,S(C(a.attrs,a.attrs.colspan,r.right-r.left-a.attrs.colspan),"rowspan",r.bottom-r.top)),u.size){var m=i+1+a.content.size,y=ne(a)?i+1:m;l.replaceWith(y+r.tableStart,m+r.tableStart,u)}l.setSelection(new x(l.doc.resolve(i+r.tableStart))),t(l)}return!0},t.splitCell=function(e,t){var n,r,o=e.selection;if(o instanceof x){if(o.$anchorCell.pos!=o.$headCell.pos)return!1;n=o.$anchorCell.nodeAfter,r=o.$anchorCell.pos}else{if(!(n=function(e){for(var t=e.depth-1;t>0;t--){var n=e.node(t).type.spec.tableRole;if("cell"===n||"header_cell"===n)return e.node(t)}return null}(o.$from)))return!1;r=y(o.$from).pos}if(1==n.attrs.colspan&&1==n.attrs.rowspan)return!1;if(t){var i=n.attrs,a=[],s=i.colwidth;i.rowspan>1&&(i=S(i,"rowspan",1)),i.colspan>1&&(i=S(i,"colspan",1));for(var l=U(e),c=e.tr,u=0;u<l.right-l.left;u++)a.push(s?S(i,"colwidth",s&&s[u]?[s[u]]:null):i);for(var f,p=E(e.schema)[n.type.spec.tableRole],d=0;d<l.bottom;d++)if(d>=l.top){var h=l.map.positionAt(d,l.left,l.table);d==l.top&&(h+=n.nodeSize);for(var v=l.left,m=0;v<l.right;v++,m++)v==l.left&&d==l.top||c.insert(f=c.mapping.map(h+l.tableStart,1),p.createAndFill(a[m]))}c.setNodeMarkup(r,null,a[0]),o instanceof x&&c.setSelection(new x(c.doc.resolve(o.$anchorCell.pos),f&&c.doc.resolve(f))),t(c)}return!0},t.setCellAttr=function(e,t){return function(n,r){if(!g(n))return!1;var o=b(n);if(o.nodeAfter.attrs[e]===t)return!1;if(r){var i=n.tr;n.selection instanceof x?n.selection.forEachCell((function(n,r){n.attrs[e]!==t&&i.setNodeMarkup(r,null,S(n.attrs,e,t))})):i.setNodeMarkup(o.pos,null,S(o.nodeAfter.attrs,e,t)),r(i)}return!0}},t.toggleHeader=oe,t.toggleHeaderRow=ie,t.toggleHeaderColumn=ae,t.toggleHeaderCell=se,t.goToNextCell=function(e){return function(t,n){if(!g(t))return!1;var r=function(e,t){if(t<0){var n=e.nodeBefore;if(n)return e.pos-n.nodeSize;for(var r=e.index(-1)-1,o=e.before();r>=0;r--){var i=e.node(-1).child(r);if(i.childCount)return o-1-i.lastChild.nodeSize;o-=i.nodeSize}}else{if(e.index()<e.parent.childCount-1)return e.pos+e.nodeAfter.nodeSize;for(var a=e.node(-1),s=e.indexAfter(-1),l=e.after();s<a.childCount;s++){var c=a.child(s);if(c.childCount)return l+1;l+=c.nodeSize}}}(b(t),e);if(null!=r){if(n){var o=t.doc.resolve(r);n(t.tr.setSelection(i.TextSelection.between(o,k(o))).scrollIntoView())}return!0}}},t.deleteTable=function(e,t){for(var n=e.selection.$anchor,r=n.depth;r>0;r--){if("table"==n.node(r).type.spec.tableRole)return t&&t(e.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0}return!1}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(5),o=n(6),i=Object.create(null),a=function(e,t,n){this.ranges=n||[new l(e.min(t),e.max(t))],this.$anchor=e,this.$head=t},s={anchor:{},head:{},from:{},to:{},$from:{},$to:{},empty:{}};s.anchor.get=function(){return this.$anchor.pos},s.head.get=function(){return this.$head.pos},s.from.get=function(){return this.$from.pos},s.to.get=function(){return this.$to.pos},s.$from.get=function(){return this.ranges[0].$from},s.$to.get=function(){return this.ranges[0].$to},s.empty.get=function(){for(var e=this.ranges,t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0},a.prototype.content=function(){return this.$from.node(0).slice(this.from,this.to,!0)},a.prototype.replace=function(e,t){void 0===t&&(t=r.Slice.empty);for(var n=t.content.lastChild,o=null,i=0;i<t.openEnd;i++)o=n,n=n.lastChild;for(var a=e.steps.length,s=this.ranges,l=0;l<s.length;l++){var c=s[l],u=c.$from,f=c.$to,p=e.mapping.slice(a);e.replaceRange(p.map(u.pos),p.map(f.pos),l?r.Slice.empty:t),0==l&&m(e,a,(n?n.isInline:o&&o.isTextblock)?-1:1)}},a.prototype.replaceWith=function(e,t){for(var n=e.steps.length,r=this.ranges,o=0;o<r.length;o++){var i=r[o],a=i.$from,s=i.$to,l=e.mapping.slice(n),c=l.map(a.pos),u=l.map(s.pos);o?e.deleteRange(c,u):(e.replaceRangeWith(c,u,t),m(e,n,t.isInline?-1:1))}},a.findFrom=function(e,t,n){var r=e.parent.inlineContent?new c(e):v(e.node(0),e.parent,e.pos,e.index(),t,n);if(r)return r;for(var o=e.depth-1;o>=0;o--){var i=t<0?v(e.node(0),e.node(o),e.before(o+1),e.index(o),t,n):v(e.node(0),e.node(o),e.after(o+1),e.index(o)+1,t,n);if(i)return i}},a.near=function(e,t){return void 0===t&&(t=1),this.findFrom(e,t)||this.findFrom(e,-t)||new d(e.node(0))},a.atStart=function(e){return v(e,e,0,0,1)||new d(e)},a.atEnd=function(e){return v(e,e,e.content.size,e.childCount,-1)||new d(e)},a.fromJSON=function(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");var n=i[t.type];if(!n)throw new RangeError("No selection type "+t.type+" defined");return n.fromJSON(e,t)},a.jsonID=function(e,t){if(e in i)throw new RangeError("Duplicate use of selection JSON ID "+e);return i[e]=t,t.prototype.jsonID=e,t},a.prototype.getBookmark=function(){return c.between(this.$anchor,this.$head).getBookmark()},Object.defineProperties(a.prototype,s),a.prototype.visible=!0;var l=function(e,t){this.$from=e,this.$to=t},c=function(e){function t(t,n){void 0===n&&(n=t),e.call(this,t,n)}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={$cursor:{}};return n.$cursor.get=function(){return this.$anchor.pos==this.$head.pos?this.$head:null},t.prototype.map=function(n,r){var o=n.resolve(r.map(this.head));if(!o.parent.inlineContent)return e.near(o);var i=n.resolve(r.map(this.anchor));return new t(i.parent.inlineContent?i:o,o)},t.prototype.replace=function(t,n){if(void 0===n&&(n=r.Slice.empty),e.prototype.replace.call(this,t,n),n==r.Slice.empty){var o=this.$from.marksAcross(this.$to);o&&t.ensureMarks(o)}},t.prototype.eq=function(e){return e instanceof t&&e.anchor==this.anchor&&e.head==this.head},t.prototype.getBookmark=function(){return new u(this.anchor,this.head)},t.prototype.toJSON=function(){return{type:"text",anchor:this.anchor,head:this.head}},t.fromJSON=function(e,n){if("number"!=typeof n.anchor||"number"!=typeof n.head)throw new RangeError("Invalid input for TextSelection.fromJSON");return new t(e.resolve(n.anchor),e.resolve(n.head))},t.create=function(e,t,n){void 0===n&&(n=t);var r=e.resolve(t);return new this(r,n==t?r:e.resolve(n))},t.between=function(n,r,o){var i=n.pos-r.pos;if(o&&!i||(o=i>=0?1:-1),!r.parent.inlineContent){var a=e.findFrom(r,o,!0)||e.findFrom(r,-o,!0);if(!a)return e.near(r,o);r=a.$head}return n.parent.inlineContent||(0==i||(n=(e.findFrom(n,-o,!0)||e.findFrom(n,o,!0)).$anchor).pos<r.pos!=i<0)&&(n=r),new t(n,r)},Object.defineProperties(t.prototype,n),t}(a);a.jsonID("text",c);var u=function(e,t){this.anchor=e,this.head=t};u.prototype.map=function(e){return new u(e.map(this.anchor),e.map(this.head))},u.prototype.resolve=function(e){return c.between(e.resolve(this.anchor),e.resolve(this.head))};var f=function(e){function t(t){var n=t.nodeAfter,r=t.node(0).resolve(t.pos+n.nodeSize);e.call(this,t,r),this.node=n}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.map=function(n,r){var o=r.mapResult(this.anchor),i=o.deleted,a=o.pos,s=n.resolve(a);return i?e.near(s):new t(s)},t.prototype.content=function(){return new r.Slice(r.Fragment.from(this.node),0,0)},t.prototype.eq=function(e){return e instanceof t&&e.anchor==this.anchor},t.prototype.toJSON=function(){return{type:"node",anchor:this.anchor}},t.prototype.getBookmark=function(){return new p(this.anchor)},t.fromJSON=function(e,n){if("number"!=typeof n.anchor)throw new RangeError("Invalid input for NodeSelection.fromJSON");return new t(e.resolve(n.anchor))},t.create=function(e,t){return new this(e.resolve(t))},t.isSelectable=function(e){return!e.isText&&!1!==e.type.spec.selectable},t}(a);f.prototype.visible=!1,a.jsonID("node",f);var p=function(e){this.anchor=e};p.prototype.map=function(e){var t=e.mapResult(this.anchor),n=t.deleted,r=t.pos;return n?new u(r,r):new p(r)},p.prototype.resolve=function(e){var t=e.resolve(this.anchor),n=t.nodeAfter;return n&&f.isSelectable(n)?new f(t):a.near(t)};var d=function(e){function t(t){e.call(this,t.resolve(0),t.resolve(t.content.size))}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.toJSON=function(){return{type:"all"}},t.fromJSON=function(e){return new t(e)},t.prototype.map=function(e){return new t(e)},t.prototype.eq=function(e){return e instanceof t},t.prototype.getBookmark=function(){return h},t}(a);a.jsonID("all",d);var h={map:function(){return this},resolve:function(e){return new d(e)}};function v(e,t,n,r,o,i){if(t.inlineContent)return c.create(e,n);for(var a=r-(o>0?0:1);o>0?a<t.childCount:a>=0;a+=o){var s=t.child(a);if(s.isAtom){if(!i&&f.isSelectable(s))return f.create(e,n-(o<0?s.nodeSize:0))}else{var l=v(e,s,n+o,o<0?s.childCount:0,o,i);if(l)return l}n+=s.nodeSize*o}}function m(e,t,n){var r=e.steps.length-1;if(!(r<t)){var i,s=e.steps[r];if(s instanceof o.ReplaceStep||s instanceof o.ReplaceAroundStep)e.mapping.maps[r].forEach((function(e,t,n,r){null==i&&(i=r)})),e.setSelection(a.near(e.doc.resolve(i),n))}}var y=function(e){function t(t){e.call(this,t.doc),this.time=Date.now(),this.curSelection=t.selection,this.curSelectionFor=0,this.storedMarks=t.storedMarks,this.updated=0,this.meta=Object.create(null)}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={selection:{},selectionSet:{},storedMarksSet:{},isGeneric:{},scrolledIntoView:{}};return n.selection.get=function(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection},t.prototype.setSelection=function(e){return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=-3&(1|this.updated),this.storedMarks=null,this},n.selectionSet.get=function(){return(1&this.updated)>0},t.prototype.setStoredMarks=function(e){return this.storedMarks=e,this.updated|=2,this},t.prototype.ensureMarks=function(e){return r.Mark.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this},t.prototype.addStoredMark=function(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))},t.prototype.removeStoredMark=function(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))},n.storedMarksSet.get=function(){return(2&this.updated)>0},t.prototype.addStep=function(t,n){e.prototype.addStep.call(this,t,n),this.updated=-3&this.updated,this.storedMarks=null},t.prototype.setTime=function(e){return this.time=e,this},t.prototype.replaceSelection=function(e){return this.selection.replace(this,e),this},t.prototype.replaceSelectionWith=function(e,t){var n=this.selection;return!1!==t&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||r.Mark.none))),n.replaceWith(this,e),this},t.prototype.deleteSelection=function(){return this.selection.replace(this),this},t.prototype.insertText=function(e,t,n){void 0===n&&(n=t);var r=this.doc.type.schema;if(null==t)return e?this.replaceSelectionWith(r.text(e),!0):this.deleteSelection();if(!e)return this.deleteRange(t,n);var o=this.storedMarks;if(!o){var i=this.doc.resolve(t);o=n==t?i.marks():i.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,r.text(e,o)),this.selection.empty||this.setSelection(a.near(this.selection.$to)),this},t.prototype.setMeta=function(e,t){return this.meta["string"==typeof e?e:e.key]=t,this},t.prototype.getMeta=function(e){return this.meta["string"==typeof e?e:e.key]},n.isGeneric.get=function(){for(var e in this.meta)return!1;return!0},t.prototype.scrollIntoView=function(){return this.updated|=4,this},n.scrolledIntoView.get=function(){return(4&this.updated)>0},Object.defineProperties(t.prototype,n),t}(o.Transform);function g(e,t){return t&&e?e.bind(t):e}var b=function(e,t,n){this.name=e,this.init=g(t.init,n),this.apply=g(t.apply,n)},w=[new b("doc",{init:function(e){return e.doc||e.schema.topNodeType.createAndFill()},apply:function(e){return e.doc}}),new b("selection",{init:function(e,t){return e.selection||a.atStart(t.doc)},apply:function(e){return e.selection}}),new b("storedMarks",{init:function(e){return e.storedMarks||null},apply:function(e,t,n,r){return r.selection.$cursor?e.storedMarks:null}}),new b("scrollToSelection",{init:function(){return 0},apply:function(e,t){return e.scrolledIntoView?t+1:t}})],k=function(e,t){var n=this;this.schema=e,this.fields=w.concat(),this.plugins=[],this.pluginsByKey=Object.create(null),t&&t.forEach((function(e){if(n.pluginsByKey[e.key])throw new RangeError("Adding different instances of a keyed plugin ("+e.key+")");n.plugins.push(e),n.pluginsByKey[e.key]=e,e.spec.state&&n.fields.push(new b(e.key,e.spec.state,e))}))},O=function(e){this.config=e},M={schema:{},plugins:{},tr:{}};M.schema.get=function(){return this.config.schema},M.plugins.get=function(){return this.config.plugins},O.prototype.apply=function(e){return this.applyTransaction(e).state},O.prototype.filterTransaction=function(e,t){void 0===t&&(t=-1);for(var n=0;n<this.config.plugins.length;n++)if(n!=t){var r=this.config.plugins[n];if(r.spec.filterTransaction&&!r.spec.filterTransaction.call(r,e,this))return!1}return!0},O.prototype.applyTransaction=function(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};for(var t=[e],n=this.applyInner(e),r=null;;){for(var o=!1,i=0;i<this.config.plugins.length;i++){var a=this.config.plugins[i];if(a.spec.appendTransaction){var s=r?r[i].n:0,l=r?r[i].state:this,c=s<t.length&&a.spec.appendTransaction.call(a,s?t.slice(s):t,l,n);if(c&&n.filterTransaction(c,i)){if(c.setMeta("appendedTransaction",e),!r){r=[];for(var u=0;u<this.config.plugins.length;u++)r.push(u<i?{state:n,n:t.length}:{state:this,n:0})}t.push(c),n=n.applyInner(c),o=!0}r&&(r[i]={state:n,n:t.length})}}if(!o)return{state:n,transactions:t}}},O.prototype.applyInner=function(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");for(var t=new O(this.config),n=this.config.fields,r=0;r<n.length;r++){var o=n[r];t[o.name]=o.apply(e,this[o.name],this,t)}for(var i=0;i<S.length;i++)S[i](this,e,t);return t},M.tr.get=function(){return new y(this)},O.create=function(e){for(var t=new k(e.schema||e.doc.type.schema,e.plugins),n=new O(t),r=0;r<t.fields.length;r++)n[t.fields[r].name]=t.fields[r].init(e,n);return n},O.prototype.reconfigure=function(e){for(var t=new k(e.schema||this.schema,e.plugins),n=t.fields,r=new O(t),o=0;o<n.length;o++){var i=n[o].name;r[i]=this.hasOwnProperty(i)?this[i]:n[o].init(e,r)}return r},O.prototype.toJSON=function(e){var t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map((function(e){return e.toJSON()}))),e&&"object"==typeof e)for(var n in e){if("doc"==n||"selection"==n)throw new RangeError("The JSON fields `doc` and `selection` are reserved");var r=e[n],o=r.spec.state;o&&o.toJSON&&(t[n]=o.toJSON.call(r,this[r.key]))}return t},O.fromJSON=function(e,t,n){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");var o=new k(e.schema,e.plugins),i=new O(o);return o.fields.forEach((function(o){if("doc"==o.name)i.doc=r.Node.fromJSON(e.schema,t.doc);else if("selection"==o.name)i.selection=a.fromJSON(i.doc,t.selection);else if("storedMarks"==o.name)t.storedMarks&&(i.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(n)for(var s in n){var l=n[s],c=l.spec.state;if(l.key==o.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,s))return void(i[o.name]=c.fromJSON.call(l,e,t[s],i))}i[o.name]=o.init(e,i)}})),i},O.addApplyListener=function(e){S.push(e)},O.removeApplyListener=function(e){var t=S.indexOf(e);t>-1&&S.splice(t,1)},Object.defineProperties(O.prototype,M);var S=[];var _=function(e){this.props={},e.props&&function e(t,n,r){for(var o in t){var i=t[o];i instanceof Function?i=i.bind(n):"handleDOMEvents"==o&&(i=e(i,n,{})),r[o]=i}return r}(e.props,this,this.props),this.spec=e,this.key=e.key?e.key.key:x("plugin")};_.prototype.getState=function(e){return e[this.key]};var C=Object.create(null);function x(e){return e in C?e+"$"+ ++C[e]:(C[e]=0,e+"$")}var A=function(e){void 0===e&&(e="key"),this.key=x(e)};A.prototype.get=function(e){return e.config.pluginsByKey[this.key]},A.prototype.getState=function(e){return e[this.key]},t.Selection=a,t.SelectionRange=l,t.TextSelection=c,t.NodeSelection=f,t.AllSelection=d,t.Transaction=y,t.EditorState=O,t.Plugin=_,t.PluginKey=A},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r,o=(r=n(28))&&"object"==typeof r&&"default"in r?r.default:r;var i=function(e,t){if(this.content=e,this.size=t||0,null==t)for(var n=0;n<e.length;n++)this.size+=e[n].nodeSize},a={firstChild:{},lastChild:{},childCount:{}};i.prototype.nodesBetween=function(e,t,n,r,o){void 0===r&&(r=0);for(var i=0,a=0;a<t;i++){var s=this.content[i],l=a+s.nodeSize;if(l>e&&!1!==n(s,r+a,o,i)&&s.content.size){var c=a+1;s.nodesBetween(Math.max(0,e-c),Math.min(s.content.size,t-c),n,r+c)}a=l}},i.prototype.descendants=function(e){this.nodesBetween(0,this.size,e)},i.prototype.textBetween=function(e,t,n,r){var o="",i=!0;return this.nodesBetween(e,t,(function(a,s){a.isText?(o+=a.text.slice(Math.max(e,s)-s,t-s),i=!n):a.isLeaf&&r?(o+=r,i=!n):!i&&a.isBlock&&(o+=n,i=!0)}),0),o},i.prototype.append=function(e){if(!e.size)return this;if(!this.size)return e;var t=this.lastChild,n=e.firstChild,r=this.content.slice(),o=0;for(t.isText&&t.sameMarkup(n)&&(r[r.length-1]=t.withText(t.text+n.text),o=1);o<e.content.length;o++)r.push(e.content[o]);return new i(r,this.size+e.size)},i.prototype.cut=function(e,t){if(null==t&&(t=this.size),0==e&&t==this.size)return this;var n=[],r=0;if(t>e)for(var o=0,a=0;a<t;o++){var s=this.content[o],l=a+s.nodeSize;l>e&&((a<e||l>t)&&(s=s.isText?s.cut(Math.max(0,e-a),Math.min(s.text.length,t-a)):s.cut(Math.max(0,e-a-1),Math.min(s.content.size,t-a-1))),n.push(s),r+=s.nodeSize),a=l}return new i(n,r)},i.prototype.cutByIndex=function(e,t){return e==t?i.empty:0==e&&t==this.content.length?this:new i(this.content.slice(e,t))},i.prototype.replaceChild=function(e,t){var n=this.content[e];if(n==t)return this;var r=this.content.slice(),o=this.size+t.nodeSize-n.nodeSize;return r[e]=t,new i(r,o)},i.prototype.addToStart=function(e){return new i([e].concat(this.content),this.size+e.nodeSize)},i.prototype.addToEnd=function(e){return new i(this.content.concat(e),this.size+e.nodeSize)},i.prototype.eq=function(e){if(this.content.length!=e.content.length)return!1;for(var t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0},a.firstChild.get=function(){return this.content.length?this.content[0]:null},a.lastChild.get=function(){return this.content.length?this.content[this.content.length-1]:null},a.childCount.get=function(){return this.content.length},i.prototype.child=function(e){var t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t},i.prototype.maybeChild=function(e){return this.content[e]},i.prototype.forEach=function(e){for(var t=0,n=0;t<this.content.length;t++){var r=this.content[t];e(r,n,t),n+=r.nodeSize}},i.prototype.findDiffStart=function(e,t){return void 0===t&&(t=0),function e(t,n,r){for(var o=0;;o++){if(o==t.childCount||o==n.childCount)return t.childCount==n.childCount?null:r;var i=t.child(o),a=n.child(o);if(i!=a){if(!i.sameMarkup(a))return r;if(i.isText&&i.text!=a.text){for(var s=0;i.text[s]==a.text[s];s++)r++;return r}if(i.content.size||a.content.size){var l=e(i.content,a.content,r+1);if(null!=l)return l}r+=i.nodeSize}else r+=i.nodeSize}}(this,e,t)},i.prototype.findDiffEnd=function(e,t,n){return void 0===t&&(t=this.size),void 0===n&&(n=e.size),function e(t,n,r,o){for(var i=t.childCount,a=n.childCount;;){if(0==i||0==a)return i==a?null:{a:r,b:o};var s=t.child(--i),l=n.child(--a),c=s.nodeSize;if(s!=l){if(!s.sameMarkup(l))return{a:r,b:o};if(s.isText&&s.text!=l.text){for(var u=0,f=Math.min(s.text.length,l.text.length);u<f&&s.text[s.text.length-u-1]==l.text[l.text.length-u-1];)u++,r--,o--;return{a:r,b:o}}if(s.content.size||l.content.size){var p=e(s.content,l.content,r-1,o-1);if(p)return p}r-=c,o-=c}else r-=c,o-=c}}(this,e,t,n)},i.prototype.findIndex=function(e,t){if(void 0===t&&(t=-1),0==e)return l(0,e);if(e==this.size)return l(this.content.length,e);if(e>this.size||e<0)throw new RangeError("Position "+e+" outside of fragment ("+this+")");for(var n=0,r=0;;n++){var o=r+this.child(n).nodeSize;if(o>=e)return o==e||t>0?l(n+1,o):l(n,r);r=o}},i.prototype.toString=function(){return"<"+this.toStringInner()+">"},i.prototype.toStringInner=function(){return this.content.join(", ")},i.prototype.toJSON=function(){return this.content.length?this.content.map((function(e){return e.toJSON()})):null},i.fromJSON=function(e,t){if(!t)return i.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new i(t.map(e.nodeFromJSON))},i.fromArray=function(e){if(!e.length)return i.empty;for(var t,n=0,r=0;r<e.length;r++){var o=e[r];n+=o.nodeSize,r&&o.isText&&e[r-1].sameMarkup(o)?(t||(t=e.slice(0,r)),t[t.length-1]=o.withText(t[t.length-1].text+o.text)):t&&t.push(o)}return new i(t||e,n)},i.from=function(e){if(!e)return i.empty;if(e instanceof i)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new i([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))},Object.defineProperties(i.prototype,a);var s={index:0,offset:0};function l(e,t){return s.index=e,s.offset=t,s}function c(e,t){if(e===t)return!0;if(!e||"object"!=typeof e||!t||"object"!=typeof t)return!1;var n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(var r=0;r<e.length;r++)if(!c(e[r],t[r]))return!1}else{for(var o in e)if(!(o in t)||!c(e[o],t[o]))return!1;for(var i in t)if(!(i in e))return!1}return!0}i.empty=new i([],0);var u=function(e,t){this.type=e,this.attrs=t};function f(e){var t=Error.call(this,e);return t.__proto__=f.prototype,t}u.prototype.addToSet=function(e){for(var t,n=!1,r=0;r<e.length;r++){var o=e[r];if(this.eq(o))return e;if(this.type.excludes(o.type))t||(t=e.slice(0,r));else{if(o.type.excludes(this.type))return e;!n&&o.type.rank>this.type.rank&&(t||(t=e.slice(0,r)),t.push(this),n=!0),t&&t.push(o)}}return t||(t=e.slice()),n||t.push(this),t},u.prototype.removeFromSet=function(e){for(var t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e},u.prototype.isInSet=function(e){for(var t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1},u.prototype.eq=function(e){return this==e||this.type==e.type&&c(this.attrs,e.attrs)},u.prototype.toJSON=function(){var e={type:this.type.name};for(var t in this.attrs){e.attrs=this.attrs;break}return e},u.fromJSON=function(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");var n=e.marks[t.type];if(!n)throw new RangeError("There is no mark type "+t.type+" in this schema");return n.create(t.attrs)},u.sameSet=function(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(var n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0},u.setFrom=function(e){if(!e||0==e.length)return u.none;if(e instanceof u)return[e];var t=e.slice();return t.sort((function(e,t){return e.type.rank-t.type.rank})),t},u.none=[],f.prototype=Object.create(Error.prototype),f.prototype.constructor=f,f.prototype.name="ReplaceError";var p=function(e,t,n){this.content=e,this.openStart=t,this.openEnd=n},d={size:{}};function h(e,t,n){if(n.openStart>e.depth)throw new f("Inserted content deeper than insertion position");if(e.depth-n.openStart!=t.depth-n.openEnd)throw new f("Inconsistent open depths");return function e(t,n,r,o){var a=t.index(o),s=t.node(o);if(a==n.index(o)&&o<t.depth-r.openStart){var l=e(t,n,r,o+1);return s.copy(s.content.replaceChild(a,l))}if(r.content.size){if(r.openStart||r.openEnd||t.depth!=o||n.depth!=o){var c=function(e,t){for(var n=t.depth-e.openStart,r=t.node(n).copy(e.content),o=n-1;o>=0;o--)r=t.node(o).copy(i.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}(r,t),u=c.start,f=c.end;return b(s,function e(t,n,r,o,a){var s=t.depth>a&&m(t,n,a+1),l=o.depth>a&&m(r,o,a+1),c=[];g(null,t,a,c),s&&l&&n.index(a)==r.index(a)?(v(s,l),y(b(s,e(t,n,r,o,a+1)),c)):(s&&y(b(s,w(t,n,a+1)),c),g(n,r,a,c),l&&y(b(l,w(r,o,a+1)),c));return g(o,null,a,c),new i(c)}(t,u,f,n,o))}var p=t.parent,d=p.content;return b(p,d.cut(0,t.parentOffset).append(r.content).append(d.cut(n.parentOffset)))}return b(s,w(t,n,o))}(e,t,n,0)}function v(e,t){if(!t.type.compatibleContent(e.type))throw new f("Cannot join "+t.type.name+" onto "+e.type.name)}function m(e,t,n){var r=e.node(n);return v(r,t.node(n)),r}function y(e,t){var n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function g(e,t,n,r){var o=(t||e).node(n),i=0,a=t?t.index(n):o.childCount;e&&(i=e.index(n),e.depth>n?i++:e.textOffset&&(y(e.nodeAfter,r),i++));for(var s=i;s<a;s++)y(o.child(s),r);t&&t.depth==n&&t.textOffset&&y(t.nodeBefore,r)}function b(e,t){if(!e.type.validContent(t))throw new f("Invalid content for node "+e.type.name);return e.copy(t)}function w(e,t,n){var r=[];(g(null,e,n,r),e.depth>n)&&y(b(m(e,t,n+1),w(e,t,n+1)),r);return g(t,null,n,r),new i(r)}d.size.get=function(){return this.content.size-this.openStart-this.openEnd},p.prototype.insertAt=function(e,t){var n=function e(t,n,r,o){var i=t.findIndex(n),a=i.index,s=i.offset,l=t.maybeChild(a);if(s==n||l.isText)return o&&!o.canReplace(a,a,r)?null:t.cut(0,n).append(r).append(t.cut(n));var c=e(l.content,n-s-1,r);return c&&t.replaceChild(a,l.copy(c))}(this.content,e+this.openStart,t,null);return n&&new p(n,this.openStart,this.openEnd)},p.prototype.removeBetween=function(e,t){return new p(function e(t,n,r){var o=t.findIndex(n),i=o.index,a=o.offset,s=t.maybeChild(i),l=t.findIndex(r),c=l.index,u=l.offset;if(a==n||s.isText){if(u!=r&&!t.child(c).isText)throw new RangeError("Removing non-flat range");return t.cut(0,n).append(t.cut(r))}if(i!=c)throw new RangeError("Removing non-flat range");return t.replaceChild(i,s.copy(e(s.content,n-a-1,r-a-1)))}(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)},p.prototype.eq=function(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd},p.prototype.toString=function(){return this.content+"("+this.openStart+","+this.openEnd+")"},p.prototype.toJSON=function(){if(!this.content.size)return null;var e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e},p.fromJSON=function(e,t){if(!t)return p.empty;var n=t.openStart||0,r=t.openEnd||0;if("number"!=typeof n||"number"!=typeof r)throw new RangeError("Invalid input for Slice.fromJSON");return new p(i.fromJSON(e,t.content),t.openStart||0,t.openEnd||0)},p.maxOpen=function(e,t){void 0===t&&(t=!0);for(var n=0,r=0,o=e.firstChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.firstChild)n++;for(var i=e.lastChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.lastChild)r++;return new p(e,n,r)},Object.defineProperties(p.prototype,d),p.empty=new p(i.empty,0,0);var k=function(e,t,n){this.pos=e,this.path=t,this.depth=t.length/3-1,this.parentOffset=n},O={parent:{},doc:{},textOffset:{},nodeAfter:{},nodeBefore:{}};k.prototype.resolveDepth=function(e){return null==e?this.depth:e<0?this.depth+e:e},O.parent.get=function(){return this.node(this.depth)},O.doc.get=function(){return this.node(0)},k.prototype.node=function(e){return this.path[3*this.resolveDepth(e)]},k.prototype.index=function(e){return this.path[3*this.resolveDepth(e)+1]},k.prototype.indexAfter=function(e){return e=this.resolveDepth(e),this.index(e)+(e!=this.depth||this.textOffset?1:0)},k.prototype.start=function(e){return 0==(e=this.resolveDepth(e))?0:this.path[3*e-1]+1},k.prototype.end=function(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size},k.prototype.before=function(e){if(!(e=this.resolveDepth(e)))throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]},k.prototype.after=function(e){if(!(e=this.resolveDepth(e)))throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]+this.path[3*e].nodeSize},O.textOffset.get=function(){return this.pos-this.path[this.path.length-1]},O.nodeAfter.get=function(){var e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;var n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r},O.nodeBefore.get=function(){var e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):0==e?null:this.parent.child(e-1)},k.prototype.marks=function(){var e=this.parent,t=this.index();if(0==e.content.size)return u.none;if(this.textOffset)return e.child(t).marks;var n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){var o=n;n=r,r=o}for(var i=n.marks,a=0;a<i.length;a++)!1!==i[a].type.spec.inclusive||r&&i[a].isInSet(r.marks)||(i=i[a--].removeFromSet(i));return i},k.prototype.marksAcross=function(e){var t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;for(var n=t.marks,r=e.parent.maybeChild(e.index()),o=0;o<n.length;o++)!1!==n[o].type.spec.inclusive||r&&n[o].isInSet(r.marks)||(n=n[o--].removeFromSet(n));return n},k.prototype.sharedDepth=function(e){for(var t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0},k.prototype.blockRange=function(e,t){if(void 0===e&&(e=this),e.pos<this.pos)return e.blockRange(this);for(var n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new C(this,e,n)},k.prototype.sameParent=function(e){return this.pos-this.parentOffset==e.pos-e.parentOffset},k.prototype.max=function(e){return e.pos>this.pos?e:this},k.prototype.min=function(e){return e.pos<this.pos?e:this},k.prototype.toString=function(){for(var e="",t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset},k.resolve=function(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");for(var n=[],r=0,o=t,i=e;;){var a=i.content.findIndex(o),s=a.index,l=a.offset,c=o-l;if(n.push(i,s,r+l),!c)break;if((i=i.child(s)).isText)break;o=c-1,r+=l+1}return new k(t,n,o)},k.resolveCached=function(e,t){for(var n=0;n<M.length;n++){var r=M[n];if(r.pos==t&&r.doc==e)return r}var o=M[S]=k.resolve(e,t);return S=(S+1)%_,o},Object.defineProperties(k.prototype,O);var M=[],S=0,_=12,C=function(e,t,n){this.$from=e,this.$to=t,this.depth=n},x={start:{},end:{},parent:{},startIndex:{},endIndex:{}};x.start.get=function(){return this.$from.before(this.depth+1)},x.end.get=function(){return this.$to.after(this.depth+1)},x.parent.get=function(){return this.$from.node(this.depth)},x.startIndex.get=function(){return this.$from.index(this.depth)},x.endIndex.get=function(){return this.$to.indexAfter(this.depth)},Object.defineProperties(C.prototype,x);var A=Object.create(null),T=function(e,t,n,r){this.type=e,this.attrs=t,this.content=n||i.empty,this.marks=r||u.none},V={nodeSize:{},childCount:{},textContent:{},firstChild:{},lastChild:{},isBlock:{},isTextblock:{},inlineContent:{},isInline:{},isText:{},isLeaf:{},isAtom:{}};V.nodeSize.get=function(){return this.isLeaf?1:2+this.content.size},V.childCount.get=function(){return this.content.childCount},T.prototype.child=function(e){return this.content.child(e)},T.prototype.maybeChild=function(e){return this.content.maybeChild(e)},T.prototype.forEach=function(e){this.content.forEach(e)},T.prototype.nodesBetween=function(e,t,n,r){void 0===r&&(r=0),this.content.nodesBetween(e,t,n,r,this)},T.prototype.descendants=function(e){this.nodesBetween(0,this.content.size,e)},V.textContent.get=function(){return this.textBetween(0,this.content.size,"")},T.prototype.textBetween=function(e,t,n,r){return this.content.textBetween(e,t,n,r)},V.firstChild.get=function(){return this.content.firstChild},V.lastChild.get=function(){return this.content.lastChild},T.prototype.eq=function(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)},T.prototype.sameMarkup=function(e){return this.hasMarkup(e.type,e.attrs,e.marks)},T.prototype.hasMarkup=function(e,t,n){return this.type==e&&c(this.attrs,t||e.defaultAttrs||A)&&u.sameSet(this.marks,n||u.none)},T.prototype.copy=function(e){return void 0===e&&(e=null),e==this.content?this:new this.constructor(this.type,this.attrs,e,this.marks)},T.prototype.mark=function(e){return e==this.marks?this:new this.constructor(this.type,this.attrs,this.content,e)},T.prototype.cut=function(e,t){return 0==e&&t==this.content.size?this:this.copy(this.content.cut(e,t))},T.prototype.slice=function(e,t,n){if(void 0===t&&(t=this.content.size),void 0===n&&(n=!1),e==t)return p.empty;var r=this.resolve(e),o=this.resolve(t),i=n?0:r.sharedDepth(t),a=r.start(i),s=r.node(i).content.cut(r.pos-a,o.pos-a);return new p(s,r.depth-i,o.depth-i)},T.prototype.replace=function(e,t,n){return h(this.resolve(e),this.resolve(t),n)},T.prototype.nodeAt=function(e){for(var t=this;;){var n=t.content.findIndex(e),r=n.index,o=n.offset;if(!(t=t.maybeChild(r)))return null;if(o==e||t.isText)return t;e-=o+1}},T.prototype.childAfter=function(e){var t=this.content.findIndex(e),n=t.index,r=t.offset;return{node:this.content.maybeChild(n),index:n,offset:r}},T.prototype.childBefore=function(e){if(0==e)return{node:null,index:0,offset:0};var t=this.content.findIndex(e),n=t.index,r=t.offset;if(r<e)return{node:this.content.child(n),index:n,offset:r};var o=this.content.child(n-1);return{node:o,index:n-1,offset:r-o.nodeSize}},T.prototype.resolve=function(e){return k.resolveCached(this,e)},T.prototype.resolveNoCache=function(e){return k.resolve(this,e)},T.prototype.rangeHasMark=function(e,t,n){var r=!1;return t>e&&this.nodesBetween(e,t,(function(e){return n.isInSet(e.marks)&&(r=!0),!r})),r},V.isBlock.get=function(){return this.type.isBlock},V.isTextblock.get=function(){return this.type.isTextblock},V.inlineContent.get=function(){return this.type.inlineContent},V.isInline.get=function(){return this.type.isInline},V.isText.get=function(){return this.type.isText},V.isLeaf.get=function(){return this.type.isLeaf},V.isAtom.get=function(){return this.type.isAtom},T.prototype.toString=function(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);var e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),E(this.marks,e)},T.prototype.contentMatchAt=function(e){var t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t},T.prototype.canReplace=function(e,t,n,r,o){void 0===n&&(n=i.empty),void 0===r&&(r=0),void 0===o&&(o=n.childCount);var a=this.contentMatchAt(e).matchFragment(n,r,o),s=a&&a.matchFragment(this.content,t);if(!s||!s.validEnd)return!1;for(var l=r;l<o;l++)if(!this.type.allowsMarks(n.child(l).marks))return!1;return!0},T.prototype.canReplaceWith=function(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;var o=this.contentMatchAt(e).matchType(n),i=o&&o.matchFragment(this.content,t);return!!i&&i.validEnd},T.prototype.canAppend=function(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)},T.prototype.defaultContentType=function(e){return this.contentMatchAt(e).defaultType},T.prototype.check=function(){if(!this.type.validContent(this.content))throw new RangeError("Invalid content for node "+this.type.name+": "+this.content.toString().slice(0,50));this.content.forEach((function(e){return e.check()}))},T.prototype.toJSON=function(){var e={type:this.type.name};for(var t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map((function(e){return e.toJSON()}))),e},T.fromJSON=function(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");var n=null;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");n=t.marks.map(e.markFromJSON)}if("text"==t.type){if("string"!=typeof t.text)throw new RangeError("Invalid text node in JSON");return e.text(t.text,n)}var r=i.fromJSON(e,t.content);return e.nodeType(t.type).create(t.attrs,r,n)},Object.defineProperties(T.prototype,V);var j=function(e){function t(t,n,r,o){if(e.call(this,t,n,null,o),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={textContent:{},nodeSize:{}};return t.prototype.toString=function(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):E(this.marks,JSON.stringify(this.text))},n.textContent.get=function(){return this.text},t.prototype.textBetween=function(e,t){return this.text.slice(e,t)},n.nodeSize.get=function(){return this.text.length},t.prototype.mark=function(e){return e==this.marks?this:new t(this.type,this.attrs,this.text,e)},t.prototype.withText=function(e){return e==this.text?this:new t(this.type,this.attrs,e,this.marks)},t.prototype.cut=function(e,t){return void 0===e&&(e=0),void 0===t&&(t=this.text.length),0==e&&t==this.text.length?this:this.withText(this.text.slice(e,t))},t.prototype.eq=function(e){return this.sameMarkup(e)&&this.text==e.text},t.prototype.toJSON=function(){var t=e.prototype.toJSON.call(this);return t.text=this.text,t},Object.defineProperties(t.prototype,n),t}(T);function E(e,t){for(var n=e.length-1;n>=0;n--)t=e[n].type.name+"("+t+")";return t}var P=function(e){this.validEnd=e,this.next=[],this.wrapCache=[]},N={inlineContent:{},defaultType:{},edgeCount:{}};P.parse=function(e,t){var n=new H(e,t);if(null==n.next)return P.empty;var r=D(n);n.next&&n.err("Unexpected trailing text");var o=function(e){var t=Object.create(null);return function n(r){var o=[];r.forEach((function(t){e[t].forEach((function(t){var n=t.term,r=t.to;if(n){var i=o.indexOf(n),a=i>-1&&o[i+1];B(e,r).forEach((function(e){a||o.push(n,a=[]),-1==a.indexOf(e)&&a.push(e)}))}}))}));for(var i=t[r.join(",")]=new P(r.indexOf(e.length-1)>-1),a=0;a<o.length;a+=2){var s=o[a+1].sort(z);i.next.push(o[a],t[s.join(",")]||n(s))}return i}(B(e,0))}(function(e){var t=[[]];return o(function e(t,i){if("choice"==t.type)return t.exprs.reduce((function(t,n){return t.concat(e(n,i))}),[]);if("seq"==t.type)for(var a=0;;a++){var s=e(t.exprs[a],i);if(a==t.exprs.length-1)return s;o(s,i=n())}else{if("star"==t.type){var l=n();return r(i,l),o(e(t.expr,l),l),[r(l)]}if("plus"==t.type){var c=n();return o(e(t.expr,i),c),o(e(t.expr,c),c),[r(c)]}if("opt"==t.type)return[r(i)].concat(e(t.expr,i));if("range"==t.type){for(var u=i,f=0;f<t.min;f++){var p=n();o(e(t.expr,u),p),u=p}if(-1==t.max)o(e(t.expr,u),u);else for(var d=t.min;d<t.max;d++){var h=n();r(u,h),o(e(t.expr,u),h),u=h}return[r(u)]}if("name"==t.type)return[r(i,null,t.value)]}}(e,0),n()),t;function n(){return t.push([])-1}function r(e,n,r){var o={term:r,to:n};return t[e].push(o),o}function o(e,t){e.forEach((function(e){return e.to=t}))}}(r));return function(e,t){for(var n=0,r=[e];n<r.length;n++){for(var o=r[n],i=!o.validEnd,a=[],s=0;s<o.next.length;s+=2){var l=o.next[s],c=o.next[s+1];a.push(l.name),!i||l.isText||l.hasRequiredAttrs()||(i=!1),-1==r.indexOf(c)&&r.push(c)}i&&t.err("Only non-generatable nodes ("+a.join(", ")+") in a required position")}}(o,n),o},P.prototype.matchType=function(e){for(var t=0;t<this.next.length;t+=2)if(this.next[t]==e)return this.next[t+1];return null},P.prototype.matchFragment=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=e.childCount);for(var r=this,o=t;r&&o<n;o++)r=r.matchType(e.child(o).type);return r},N.inlineContent.get=function(){var e=this.next[0];return!!e&&e.isInline},N.defaultType.get=function(){for(var e=0;e<this.next.length;e+=2){var t=this.next[e];if(!t.isText&&!t.hasRequiredAttrs())return t}},P.prototype.compatible=function(e){for(var t=0;t<this.next.length;t+=2)for(var n=0;n<e.next.length;n+=2)if(this.next[t]==e.next[n])return!0;return!1},P.prototype.fillBefore=function(e,t,n){void 0===t&&(t=!1),void 0===n&&(n=0);var r=[this];return function o(a,s){var l=a.matchFragment(e,n);if(l&&(!t||l.validEnd))return i.from(s.map((function(e){return e.createAndFill()})));for(var c=0;c<a.next.length;c+=2){var u=a.next[c],f=a.next[c+1];if(!u.isText&&!u.hasRequiredAttrs()&&-1==r.indexOf(f)){r.push(f);var p=o(f,s.concat(u));if(p)return p}}}(this,[])},P.prototype.findWrapping=function(e){for(var t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];var n=this.computeWrapping(e);return this.wrapCache.push(e,n),n},P.prototype.computeWrapping=function(e){for(var t=Object.create(null),n=[{match:this,type:null,via:null}];n.length;){var r=n.shift(),o=r.match;if(o.matchType(e)){for(var i=[],a=r;a.type;a=a.via)i.push(a.type);return i.reverse()}for(var s=0;s<o.next.length;s+=2){var l=o.next[s];l.isLeaf||l.hasRequiredAttrs()||l.name in t||r.type&&!o.next[s+1].validEnd||(n.push({match:l.contentMatch,type:l,via:r}),t[l.name]=!0)}}},N.edgeCount.get=function(){return this.next.length>>1},P.prototype.edge=function(e){var t=e<<1;if(t>this.next.length)throw new RangeError("There's no "+e+"th edge in this content match");return{type:this.next[t],next:this.next[t+1]}},P.prototype.toString=function(){var e=[];return function t(n){e.push(n);for(var r=1;r<n.next.length;r+=2)-1==e.indexOf(n.next[r])&&t(n.next[r])}(this),e.map((function(t,n){for(var r=n+(t.validEnd?"*":" ")+" ",o=0;o<t.next.length;o+=2)r+=(o?", ":"")+t.next[o].name+"->"+e.indexOf(t.next[o+1]);return r})).join("\n")},Object.defineProperties(P.prototype,N),P.empty=new P(!0);var H=function(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),""==this.tokens[this.tokens.length-1]&&this.tokens.pop(),""==this.tokens[0]&&this.tokens.unshift()},L={next:{}};function D(e){var t=[];do{t.push(I(e))}while(e.eat("|"));return 1==t.length?t[0]:{type:"choice",exprs:t}}function I(e){var t=[];do{t.push(R(e))}while(e.next&&")"!=e.next&&"|"!=e.next);return 1==t.length?t[0]:{type:"seq",exprs:t}}function R(e){for(var t=function(e){if(e.eat("(")){var t=D(e);return e.eat(")")||e.err("Missing closing paren"),t}if(!/\W/.test(e.next)){var n=function(e,t){var n=e.nodeTypes,r=n[t];if(r)return[r];var o=[];for(var i in n){var a=n[i];a.groups.indexOf(t)>-1&&o.push(a)}0==o.length&&e.err("No node type or group '"+t+"' found");return o}(e,e.next).map((function(t){return null==e.inline?e.inline=t.isInline:e.inline!=t.isInline&&e.err("Mixing inline and block content"),{type:"name",value:t}}));return e.pos++,1==n.length?n[0]:{type:"choice",exprs:n}}e.err("Unexpected token '"+e.next+"'")}(e);;)if(e.eat("+"))t={type:"plus",expr:t};else if(e.eat("*"))t={type:"star",expr:t};else if(e.eat("?"))t={type:"opt",expr:t};else{if(!e.eat("{"))break;t=F(e,t)}return t}function $(e){/\D/.test(e.next)&&e.err("Expected number, got '"+e.next+"'");var t=Number(e.next);return e.pos++,t}function F(e,t){var n=$(e),r=n;return e.eat(",")&&(r="}"!=e.next?$(e):-1),e.eat("}")||e.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:t}}function z(e,t){return e-t}function B(e,t){var n=[];return function t(r){var o=e[r];if(1==o.length&&!o[0].term)return t(o[0].to);n.push(r);for(var i=0;i<o.length;i++){var a=o[i],s=a.term,l=a.to;s||-1!=n.indexOf(l)||t(l)}}(t),n.sort(z)}function J(e){var t=Object.create(null);for(var n in e){var r=e[n];if(!r.hasDefault)return null;t[n]=r.default}return t}function W(e,t){var n=Object.create(null);for(var r in e){var o=t&&t[r];if(void 0===o){var i=e[r];if(!i.hasDefault)throw new RangeError("No value supplied for attribute "+r);o=i.default}n[r]=o}return n}function q(e){var t=Object.create(null);if(e)for(var n in e)t[n]=new Q(e[n]);return t}L.next.get=function(){return this.tokens[this.pos]},H.prototype.eat=function(e){return this.next==e&&(this.pos++||!0)},H.prototype.err=function(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")},Object.defineProperties(H.prototype,L);var K=function(e,t,n){this.name=e,this.schema=t,this.spec=n,this.groups=n.group?n.group.split(" "):[],this.attrs=q(n.attrs),this.defaultAttrs=J(this.attrs),this.contentMatch=null,this.markSet=null,this.inlineContent=null,this.isBlock=!(n.inline||"text"==e),this.isText="text"==e},G={isInline:{},isTextblock:{},isLeaf:{},isAtom:{}};G.isInline.get=function(){return!this.isBlock},G.isTextblock.get=function(){return this.isBlock&&this.inlineContent},G.isLeaf.get=function(){return this.contentMatch==P.empty},G.isAtom.get=function(){return this.isLeaf||this.spec.atom},K.prototype.hasRequiredAttrs=function(e){for(var t in this.attrs)if(this.attrs[t].isRequired&&(!e||!(t in e)))return!0;return!1},K.prototype.compatibleContent=function(e){return this==e||this.contentMatch.compatible(e.contentMatch)},K.prototype.computeAttrs=function(e){return!e&&this.defaultAttrs?this.defaultAttrs:W(this.attrs,e)},K.prototype.create=function(e,t,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new T(this,this.computeAttrs(e),i.from(t),u.setFrom(n))},K.prototype.createChecked=function(e,t,n){if(t=i.from(t),!this.validContent(t))throw new RangeError("Invalid content for node "+this.name);return new T(this,this.computeAttrs(e),t,u.setFrom(n))},K.prototype.createAndFill=function(e,t,n){if(e=this.computeAttrs(e),(t=i.from(t)).size){var r=this.contentMatch.fillBefore(t);if(!r)return null;t=r.append(t)}var o=this.contentMatch.matchFragment(t).fillBefore(i.empty,!0);return o?new T(this,e,t.append(o),u.setFrom(n)):null},K.prototype.validContent=function(e){var t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(var n=0;n<e.childCount;n++)if(!this.allowsMarks(e.child(n).marks))return!1;return!0},K.prototype.allowsMarkType=function(e){return null==this.markSet||this.markSet.indexOf(e)>-1},K.prototype.allowsMarks=function(e){if(null==this.markSet)return!0;for(var t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0},K.prototype.allowedMarks=function(e){var t;if(null==this.markSet)return e;for(var n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?t&&t.push(e[n]):t||(t=e.slice(0,n));return t?t.length?t:u.empty:e},K.compile=function(e,t){var n=Object.create(null);e.forEach((function(e,r){return n[e]=new K(e,t,r)}));var r=t.spec.topNode||"doc";if(!n[r])throw new RangeError("Schema is missing its top node type ('"+r+"')");if(!n.text)throw new RangeError("Every schema needs a 'text' type");for(var o in n.text.attrs)throw new RangeError("The text node type should not have attributes");return n},Object.defineProperties(K.prototype,G);var Q=function(e){this.hasDefault=Object.prototype.hasOwnProperty.call(e,"default"),this.default=e.default},Z={isRequired:{}};Z.isRequired.get=function(){return!this.hasDefault},Object.defineProperties(Q.prototype,Z);var U=function(e,t,n,r){this.name=e,this.schema=n,this.spec=r,this.attrs=q(r.attrs),this.rank=t,this.excluded=null;var o=J(this.attrs);this.instance=o&&new u(this,o)};U.prototype.create=function(e){return!e&&this.instance?this.instance:new u(this,W(this.attrs,e))},U.compile=function(e,t){var n=Object.create(null),r=0;return e.forEach((function(e,o){return n[e]=new U(e,r++,t,o)})),n},U.prototype.removeFromSet=function(e){for(var t=0;t<e.length;t++)if(e[t].type==this)return e.slice(0,t).concat(e.slice(t+1));return e},U.prototype.isInSet=function(e){for(var t=0;t<e.length;t++)if(e[t].type==this)return e[t]},U.prototype.excludes=function(e){return this.excluded.indexOf(e)>-1};var X=function(e){for(var t in this.spec={},e)this.spec[t]=e[t];this.spec.nodes=o.from(e.nodes),this.spec.marks=o.from(e.marks),this.nodes=K.compile(this.spec.nodes,this),this.marks=U.compile(this.spec.marks,this);var n=Object.create(null);for(var r in this.nodes){if(r in this.marks)throw new RangeError(r+" can not be both a node and a mark");var i=this.nodes[r],a=i.spec.content||"",s=i.spec.marks;i.contentMatch=n[a]||(n[a]=P.parse(a,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.markSet="_"==s?null:s?Y(this,s.split(" ")):""!=s&&i.inlineContent?null:[]}for(var l in this.marks){var c=this.marks[l],u=c.spec.excludes;c.excluded=null==u?[c]:""==u?[]:Y(this,u.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached=Object.create(null),this.cached.wrappings=Object.create(null)};function Y(e,t){for(var n=[],r=0;r<t.length;r++){var o=t[r],i=e.marks[o],a=i;if(i)n.push(i);else for(var s in e.marks){var l=e.marks[s];("_"==o||l.spec.group&&l.spec.group.split(" ").indexOf(o)>-1)&&n.push(a=l)}if(!a)throw new SyntaxError("Unknown mark type: '"+t[r]+"'")}return n}X.prototype.node=function(e,t,n,r){if("string"==typeof e)e=this.nodeType(e);else{if(!(e instanceof K))throw new RangeError("Invalid node type: "+e);if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}return e.createChecked(t,n,r)},X.prototype.text=function(e,t){var n=this.nodes.text;return new j(n,n.defaultAttrs,e,u.setFrom(t))},X.prototype.mark=function(e,t){return"string"==typeof e&&(e=this.marks[e]),e.create(t)},X.prototype.nodeFromJSON=function(e){return T.fromJSON(this,e)},X.prototype.markFromJSON=function(e){return u.fromJSON(this,e)},X.prototype.nodeType=function(e){var t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t};var ee=function(e,t){var n=this;this.schema=e,this.rules=t,this.tags=[],this.styles=[],t.forEach((function(e){e.tag?n.tags.push(e):e.style&&n.styles.push(e)}))};ee.prototype.parse=function(e,t){void 0===t&&(t={});var n=new ae(this,t,!1);return n.addAll(e,null,t.from,t.to),n.finish()},ee.prototype.parseSlice=function(e,t){void 0===t&&(t={});var n=new ae(this,t,!0);return n.addAll(e,null,t.from,t.to),p.maxOpen(n.finish())},ee.prototype.matchTag=function(e,t){for(var n=0;n<this.tags.length;n++){var r=this.tags[n];if(le(e,r.tag)&&(void 0===r.namespace||e.namespaceURI==r.namespace)&&(!r.context||t.matchesContext(r.context))){if(r.getAttrs){var o=r.getAttrs(e);if(!1===o)continue;r.attrs=o}return r}}},ee.prototype.matchStyle=function(e,t,n){for(var r=0;r<this.styles.length;r++){var o=this.styles[r];if(!(0!=o.style.indexOf(e)||o.context&&!n.matchesContext(o.context)||o.style.length>e.length&&(61!=o.style.charCodeAt(e.length)||o.style.slice(e.length+1)!=t))){if(o.getAttrs){var i=o.getAttrs(t);if(!1===i)continue;o.attrs=i}return o}}},ee.schemaRules=function(e){var t=[];function n(e){for(var n=null==e.priority?50:e.priority,r=0;r<t.length;r++){var o=t[r];if((null==o.priority?50:o.priority)<n)break}t.splice(r,0,e)}var r=function(t){var r=e.marks[t].spec.parseDOM;r&&r.forEach((function(e){n(e=ce(e)),e.mark=t}))};for(var o in e.marks)r(o);var i;for(var a in e.nodes)i=void 0,(i=e.nodes[a].spec.parseDOM)&&i.forEach((function(e){n(e=ce(e)),e.node=a}));return t},ee.fromSchema=function(e){return e.cached.domParser||(e.cached.domParser=new ee(e,ee.schemaRules(e)))};var te={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},ne={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},re={ol:!0,ul:!0};function oe(e){return(e?1:0)|("full"===e?2:0)}var ie=function(e,t,n,r,o,i){this.type=e,this.attrs=t,this.solid=r,this.match=o||(4&i?null:e.contentMatch),this.options=i,this.content=[],this.marks=n,this.activeMarks=u.none};ie.prototype.findWrapping=function(e){if(!this.match){if(!this.type)return[];var t=this.type.contentMatch.fillBefore(i.from(e));if(!t){var n,r=this.type.contentMatch;return(n=r.findWrapping(e.type))?(this.match=r,n):null}this.match=this.type.contentMatch.matchFragment(t)}return this.match.findWrapping(e.type)},ie.prototype.finish=function(e){if(!(1&this.options)){var t,n=this.content[this.content.length-1];n&&n.isText&&(t=/\s+$/.exec(n.text))&&(n.text.length==t[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-t[0].length)))}var r=i.from(this.content);return!e&&this.match&&(r=r.append(this.match.fillBefore(i.empty,!0))),this.type?this.type.create(this.attrs,r,this.marks):r};var ae=function(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.pendingMarks=[];var r,o=t.topNode,i=oe(t.preserveWhitespace)|(n?4:0);r=o?new ie(o.type,o.attrs,u.none,!0,t.topMatch||o.type.contentMatch,i):new ie(n?null:e.schema.topNodeType,null,u.none,!0,null,i),this.nodes=[r],this.open=0,this.find=t.findPositions,this.needsBlock=!1},se={top:{},currentPos:{}};function le(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function ce(e){var t={};for(var n in e)t[n]=e[n];return t}se.top.get=function(){return this.nodes[this.open]},ae.prototype.addDOM=function(e){if(3==e.nodeType)this.addTextNode(e);else if(1==e.nodeType){var t=e.getAttribute("style"),n=t?this.readStyles(function(e){var t,n=/\s*([\w-]+)\s*:\s*([^;]+)/g,r=[];for(;t=n.exec(e);)r.push(t[1],t[2].trim());return r}(t)):null;if(null!=n)for(var r=0;r<n.length;r++)this.addPendingMark(n[r]);if(this.addElement(e),null!=n)for(var o=0;o<n.length;o++)this.removePendingMark(n[o])}},ae.prototype.addTextNode=function(e){var t=e.nodeValue,n=this.top;if((n.type?n.type.inlineContent:n.content.length&&n.content[0].isInline)||/\S/.test(t)){if(1&n.options)2&n.options||(t=t.replace(/\r?\n|\r/g," "));else if(t=t.replace(/\s+/g," "),/^\s/.test(t)&&this.open==this.nodes.length-1){var r=n.content[n.content.length-1],o=e.previousSibling;(!r||o&&"BR"==o.nodeName||r.isText&&/\s$/.test(r.text))&&(t=t.slice(1))}t&&this.insertNode(this.parser.schema.text(t)),this.findInText(e)}else this.findInside(e)},ae.prototype.addElement=function(e){var t=e.nodeName.toLowerCase();re.hasOwnProperty(t)&&function(e){for(var t=e.firstChild,n=null;t;t=t.nextSibling){var r=1==t.nodeType?t.nodeName.toLowerCase():null;r&&re.hasOwnProperty(r)&&n?(n.appendChild(t),t=n):"li"==r?n=t:r&&(n=null)}}(e);var n=this.options.ruleFromNode&&this.options.ruleFromNode(e)||this.parser.matchTag(e,this);if(n?n.ignore:ne.hasOwnProperty(t))this.findInside(e);else if(!n||n.skip){n&&n.skip.nodeType&&(e=n.skip);var r,o=this.top,i=this.needsBlock;te.hasOwnProperty(t)&&(r=!0,o.type||(this.needsBlock=!0)),this.addAll(e),r&&this.sync(o),this.needsBlock=i}else this.addElementByRule(e,n)},ae.prototype.readStyles=function(e){for(var t=u.none,n=0;n<e.length;n+=2){var r=this.parser.matchStyle(e[n],e[n+1],this);if(r){if(r.ignore)return null;t=this.parser.schema.marks[r.mark].create(r.attrs).addToSet(t)}}return t},ae.prototype.addElementByRule=function(e,t){var n,r,o,i=this;t.node?(r=this.parser.schema.nodes[t.node]).isLeaf?this.insertNode(r.create(t.attrs)):n=this.enter(r,t.attrs,t.preserveWhitespace):(o=this.parser.schema.marks[t.mark].create(t.attrs),this.addPendingMark(o));var a=this.top;if(r&&r.isLeaf)this.findInside(e);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach((function(e){return i.insertNode(e)}));else{var s=t.contentElement;"string"==typeof s?s=e.querySelector(s):"function"==typeof s&&(s=s(e)),s||(s=e),this.findAround(e,s,!0),this.addAll(s,n)}return n&&(this.sync(a),this.open--),o&&this.removePendingMark(o),!0},ae.prototype.addAll=function(e,t,n,r){for(var o=n||0,i=n?e.childNodes[n]:e.firstChild,a=null==r?null:e.childNodes[r];i!=a;i=i.nextSibling,++o)this.findAtPoint(e,o),this.addDOM(i),t&&te.hasOwnProperty(i.nodeName.toLowerCase())&&this.sync(t);this.findAtPoint(e,o)},ae.prototype.findPlace=function(e){for(var t,n,r=this.open;r>=0;r--){var o=this.nodes[r],i=o.findWrapping(e);if(i&&(!t||t.length>i.length)&&(t=i,n=o,!i.length))break;if(o.solid)break}if(!t)return!1;this.sync(n);for(var a=0;a<t.length;a++)this.enterInner(t[a],null,!1);return!0},ae.prototype.insertNode=function(e){if(e.isInline&&this.needsBlock&&!this.top.type){var t=this.textblockFromContext();t&&this.enterInner(t)}if(this.findPlace(e)){this.closeExtra();var n=this.top;this.applyPendingMarks(n),n.match&&(n.match=n.match.matchType(e.type));for(var r=n.activeMarks,o=0;o<e.marks.length;o++)n.type&&!n.type.allowsMarkType(e.marks[o].type)||(r=e.marks[o].addToSet(r));n.content.push(e.mark(r))}},ae.prototype.applyPendingMarks=function(e){for(var t=0;t<this.pendingMarks.length;t++){var n=this.pendingMarks[t];e.type&&!e.type.allowsMarkType(n.type)||n.isInSet(e.activeMarks)||(e.activeMarks=n.addToSet(e.activeMarks),this.pendingMarks.splice(t--,1))}},ae.prototype.enter=function(e,t,n){var r=this.findPlace(e.create(t));return r&&(this.applyPendingMarks(this.top),this.enterInner(e,t,!0,n)),r},ae.prototype.enterInner=function(e,t,n,r){this.closeExtra();var o=this.top;o.match=o.match&&o.match.matchType(e,t);var i=null==r?-5&o.options:oe(r);4&o.options&&0==o.content.length&&(i|=4),this.nodes.push(new ie(e,t,o.activeMarks,n,null,i)),this.open++},ae.prototype.closeExtra=function(e){var t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}},ae.prototype.finish=function(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(this.isOpen||this.options.topOpen)},ae.prototype.sync=function(e){for(var t=this.open;t>=0;t--)if(this.nodes[t]==e)return void(this.open=t)},ae.prototype.addPendingMark=function(e){this.pendingMarks.push(e)},ae.prototype.removePendingMark=function(e){var t=this.pendingMarks.lastIndexOf(e);if(t>-1)this.pendingMarks.splice(t,1);else{var n=this.top;n.activeMarks=e.removeFromSet(n.activeMarks)}},se.currentPos.get=function(){this.closeExtra();for(var e=0,t=this.open;t>=0;t--){for(var n=this.nodes[t].content,r=n.length-1;r>=0;r--)e+=n[r].nodeSize;t&&e++}return e},ae.prototype.findAtPoint=function(e,t){if(this.find)for(var n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)},ae.prototype.findInside=function(e){if(this.find)for(var t=0;t<this.find.length;t++)null==this.find[t].pos&&1==e.nodeType&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)},ae.prototype.findAround=function(e,t,n){if(e!=t&&this.find)for(var r=0;r<this.find.length;r++){if(null==this.find[r].pos&&1==e.nodeType&&e.contains(this.find[r].node))t.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].pos=this.currentPos)}},ae.prototype.findInText=function(e){if(this.find)for(var t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))},ae.prototype.matchesContext=function(e){var t=this;if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);var n=e.split("/"),r=this.options.context,o=!(this.isOpen||r&&r.parent.type!=this.nodes[0].type),i=-(r?r.depth+1:0)+(o?0:1),a=function(e,s){for(;e>=0;e--){var l=n[e];if(""==l){if(e==n.length-1||0==e)continue;for(;s>=i;s--)if(a(e-1,s))return!0;return!1}var c=s>0||0==s&&o?t.nodes[s].type:r&&s>=i?r.node(s-i).type:null;if(!c||c.name!=l&&-1==c.groups.indexOf(l))return!1;s--}return!0};return a(n.length-1,this.open)},ae.prototype.textblockFromContext=function(){var e=this.options.context;if(e)for(var t=e.depth;t>=0;t--){var n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(var r in this.parser.schema.nodes){var o=this.parser.schema.nodes[r];if(o.isTextblock&&o.defaultAttrs)return o}},Object.defineProperties(ae.prototype,se);var ue=function(e,t){this.nodes=e||{},this.marks=t||{}};function fe(e){var t={};for(var n in e){var r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function pe(e){return e.document||window.document}ue.prototype.serializeFragment=function(e,t,n){var r=this;void 0===t&&(t={}),n||(n=pe(t).createDocumentFragment());var o=n,i=null;return e.forEach((function(e){if(i||e.marks.length){i||(i=[]);for(var n=0,a=0;n<i.length&&a<e.marks.length;){var s=e.marks[a];if(r.marks[s.type.name]){if(!s.eq(i[n])||!1===s.type.spec.spanning)break;n+=2,a++}else a++}for(;n<i.length;)o=i.pop(),i.pop();for(;a<e.marks.length;){var l=e.marks[a++],c=r.serializeMark(l,e.isInline,t);c&&(i.push(l,o),o.appendChild(c.dom),o=c.contentDOM||c.dom)}}o.appendChild(r.serializeNode(e,t))})),n},ue.prototype.serializeNode=function(e,t){void 0===t&&(t={});var n=ue.renderSpec(pe(t),this.nodes[e.type.name](e)),r=n.dom,o=n.contentDOM;if(o){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");t.onContent?t.onContent(e,o,t):this.serializeFragment(e.content,t,o)}return r},ue.prototype.serializeNodeAndMarks=function(e,t){void 0===t&&(t={});for(var n=this.serializeNode(e,t),r=e.marks.length-1;r>=0;r--){var o=this.serializeMark(e.marks[r],e.isInline,t);o&&((o.contentDOM||o.dom).appendChild(n),n=o.dom)}return n},ue.prototype.serializeMark=function(e,t,n){void 0===n&&(n={});var r=this.marks[e.type.name];return r&&ue.renderSpec(pe(n),r(e,t))},ue.renderSpec=function(e,t){if("string"==typeof t)return{dom:e.createTextNode(t)};if(null!=t.nodeType)return{dom:t};var n=e.createElement(t[0]),r=null,o=t[1],i=1;if(o&&"object"==typeof o&&null==o.nodeType&&!Array.isArray(o))for(var a in i=2,o)null!=o[a]&&n.setAttribute(a,o[a]);for(var s=i;s<t.length;s++){var l=t[s];if(0===l){if(s<t.length-1||s>i)throw new RangeError("Content hole must be the only child of its parent node");return{dom:n,contentDOM:n}}var c=ue.renderSpec(e,l),u=c.dom,f=c.contentDOM;if(n.appendChild(u),f){if(r)throw new RangeError("Multiple content holes");r=f}}return{dom:n,contentDOM:r}},ue.fromSchema=function(e){return e.cached.domSerializer||(e.cached.domSerializer=new ue(this.nodesFromSchema(e),this.marksFromSchema(e)))},ue.nodesFromSchema=function(e){var t=fe(e.nodes);return t.text||(t.text=function(e){return e.text}),t},ue.marksFromSchema=function(e){return fe(e.marks)},t.Node=T,t.ResolvedPos=k,t.NodeRange=C,t.Fragment=i,t.Slice=p,t.ReplaceError=f,t.Mark=u,t.Schema=X,t.NodeType=K,t.MarkType=U,t.ContentMatch=P,t.DOMParser=ee,t.DOMSerializer=ue},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(5),o=Math.pow(2,16);function i(e){return 65535&e}var a=function(e,t,n){void 0===t&&(t=!1),void 0===n&&(n=null),this.pos=e,this.deleted=t,this.recover=n},s=function(e,t){void 0===t&&(t=!1),this.ranges=e,this.inverted=t};s.prototype.recover=function(e){var t=0,n=i(e);if(!this.inverted)for(var r=0;r<n;r++)t+=this.ranges[3*r+2]-this.ranges[3*r+1];return this.ranges[3*n]+t+function(e){return(e-(65535&e))/o}(e)},s.prototype.mapResult=function(e,t){return void 0===t&&(t=1),this._map(e,t,!1)},s.prototype.map=function(e,t){return void 0===t&&(t=1),this._map(e,t,!0)},s.prototype._map=function(e,t,n){for(var r=0,i=this.inverted?2:1,s=this.inverted?1:2,l=0;l<this.ranges.length;l+=3){var c=this.ranges[l]-(this.inverted?r:0);if(c>e)break;var u=this.ranges[l+i],f=this.ranges[l+s],p=c+u;if(e<=p){var d=c+r+((u?e==c?-1:e==p?1:t:t)<0?0:f);if(n)return d;var h=l/3+(e-c)*o;return new a(d,t<0?e!=c:e!=p,h)}r+=f-u}return n?e+r:new a(e+r)},s.prototype.touches=function(e,t){for(var n=0,r=i(t),o=this.inverted?2:1,a=this.inverted?1:2,s=0;s<this.ranges.length;s+=3){var l=this.ranges[s]-(this.inverted?n:0);if(l>e)break;var c=this.ranges[s+o];if(e<=l+c&&s==3*r)return!0;n+=this.ranges[s+a]-c}return!1},s.prototype.forEach=function(e){for(var t=this.inverted?2:1,n=this.inverted?1:2,r=0,o=0;r<this.ranges.length;r+=3){var i=this.ranges[r],a=i-(this.inverted?o:0),s=i+(this.inverted?0:o),l=this.ranges[r+t],c=this.ranges[r+n];e(a,a+l,s,s+c),o+=c-l}},s.prototype.invert=function(){return new s(this.ranges,!this.inverted)},s.prototype.toString=function(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)},s.offset=function(e){return 0==e?s.empty:new s(e<0?[0,-e,0]:[0,0,e])},s.empty=new s([]);var l=function(e,t,n,r){this.maps=e||[],this.from=n||0,this.to=null==r?this.maps.length:r,this.mirror=t};function c(e){var t=Error.call(this,e);return t.__proto__=c.prototype,t}l.prototype.slice=function(e,t){return void 0===e&&(e=0),void 0===t&&(t=this.maps.length),new l(this.maps,this.mirror,e,t)},l.prototype.copy=function(){return new l(this.maps.slice(),this.mirror&&this.mirror.slice(),this.from,this.to)},l.prototype.appendMap=function(e,t){this.to=this.maps.push(e),null!=t&&this.setMirror(this.maps.length-1,t)},l.prototype.appendMapping=function(e){for(var t=0,n=this.maps.length;t<e.maps.length;t++){var r=e.getMirror(t);this.appendMap(e.maps[t],null!=r&&r<t?n+r:null)}},l.prototype.getMirror=function(e){if(this.mirror)for(var t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]},l.prototype.setMirror=function(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)},l.prototype.appendMappingInverted=function(e){for(var t=e.maps.length-1,n=this.maps.length+e.maps.length;t>=0;t--){var r=e.getMirror(t);this.appendMap(e.maps[t].invert(),null!=r&&r>t?n-r-1:null)}},l.prototype.invert=function(){var e=new l;return e.appendMappingInverted(this),e},l.prototype.map=function(e,t){if(void 0===t&&(t=1),this.mirror)return this._map(e,t,!0);for(var n=this.from;n<this.to;n++)e=this.maps[n].map(e,t);return e},l.prototype.mapResult=function(e,t){return void 0===t&&(t=1),this._map(e,t,!1)},l.prototype._map=function(e,t,n){for(var r=!1,o=null,i=this.from;i<this.to;i++){var s=this.maps[i],l=o&&o[i];if(null!=l&&s.touches(e,l))e=s.recover(l);else{var c=s.mapResult(e,t);if(null!=c.recover){var u=this.getMirror(i);if(null!=u&&u>i&&u<this.to){if(c.deleted){i=u,e=this.maps[u].recover(c.recover);continue}(o||(o=Object.create(null)))[u]=c.recover}}c.deleted&&(r=!0),e=c.pos}}return n?e:new a(e,r)},c.prototype=Object.create(Error.prototype),c.prototype.constructor=c,c.prototype.name="TransformError";var u=function(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new l},f={before:{},docChanged:{}};function p(){throw new Error("Override me")}f.before.get=function(){return this.docs.length?this.docs[0]:this.doc},u.prototype.step=function(e){var t=this.maybeStep(e);if(t.failed)throw new c(t.failed);return this},u.prototype.maybeStep=function(e){var t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t},f.docChanged.get=function(){return this.steps.length>0},u.prototype.addStep=function(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t},Object.defineProperties(u.prototype,f);var d=Object.create(null),h=function(){};h.prototype.apply=function(e){return p()},h.prototype.getMap=function(){return s.empty},h.prototype.invert=function(e){return p()},h.prototype.map=function(e){return p()},h.prototype.merge=function(e){return null},h.prototype.toJSON=function(){return p()},h.fromJSON=function(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");var n=d[t.stepType];if(!n)throw new RangeError("No step type "+t.stepType+" defined");return n.fromJSON(e,t)},h.jsonID=function(e,t){if(e in d)throw new RangeError("Duplicate use of step JSON ID "+e);return d[e]=t,t.prototype.jsonID=e,t};var v=function(e,t){this.doc=e,this.failed=t};v.ok=function(e){return new v(e,null)},v.fail=function(e){return new v(null,e)},v.fromReplace=function(e,t,n,o){try{return v.ok(e.replace(t,n,o))}catch(e){if(e instanceof r.ReplaceError)return v.fail(e.message);throw e}};var m=function(e){function t(t,n,r,o){e.call(this),this.from=t,this.to=n,this.slice=r,this.structure=!!o}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.apply=function(e){return this.structure&&g(e,this.from,this.to)?v.fail("Structure replace would overwrite content"):v.fromReplace(e,this.from,this.to,this.slice)},t.prototype.getMap=function(){return new s([this.from,this.to-this.from,this.slice.size])},t.prototype.invert=function(e){return new t(this.from,this.from+this.slice.size,e.slice(this.from,this.to))},t.prototype.map=function(e){var n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted?null:new t(n.pos,Math.max(n.pos,r.pos),this.slice)},t.prototype.merge=function(e){if(!(e instanceof t)||e.structure!=this.structure)return null;if(this.from+this.slice.size!=e.from||this.slice.openEnd||e.slice.openStart){if(e.to!=this.from||this.slice.openStart||e.slice.openEnd)return null;var n=this.slice.size+e.slice.size==0?r.Slice.empty:new r.Slice(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new t(e.from,this.to,n,this.structure)}var o=this.slice.size+e.slice.size==0?r.Slice.empty:new r.Slice(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new t(this.from,this.to+(e.to-e.from),o,this.structure)},t.prototype.toJSON=function(){var e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e},t.fromJSON=function(e,n){if("number"!=typeof n.from||"number"!=typeof n.to)throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new t(n.from,n.to,r.Slice.fromJSON(e,n.slice),!!n.structure)},t}(h);h.jsonID("replace",m);var y=function(e){function t(t,n,r,o,i,a,s){e.call(this),this.from=t,this.to=n,this.gapFrom=r,this.gapTo=o,this.slice=i,this.insert=a,this.structure=!!s}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.apply=function(e){if(this.structure&&(g(e,this.from,this.gapFrom)||g(e,this.gapTo,this.to)))return v.fail("Structure gap-replace would overwrite content");var t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return v.fail("Gap is not a flat range");var n=this.slice.insertAt(this.insert,t.content);return n?v.fromReplace(e,this.from,this.to,n):v.fail("Content does not fit in gap")},t.prototype.getMap=function(){return new s([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])},t.prototype.invert=function(e){var n=this.gapTo-this.gapFrom;return new t(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)},t.prototype.map=function(e){var n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),o=e.map(this.gapFrom,-1),i=e.map(this.gapTo,1);return n.deleted&&r.deleted||o<n.pos||i>r.pos?null:new t(n.pos,r.pos,o,i,this.slice,this.insert,this.structure)},t.prototype.toJSON=function(){var e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e},t.fromJSON=function(e,n){if("number"!=typeof n.from||"number"!=typeof n.to||"number"!=typeof n.gapFrom||"number"!=typeof n.gapTo||"number"!=typeof n.insert)throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new t(n.from,n.to,n.gapFrom,n.gapTo,r.Slice.fromJSON(e,n.slice),n.insert,!!n.structure)},t}(h);function g(e,t,n){for(var r=e.resolve(t),o=n-t,i=r.depth;o>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,o--;if(o>0)for(var a=r.node(i).maybeChild(r.indexAfter(i));o>0;){if(!a||a.isLeaf)return!0;a=a.firstChild,o--}return!1}function b(e,t,n){return(0==t||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function w(e){return{type:e,attrs:null}}function k(e,t){return e&&t&&!e.isLeaf&&e.canAppend(t)}function O(e,t,n){var r=e.resolve(t);if(r.parent.canReplaceWith(r.index(),r.index(),n))return t;if(0==r.parentOffset)for(var o=r.depth-1;o>=0;o--){var i=r.index(o);if(r.node(o).canReplaceWith(i,i,n))return r.before(o+1);if(i>0)return null}if(r.parentOffset==r.parent.content.size)for(var a=r.depth-1;a>=0;a--){var s=r.indexAfter(a);if(r.node(a).canReplaceWith(s,s,n))return r.after(a+1);if(s<r.node(a).childCount)return null}}function M(e,t,n){for(var o=[],i=0;i<e.childCount;i++){var a=e.child(i);a.content.size&&(a=a.copy(M(a.content,t,a))),a.isInline&&(a=t(a,n,i)),o.push(a)}return r.Fragment.fromArray(o)}h.jsonID("replaceAround",y),u.prototype.lift=function(e,t){for(var n=e.$from,o=e.$to,i=e.depth,a=n.before(i+1),s=o.after(i+1),l=a,c=s,u=r.Fragment.empty,f=0,p=i,d=!1;p>t;p--)d||n.index(p)>0?(d=!0,u=r.Fragment.from(n.node(p).copy(u)),f++):l--;for(var h=r.Fragment.empty,v=0,m=i,g=!1;m>t;m--)g||o.after(m+1)<o.end(m)?(g=!0,h=r.Fragment.from(o.node(m).copy(h)),v++):c++;return this.step(new y(l,c,a,s,new r.Slice(u.append(h),f,v),u.size-f,!0))},u.prototype.wrap=function(e,t){for(var n=r.Fragment.empty,o=t.length-1;o>=0;o--)n=r.Fragment.from(t[o].type.create(t[o].attrs,n));var i=e.start,a=e.end;return this.step(new y(i,a,i,a,new r.Slice(n,0,0),t.length,!0))},u.prototype.setBlockType=function(e,t,n,o){var i=this;if(void 0===t&&(t=e),!n.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");var a=this.steps.length;return this.doc.nodesBetween(e,t,(function(e,t){if(e.isTextblock&&!e.hasMarkup(n,o)&&function(e,t,n){var r=e.resolve(t),o=r.index();return r.parent.canReplaceWith(o,o+1,n)}(i.doc,i.mapping.slice(a).map(t),n)){i.clearIncompatible(i.mapping.slice(a).map(t,1),n);var s=i.mapping.slice(a),l=s.map(t,1),c=s.map(t+e.nodeSize,1);return i.step(new y(l,c,l+1,c-1,new r.Slice(r.Fragment.from(n.create(o,null,e.marks)),0,0),1,!0)),!1}})),this},u.prototype.setNodeMarkup=function(e,t,n,o){var i=this.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");t||(t=i.type);var a=t.create(n,null,o||i.marks);if(i.isLeaf)return this.replaceWith(e,e+i.nodeSize,a);if(!t.validContent(i.content))throw new RangeError("Invalid content for node type "+t.name);return this.step(new y(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new r.Slice(r.Fragment.from(a),0,0),1,!0))},u.prototype.split=function(e,t,n){void 0===t&&(t=1);for(var o=this.doc.resolve(e),i=r.Fragment.empty,a=r.Fragment.empty,s=o.depth,l=o.depth-t,c=t-1;s>l;s--,c--){i=r.Fragment.from(o.node(s).copy(i));var u=n&&n[c];a=r.Fragment.from(u?u.type.create(u.attrs,a):o.node(s).copy(a))}return this.step(new m(e,e,new r.Slice(i.append(a),t,t,!0)))},u.prototype.join=function(e,t){void 0===t&&(t=1);var n=new m(e-t,e+t,r.Slice.empty,!0);return this.step(n)};var S=function(e){function t(t,n,r){e.call(this),this.from=t,this.to=n,this.mark=r}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.apply=function(e){var t=this,n=e.slice(this.from,this.to),o=e.resolve(this.from),i=o.node(o.sharedDepth(this.to)),a=new r.Slice(M(n.content,(function(e,n){return n.type.allowsMarkType(t.mark.type)?e.mark(t.mark.addToSet(e.marks)):e}),i),n.openStart,n.openEnd);return v.fromReplace(e,this.from,this.to,a)},t.prototype.invert=function(){return new _(this.from,this.to,this.mark)},t.prototype.map=function(e){var n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new t(n.pos,r.pos,this.mark)},t.prototype.merge=function(e){if(e instanceof t&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from)return new t(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark)},t.prototype.toJSON=function(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}},t.fromJSON=function(e,n){if("number"!=typeof n.from||"number"!=typeof n.to)throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new t(n.from,n.to,e.markFromJSON(n.mark))},t}(h);h.jsonID("addMark",S);var _=function(e){function t(t,n,r){e.call(this),this.from=t,this.to=n,this.mark=r}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.apply=function(e){var t=this,n=e.slice(this.from,this.to),o=new r.Slice(M(n.content,(function(e){return e.mark(t.mark.removeFromSet(e.marks))})),n.openStart,n.openEnd);return v.fromReplace(e,this.from,this.to,o)},t.prototype.invert=function(){return new S(this.from,this.to,this.mark)},t.prototype.map=function(e){var n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new t(n.pos,r.pos,this.mark)},t.prototype.merge=function(e){if(e instanceof t&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from)return new t(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark)},t.prototype.toJSON=function(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}},t.fromJSON=function(e,n){if("number"!=typeof n.from||"number"!=typeof n.to)throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new t(n.from,n.to,e.markFromJSON(n.mark))},t}(h);function C(e,t,n,o){if(void 0===n&&(n=t),void 0===o&&(o=r.Slice.empty),t==n&&!o.size)return null;var i=e.resolve(t),a=e.resolve(n);if(T(i,a,o))return new m(t,n,o);var s=function(e,t){var n=function e(t,n,o,i){var a=r.Fragment.empty,s=0,l=o[n];if(t.depth>n){var c=e(t,n+1,o,i||l);s=c.openEnd+1,a=r.Fragment.from(t.node(n+1).copy(c.content))}l&&(a=a.append(l.content),s=l.openEnd);i&&(a=a.append(t.node(n).contentMatchAt(t.indexAfter(n)).fillBefore(r.Fragment.empty,!0)),s=0);return{content:a,openEnd:s}}(e,0,t,!1),o=n.content,i=n.openEnd;return new r.Slice(o,e.depth,i||0)}(i,function(e,t){for(var n=new V(e),r=1;t.size&&r<=3;r++)t=n.placeSlice(t.content,t.openStart,t.openEnd,r);for(;n.open.length;)n.closeNode();return n.placed}(i,o)),l=A(i,a,s);if(!l)return null;if(s.size!=l.size&&function(e,t,n){if(!t.parent.isTextblock)return!1;var r,o=n.openEnd?function(e,t){for(var n=1;n<t;n++)e=e.lastChild.content;return e.lastChild}(n.content,n.openEnd):e.node(e.depth-(n.openStart-n.openEnd));if(!o.isTextblock)return!1;for(var i=t.index();i<t.parent.childCount;i++)if(!o.type.allowsMarks(t.parent.child(i).marks))return!1;n.openEnd?r=o.contentMatchAt(o.childCount):(r=o.contentMatchAt(o.childCount),n.size&&(r=r.matchFragment(n.content,n.openStart?1:0)));return(r=r.matchFragment(t.parent.content,t.index()))&&r.validEnd}(i,a,s)){for(var c=a.depth,u=a.after(c);c>1&&u==a.end(--c);)++u;var f=A(i,e.resolve(u),s);if(f)return new y(t,u,n,a.end(),f,s.size)}return l.size||t!=n?new m(t,n,l):null}function x(e,t,n,o,i,a,s){var l,c=e.childCount,u=c-(s>0?1:0),f=a<0?t:n.node(i);l=a<0?f.contentMatchAt(u):1==c&&s>0?f.contentMatchAt(a?n.index(i):n.indexAfter(i)):f.contentMatchAt(n.indexAfter(i)).matchFragment(e,c>0&&a?1:0,u);var p=o.node(i);if(s>0&&i<o.depth){var d=p.content.cutByIndex(o.indexAfter(i)).addToStart(e.lastChild),h=l.fillBefore(d,!0);if(h&&h.size&&a>0&&1==c&&(h=null),h){var v=x(e.lastChild.content,e.lastChild,n,o,i+1,1==c?a-1:-1,s-1);if(v){var m=e.lastChild.copy(v);return h.size?e.cutByIndex(0,c-1).append(h).addToEnd(m):e.replaceChild(c-1,m)}}}s>0&&(l=l.matchType((1==c&&a>0?n.node(i+1):e.lastChild).type));var y=o.index(i);if(y==p.childCount&&!p.type.compatibleContent(t.type))return null;for(var g=l.fillBefore(p.content,!0,y),b=y;g&&b<p.content.childCount;b++)f.type.allowsMarks(p.content.child(b).marks)||(g=null);if(!g)return null;if(s>0){var w=function e(t,n,o,i,a){var s,l=t.content,c=l.childCount;s=a>=0?o.node(i).contentMatchAt(o.indexAfter(i)).matchFragment(l,a>0?1:0,c):t.contentMatchAt(c);if(n>0){var u=e(l.lastChild,n-1,o,i+1,1==c?a-1:-1);l=l.replaceChild(c-1,u)}return t.copy(l.append(s.fillBefore(r.Fragment.empty,!0)))}(e.lastChild,s-1,n,i+1,1==c?a-1:-1);e=e.replaceChild(c-1,w)}return e=e.append(g),o.depth>i&&(e=e.addToEnd(function e(t,n){var r=t.node(n),o=r.contentMatchAt(0).fillBefore(r.content,!0,t.index(n));t.depth>n&&(o=o.addToEnd(e(t,n+1)));return r.copy(o)}(o,i+1))),e}function A(e,t,n){var o=x(n.content,e.node(0),e,t,0,n.openStart,n.openEnd);return o?function(e,t,n){for(;t>0&&n>0&&1==e.childCount;)e=e.firstChild.content,t--,n--;return new r.Slice(e,t,n)}(o,n.openStart,t.depth):null}function T(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}h.jsonID("removeMark",_),u.prototype.addMark=function(e,t,n){var r=this,o=[],i=[],a=null,s=null;return this.doc.nodesBetween(e,t,(function(r,l,c){if(r.isInline){var u=r.marks;if(!n.isInSet(u)&&c.type.allowsMarkType(n.type)){for(var f=Math.max(l,e),p=Math.min(l+r.nodeSize,t),d=n.addToSet(u),h=0;h<u.length;h++)u[h].isInSet(d)||(a&&a.to==f&&a.mark.eq(u[h])?a.to=p:o.push(a=new _(f,p,u[h])));s&&s.to==f?s.to=p:i.push(s=new S(f,p,n))}}})),o.forEach((function(e){return r.step(e)})),i.forEach((function(e){return r.step(e)})),this},u.prototype.removeMark=function(e,t,n){var o=this;void 0===n&&(n=null);var i=[],a=0;return this.doc.nodesBetween(e,t,(function(o,s){if(o.isInline){a++;var l=null;if(n instanceof r.MarkType){var c=n.isInSet(o.marks);c&&(l=[c])}else n?n.isInSet(o.marks)&&(l=[n]):l=o.marks;if(l&&l.length)for(var u=Math.min(s+o.nodeSize,t),f=0;f<l.length;f++){for(var p=l[f],d=void 0,h=0;h<i.length;h++){var v=i[h];v.step==a-1&&p.eq(i[h].style)&&(d=v)}d?(d.to=u,d.step=a):i.push({style:p,from:Math.max(s,e),to:u,step:a})}}})),i.forEach((function(e){return o.step(new _(e.from,e.to,e.style))})),this},u.prototype.clearIncompatible=function(e,t,n){void 0===n&&(n=t.contentMatch);for(var o=this.doc.nodeAt(e),i=[],a=e+1,s=0;s<o.childCount;s++){var l=o.child(s),c=a+l.nodeSize,u=n.matchType(l.type,l.attrs);if(u){n=u;for(var f=0;f<l.marks.length;f++)t.allowsMarkType(l.marks[f].type)||this.step(new _(a,c,l.marks[f]))}else i.push(new m(a,c,r.Slice.empty));a=c}if(!n.validEnd){var p=n.fillBefore(r.Fragment.empty,!0);this.replace(a,a,new r.Slice(p,0,0))}for(var d=i.length-1;d>=0;d--)this.step(i[d]);return this},u.prototype.replace=function(e,t,n){void 0===t&&(t=e),void 0===n&&(n=r.Slice.empty);var o=C(this.doc,e,t,n);return o&&this.step(o),this},u.prototype.replaceWith=function(e,t,n){return this.replace(e,t,new r.Slice(r.Fragment.from(n),0,0))},u.prototype.delete=function(e,t){return this.replace(e,t,r.Slice.empty)},u.prototype.insert=function(e,t){return this.replaceWith(e,e,t)};var V=function(e){this.open=[];for(var t=0;t<=e.depth;t++){var n=e.node(t),o=n.contentMatchAt(e.indexAfter(t));this.open.push({parent:n,match:o,content:r.Fragment.empty,wrapper:!1,openEnd:0,depth:t})}this.placed=[]};function j(e,t,n){var r=e.content;if(t>1){var o=j(e.firstChild,t-1,1==e.childCount?n-1:0);r=e.content.replaceChild(0,o)}var i=e.type.contentMatch.fillBefore(r,0==n);return e.copy(i.append(r))}function E(e,t,n,r,o){if(t<n){var i=e.firstChild;e=e.replaceChild(0,i.copy(E(i.content,t+1,n,r,i)))}return t>r&&(e=o.contentMatchAt(0).fillBefore(e,!0).append(e)),e}function P(e,t){for(var n=[],r=Math.min(e.depth,t.depth);r>=0;r--){var o=e.start(r);if(o<e.pos-(e.depth-r)||t.end(r)>t.pos+(t.depth-r)||e.node(r).type.spec.isolating||t.node(r).type.spec.isolating)break;o==t.start(r)&&n.push(r)}return n}V.prototype.placeSlice=function(e,t,n,o,i){if(t>0){var a=e.firstChild,s=this.placeSlice(a.content,Math.max(0,t-1),n&&1==e.childCount?n-1:0,o,a);s.content!=a.content&&(s.content.size?(e=e.replaceChild(0,a.copy(s.content)),t=s.openStart+1):(1==e.childCount&&(n=0),e=e.cutByIndex(1),t=0))}var l=this.placeContent(e,t,n,o,i);if(o>2&&l.size&&0==t){for(var c=0;c<l.content.childCount;c++){var u=l.content.child(c);this.placeContent(u.content,0,n&&c==l.content.childCount.length-1?n-1:0,o,u)}l=r.Fragment.empty}return l},V.prototype.placeContent=function(e,t,n,o,i){for(var a=0;a<e.childCount;a++){for(var s=e.child(a),l=!1,c=a==e.childCount-1,u=this.open.length-1;u>=0;u--){var f=this.open[u],p=void 0;if(o>1&&(p=f.match.findWrapping(s.type))&&(!i||!p.length||p[p.length-1]!=i.type)){for(;this.open.length-1>u;)this.closeNode();for(var d=0;d<p.length;d++)f.match=f.match.matchType(p[d]),u++,f={parent:p[d].create(),match:p[d].contentMatch,content:r.Fragment.empty,wrapper:!0,openEnd:0,depth:u+d},this.open.push(f)}var h=f.match.matchType(s.type);if(!h){var v=f.match.fillBefore(r.Fragment.from(s));if(!v){if(i&&f.match.matchType(i.type))break;continue}for(var m=0;m<v.childCount;m++){var y=v.child(m);this.addNode(f,y,0),h=f.match.matchFragment(y)}}for(;this.open.length-1>u;)this.closeNode();s=s.mark(f.parent.type.allowedMarks(s.marks)),t&&(s=j(s,t,c?n:0),t=0),this.addNode(f,s,c?n:0),f.match=h,c&&(n=0),l=!0;break}if(!l)break}return this.open.length>1&&(a>0&&a==e.childCount||i&&this.open[this.open.length-1].parent.type==i.type)&&this.closeNode(),new r.Slice(e.cutByIndex(a),t,n)},V.prototype.addNode=function(e,t,n){var o,i;e.content=(o=e.content,i=e.openEnd,i?o.replaceChild(o.childCount-1,function e(t,n){var o=t.content;if(n>1){var i=e(t.lastChild,n-1);o=t.content.replaceChild(t.childCount-1,i)}var a=t.contentMatchAt(t.childCount).fillBefore(r.Fragment.empty,!0);return t.copy(o.append(a))}(o.lastChild,i)):o).addToEnd(t),e.openEnd=n},V.prototype.closeNode=function(){var e=this.open.pop();0==e.content.size||(e.wrapper?this.addNode(this.open[this.open.length-1],e.parent.copy(e.content),e.openEnd+1):this.placed[e.depth]={depth:e.depth,content:e.content,openEnd:e.openEnd})},u.prototype.replaceRange=function(e,t,n){if(!n.size)return this.deleteRange(e,t);var o=this.doc.resolve(e),i=this.doc.resolve(t);if(T(o,i,n))return this.step(new m(e,t,n));var a=P(o,this.doc.resolve(t));0==a[a.length-1]&&a.pop();var s=-(o.depth+1);a.unshift(s);for(var l=o.depth,c=o.pos-1;l>0;l--,c--){var u=o.node(l).type.spec;if(u.defining||u.isolating)break;a.indexOf(l)>-1?s=l:o.before(l)==c&&a.splice(1,0,-l)}for(var f=a.indexOf(s),p=[],d=n.openStart,h=n.content,v=0;;v++){var y=h.firstChild;if(p.push(y),v==n.openStart)break;h=y.content}d>0&&p[d-1].type.spec.defining&&o.node(f).type!=p[d-1].type?d-=1:d>=2&&p[d-1].isTextblock&&p[d-2].type.spec.defining&&o.node(f).type!=p[d-2].type&&(d-=2);for(var g=n.openStart;g>=0;g--){var b=(g+d+1)%(n.openStart+1),w=p[b];if(w)for(var k=0;k<a.length;k++){var O=a[(k+f)%a.length],M=!0;O<0&&(M=!1,O=-O);var S=o.node(O-1),_=o.index(O-1);if(S.canReplaceWith(_,_,w.type,w.marks))return this.replace(o.before(O),M?i.after(O):t,new r.Slice(E(n.content,0,n.openStart,b),b,n.openEnd))}}return this.replace(e,t,n)},u.prototype.replaceRangeWith=function(e,t,n){if(!n.isInline&&e==t&&this.doc.resolve(e).parent.content.size){var o=O(this.doc,e,n.type);null!=o&&(e=t=o)}return this.replaceRange(e,t,new r.Slice(r.Fragment.from(n),0,0))},u.prototype.deleteRange=function(e,t){for(var n=this.doc.resolve(e),r=this.doc.resolve(t),o=P(n,r),i=0;i<o.length;i++){var a=o[i],s=i==o.length-1;if(s&&0==a||n.node(a).type.contentMatch.validEnd)return this.delete(n.start(a),r.end(a));if(a>0&&(s||n.node(a-1).canReplace(n.index(a-1),r.indexAfter(a-1))))return this.delete(n.before(a),r.after(a))}for(var l=1;l<=n.depth;l++)if(e-n.start(l)==n.depth-l&&t>n.end(l))return this.delete(n.before(l),t);return this.delete(e,t)},t.Transform=u,t.TransformError=c,t.Step=h,t.StepResult=v,t.joinPoint=function(e,t,n){void 0===n&&(n=-1);for(var r=e.resolve(t),o=r.depth;;o--){var i=void 0,a=void 0;if(o==r.depth?(i=r.nodeBefore,a=r.nodeAfter):n>0?(i=r.node(o+1),a=r.node(o).maybeChild(r.index(o)+1)):(i=r.node(o).maybeChild(r.index(o)-1),a=r.node(o+1)),i&&!i.isTextblock&&k(i,a))return t;if(0==o)break;t=n<0?r.before(o):r.after(o)}},t.canJoin=function(e,t){var n=e.resolve(t),r=n.index();return k(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)},t.canSplit=function(e,t,n,r){void 0===n&&(n=1);var o=e.resolve(t),i=o.depth-n,a=r&&r[r.length-1]||o.parent;if(i<0||o.parent.type.spec.isolating||!o.parent.canReplace(o.index(),o.parent.childCount)||!a.type.validContent(o.parent.content.cutByIndex(o.index(),o.parent.childCount)))return!1;for(var s=o.depth-1,l=n-2;s>i;s--,l--){var c=o.node(s),u=o.index(s);if(c.type.spec.isolating)return!1;var f=c.content.cutByIndex(u,c.childCount),p=r&&r[l]||c;if(p!=c&&(f=f.replaceChild(0,p.type.create(p.attrs))),!c.canReplace(u+1,c.childCount)||!p.type.validContent(f))return!1}var d=o.indexAfter(i),h=r&&r[0];return o.node(i).canReplaceWith(d,d,h?h.type:o.node(i+1).type)},t.insertPoint=O,t.dropPoint=function(e,t,n){var r=e.resolve(t);if(!n.content.size)return t;for(var o=n.content,i=0;i<n.openStart;i++)o=o.firstChild.content;for(var a=1;a<=(0==n.openStart&&n.size?2:1);a++)for(var s=r.depth;s>=0;s--){var l=s==r.depth?0:r.pos<=(r.start(s+1)+r.end(s+1))/2?-1:1,c=r.index(s)+(l>0?1:0);if(1==a?r.node(s).canReplace(c,c,o):r.node(s).contentMatchAt(c).findWrapping(o.firstChild.type))return 0==l?r.pos:l<0?r.before(s+1):r.after(s+1)}return null},t.liftTarget=function(e){for(var t=e.parent.content.cutByIndex(e.startIndex,e.endIndex),n=e.depth;;--n){var r=e.$from.node(n),o=e.$from.index(n),i=e.$to.indexAfter(n);if(n<e.depth&&r.canReplace(o,i,t))return n;if(0==n||r.type.spec.isolating||!b(r,o,i))break}},t.findWrapping=function(e,t,n,r){void 0===r&&(r=e);var o=function(e,t){var n=e.parent,r=e.startIndex,o=e.endIndex,i=n.contentMatchAt(r).findWrapping(t);if(!i)return null;var a=i.length?i[0]:t;return n.canReplaceWith(r,o,a)?i:null}(e,t),i=o&&function(e,t){var n=e.parent,r=e.startIndex,o=e.endIndex,i=n.child(r),a=t.contentMatch.findWrapping(i.type);if(!a)return null;for(var s=(a.length?a[a.length-1]:t).contentMatch,l=r;s&&l<o;l++)s=s.matchType(n.child(l).type);if(!s||!s.validEnd)return null;return a}(r,t);return i?o.map(w).concat({type:t,attrs:n}).concat(i.map(w)):null},t.StepMap=s,t.MapResult=a,t.Mapping=l,t.AddMarkStep=S,t.RemoveMarkStep=_,t.ReplaceStep=m,t.ReplaceAroundStep=y,t.replaceStep=C},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(6),o=n(5),i=["ol",0],a=["ul",0],s=["li",0],l={attrs:{order:{default:1}},parseDOM:[{tag:"ol",getAttrs:function(e){return{order:e.hasAttribute("start")?+e.getAttribute("start"):1}}}],toDOM:function(e){return 1==e.attrs.order?i:["ol",{start:e.attrs.order},0]}},c={parseDOM:[{tag:"ul"}],toDOM:function(){return a}},u={parseDOM:[{tag:"li"}],toDOM:function(){return s},defining:!0};function f(e,t){var n={};for(var r in e)n[r]=e[r];for(var o in t)n[o]=t[o];return n}t.orderedList=l,t.bulletList=c,t.listItem=u,t.addListNodes=function(e,t,n){return e.append({ordered_list:f(l,{content:"list_item+",group:n}),bullet_list:f(c,{content:"list_item+",group:n}),list_item:f(u,{content:t})})},t.wrapInList=function(e,t){return function(n,i){var a=n.selection,s=a.$from,l=a.$to,c=s.blockRange(l),u=!1,f=c;if(!c)return!1;if(c.depth>=2&&s.node(c.depth-1).type.compatibleContent(e)&&0==c.startIndex){if(0==s.index(c.depth-1))return!1;var p=n.doc.resolve(c.start-2);f=new o.NodeRange(p,p,c.depth),c.endIndex<c.parent.childCount&&(c=new o.NodeRange(s,n.doc.resolve(l.end(c.depth)),c.depth)),u=!0}var d=r.findWrapping(f,e,t,c);return!!d&&(i&&i(function(e,t,n,i,a){for(var s=o.Fragment.empty,l=n.length-1;l>=0;l--)s=o.Fragment.from(n[l].type.create(n[l].attrs,s));e.step(new r.ReplaceAroundStep(t.start-(i?2:0),t.end,t.start,t.end,new o.Slice(s,0,0),n.length,!0));for(var c=0,u=0;u<n.length;u++)n[u].type==a&&(c=u+1);for(var f=n.length-c,p=t.start+n.length-(i?2:0),d=t.parent,h=t.startIndex,v=t.endIndex,m=!0;h<v;h++,m=!1)!m&&r.canSplit(e.doc,p,f)&&(e.split(p,f),p+=2*f),p+=d.child(h).nodeSize;return e}(n.tr,c,d,u,e).scrollIntoView()),!0)}},t.splitListItem=function(e){return function(t,n){var i=t.selection,a=i.$from,s=i.$to,l=i.node;if(l&&l.isBlock||a.depth<2||!a.sameParent(s))return!1;var c=a.node(-1);if(c.type!=e)return!1;if(0==a.parent.content.size){if(2==a.depth||a.node(-3).type!=e||a.index(-2)!=a.node(-2).childCount-1)return!1;if(n){for(var u=o.Fragment.empty,f=a.index(-1)>0,p=a.depth-(f?1:2);p>=a.depth-3;p--)u=o.Fragment.from(a.node(p).copy(u));u=u.append(o.Fragment.from(e.createAndFill()));var d=t.tr.replace(a.before(f?null:-1),a.after(-3),new o.Slice(u,f?3:2,2));d.setSelection(t.selection.constructor.near(d.doc.resolve(a.pos+(f?3:2)))),n(d.scrollIntoView())}return!0}var h=s.pos==a.end()?c.contentMatchAt(a.indexAfter(-1)).defaultType:null,v=t.tr.delete(a.pos,s.pos),m=h&&[null,{type:h}];return!!r.canSplit(v.doc,a.pos,2,m)&&(n&&n(v.split(a.pos,2,m).scrollIntoView()),!0)}},t.liftListItem=function(e){return function(t,n){var i=t.selection,a=i.$from,s=i.$to,l=a.blockRange(s,(function(t){return t.childCount&&t.firstChild.type==e}));return!!l&&(!n||(a.node(l.depth-1).type==e?function(e,t,n,i){var a=e.tr,s=i.end,l=i.$to.end(i.depth);s<l&&(a.step(new r.ReplaceAroundStep(s-1,l,s,l,new o.Slice(o.Fragment.from(n.create(null,i.parent.copy())),1,0),1,!0)),i=new o.NodeRange(a.doc.resolve(i.$from.pos),a.doc.resolve(l),i.depth));return t(a.lift(i,r.liftTarget(i)).scrollIntoView()),!0}(t,n,e,l):function(e,t,n){for(var i=e.tr,a=n.parent,s=n.end,l=n.endIndex-1,c=n.startIndex;l>c;l--)s-=a.child(l).nodeSize,i.delete(s-1,s+1);var u=i.doc.resolve(n.start),f=u.nodeAfter,p=0==n.startIndex,d=n.endIndex==a.childCount,h=u.node(-1),v=u.index(-1);if(!h.canReplace(v+(p?0:1),v+1,f.content.append(d?o.Fragment.empty:o.Fragment.from(a))))return!1;var m=u.pos,y=m+f.nodeSize;return i.step(new r.ReplaceAroundStep(m-(p?1:0),y+(d?1:0),m+1,y-1,new o.Slice((p?o.Fragment.empty:o.Fragment.from(a.copy(o.Fragment.empty))).append(d?o.Fragment.empty:o.Fragment.from(a.copy(o.Fragment.empty))),p?0:1,d?0:1),p?0:1)),t(i.scrollIntoView()),!0}(t,n,l)))}},t.sinkListItem=function(e){return function(t,n){var i=t.selection,a=i.$from,s=i.$to,l=a.blockRange(s,(function(t){return t.childCount&&t.firstChild.type==e}));if(!l)return!1;var c=l.startIndex;if(0==c)return!1;var u=l.parent,f=u.child(c-1);if(f.type!=e)return!1;if(n){var p=f.lastChild&&f.lastChild.type==u.type,d=o.Fragment.from(p?e.create():null),h=new o.Slice(o.Fragment.from(e.create(null,o.Fragment.from(u.type.create(null,d)))),p?3:1,0),v=l.start,m=l.end;n(t.tr.step(new r.ReplaceAroundStep(v-(p?3:1),m,v,m,h,1,!0)).scrollIntoView())}return!0}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(6),o=n(5),i=n(4);function a(e,t){return!e.selection.empty&&(t&&t(e.tr.deleteSelection().scrollIntoView()),!0)}function s(e,t,n){var o=e.selection.$cursor;if(!o||(n?!n.endOfTextblock("backward",e):o.parentOffset>0))return!1;var a=u(o);if(!a){var s=o.blockRange(),c=s&&r.liftTarget(s);return null!=c&&(t&&t(e.tr.lift(s,c).scrollIntoView()),!0)}var f=a.nodeBefore;if(!f.type.spec.isolating&&w(e,a,t))return!0;if(0==o.parent.content.size&&(l(f,"end")||i.NodeSelection.isSelectable(f))){if(t){var p=e.tr.deleteRange(o.before(),o.after());p.setSelection(l(f,"end")?i.Selection.findFrom(p.doc.resolve(p.mapping.map(a.pos,-1)),-1):i.NodeSelection.create(p.doc,a.pos-f.nodeSize)),t(p.scrollIntoView())}return!0}return!(!f.isAtom||a.depth!=o.depth-1)&&(t&&t(e.tr.delete(a.pos-f.nodeSize,a.pos).scrollIntoView()),!0)}function l(e,t){for(;e;e="start"==t?e.firstChild:e.lastChild)if(e.isTextblock)return!0;return!1}function c(e,t,n){var r=e.selection.$cursor;if(!r||(n?!n.endOfTextblock("backward",e):r.parentOffset>0))return!1;var o=u(r),a=o&&o.nodeBefore;return!(!a||!i.NodeSelection.isSelectable(a))&&(t&&t(e.tr.setSelection(i.NodeSelection.create(e.doc,o.pos-a.nodeSize)).scrollIntoView()),!0)}function u(e){if(!e.parent.type.spec.isolating)for(var t=e.depth-1;t>=0;t--){if(e.index(t)>0)return e.doc.resolve(e.before(t+1));if(e.node(t).type.spec.isolating)break}return null}function f(e,t,n){var r=e.selection.$cursor;if(!r||(n?!n.endOfTextblock("forward",e):r.parentOffset<r.parent.content.size))return!1;var o=d(r);if(!o)return!1;var a=o.nodeAfter;if(w(e,o,t))return!0;if(0==r.parent.content.size&&(l(a,"start")||i.NodeSelection.isSelectable(a))){if(t){var s=e.tr.deleteRange(r.before(),r.after());s.setSelection(l(a,"start")?i.Selection.findFrom(s.doc.resolve(s.mapping.map(o.pos)),1):i.NodeSelection.create(s.doc,s.mapping.map(o.pos))),t(s.scrollIntoView())}return!0}return!(!a.isAtom||o.depth!=r.depth-1)&&(t&&t(e.tr.delete(o.pos,o.pos+a.nodeSize).scrollIntoView()),!0)}function p(e,t,n){var r=e.selection.$cursor;if(!r||(n?!n.endOfTextblock("forward",e):r.parentOffset<r.parent.content.size))return!1;var o=d(r),a=o&&o.nodeAfter;return!(!a||!i.NodeSelection.isSelectable(a))&&(t&&t(e.tr.setSelection(i.NodeSelection.create(e.doc,o.pos)).scrollIntoView()),!0)}function d(e){if(!e.parent.type.spec.isolating)for(var t=e.depth-1;t>=0;t--){var n=e.node(t);if(e.index(t)+1<n.childCount)return e.doc.resolve(e.after(t+1));if(n.type.spec.isolating)break}return null}function h(e,t){var n=e.selection,r=n.$head,o=n.$anchor;return!(!r.parent.type.spec.code||!r.sameParent(o))&&(t&&t(e.tr.insertText("\n").scrollIntoView()),!0)}function v(e,t){var n=e.selection,r=n.$head,o=n.$anchor;if(!r.parent.type.spec.code||!r.sameParent(o))return!1;var a=r.node(-1),s=r.indexAfter(-1),l=a.contentMatchAt(s).defaultType;if(!a.canReplaceWith(s,s,l))return!1;if(t){var c=r.after(),u=e.tr.replaceWith(c,c,l.createAndFill());u.setSelection(i.Selection.near(u.doc.resolve(c),1)),t(u.scrollIntoView())}return!0}function m(e,t){var n=e.selection,r=n.$from,o=n.$to;if(r.parent.inlineContent||o.parent.inlineContent)return!1;var a=r.parent.contentMatchAt(o.indexAfter()).defaultType;if(!a||!a.isTextblock)return!1;if(t){var s=(!r.parentOffset&&o.index()<o.parent.childCount?r:o).pos,l=e.tr.insert(s,a.createAndFill());l.setSelection(i.TextSelection.create(l.doc,s+1)),t(l.scrollIntoView())}return!0}function y(e,t){var n=e.selection.$cursor;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){var o=n.before();if(r.canSplit(e.doc,o))return t&&t(e.tr.split(o).scrollIntoView()),!0}var i=n.blockRange(),a=i&&r.liftTarget(i);return null!=a&&(t&&t(e.tr.lift(i,a).scrollIntoView()),!0)}function g(e,t){var n=e.selection,a=n.$from,s=n.$to;if(e.selection instanceof i.NodeSelection&&e.selection.node.isBlock)return!(!a.parentOffset||!r.canSplit(e.doc,a.pos))&&(t&&t(e.tr.split(a.pos).scrollIntoView()),!0);if(!a.parent.isBlock)return!1;if(t){var l=s.parentOffset==s.parent.content.size,c=e.tr;e.selection instanceof i.TextSelection&&c.deleteSelection();var u=0==a.depth?null:a.node(-1).contentMatchAt(a.indexAfter(-1)).defaultType,f=l&&u?[{type:u}]:null,p=r.canSplit(c.doc,c.mapping.map(a.pos),1,f);f||p||!r.canSplit(c.doc,c.mapping.map(a.pos),1,u&&[{type:u}])||(f=[{type:u}],p=!0),p&&(c.split(c.mapping.map(a.pos),1,f),l||a.parentOffset||a.parent.type==u||!a.node(-1).canReplace(a.index(-1),a.indexAfter(-1),o.Fragment.from(u.create(),a.parent))||c.setNodeMarkup(c.mapping.map(a.before()),u)),t(c.scrollIntoView())}return!0}function b(e,t){return t&&t(e.tr.setSelection(new i.AllSelection(e.doc))),!0}function w(e,t,n){var a,s,l=t.nodeBefore,c=t.nodeAfter;if(l.type.spec.isolating||c.type.spec.isolating)return!1;if(function(e,t,n){var o=t.nodeBefore,i=t.nodeAfter,a=t.index();return!!(o&&i&&o.type.compatibleContent(i.type))&&(!o.content.size&&t.parent.canReplace(a-1,a)?(n&&n(e.tr.delete(t.pos-o.nodeSize,t.pos).scrollIntoView()),!0):!(!t.parent.canReplace(a,a+1)||!i.isTextblock&&!r.canJoin(e.doc,t.pos))&&(n&&n(e.tr.clearIncompatible(t.pos,o.type,o.contentMatchAt(o.childCount)).join(t.pos).scrollIntoView()),!0))}(e,t,n))return!0;if(t.parent.canReplace(t.index(),t.index()+1)&&(a=(s=l.contentMatchAt(l.childCount)).findWrapping(c.type))&&s.matchType(a[0]||c.type).validEnd){if(n){for(var u=t.pos+c.nodeSize,f=o.Fragment.empty,p=a.length-1;p>=0;p--)f=o.Fragment.from(a[p].create(null,f));f=o.Fragment.from(l.copy(f));var d=e.tr.step(new r.ReplaceAroundStep(t.pos-1,u,t.pos,u,new o.Slice(f,1,0),a.length,!0)),h=u+2*a.length;r.canJoin(d.doc,h)&&d.join(h),n(d.scrollIntoView())}return!0}var v=i.Selection.findFrom(t,1),m=v&&v.$from.blockRange(v.$to),y=m&&r.liftTarget(m);return null!=y&&y>=t.depth&&(n&&n(e.tr.lift(m,y).scrollIntoView()),!0)}function k(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];return function(t,n,r){for(var o=0;o<e.length;o++)if(e[o](t,n,r))return!0;return!1}}var O=k(a,s,c),M=k(a,f,p),S={Enter:k(h,m,y,g),"Mod-Enter":v,Backspace:O,"Mod-Backspace":O,Delete:M,"Mod-Delete":M,"Mod-a":b},_={"Ctrl-h":S.Backspace,"Alt-Backspace":S["Mod-Backspace"],"Ctrl-d":S.Delete,"Ctrl-Alt-Backspace":S["Mod-Delete"],"Alt-Delete":S["Mod-Delete"],"Alt-d":S["Mod-Delete"]};for(var C in S)_[C]=S[C];var x=("undefined"!=typeof navigator?/Mac/.test(navigator.platform):"undefined"!=typeof os&&"darwin"==os.platform())?_:S;t.deleteSelection=a,t.joinBackward=s,t.selectNodeBackward=c,t.joinForward=f,t.selectNodeForward=p,t.joinUp=function(e,t){var n,o=e.selection,a=o instanceof i.NodeSelection;if(a){if(o.node.isTextblock||!r.canJoin(e.doc,o.from))return!1;n=o.from}else if(null==(n=r.joinPoint(e.doc,o.from,-1)))return!1;if(t){var s=e.tr.join(n);a&&s.setSelection(i.NodeSelection.create(s.doc,n-e.doc.resolve(n).nodeBefore.nodeSize)),t(s.scrollIntoView())}return!0},t.joinDown=function(e,t){var n,o=e.selection;if(o instanceof i.NodeSelection){if(o.node.isTextblock||!r.canJoin(e.doc,o.to))return!1;n=o.to}else if(null==(n=r.joinPoint(e.doc,o.to,1)))return!1;return t&&t(e.tr.join(n).scrollIntoView()),!0},t.lift=function(e,t){var n=e.selection,o=n.$from,i=n.$to,a=o.blockRange(i),s=a&&r.liftTarget(a);return null!=s&&(t&&t(e.tr.lift(a,s).scrollIntoView()),!0)},t.newlineInCode=h,t.exitCode=v,t.createParagraphNear=m,t.liftEmptyBlock=y,t.splitBlock=g,t.splitBlockKeepMarks=function(e,t){return g(e,t&&function(n){var r=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();r&&n.ensureMarks(r),t(n)})},t.selectParentNode=function(e,t){var n,r=e.selection,o=r.$from,a=r.to,s=o.sharedDepth(a);return 0!=s&&(n=o.before(s),t&&t(e.tr.setSelection(i.NodeSelection.create(e.doc,n))),!0)},t.selectAll=b,t.wrapIn=function(e,t){return function(n,o){var i=n.selection,a=i.$from,s=i.$to,l=a.blockRange(s),c=l&&r.findWrapping(l,e,t);return!!c&&(o&&o(n.tr.wrap(l,c).scrollIntoView()),!0)}},t.setBlockType=function(e,t){return function(n,r){var o=n.selection,i=o.from,a=o.to,s=!1;return n.doc.nodesBetween(i,a,(function(r,o){if(s)return!1;if(r.isTextblock&&!r.hasMarkup(e,t))if(r.type==e)s=!0;else{var i=n.doc.resolve(o),a=i.index();s=i.parent.canReplaceWith(a,a+1,e)}})),!!s&&(r&&r(n.tr.setBlockType(i,a,e,t).scrollIntoView()),!0)}},t.toggleMark=function(e,t){return function(n,r){var o=n.selection,i=o.empty,a=o.$cursor,s=o.ranges;if(i&&!a||!function(e,t,n){for(var r=function(r){var o=t[r],i=o.$from,a=o.$to,s=0==i.depth&&e.type.allowsMarkType(n);if(e.nodesBetween(i.pos,a.pos,(function(e){if(s)return!1;s=e.inlineContent&&e.type.allowsMarkType(n)})),s)return{v:!0}},o=0;o<t.length;o++){var i=r(o);if(i)return i.v}return!1}(n.doc,s,e))return!1;if(r)if(a)e.isInSet(n.storedMarks||a.marks())?r(n.tr.removeStoredMark(e)):r(n.tr.addStoredMark(e.create(t)));else{for(var l=!1,c=n.tr,u=0;!l&&u<s.length;u++){var f=s[u],p=f.$from,d=f.$to;l=n.doc.rangeHasMark(p.pos,d.pos,e)}for(var h=0;h<s.length;h++){var v=s[h],m=v.$from,y=v.$to;l?c.removeMark(m.pos,y.pos,e):c.addMark(m.pos,y.pos,e.create(t))}r(c.scrollIntoView())}return!0}},t.autoJoin=function(e,t){if(Array.isArray(t)){var n=t;t=function(e){return n.indexOf(e.type.name)>-1}}return function(n,o){return e(n,o&&function(e,t){return function(n){if(!n.isGeneric)return e(n);for(var o=[],i=0;i<n.mapping.maps.length;i++){for(var a=n.mapping.maps[i],s=0;s<o.length;s++)o[s]=a.map(o[s]);a.forEach((function(e,t,n,r){return o.push(n,r)}))}for(var l=[],c=0;c<o.length;c+=2)for(var u=o[c],f=o[c+1],p=n.doc.resolve(u),d=p.sharedDepth(f),h=p.node(d),v=p.indexAfter(d),m=p.after(d+1);m<=f;++v){var y=h.maybeChild(v);if(!y)break;if(v&&-1==l.indexOf(m)){var g=h.child(v-1);g.type==y.type&&t(g,y)&&l.push(m)}m+=y.nodeSize}l.sort((function(e,t){return e-t}));for(var b=l.length-1;b>=0;b--)r.canJoin(n.doc,l[b])&&n.join(l[b]);e(n)}}(o,t))}},t.chainCommands=k,t.pcBaseKeymap=S,t.macBaseKeymap=_,t.baseKeymap=x},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();var o=function(){function e(t,n,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.node=t,this.outerView=n,this.getPos=r,this.renderNode(t.attrs)}return r(e,[{key:"renderNode",value:function(e){throw console.log(this.node,e),new Error("renderNode must be implemented by child class!")}}],[{key:"unsetPrefixAttributes",value:function(e,t){var n={};return Object.keys(t).forEach((function(r){r.substr(0,e.length)!==e&&(n[r]=t[r])})),n}}]),e}();t.default=o,window.AbstractNodeView=o},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r,o=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),i=n(39),a=(r=i)&&r.__esModule?r:{default:r};var s=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.items=t}return o(e,[{key:"isAvailable",value:function(e){return this.items.some((function(t){return t.isAvailable(e)}))}},{key:"getMenuItem",value:function(e,t){if(!this.isAvailable(e))throw new Error("None of the items is valid for this Schema!");if(!t)throw new Error("dropdown attributes missing!");return new a.default(this.items.filter((function(t){return t.isAvailable(e)})).map((function(t){return t.getMenuItem(e)})),t)}}]),e}();t.default=s},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r,o=(r=n(30))&&"object"==typeof r&&"default"in r?r.default:r,i=n(6),a=n(4),s=function(e,t){this.items=e,this.eventCount=t};s.prototype.popEvent=function(e,t){var n=this;if(0==this.eventCount)return null;for(var r,o,i=this.items.length;;i--){if(n.items.get(i-1).selection){--i;break}}t&&(r=this.remapping(i,this.items.length),o=r.maps.length);var a,c,u=e.tr,f=[],p=[];return this.items.forEach((function(e,t){if(!e.step)return r||(r=n.remapping(i,t+1),o=r.maps.length),o--,void p.push(e);if(r){p.push(new l(e.map));var d,h=e.step.map(r.slice(o));h&&u.maybeStep(h).doc&&(d=u.mapping.maps[u.mapping.maps.length-1],f.push(new l(d,null,null,f.length+p.length))),o--,d&&r.appendMap(d,o)}else u.maybeStep(e.step);return e.selection?(a=r?e.selection.map(r.slice(o)):e.selection,c=new s(n.items.slice(0,i).append(p.reverse().concat(f)),n.eventCount-1),!1):void 0}),this.items.length,0),{remaining:c,transform:u,selection:a}},s.prototype.addTransform=function(e,t,n,r){for(var o=[],i=this.eventCount,a=this.items,c=!r&&a.length?a.get(a.length-1):null,f=0;f<e.steps.length;f++){var p,d=e.steps[f].invert(e.docs[f]),h=new l(e.mapping.maps[f],d,t);(p=c&&c.merge(h))&&(h=p,f?o.pop():a=a.slice(0,a.length-1)),o.push(h),t&&(i++,t=null),r||(c=h)}var v,m,y,g=i-n.depth;return g>u&&(m=g,(v=a).forEach((function(e,t){if(e.selection&&0==m--)return y=t,!1})),a=v.slice(y),i-=g),new s(a.append(o),i)},s.prototype.remapping=function(e,t){var n=new i.Mapping;return this.items.forEach((function(t,r){var o=null!=t.mirrorOffset&&r-t.mirrorOffset>=e?o=n.maps.length-t.mirrorOffset:null;n.appendMap(t.map,o)}),e,t),n},s.prototype.addMaps=function(e){return 0==this.eventCount?this:new s(this.items.append(e.map((function(e){return new l(e)}))),this.eventCount)},s.prototype.rebased=function(e,t){if(!this.eventCount)return this;var n=[],r=Math.max(0,this.items.length-t),o=e.mapping,i=e.steps.length,a=this.eventCount;this.items.forEach((function(e){e.selection&&a--}),r);var c=t;this.items.forEach((function(t){var r=o.getMirror(--c);if(null!=r){i=Math.min(i,r);var s=o.maps[r];if(t.step){var u=e.steps[r].invert(e.docs[r]),f=t.selection&&t.selection.map(o.slice(c+1,r));f&&a++,n.push(new l(s,u,f))}else n.push(new l(s))}}),r);for(var u=[],f=t;f<i;f++)u.push(new l(o.maps[f]));var p=this.items.slice(0,r).append(u).append(n),d=new s(p,a);return d.emptyItemCount()>500&&(d=d.compress(this.items.length-n.length)),d},s.prototype.emptyItemCount=function(){var e=0;return this.items.forEach((function(t){t.step||e++})),e},s.prototype.compress=function(e){void 0===e&&(e=this.items.length);var t=this.remapping(0,e),n=t.maps.length,r=[],i=0;return this.items.forEach((function(o,a){if(a>=e)r.push(o),o.selection&&i++;else if(o.step){var s=o.step.map(t.slice(n)),c=s&&s.getMap();if(n--,c&&t.appendMap(c,n),s){var u=o.selection&&o.selection.map(t.slice(n));u&&i++;var f,p=new l(c.invert(),s,u),d=r.length-1;(f=r.length&&r[d].merge(p))?r[d]=f:r.push(p)}}else o.map&&n--}),this.items.length,0),new s(o.from(r.reverse()),i)},s.empty=new s(o.empty,0);var l=function(e,t,n,r){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=r};l.prototype.merge=function(e){if(this.step&&e.step&&!e.selection){var t=e.step.merge(this.step);if(t)return new l(t.getMap().invert(),t,this.selection)}};var c=function(e,t,n,r){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r},u=20;function f(e){var t=[];return e.forEach((function(e,n,r,o){return t.push(r,o)})),t}function p(e,t){if(!e)return null;for(var n=[],r=0;r<e.length;r+=2){var o=t.map(e[r],1),i=t.map(e[r+1],-1);o<=i&&n.push(o,i)}return n}function d(e,t,n,r){var o=m(t),i=y.get(t).spec.config,a=(r?e.undone:e.done).popEvent(t,o);if(a){var s=a.selection.resolve(a.transform.doc),l=(r?e.done:e.undone).addTransform(a.transform,t.selection.getBookmark(),i,o),u=new c(r?l:a.remaining,r?a.remaining:l,null,0);n(a.transform.setSelection(s).setMeta(y,{redo:r,historyState:u}).scrollIntoView())}}var h=!1,v=null;function m(e){var t=e.plugins;if(v!=t){h=!1,v=t;for(var n=0;n<t.length;n++)if(t[n].spec.historyPreserveItems){h=!0;break}}return h}var y=new a.PluginKey("history"),g=new a.PluginKey("closeHistory");t.HistoryState=c,t.closeHistory=function(e){return e.setMeta(g,!0)},t.history=function(e){return e={depth:e&&e.depth||100,newGroupDelay:e&&e.newGroupDelay||500},new a.Plugin({key:y,state:{init:function(){return new c(s.empty,s.empty,null,0)},apply:function(t,n,r){return function(e,t,n,r){var o,i=n.getMeta(y);if(i)return i.historyState;n.getMeta(g)&&(e=new c(e.done,e.undone,null,0));var a=n.getMeta("appendedTransaction");if(0==n.steps.length)return e;if(a&&a.getMeta(y))return a.getMeta(y).redo?new c(e.done.addTransform(n,null,r,m(t)),e.undone,f(n.mapping.maps[n.steps.length-1]),e.prevTime):new c(e.done,e.undone.addTransform(n,null,r,m(t)),null,e.prevTime);if(!1===n.getMeta("addToHistory")||a&&!1===a.getMeta("addToHistory"))return(o=n.getMeta("rebased"))?new c(e.done.rebased(n,o),e.undone.rebased(n,o),p(e.prevRanges,n.mapping),e.prevTime):new c(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),p(e.prevRanges,n.mapping),e.prevTime);var l=e.prevTime<(n.time||0)-r.newGroupDelay||!a&&!function(e,t){if(!t)return!1;if(!e.docChanged)return!0;var n=!1;return e.mapping.maps[0].forEach((function(e,r){for(var o=0;o<t.length;o+=2)e<=t[o+1]&&r>=t[o]&&(n=!0)})),n}(n,e.prevRanges),u=a?p(e.prevRanges,n.mapping):f(n.mapping.maps[n.steps.length-1]);return new c(e.done.addTransform(n,l?t.selection.getBookmark():null,r,m(t)),s.empty,u,n.time)}(n,r,t,e)}},config:e})},t.undo=function(e,t){var n=y.getState(e);return!(!n||0==n.done.eventCount)&&(t&&d(n,e,t,!1),!0)},t.redo=function(e,t){var n=y.getState(e);return!(!n||0==n.undone.eventCount)&&(t&&d(n,e,t,!0),!0)},t.undoDepth=function(e){var t=y.getState(e);return t?t.done.eventCount:0},t.redoDepth=function(e){var t=y.getState(e);return t?t.undone.eventCount:0}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setBlockTypeNoAttrCheck=function(e,t){return function(n,r){var o=n.selection,i=o.from,a=o.to,s=!1;return n.doc.nodesBetween(i,a,(function(t,r){if(s)return!1;if(!t.isTextblock||t.type===e)return!0;var o=n.doc.resolve(r),i=o.index();return s=o.parent.canReplaceWith(i,i+1,e),!0})),!!s&&(r&&r(n.tr.setBlockType(i,a,e,t).scrollIntoView()),!0)}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(5),o=n(4),i=n(6),a={};if("undefined"!=typeof navigator&&"undefined"!=typeof document){var s=/Edge\/(\d+)/.exec(navigator.userAgent),l=/MSIE \d/.test(navigator.userAgent),c=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);a.mac=/Mac/.test(navigator.platform);var u=a.ie=!!(l||c||s);a.ie_version=l?document.documentMode||6:c?+c[1]:s?+s[1]:null,a.gecko=!u&&/gecko\/(\d+)/i.test(navigator.userAgent),a.gecko_version=a.gecko&&+(/Firefox\/(\d+)/.exec(navigator.userAgent)||[0,0])[1];var f=!u&&/Chrome\/(\d+)/.exec(navigator.userAgent);a.chrome=!!f,a.chrome_version=f&&+f[1],a.ios=!u&&/AppleWebKit/.test(navigator.userAgent)&&/Mobile\/\w+/.test(navigator.userAgent),a.android=/Android \d/.test(navigator.userAgent),a.webkit=!u&&"WebkitAppearance"in document.documentElement.style,a.safari=/Apple Computer/.test(navigator.vendor),a.webkit_version=a.webkit&&+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]}var p=function(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t},d=function(e){var t=e.parentNode;return t&&11==t.nodeType?t.host:t},h=function(e,t,n){var r=document.createRange();return r.setEnd(e,null==n?e.nodeValue.length:n),r.setStart(e,t||0),r},v=function(e,t,n,r){return n&&(y(e,t,n,r,-1)||y(e,t,n,r,1))},m=/^(img|br|input|textarea|hr)$/i;function y(e,t,n,r,o){for(;;){if(e==n&&t==r)return!0;if(t==(o<0?0:g(e))||3==e.nodeType&&"\ufeff"==e.nodeValue){var i=e.parentNode;if(1!=i.nodeType||(a=void 0,(a=e.pmViewDesc)&&a.node&&a.node.isBlock)||m.test(e.nodeName)||"false"==e.contentEditable)return!1;t=p(e)+(o<0?0:1),e=i}else{if(1!=e.nodeType)return!1;e=e.childNodes[t+(o<0?-1:0)],t=o<0?g(e):0}}var a}function g(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}var b=function(e){var t=e.isCollapsed;return t&&a.chrome&&e.rangeCount&&!e.getRangeAt(0).collapsed&&(t=!1),t};function w(e,t){var n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=e,n.key=n.code=t,n}function k(e){return{left:0,right:e.innerWidth,top:0,bottom:e.innerHeight}}function O(e,t){return"number"==typeof e?e:e[t]}function M(e,t,n){for(var r=e.someProp("scrollThreshold")||0,o=e.someProp("scrollMargin")||5,i=e.dom.ownerDocument,a=i.defaultView,s=n||e.dom;s;s=d(s))if(1==s.nodeType){var l=s==i.body||1!=s.nodeType,c=l?k(a):s.getBoundingClientRect(),u=0,f=0;if(t.top<c.top+O(r,"top")?f=-(c.top-t.top+O(o,"top")):t.bottom>c.bottom-O(r,"bottom")&&(f=t.bottom-c.bottom+O(o,"bottom")),t.left<c.left+O(r,"left")?u=-(c.left-t.left+O(o,"left")):t.right>c.right-O(r,"right")&&(u=t.right-c.right+O(o,"right")),(u||f)&&(l?a.scrollBy(u,f):(f&&(s.scrollTop+=f),u&&(s.scrollLeft+=u))),l)break}}function S(e,t){for(var n,r,o=2e8,i=0,a=t.top,s=t.top,l=e.firstChild,c=0;l;l=l.nextSibling,c++){var u=void 0;if(1==l.nodeType)u=l.getClientRects();else{if(3!=l.nodeType)continue;u=h(l).getClientRects()}for(var f=0;f<u.length;f++){var p=u[f];if(p.top<=a&&p.bottom>=s){a=Math.max(p.bottom,a),s=Math.min(p.top,s);var d=p.left>t.left?p.left-t.left:p.right<t.left?t.left-p.right:0;if(d<o){n=l,o=d,r=d&&3==n.nodeType?{left:p.right<t.left?p.right:p.left,top:t.top}:t,1==l.nodeType&&d&&(i=c+(t.left>=(p.left+p.right)/2?1:0));continue}}!n&&(t.left>=p.right&&t.top>=p.top||t.left>=p.left&&t.top>=p.bottom)&&(i=c+1)}}return n&&3==n.nodeType?function(e,t){for(var n=e.nodeValue.length,r=document.createRange(),o=0;o<n;o++){r.setEnd(e,o+1),r.setStart(e,o);var i=x(r,1);if(i.top!=i.bottom&&_(t,i))return{node:e,offset:o+(t.left>=(i.left+i.right)/2?1:0)}}return{node:e,offset:0}}(n,r):!n||o&&1==n.nodeType?{node:e,offset:i}:S(n,r)}function _(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function C(e,t){var n,r,o=e.root;if(o.caretPositionFromPoint){var i,a=o.caretPositionFromPoint(t.left,t.top);if(a)n=(i=a).offsetNode,r=i.offset}if(!n&&o.caretRangeFromPoint){var s,l=o.caretRangeFromPoint(t.left,t.top);if(l)n=(s=l).startContainer,r=s.startOffset}var c,u=o.elementFromPoint(t.left,t.top+1);if(!u||!e.dom.contains(1!=u.nodeType?u.parentNode:u)){var f=e.dom.getBoundingClientRect();if(!_(t,f))return null;if(!(u=function e(t,n,r){var o=t.childNodes.length;if(o&&r.top<r.bottom)for(var i=Math.max(0,Math.floor(o*(n.top-r.top)/(r.bottom-r.top))-2),a=i;;){var s=t.childNodes[a];if(1==s.nodeType)for(var l=s.getClientRects(),c=0;c<l.length;c++){var u=l[c];if(_(n,u))return e(s,n,u)}if((a=(a+1)%o)==i)break}return t}(e.dom,t,f)))return null}u=function(e,t){var n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left<e.getBoundingClientRect().left?n:e}(u,t),n&&(1==n.nodeType&&(r=Math.min(r,n.childNodes.length)),n==e.dom&&r==n.childNodes.length-1&&1==n.lastChild.nodeType&&t.top>n.lastChild.getBoundingClientRect().bottom?c=e.state.doc.content.size:0!=r&&1==n.nodeType&&"BR"==n.childNodes[r-1].nodeName||(c=function(e,t,n,r){for(var o=-1,i=t;i!=e.dom;){var a=e.docView.nearestDesc(i,!0);if(!a)return null;if(a.node.isBlock&&a.parent){var s=a.dom.getBoundingClientRect();if(s.left>r.left||s.top>r.top)o=a.posBefore;else{if(!(s.right<r.left||s.bottom<r.top))break;o=a.posAfter}}i=a.dom.parentNode}return o>-1?o:e.docView.posFromDOM(t,n)}(e,n,r,t))),null==c&&(c=function(e,t,n){var r=S(t,n),o=r.node,i=r.offset,a=-1;if(1==o.nodeType&&!o.firstChild){var s=o.getBoundingClientRect();a=s.left!=s.right&&n.left>(s.left+s.right)/2?1:-1}return e.docView.posFromDOM(o,i,a)}(e,u,t));var p=e.docView.nearestDesc(u,!0);return{pos:c,inside:p?p.posAtStart-p.border:-1}}function x(e,t){var n=e.getClientRects();return n.length?n[t<0?0:n.length-1]:e.getBoundingClientRect()}function A(e,t){var n=e.docView.domFromPos(t),r=n.node,o=n.offset;if(3==r.nodeType&&(a.chrome||a.gecko)){var i=x(h(r,o,o),0);if(a.gecko&&o&&/\s/.test(r.nodeValue[o-1])&&o<r.nodeValue.length){var s=x(h(r,o-1,o-1),-1);if(Math.abs(s.left-i.left)<1&&s.top==i.top){var l=x(h(r,o,o+1),-1);return T(l,l.left<s.left)}}return i}if(1==r.nodeType&&!e.state.doc.resolve(t).parent.inlineContent){var c,u=!0;if(o<r.childNodes.length){var f=r.childNodes[o];1==f.nodeType&&(c=f.getBoundingClientRect())}if(!c&&o){var p=r.childNodes[o-1];1==p.nodeType&&(c=p.getBoundingClientRect(),u=!1)}return function(e,t){if(0==e.height)return e;var n=t?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}(c||r.getBoundingClientRect(),u)}for(var d=-1;d<2;d+=2)if(d<0&&o){var v=void 0,m=3==r.nodeType?h(r,o-1,o):3==(v=r.childNodes[o-1]).nodeType?h(v):1==v.nodeType&&"BR"!=v.nodeName?v:null;if(m){var y=x(m,1);if(y.top<y.bottom)return T(y,!1)}}else if(d>0&&o<g(r)){var b=void 0,w=3==r.nodeType?h(r,o,o+1):3==(b=r.childNodes[o]).nodeType?h(b):1==b.nodeType?b:null;if(w){var k=x(w,-1);if(k.top<k.bottom)return T(k,!0)}}return T(x(3==r.nodeType?h(r):r,0),!1)}function T(e,t){if(0==e.width)return e;var n=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}function V(e,t,n){var r=e.state,o=e.root.activeElement;r!=t&&e.updateState(t),o!=e.dom&&e.focus();try{return n()}finally{r!=t&&e.updateState(r),o!=e.dom&&o.focus()}}var j=/[\u0590-\u08ac]/;var E=null,P=null,N=!1;function H(e,t,n){return E==t&&P==n?N:(E=t,P=n,N="up"==n||"down"==n?function(e,t,n){var r=t.selection,o="up"==n?r.$anchor.min(r.$head):r.$anchor.max(r.$head);return V(e,t,(function(){for(var t=e.docView.domFromPos(o.pos).node;;){var r=e.docView.nearestDesc(t,!0);if(!r)break;if(r.node.isBlock){t=r.dom;break}t=r.dom.parentNode}for(var i=A(e,o.pos),a=t.firstChild;a;a=a.nextSibling){var s=void 0;if(1==a.nodeType)s=a.getClientRects();else{if(3!=a.nodeType)continue;s=h(a,0,a.nodeValue.length).getClientRects()}for(var l=0;l<s.length;l++){var c=s[l];if(c.bottom>c.top&&("up"==n?c.bottom<i.top+1:c.top>i.bottom-1))return!1}}return!0}))}(e,t,n):function(e,t,n){var r=t.selection.$head;if(!r.parent.isTextblock)return!1;var o=r.parentOffset,i=!o,a=o==r.parent.content.size,s=getSelection();return j.test(r.parent.textContent)&&s.modify?V(e,t,(function(){var t=s.getRangeAt(0),o=s.focusNode,i=s.focusOffset;s.modify("move",n,"character");var a=!(r.depth?e.docView.domAfterPos(r.before()):e.dom).contains(1==s.focusNode.nodeType?s.focusNode:s.focusNode.parentNode)||o==s.focusNode&&i==s.focusOffset;return s.removeAllRanges(),s.addRange(t),a})):"left"==n||"backward"==n?i:a}(e,t,n))}var L=function(e,t,n,r){this.parent=e,this.children=t,this.dom=n,n.pmViewDesc=this,this.contentDOM=r,this.dirty=0},D={beforePosition:{},size:{},border:{},posBefore:{},posAtStart:{},posAfter:{},posAtEnd:{},contentLost:{}};L.prototype.matchesWidget=function(){return!1},L.prototype.matchesMark=function(){return!1},L.prototype.matchesNode=function(){return!1},L.prototype.matchesHack=function(){return!1},D.beforePosition.get=function(){return!1},L.prototype.parseRule=function(){return null},L.prototype.stopEvent=function(){return!1},D.size.get=function(){for(var e=0,t=0;t<this.children.length;t++)e+=this.children[t].size;return e},D.border.get=function(){return 0},L.prototype.destroy=function(){this.parent=null,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=null);for(var e=0;e<this.children.length;e++)this.children[e].destroy()},L.prototype.posBeforeChild=function(e){for(var t=0,n=this.posAtStart;t<this.children.length;t++){var r=this.children[t];if(r==e)return n;n+=r.size}},D.posBefore.get=function(){return this.parent.posBeforeChild(this)},D.posAtStart.get=function(){return this.parent?this.parent.posBeforeChild(this)+this.border:0},D.posAfter.get=function(){return this.posBefore+this.size},D.posAtEnd.get=function(){return this.posAtStart+this.size-2*this.border},L.prototype.localPosFromDOM=function(e,t,n){var r;if(this.contentDOM&&this.contentDOM.contains(1==e.nodeType?e:e.parentNode)){if(n<0){var o,i;if(e==this.contentDOM)o=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;o=e.previousSibling}for(;o&&(!(i=o.pmViewDesc)||i.parent!=this);)o=o.previousSibling;return o?this.posBeforeChild(i)+i.size:this.posAtStart}var a,s;if(e==this.contentDOM)a=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;a=e.nextSibling}for(;a&&(!(s=a.pmViewDesc)||s.parent!=this);)a=a.nextSibling;return a?this.posBeforeChild(s):this.posAtEnd}if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))r=2&e.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==t)for(var l=e;;l=l.parentNode){if(l==this.dom){r=!1;break}if(l.parentNode.firstChild!=l)break}if(null==r&&t==e.childNodes.length)for(var c=e;;c=c.parentNode){if(c==this.dom){r=!0;break}if(c.parentNode.lastChild!=c)break}}return(null==r?n>0:r)?this.posAtEnd:this.posAtStart},L.prototype.nearestDesc=function(e,t){for(var n=!0,r=e;r;r=r.parentNode){var o=this.getDesc(r);if(o&&(!t||o.node)){if(!n||!o.nodeDOM||(1==o.nodeDOM.nodeType?o.nodeDOM.contains(e):o.nodeDOM==e))return o;n=!1}}},L.prototype.getDesc=function(e){for(var t=e.pmViewDesc,n=t;n;n=n.parent)if(n==this)return t},L.prototype.posFromDOM=function(e,t,n){for(var r=e;;r=r.parentNode){var o=this.getDesc(r);if(o)return o.localPosFromDOM(e,t,n)}},L.prototype.descAt=function(e){for(var t=0,n=0;t<this.children.length;t++){var r=this.children[t],o=n+r.size;if(n==e&&o!=n){for(;!r.border&&r.children.length;)r=r.children[0];return r}if(e<o)return r.descAt(e-n-r.border);n=o}},L.prototype.domFromPos=function(e){if(!this.contentDOM)return{node:this.dom,offset:0};for(var t=0,n=0;;n++){if(t==e){for(;n<this.children.length&&(this.children[n].beforePosition||this.children[n].dom.parentNode!=this.contentDOM);)n++;return{node:this.contentDOM,offset:n==this.children.length?this.contentDOM.childNodes.length:p(this.children[n].dom)}}if(n==this.children.length)throw new Error("Invalid position "+e);var r=this.children[n],o=t+r.size;if(e<o)return r.domFromPos(e-t-r.border);t=o}},L.prototype.parseRange=function(e,t,n){if(void 0===n&&(n=0),0==this.children.length)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};for(var r=-1,o=-1,i=n,a=0;;a++){var s=this.children[a],l=i+s.size;if(-1==r&&e<=l){var c=i+s.border;if(e>=c&&t<=l-s.border&&s.node&&s.contentDOM&&this.contentDOM.contains(s.contentDOM))return s.parseRange(e,t,c);e=i;for(var u=a;u>0;u--){var f=this.children[u-1];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(1)){r=p(f.dom)+1;break}e-=f.size}-1==r&&(r=0)}if(r>-1&&t<=l){t=l;for(var d=a+1;d<this.children.length;d++){var h=this.children[d];if(h.size&&h.dom.parentNode==this.contentDOM&&!h.emptyChildAt(-1)){o=p(h.dom);break}t+=h.size}-1==o&&(o=this.contentDOM.childNodes.length);break}i=l}return{node:this.contentDOM,from:e,to:t,fromOffset:r,toOffset:o}},L.prototype.emptyChildAt=function(e){if(this.border||!this.contentDOM||!this.children.length)return!1;var t=this.children[e<0?0:this.children.length-1];return 0==t.size||t.emptyChildAt(e)},L.prototype.domAfterPos=function(e){var t=this.domFromPos(e),n=t.node,r=t.offset;if(1!=n.nodeType||r==n.childNodes.length)throw new RangeError("No node after pos "+e);return n.childNodes[r]},L.prototype.setSelection=function(e,t,n,r){for(var o=Math.min(e,t),i=Math.max(e,t),a=0,s=0;a<this.children.length;a++){var l=this.children[a],c=s+l.size;if(o>s&&i<c)return l.setSelection(e-s-l.border,t-s-l.border,n,r);s=c}var u=this.domFromPos(e),f=this.domFromPos(t),p=n.getSelection(),d=document.createRange();if(r||!v(u.node,u.offset,p.anchorNode,p.anchorOffset)||!v(f.node,f.offset,p.focusNode,p.focusOffset)){if(p.extend)d.setEnd(u.node,u.offset),d.collapse(!1);else{if(e>t){var h=u;u=f,f=h}d.setEnd(f.node,f.offset),d.setStart(u.node,u.offset)}p.removeAllRanges(),p.addRange(d),p.extend&&p.extend(f.node,f.offset)}},L.prototype.ignoreMutation=function(e){return!this.contentDOM},D.contentLost.get=function(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)},L.prototype.markDirty=function(e,t){for(var n=0,r=0;r<this.children.length;r++){var o=this.children[r],i=n+o.size;if(n==i?e<=i&&t>=n:e<i&&t>n){var a=n+o.border,s=i-o.border;if(e>=a&&t<=s)return this.dirty=e==n||t==i?2:1,void(e==a&&t==s&&o.contentLost?o.dirty=3:o.markDirty(e-a,t-a));o.dirty=3}n=i}this.dirty=2},L.prototype.markParentsDirty=function(){for(var e=this.parent;e;e=e.parent){e.dirty<2&&(e.dirty=2)}},Object.defineProperties(L.prototype,D);var I=[],R=function(e){function t(t,n,r,o){var i,a=n.type.toDOM;if("function"==typeof a&&(a=a(r,(function(){return i?i.parent?i.parent.posBeforeChild(i):void 0:o}))),!n.type.spec.raw){if(1!=a.nodeType){var s=document.createElement("span");s.appendChild(a),a=s}a.contentEditable=!1,a.classList.add("ProseMirror-widget")}e.call(this,t,I,a,null),this.widget=n,i=this}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={beforePosition:{}};return n.beforePosition.get=function(){return this.widget.type.side<0},t.prototype.matchesWidget=function(e){return 0==this.dirty&&e.type.eq(this.widget.type)},t.prototype.parseRule=function(){return{ignore:!0}},t.prototype.stopEvent=function(e){var t=this.widget.spec.stopEvent;return!!t&&t(e)},Object.defineProperties(t.prototype,n),t}(L),$=function(e){function t(){e.apply(this,arguments)}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.parseRule=function(){return{skip:ie(this.dom)}},t.prototype.ignoreMutation=function(){return!1},t}(R),F=function(e){function t(t,n,r,o){e.call(this,t,I,n,null),this.textDOM=r,this.text=o}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={size:{}};return n.size.get=function(){return this.text.length},t.prototype.parseRule=function(){return{skip:ie(this.dom)}},t.prototype.localPosFromDOM=function(e,t){if(e!=this.textDOM)return this.posAtStart+(t?this.size:0);var n=this.textDOM.nodeValue.indexOf("\ufeff");return this.posAtStart+t-(n>-1&&n<t?1:0)},t.prototype.domFromPos=function(e){var t=this.textDOM.nodeValue.indexOf("\ufeff");return{node:this.textDOM,offset:e+(t>-1&&t<=e?1:0)}},t.prototype.ignoreMutation=function(){return!1},Object.defineProperties(t.prototype,n),t}(L),z=function(e){function t(t,n,r,o){e.call(this,t,[],r,o),this.mark=n}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.create=function(e,n,o,i){var a=i.nodeViews[n.type.name],s=a&&a(n,i,o);return s&&s.dom||(s=r.DOMSerializer.renderSpec(document,n.type.spec.toDOM(n,o))),new t(e,n,s.dom,s.contentDOM||s.dom)},t.prototype.parseRule=function(){return{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}},t.prototype.matchesMark=function(e){return 3!=this.dirty&&this.mark.eq(e)},t.prototype.markDirty=function(t,n){if(e.prototype.markDirty.call(this,t,n),0!=this.dirty){for(var r=this.parent;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=0}},t.prototype.slice=function(e,n,r){var o=t.create(this.parent,this.mark,!0,r),i=this.children,a=this.size;n<a&&(i=oe(i,n,a,r)),e>0&&(i=oe(i,0,e,r));for(var s=0;s<i.length;s++)i[s].parent=o;return o.children=i,o},t}(L),B=function(e){function t(t,n,r,o,i,a,s,l,c){e.call(this,t,n.isLeaf?I:[],i,a),this.nodeDOM=s,this.node=n,this.outerDeco=r,this.innerDeco=o,a&&this.updateChildren(l,c)}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={size:{},border:{}};return t.create=function(e,n,o,i,a,s){var l,c=a.nodeViews[n.type.name],u=c&&c(n,a,(function(){return l?l.parent?l.parent.posBeforeChild(l):void 0:s}),o),f=u&&u.dom,p=u&&u.contentDOM;if(n.isText)if(f){if(3!=f.nodeType)throw new RangeError("Text must be rendered as a DOM text node")}else f=document.createTextNode(n.text);else if(!f){var d;f=(d=r.DOMSerializer.renderSpec(document,n.type.spec.toDOM(n))).dom,p=d.contentDOM}p||n.isText||"BR"==f.nodeName||(f.hasAttribute("contenteditable")||(f.contentEditable=!1),n.type.spec.draggable&&(f.draggable=!0));var h=f;return f=Y(f,o,n),u?l=new K(e,n,o,i,f,p,h,u,a,s+1):n.isText?new W(e,n,o,i,f,h,a):new t(e,n,o,i,f,p,h,a,s+1)},t.prototype.parseRule=function(){var e=this;if(this.node.type.spec.reparseInView)return null;var t={node:this.node.type.name,attrs:this.node.attrs};return this.node.type.spec.code&&(t.preserveWhitespace="full"),this.contentDOM&&!this.contentLost?t.contentElement=this.contentDOM:t.getContent=function(){return e.contentDOM?r.Fragment.empty:e.node.content},t},t.prototype.matchesNode=function(e,t,n){return 0==this.dirty&&e.eq(this.node)&&ee(t,this.outerDeco)&&n.eq(this.innerDeco)},n.size.get=function(){return this.node.nodeSize},n.border.get=function(){return this.node.isLeaf?0:1},t.prototype.updateChildren=function(e,t){var n=this,o=this.node.inlineContent,i=t,a=o&&e.composing&&this.localCompositionNode(e,t),s=new ne(this,a&&a.node);!function(e,t,n,r){var o=t.locals(e),i=0;if(0==o.length){for(var a=0;a<e.childCount;a++){var s=e.child(a);r(s,o,t.forChild(i,s),a),i+=s.nodeSize}return}for(var l=0,c=[],u=null,f=0;;){if(l<o.length&&o[l].to==i){for(var p=o[l++],d=void 0;l<o.length&&o[l].to==i;)(d||(d=[p])).push(o[l++]);if(d){d.sort(re);for(var h=0;h<d.length;h++)n(d[h],f)}else n(p,f)}var v=void 0,m=void 0;if(u)m=-1,v=u,u=null;else{if(!(f<e.childCount))break;m=f,v=e.child(f++)}for(var y=0;y<c.length;y++)c[y].to<=i&&c.splice(y--,1);for(;l<o.length&&o[l].from==i;)c.push(o[l++]);var g=i+v.nodeSize;if(v.isText){var b=g;l<o.length&&o[l].from<b&&(b=o[l].from);for(var w=0;w<c.length;w++)c[w].to<b&&(b=c[w].to);b<g&&(u=v.cut(b-i),v=v.cut(0,b-i),g=b,m=-1)}r(v,c.length?c.slice():I,t.forChild(i,v),m),i=g}}(this.node,this.innerDeco,(function(t,a){t.spec.marks?s.syncToMarks(t.spec.marks,o,e):t.type.side>=0&&s.syncToMarks(a==n.node.childCount?r.Mark.none:n.node.child(a).marks,o,e),s.placeWidget(t,e,i)}),(function(t,n,r,a){s.syncToMarks(t.marks,o,e),s.findNodeMatch(t,n,r,a)||s.updateNextNode(t,n,r,e,a)||s.addNode(t,n,r,e,i),i+=t.nodeSize})),s.syncToMarks(I,o,e),this.node.isTextblock&&s.addTextblockHacks(),s.destroyRest(),(s.changed||2==this.dirty)&&(a&&this.protectLocalComposition(e,a),this.renderChildren())},t.prototype.renderChildren=function(){!function e(t,n){for(var r=t.firstChild,o=0;o<n.length;o++){var i=n[o],a=i.dom;if(a.parentNode==t){for(;a!=r;)r=te(r);r=r.nextSibling}else t.insertBefore(a,r);if(i instanceof z){var s=r?r.previousSibling:t.lastChild;e(i.contentDOM,i.children),r=s?s.nextSibling:t.firstChild}}for(;r;)r=te(r)}(this.contentDOM,this.children,t.is),a.ios&&function(e){if("UL"==e.nodeName||"OL"==e.nodeName){var t=e.style.cssText;e.style.cssText=t+"; list-style: square !important",window.getComputedStyle(e).listStyle,e.style.cssText=t}}(this.dom)},t.prototype.localCompositionNode=function(e,t){var n=e.state.selection,r=n.from,i=n.to;if(!(!(e.state.selection instanceof o.TextSelection)||r<t||i>t+this.node.content.size)){var a=e.root.getSelection(),s=function(e,t){for(;;){if(3==e.nodeType)return e;if(1==e.nodeType&&t>0)e=e.childNodes[t-1],t=g(e);else{if(!(1==e.nodeType&&t<e.childNodes.length))return null;e=e.childNodes[t],t=0}}}(a.focusNode,a.focusOffset);if(s&&this.dom.contains(s.parentNode)){var l=s.nodeValue.replace(/\ufeff/g,""),c=function(e,t,n,r){for(var o="",i=0,a=0;i<e.childCount;i++){var s=e.child(i),l=a+s.nodeSize;if(s.isText){if(o+=s.text,l>=r){for(var c=l-o.length,u=o.lastIndexOf(t);u>-1&&c+u>n;)u=o.lastIndexOf(t,u-1);if(u>-1&&c+u+t.length>=r)return c+u;if(l>r-t.length)break}}else o="";a=l}return-1}(this.node.content,l,r-t,i-t);return c<0?null:{node:s,pos:c,text:l}}}},t.prototype.protectLocalComposition=function(e,t){var n=t.node,r=t.pos,o=t.text;if(!this.getDesc(n)){for(var i=n;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=null)}var a=new F(this,i,n,o);e.compositionNodes.push(a),this.children=oe(this.children,r,r+o.length,e,a)}},t.prototype.update=function(e,t,n,r){return!(3==this.dirty||!e.sameMarkup(this.node))&&(this.updateInner(e,t,n,r),!0)},t.prototype.updateInner=function(e,t,n,r){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=0},t.prototype.updateOuterDeco=function(e){if(!ee(e,this.outerDeco)){var t=1!=this.nodeDOM.nodeType,n=this.dom;this.dom=U(this.dom,this.nodeDOM,Z(this.outerDeco,this.node,t),Z(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=null,this.dom.pmViewDesc=this),this.outerDeco=e}},t.prototype.selectNode=function(){this.nodeDOM.classList.add("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||(this.dom.draggable=!0)},t.prototype.deselectNode=function(){this.nodeDOM.classList.remove("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||(this.dom.draggable=!1)},Object.defineProperties(t.prototype,n),t}(L);function J(e,t,n,r,o){return Y(r,t,e),new B(null,e,t,n,r,r,r,o,0)}var W=function(e){function t(t,n,r,o,i,a,s){e.call(this,t,n,r,o,i,null,a,s)}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.parseRule=function(){var e=this.nodeDOM.parentNode;return e?{skip:e}:{ignore:!0}},t.prototype.update=function(e,t){return!(3==this.dirty||0!=this.dirty&&!this.inParent()||!e.sameMarkup(this.node))&&(this.updateOuterDeco(t),0==this.dirty&&e.text==this.node.text||e.text==this.nodeDOM.nodeValue||(this.nodeDOM.nodeValue=e.text),this.node=e,this.dirty=0,!0)},t.prototype.inParent=function(){for(var e=this.parent.contentDOM,t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1},t.prototype.domFromPos=function(e){return{node:this.nodeDOM,offset:e}},t.prototype.localPosFromDOM=function(t,n,r){return t==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):e.prototype.localPosFromDOM.call(this,t,n,r)},t.prototype.ignoreMutation=function(e){return"characterData"!=e.type},t.prototype.slice=function(e,n,r){var o=this.node.cut(e,n),i=document.createTextNode(o.text);return new t(this.parent,o,this.outerDeco,this.innerDeco,i,i,r)},t}(B),q=function(e){function t(){e.apply(this,arguments)}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.parseRule=function(){return{ignore:!0}},t.prototype.matchesHack=function(){return 0==this.dirty},t}(L),K=function(e){function t(t,n,r,o,i,a,s,l,c,u){e.call(this,t,n,r,o,i,a,s,c,u),this.spec=l}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.update=function(t,n,r,o){if(3==this.dirty)return!1;if(this.spec.update){var i=this.spec.update(t,n);return i&&this.updateInner(t,n,r,o),i}return!(!this.contentDOM&&!t.isLeaf)&&e.prototype.update.call(this,t,n,r,o)},t.prototype.selectNode=function(){this.spec.selectNode?this.spec.selectNode():e.prototype.selectNode.call(this)},t.prototype.deselectNode=function(){this.spec.deselectNode?this.spec.deselectNode():e.prototype.deselectNode.call(this)},t.prototype.setSelection=function(t,n,r,o){this.spec.setSelection?this.spec.setSelection(t,n,r):e.prototype.setSelection.call(this,t,n,r,o)},t.prototype.destroy=function(){this.spec.destroy&&this.spec.destroy(),e.prototype.destroy.call(this)},t.prototype.stopEvent=function(e){return!!this.spec.stopEvent&&this.spec.stopEvent(e)},t.prototype.ignoreMutation=function(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):e.prototype.ignoreMutation.call(this,t)},t}(B);function G(e){e&&(this.nodeName=e)}G.prototype=Object.create(null);var Q=[new G];function Z(e,t,n){if(0==e.length)return Q;for(var r=n?Q[0]:new G,o=[r],i=0;i<e.length;i++){var a=e[i].type.attrs,s=r;if(a)for(var l in a.nodeName&&o.push(s=new G(a.nodeName)),a){var c=a[l];null!=c&&(n&&1==o.length&&o.push(s=r=new G(t.isInline?"span":"div")),"class"==l?s.class=(s.class?s.class+" ":"")+c:"style"==l?s.style=(s.style?s.style+";":"")+c:"nodeName"!=l&&(s[l]=c))}}return o}function U(e,t,n,r){if(n==Q&&r==Q)return t;for(var o=t,i=0;i<r.length;i++){var a=r[i],s=n[i];if(i){var l=void 0;s&&s.nodeName==a.nodeName&&o!=e&&(l=t.parentNode)&&l.tagName.toLowerCase()==a.nodeName||(l=document.createElement(a.nodeName)).appendChild(o),o=l}X(o,s||Q[0],a)}return o}function X(e,t,n){for(var r in t)"class"==r||"style"==r||"nodeName"==r||r in n||e.removeAttribute(r);for(var o in n)"class"!=o&&"style"!=o&&"nodeName"!=o&&n[o]!=t[o]&&e.setAttribute(o,n[o]);if(t.class!=n.class){for(var i=t.class?t.class.split(" "):I,a=n.class?n.class.split(" "):I,s=0;s<i.length;s++)-1==a.indexOf(i[s])&&e.classList.remove(i[s]);for(var l=0;l<a.length;l++)-1==i.indexOf(a[l])&&e.classList.add(a[l])}if(t.style!=n.style){if(t.style)for(var c,u=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g;c=u.exec(t.style);)e.style[c[1].toLowerCase()]="";n.style&&(e.style.cssText+=n.style)}}function Y(e,t,n){return U(e,e,Q,Z(t,n,1!=e.nodeType))}function ee(e,t){if(e.length!=t.length)return!1;for(var n=0;n<e.length;n++)if(!e[n].type.eq(t[n].type))return!1;return!0}function te(e){var t=e.nextSibling;return e.parentNode.removeChild(e),t}var ne=function(e,t){this.top=e,this.lock=t,this.index=0,this.stack=[],this.changed=!1;var n=function(e,t){for(var n=[],r=e.childCount,o=t.length-1;r>0&&o>=0;o--){var i=t[o],a=i.node;if(a){if(a!=e.child(r-1))break;n.push(i),--r}}return{nodes:n.reverse(),offset:r}}(e.node.content,e.children);this.preMatched=n.nodes,this.preMatchOffset=n.offset};function re(e,t){return e.type.side-t.type.side}function oe(e,t,n,r,o){for(var i=[],a=0,s=0;a<e.length;a++){var l=e[a],c=s,u=s+=l.size;c>=n||u<=t?i.push(l):(c<t&&i.push(l.slice(0,t-c,r)),o&&(i.push(o),o=null),u>n&&i.push(l.slice(n-c,l.size,r)))}return i}function ie(e){var t=e.cloneNode(!0);return function e(t){if(1==t.nodeType)for(var n=t.firstChild;n;n=n.nextSibling)e(n);else 3==t.nodeType&&(t.nodeValue=t.nodeValue.replace(/\ufeff/g,""))}(t),t}function ae(e,t){var n=e.selection,r=n.$anchor,i=n.$head,a=t>0?r.max(i):r.min(i),s=a.parent.inlineContent?a.depth?e.doc.resolve(t>0?a.after():a.before()):null:a;return s&&o.Selection.findFrom(s,t)}function se(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function le(e,t,n){var r=e.state.selection;if(r instanceof o.TextSelection){if(!r.empty||n.indexOf("s")>-1)return!1;if(e.endOfTextblock(t>0?"right":"left")){var i=ae(e.state,t);return!!(i&&i instanceof o.NodeSelection)&&se(e,i)}var s,l=r.$head,c=l.textOffset?null:t<0?l.nodeBefore:l.nodeAfter;if(!c||c.isText)return!1;var u=t<0?l.pos-c.nodeSize:l.pos;return!!(c.isAtom||(s=e.docView.descAt(u))&&!s.contentDOM)&&(o.NodeSelection.isSelectable(c)?se(e,new o.NodeSelection(t<0?e.state.doc.resolve(l.pos-c.nodeSize):l)):!!a.webkit&&se(e,new o.TextSelection(e.state.doc.resolve(t<0?u:u+c.nodeSize))))}if(r instanceof o.NodeSelection&&r.node.isInline)return se(e,new o.TextSelection(t>0?r.$to:r.$from));var f=ae(e.state,t);return!!f&&se(e,f)}function ce(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function ue(e){var t=e.pmViewDesc;return t&&0==t.size&&(e.nextSibling||"BR"!=e.nodeName)}function fe(e){var t=e.root.getSelection(),n=t.focusNode,r=t.focusOffset;if(n){var o,i,s=!1;for(a.gecko&&1==n.nodeType&&r<ce(n)&&ue(n.childNodes[r])&&(s=!0);;)if(r>0)if(1!=n.nodeType){if(3!=n.nodeType||"\ufeff"!=n.nodeValue.charAt(r-1))break;a.ie&&a.ie_version<=11&&(s=!0),o=n,i=--r}else{var l=n.childNodes[r-1];if(ue(l))o=n,i=--r;else{if(3!=l.nodeType)break;r=(n=l).nodeValue.length}}else{if(de(n))break;for(var c=n.previousSibling;c&&ue(c);)o=n.parentNode,i=p(c),c=c.previousSibling;if(c)r=ce(n=c);else{if((n=n.parentNode)==e.dom)break;r=0}}s?he(e,t,n,r):o&&he(e,t,o,i)}}function pe(e){var t=e.root.getSelection(),n=t.focusNode,r=t.focusOffset;if(n){for(var o,i,a=ce(n);;)if(r<a){if(1!=n.nodeType)break;if(!ue(n.childNodes[r]))break;o=n,i=++r}else{if(de(n))break;for(var s=n.nextSibling;s&&ue(s);)o=s.parentNode,i=p(s)+1,s=s.nextSibling;if(s)r=0,a=ce(n=s);else{if((n=n.parentNode)==e.dom)break;r=a=0}}o&&he(e,t,o,i)}}function de(e){var t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function he(e,t,n,r){if(b(t)){var o=document.createRange();o.setEnd(n,r),o.setStart(n,r),t.removeAllRanges(),t.addRange(o)}else t.extend&&t.extend(n,r);e.domObserver.setCurSelection()}function ve(e,t,n){var r=e.state.selection;if(r instanceof o.TextSelection&&!r.empty||n.indexOf("s")>-1)return!1;var i=r.$from,a=r.$to;if(!i.parent.inlineContent||e.endOfTextblock(t<0?"up":"down")){var s=ae(e.state,t);if(s&&s instanceof o.NodeSelection)return se(e,s)}if(!i.parent.inlineContent){var l=o.Selection.findFrom(t<0?i:a,t);return!l||se(e,l)}return!1}function me(e,t){if(!(e.state.selection instanceof o.TextSelection))return!0;var n=e.state.selection,r=n.$head,i=n.$anchor,a=n.empty;if(!r.sameParent(i))return!0;if(!a)return!1;if(e.endOfTextblock(t>0?"forward":"backward"))return!0;var s=!r.textOffset&&(t<0?r.nodeBefore:r.nodeAfter);if(s&&!s.isText){var l=e.state.tr;return t<0?l.delete(r.pos-s.nodeSize,r.pos):l.delete(r.pos,r.pos+s.nodeSize),e.dispatch(l),!0}return!1}function ye(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function ge(e,t){var n=t.keyCode,r=function(e){var t="";return e.ctrlKey&&(t+="c"),e.metaKey&&(t+="m"),e.altKey&&(t+="a"),e.shiftKey&&(t+="s"),t}(t);return 8==n||a.mac&&72==n&&"c"==r?me(e,-1)||fe(e):46==n||a.mac&&68==n&&"c"==r?me(e,1)||pe(e):13==n||27==n||(37==n?le(e,-1,r)||fe(e):39==n?le(e,1,r)||pe(e):38==n?ve(e,-1,r)||fe(e):40==n?function(e){if(a.chrome&&!(e.state.selection.$head.parentOffset>0)){var t=e.root.getSelection(),n=t.focusNode,r=t.focusOffset;if(n&&1==n.nodeType&&0==r&&n.firstChild&&"false"==n.firstChild.contentEditable){var o=n.firstChild;ye(e,o,!0),setTimeout((function(){return ye(e,o,!1)}),20)}}}(e)||ve(e,1,r)||pe(e):r==(a.mac?"m":"c")&&(66==n||73==n||89==n||90==n))}function be(e,t,n){var r=e.state.selection;if(Oe(e,r),e.editable&&!e.hasFocus()){if(!t)return;a.gecko&&a.gecko_version<=55&&(e.domObserver.disconnectSelection(),e.dom.focus(),e.domObserver.connectSelection())}else if(!(e.editable||_e(e)&&document.activeElement.contains(e.dom)||t))return;if(e.domObserver.disconnectSelection(),e.cursorWrapper)!function(e){var t=e.root.getSelection(),n=document.createRange(),r=e.cursorWrapper.dom;n.setEnd(r,r.childNodes.length),n.collapse(!1),t.removeAllRanges(),t.addRange(n),!e.state.selection.visible&&a.ie&&a.ie_version<=11&&(r.disabled=!0,r.disabled=!1)}(e);else{var i,s,l=r.anchor,c=r.head;!we||r instanceof o.TextSelection||(r.$from.parent.inlineContent||(i=ke(e,r.from)),r.empty||r.$from.parent.inlineContent||(s=ke(e,r.to))),e.docView.setSelection(l,c,e.root,n),we&&(i&&(i.contentEditable="false"),s&&(s.contentEditable="false")),r.visible?e.dom.classList.remove("ProseMirror-hideselection"):l!=c&&(e.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&function(e){var t=e.dom.ownerDocument;t.removeEventListener("selectionchange",e.hideSelectionGuard);var n=e.root.getSelection(),r=n.anchorNode,o=n.anchorOffset;t.addEventListener("selectionchange",e.hideSelectionGuard=function(){n.anchorNode==r&&n.anchorOffset==o||(t.removeEventListener("selectionchange",e.hideSelectionGuard),e.dom.classList.remove("ProseMirror-hideselection"))})}(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}ne.prototype.getPreMatch=function(e){return e>=this.preMatchOffset?this.preMatched[e-this.preMatchOffset]:null},ne.prototype.destroyBetween=function(e,t){if(e!=t){for(var n=e;n<t;n++)this.top.children[n].destroy();this.top.children.splice(e,t-e),this.changed=!0}},ne.prototype.destroyRest=function(){this.destroyBetween(this.index,this.top.children.length)},ne.prototype.syncToMarks=function(e,t,n){for(var r=0,o=this.stack.length>>1,i=Math.min(o,e.length);r<i&&(r==o-1?this.top:this.stack[r+1<<1]).matchesMark(e[r])&&!1!==e[r].type.spec.spanning;)r++;for(;r<o;)this.destroyRest(),this.top.dirty=0,this.index=this.stack.pop(),this.top=this.stack.pop(),o--;for(;o<e.length;){this.stack.push(this.top,this.index+1);for(var a=-1,s=this.index;s<Math.min(this.index+3,this.top.children.length);s++)if(this.top.children[s].matchesMark(e[o])){a=s;break}if(a>-1)a>this.index&&(this.changed=!0,this.top.children.splice(this.index,a-this.index)),this.top=this.top.children[this.index];else{var l=z.create(this.top,e[o],t,n);this.top.children.splice(this.index,0,l),this.top=l,this.changed=!0}this.index=0,o++}},ne.prototype.findNodeMatch=function(e,t,n,r){var o=-1,i=r<0?void 0:this.getPreMatch(r),a=this.top.children;if(i&&i.matchesNode(e,t,n))o=a.indexOf(i);else for(var s=this.index,l=Math.min(a.length,s+5);s<l;s++){var c=a[s];if(c.matchesNode(e,t,n)&&this.preMatched.indexOf(c)<0){o=s;break}}return!(o<0)&&(this.destroyBetween(this.index,o),this.index++,!0)},ne.prototype.updateNextNode=function(e,t,n,r,o){if(this.index==this.top.children.length)return!1;var i=this.top.children[this.index];if(i instanceof B){var a=this.preMatched.indexOf(i);if(a>-1&&a+this.preMatchOffset!=o)return!1;var s=i.dom;if(!(this.lock&&(s==this.lock||1==s.nodeType&&s.contains(this.lock.parentNode))&&!(e.isText&&i.node&&i.node.isText&&i.nodeDOM.nodeValue==e.text&&3!=i.dirty&&ee(t,i.outerDeco)))&&i.update(e,t,n,r))return i.dom!=s&&(this.changed=!0),this.index++,!0}return!1},ne.prototype.addNode=function(e,t,n,r,o){this.top.children.splice(this.index++,0,B.create(this.top,e,t,n,r,o)),this.changed=!0},ne.prototype.placeWidget=function(e,t,n){if(this.index<this.top.children.length&&this.top.children[this.index].matchesWidget(e))this.index++;else{var r=new(e.spec.isCursorWrapper?$:R)(this.top,e,t,n);this.top.children.splice(this.index++,0,r),this.changed=!0}},ne.prototype.placeComposition=function(e,t){this.syncToMarks(I,!0,e),this.top.children[this.index]==t?this.index++:(this.top.children.splice(this.index++,0,t),this.changed=!0)},ne.prototype.addTextblockHacks=function(){for(var e=this.top.children[this.index-1];e instanceof z;)e=e.children[e.children.length-1];if(!e||!(e instanceof W)||/\n$/.test(e.node.text))if(this.index<this.top.children.length&&this.top.children[this.index].matchesHack())this.index++;else{var t=document.createElement("br");this.top.children.splice(this.index++,0,new q(this.top,I,t,null)),this.changed=!0}};var we=a.safari||a.chrome&&a.chrome_version<63;function ke(e,t){var n=e.docView.domFromPos(t),r=n.node,o=n.offset,i=o<r.childNodes.length?r.childNodes[o]:null,a=o?r.childNodes[o-1]:null;if(!(i&&"false"!=i.contentEditable||a&&"false"!=a.contentEditable)){if(i)return i.contentEditable="true",i;if(a)return a.contentEditable="true",a}}function Oe(e,t){if(t instanceof o.NodeSelection){var n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(Me(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else Me(e)}function Me(e){e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=null)}function Se(e,t,n,r){return e.someProp("createSelectionBetween",(function(r){return r(e,t,n)}))||o.TextSelection.between(t,n,r)}function _e(e){var t=e.root.getSelection();if(!t.anchorNode)return!1;try{return e.dom.contains(3==t.anchorNode.nodeType?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(3==t.focusNode.nodeType?t.focusNode.parentNode:t.focusNode))}catch(e){return!1}}function Ce(e){return!1===e.type.spec.inclusive}function xe(e){var t=e.selection,n=t.$head,r=t.$anchor,o=t.visible,i=n.pos!=r.pos||o&&!n.parent.inlineContent?null:n;return i&&(!o||e.storedMarks||0==i.parent.content.length||i.parentOffset&&!i.textOffset&&i.nodeBefore.marks.some(Ce))?i:null}function Ae(e,t){return function(n){var r=n.pmViewDesc;if(r)return r.parseRule();if("BR"==n.nodeName&&n.parentNode){if(a.safari&&/^(ul|ol)$/i.test(n.parentNode.nodeName))return e.matchTag(document.createElement("li"),t);if(n.parentNode.lastChild==n||a.safari&&/^(tr|table)$/i.test(n.parentNode.nodeName))return{ignore:!0}}}}function Te(e,t,n,i){if(t<0){var s=e.lastSelectionTime>Date.now()-50?e.lastSelectionOrigin:null,l=function(e,t){var n,r,i=e.root.getSelection(),a=e.state.doc,s=e.docView.nearestDesc(i.focusNode),l=s&&0==s.size,c=e.docView.posFromDOM(i.focusNode,i.focusOffset),u=a.resolve(c);if(b(i)){for(n=u;s&&!s.node;)s=s.parent;if(s&&s.node.isAtom&&o.NodeSelection.isSelectable(s.node)&&s.parent){var f=s.posBefore;r=new o.NodeSelection(c==f?u:a.resolve(f))}}else n=a.resolve(e.docView.posFromDOM(i.anchorNode,i.anchorOffset));return r||(r=Se(e,n,u,"pointer"==t||e.state.selection.head<u.pos&&!l?1:-1)),r}(e,s);if(!e.state.selection.eq(l)){var c=e.state.tr.setSelection(l);"pointer"==s?c.setMeta("pointer",!0):"key"==s&&c.scrollIntoView(),e.dispatch(c)}}else{var u=e.state.doc.resolve(t),f=u.sharedDepth(n);t=u.before(f+1),n=e.state.doc.resolve(n).after(f+1);var p,d,h=e.state.selection,v=function(e,t,n){var o=e.docView.parseRange(t,n),i=o.node,s=o.fromOffset,l=o.toOffset,c=o.from,u=o.to,f=e.root.getSelection(),p=null,d=f.anchorNode;if(d&&e.dom.contains(1==d.nodeType?d:d.parentNode)&&(p=[{node:d,offset:f.anchorOffset}],b(f)||p.push({node:f.focusNode,offset:f.focusOffset})),a.chrome&&8===e.lastKeyCode)for(var h=l;h>s;h--){var v=i.childNodes[h-1],m=v.pmViewDesc;if("BR"==v.nodeType&&!m){l=h;break}if(!m||m.size)break}var y=e.state.doc,g=e.someProp("domParser")||r.DOMParser.fromSchema(e.state.schema),w=y.resolve(c),k=null,O=g.parse(i,{topNode:w.parent,topMatch:w.parent.contentMatchAt(w.index()),topOpen:!0,from:s,to:l,preserveWhitespace:!w.parent.type.spec.code||"full",editableContent:!0,findPositions:p,ruleFromNode:Ae(g,w),context:w});if(p&&null!=p[0].pos){var M=p[0].pos,S=p[1]&&p[1].pos;null==S&&(S=M),k={anchor:M+c,head:S+c}}return{doc:O,sel:k,from:c,to:u}}(e,t,n),m=e.state.doc,y=m.slice(v.from,v.to);8===e.lastKeyCode&&Date.now()-100<e.lastKeyCodeTime?(p=e.state.selection.to,d="end"):(p=e.state.selection.from,d="start"),e.lastKeyCode=null;var g=function(e,t,n,r,o){var i=e.findDiffStart(t,n);if(null==i)return null;var a=e.findDiffEnd(t,n+e.size,n+t.size),s=a.a,l=a.b;if("end"==o){var c=Math.max(0,i-Math.min(s,l));r-=s+c-i}if(s<i&&e.size<t.size){l=(i-=r<=i&&r>=s?i-r:0)+(l-s),s=i}else if(l<i){s=(i-=r<=i&&r>=l?i-r:0)+(s-l),l=i}return{start:i,endA:s,endB:l}}(y.content,v.doc.content,v.from,p,d);if(g){e.domChangeCount++,e.state.selection.from<e.state.selection.to&&g.start==g.endB&&e.state.selection instanceof o.TextSelection&&(g.start>e.state.selection.from&&g.start<=e.state.selection.from+2?g.start=e.state.selection.from:g.endA<e.state.selection.to&&g.endA>=e.state.selection.to-2&&(g.endB+=e.state.selection.to-g.endA,g.endA=e.state.selection.to));var k,O=v.doc.resolveNoCache(g.start-v.from),M=v.doc.resolveNoCache(g.endB-v.from);if(!(!O.sameParent(M)&&O.pos<v.doc.content.size&&(k=o.Selection.findFrom(v.doc.resolve(O.pos+1),1,!0))&&k.head==M.pos&&e.someProp("handleKeyDown",(function(t){return t(e,w(13,"Enter"))}))))if(e.state.selection.anchor>g.start&&function(e,t,n,r,o){if(!r.parent.isTextblock||n-t<=o.pos-r.pos||je(r,!0,!1)<o.pos)return!1;var i=e.resolve(t);if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;var a=e.resolve(je(i,!0,!0));if(!a.parent.isTextblock||a.pos>n||je(a,!0,!1)<n)return!1;return r.parent.content.cut(r.parentOffset).eq(a.parent.content)}(m,g.start,g.endA,O,M)&&e.someProp("handleKeyDown",(function(t){return t(e,w(8,"Backspace"))})))a.android&&a.chrome&&e.domObserver.suppressSelectionUpdates();else{var S,_,C,x,A=g.start,T=g.endA;if(O.sameParent(M)&&O.parent.inlineContent)if(O.pos==M.pos)a.ie&&a.ie_version<=11&&0==O.parentOffset&&(e.domObserver.suppressSelectionUpdates(),setTimeout((function(){return be(e)}),20)),S=e.state.tr.delete(A,T),_=m.resolve(g.start).marksAcross(m.resolve(g.endA));else if(g.endA==g.endB&&(x=m.resolve(g.start))&&(C=function(e,t){for(var n,o,i,a=e.firstChild.marks,s=t.firstChild.marks,l=a,c=s,u=0;u<s.length;u++)l=s[u].removeFromSet(l);for(var f=0;f<a.length;f++)c=a[f].removeFromSet(c);if(1==l.length&&0==c.length)o=l[0],n="add",i=function(e){return e.mark(o.addToSet(e.marks))};else{if(0!=l.length||1!=c.length)return null;o=c[0],n="remove",i=function(e){return e.mark(o.removeFromSet(e.marks))}}for(var p=[],d=0;d<t.childCount;d++)p.push(i(t.child(d)));if(r.Fragment.from(p).eq(e))return{mark:o,type:n}}(O.parent.content.cut(O.parentOffset,M.parentOffset),x.parent.content.cut(x.parentOffset,g.endA-x.start()))))S=e.state.tr,"add"==C.type?S.addMark(A,T,C.mark):S.removeMark(A,T,C.mark);else if(O.parent.child(O.index()).isText&&O.index()==M.index()-(M.textOffset?0:1)){var V=O.parent.textBetween(O.parentOffset,M.parentOffset);if(e.someProp("handleTextInput",(function(t){return t(e,A,T,V)})))return;S=e.state.tr.insertText(V,A,T)}if(S||(S=e.state.tr.replace(A,T,v.doc.slice(g.start-v.from,g.endB-v.from))),v.sel){var j=Ve(e,S.doc,v.sel);j&&S.setSelection(j)}_&&S.ensureMarks(_),e.dispatch(S.scrollIntoView())}}else if(!(i&&h instanceof o.TextSelection&&!h.empty&&h.$head.sameParent(h.$anchor))||e.composing||v.sel&&v.sel.anchor!=v.sel.head){if(v.sel){var E=Ve(e,e.state.doc,v.sel);E&&!E.eq(e.state.selection)&&e.dispatch(e.state.tr.setSelection(E))}}else{var P=e.state,N=P.selection;e.dispatch(P.tr.replaceSelectionWith(P.schema.text(P.doc.textBetween(N.from,N.to)),!0).scrollIntoView())}}}function Ve(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:Se(e,t.resolve(n.anchor),t.resolve(n.head))}function je(e,t,n){for(var r=e.depth,o=t?e.end():e.pos;r>0&&(t||e.indexAfter(r)==e.node(r).childCount);)r--,o++,t=!1;if(n)for(var i=e.node(r).maybeChild(e.indexAfter(r));i&&!i.isLeaf;)i=i.firstChild,o++;return o}function Ee(e,t){for(var n=[],o=t.content,i=t.openStart,a=t.openEnd;i>1&&a>1&&1==o.childCount&&1==o.firstChild.childCount;){i--,a--;var s=o.firstChild;n.push(s.type.name,s.type.hasRequiredAttrs()?s.attrs:null),o=s.content}var l=e.someProp("clipboardSerializer")||r.DOMSerializer.fromSchema(e.state.schema),c=document.createElement("div");c.appendChild(l.serializeFragment(o));for(var u,f=c.firstChild;f&&1==f.nodeType&&(u=Le[f.nodeName.toLowerCase()]);){for(var p=u.length-1;p>=0;p--){for(var d=document.createElement(u[p]);c.firstChild;)d.appendChild(c.firstChild);c.appendChild(d)}f=c.firstChild}return f&&1==f.nodeType&&f.setAttribute("data-pm-slice",i+" "+a+" "+JSON.stringify(n)),{dom:c,text:e.someProp("clipboardTextSerializer",(function(e){return e(t)}))||t.content.textBetween(0,t.content.size,"\n\n")}}function Pe(e,t,n,o,i){var a,s,l=i.parent.type.spec.code;if(!n&&!t)return null;var c=t&&(o||l||!n);if(c){if(e.someProp("transformPastedText",(function(e){t=e(t)})),l)return new r.Slice(r.Fragment.from(e.state.schema.text(t)),0,0);var u=e.someProp("clipboardTextParser",(function(e){return e(t,i)}));u?s=u:(a=document.createElement("div"),t.trim().split(/(?:\r\n?|\n)+/).forEach((function(e){a.appendChild(document.createElement("p")).textContent=e})))}else e.someProp("transformPastedHTML",(function(e){n=e(n)})),a=function(e){var t=/(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));var n,r=(De||(De=document.implementation.createHTMLDocument("title"))).createElement("div"),o=/(?:<meta [^>]*>)*<([a-z][^>\s]+)/i.exec(e),i=0;(n=o&&Le[o[1].toLowerCase()])&&(e=n.map((function(e){return"<"+e+">"})).join("")+e+n.map((function(e){return"</"+e+">"})).reverse().join(""),i=n.length);r.innerHTML=e;for(var a=0;a<i;a++)r=r.firstChild;return r}(n);var f=a&&a.querySelector("[data-pm-slice]"),p=f&&/^(\d+) (\d+) (.*)/.exec(f.getAttribute("data-pm-slice"));if(!s){var d=e.someProp("clipboardParser")||e.someProp("domParser")||r.DOMParser.fromSchema(e.state.schema);s=d.parseSlice(a,{preserveWhitespace:!(!c&&!p),context:i})}return s=p?function(e,t){if(!e.size)return e;var n,o=e.content.firstChild.type.schema;try{n=JSON.parse(t)}catch(t){return e}for(var i=e.content,a=e.openStart,s=e.openEnd,l=n.length-2;l>=0;l-=2){var c=o.nodes[n[l]];if(!c||c.hasRequiredAttrs())break;i=r.Fragment.from(c.create(n[l+1],i)),a++,s++}return new r.Slice(i,a,s)}(function(e,t,n){t<e.openStart&&(e=new r.Slice(He(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd));n<e.openEnd&&(e=new r.Slice(He(e.content,1,n,e.openEnd,0,0),e.openStart,n));return e}(s,+p[1],+p[2]),p[3]):r.Slice.maxOpen(function(e,t){if(e.childCount<2)return e;for(var n=function(n){var o=t.node(n).contentMatchAt(t.index(n)),i=void 0,a=[];if(e.forEach((function(e){if(a){var t,n=o.findWrapping(e.type);if(!n)return a=null;if(t=a.length&&i.length&&function e(t,n,o,i,a){if(a<t.length&&a<n.length&&t[a]==n[a]){var s=e(t,n,o,i.lastChild,a+1);if(s)return i.copy(i.content.replaceChild(i.childCount-1,s));if(i.contentMatchAt(i.childCount).matchType(a==t.length-1?o.type:t[a+1]))return i.copy(i.content.append(r.Fragment.from(Ne(o,t,a+1))))}}(n,i,e,a[a.length-1],0))a[a.length-1]=t;else{a.length&&(a[a.length-1]=function e(t,n){if(0==n)return t;var o=t.content.replaceChild(t.childCount-1,e(t.lastChild,n-1)),i=t.contentMatchAt(t.childCount).fillBefore(r.Fragment.empty,!0);return t.copy(o.append(i))}(a[a.length-1],i.length));var s=Ne(e,n);a.push(s),o=o.matchType(s.type,s.attrs),i=n}}})),a)return{v:r.Fragment.from(a)}},o=t.depth;o>=0;o--){var i=n(o);if(i)return i.v}return e}(s.content,i),!1),e.someProp("transformPasted",(function(e){s=e(s)})),s}function Ne(e,t,n){void 0===n&&(n=0);for(var o=t.length-1;o>=n;o--)e=t[o].create(null,r.Fragment.from(e));return e}function He(e,t,n,o,i,a){var s=t<0?e.firstChild:e.lastChild,l=s.content;return i<o-1&&(l=He(l,t,n,o,i+1,a)),i>=n&&(l=t<0?s.contentMatchAt(0).fillBefore(l,e.childCount>1||a<=i).append(l):l.append(s.contentMatchAt(s.childCount).fillBefore(r.Fragment.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,s.copy(l))}var Le={thead:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]},De=null;var Ie={childList:!0,characterData:!0,attributes:!0,subtree:!0,characterDataOldValue:!0},Re=a.ie&&a.ie_version<=11,$e=function(){this.anchorNode=this.anchorOffset=this.focusNode=this.focusOffset=null};$e.prototype.set=function(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset},$e.prototype.eq=function(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset};var Fe=function(e,t){var n=this;this.view=e,this.handleDOMChange=t,this.observer=window.MutationObserver&&new window.MutationObserver((function(e){a.ie&&a.ie_version<=11&&e.some((function(e){return"childList"==e.type&&1==e.removedNodes.length&&e.removedNodes[0].parentNode==e.target}))?setTimeout((function(){return n.flush(e)}),10):n.flush(e)})),this.currentSelection=new $e,this.queue=[],Re&&(this.onCharData=function(e){n.queue.push({target:e.target,type:"characterData",oldValue:e.prevValue}),window.setTimeout((function(){return n.flush()}),20)}),this.onSelectionChange=this.onSelectionChange.bind(this),this.suppressingSelectionUpdates=!1};Fe.prototype.start=function(){this.observer&&this.observer.observe(this.view.dom,Ie),Re&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()},Fe.prototype.stop=function(){var e=this,t=this.observer.takeRecords();if(t.length){for(var n=0;n<t.length;n++)e.queue.push(t[n]);window.setTimeout((function(){return e.flush()}),20)}this.observer&&this.observer.disconnect(),Re&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()},Fe.prototype.connectSelection=function(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)},Fe.prototype.disconnectSelection=function(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)},Fe.prototype.suppressSelectionUpdates=function(){var e=this;this.suppressingSelectionUpdates=!0,setTimeout((function(){return e.suppressingSelectionUpdates=!1}),50)},Fe.prototype.onSelectionChange=function(){var e;if((!(e=this.view).editable||e.root.activeElement==e.dom)&&_e(e))return this.suppressingSelectionUpdates?be(this.view):void this.flush()},Fe.prototype.setCurSelection=function(){this.currentSelection.set(this.view.root.getSelection())},Fe.prototype.flush=function(e){if(this.view.docView){e||(e=this.observer.takeRecords()),this.queue.length&&(e=this.queue.concat(e),this.queue.length=0);var t=this.view.root.getSelection(),n=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(t)&&_e(this.view),r=-1,o=-1,i=!1;if(this.view.editable)for(var a=0;a<e.length;a++){var s=this.registerMutation(e[a]);s&&(r=r<0?s.from:Math.min(s.from,r),o=o<0?s.to:Math.max(s.to,o),s.typeOver&&(i=!0))}(r>-1||n)&&(r>-1&&this.view.docView.markDirty(r,o),this.handleDOMChange(r,o,i),this.view.docView.dirty?this.view.updateState(this.view.state):this.currentSelection.eq(t)||be(this.view))}},Fe.prototype.registerMutation=function(e){var t=this.view.docView.nearestDesc(e.target);if("attributes"==e.type&&(t==this.view.docView||"contenteditable"==e.attributeName))return null;if(!t||t.ignoreMutation(e))return null;if("childList"==e.type){var n=e.previousSibling&&e.previousSibling.parentNode==e.target?p(e.previousSibling)+1:0,r=t.localPosFromDOM(e.target,n,-1),o=e.nextSibling&&e.nextSibling.parentNode==e.target?p(e.nextSibling):e.target.childNodes.length;return{from:r,to:t.localPosFromDOM(e.target,o,1)}}return"attributes"==e.type?{from:t.posAtStart-t.border,to:t.posAtEnd+t.border}:{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}};var ze={},Be={};function Je(e,t){e.lastSelectionOrigin=t,e.lastSelectionTime=Date.now()}function We(e){e.someProp("handleDOMEvents",(function(t){for(var n in t)e.eventHandlers[n]||e.dom.addEventListener(n,e.eventHandlers[n]=function(t){return qe(e,t)})}))}function qe(e,t){return e.someProp("handleDOMEvents",(function(n){var r=n[t.type];return!!r&&(r(e,t)||t.defaultPrevented)}))}function Ke(e){return{left:e.clientX,top:e.clientY}}function Ge(e,t,n,r,o){if(-1==r)return!1;for(var i=e.state.doc.resolve(r),a=function(r){if(e.someProp(t,(function(t){return r>i.depth?t(e,n,i.nodeAfter,i.before(r),o,!0):t(e,n,i.node(r),i.before(r),o,!1)})))return{v:!0}},s=i.depth+1;s>0;s--){var l=a(s);if(l)return l.v}return!1}function Qe(e,t,n){e.focused||e.focus();var r=e.state.tr.setSelection(t);"pointer"==n&&r.setMeta("pointer",!0),e.dispatch(r)}function Ze(e,t,n,r,i){return Ge(e,"handleClickOn",t,n,r)||e.someProp("handleClick",(function(n){return n(e,t,r)}))||(i?function(e,t){if(-1==t)return!1;var n,r,i=e.state.selection;i instanceof o.NodeSelection&&(n=i.node);for(var a=e.state.doc.resolve(t),s=a.depth+1;s>0;s--){var l=s>a.depth?a.nodeAfter:a.node(s);if(o.NodeSelection.isSelectable(l)){r=n&&i.$from.depth>0&&s>=i.$from.depth&&a.before(i.$from.depth+1)==i.$from.pos?a.before(i.$from.depth):a.before(s);break}}return null!=r&&(Qe(e,o.NodeSelection.create(e.state.doc,r),"pointer"),!0)}(e,n):function(e,t){if(-1==t)return!1;var n=e.state.doc.resolve(t),r=n.nodeAfter;return!!(r&&r.isAtom&&o.NodeSelection.isSelectable(r))&&(Qe(e,new o.NodeSelection(n),"pointer"),!0)}(e,n))}function Ue(e,t,n,r){return Ge(e,"handleDoubleClickOn",t,n,r)||e.someProp("handleDoubleClick",(function(n){return n(e,t,r)}))}function Xe(e,t,n,r){return Ge(e,"handleTripleClickOn",t,n,r)||e.someProp("handleTripleClick",(function(n){return n(e,t,r)}))||function(e,t){var n=e.state.doc;if(-1==t)return!!n.inlineContent&&(Qe(e,o.TextSelection.create(n,0,n.content.size),"pointer"),!0);for(var r=n.resolve(t),i=r.depth+1;i>0;i--){var a=i>r.depth?r.nodeAfter:r.node(i),s=r.before(i);if(a.inlineContent)Qe(e,o.TextSelection.create(n,s+1,s+1+a.content.size),"pointer");else{if(!o.NodeSelection.isSelectable(a))continue;Qe(e,o.NodeSelection.create(n,s),"pointer")}return!0}}(e,n)}function Ye(e){return it(e)}Be.keydown=function(e,t){e.shiftKey=16==t.keyCode||t.shiftKey,nt(e,t)||(e.lastKeyCode=t.keyCode,e.lastKeyCodeTime=Date.now(),e.someProp("handleKeyDown",(function(n){return n(e,t)}))||ge(e,t)?t.preventDefault():Je(e,"key"))},Be.keyup=function(e,t){16==t.keyCode&&(e.shiftKey=!1)},Be.keypress=function(e,t){if(!(nt(e,t)||!t.charCode||t.ctrlKey&&!t.altKey||a.mac&&t.metaKey))if(e.someProp("handleKeyPress",(function(n){return n(e,t)})))t.preventDefault();else{var n=e.state.selection;if(!(n instanceof o.TextSelection&&n.$from.sameParent(n.$to))){var r=String.fromCharCode(t.charCode);e.someProp("handleTextInput",(function(t){return t(e,n.$from.pos,n.$to.pos,r)}))||e.dispatch(e.state.tr.insertText(r).scrollIntoView()),t.preventDefault()}}};var et=a.mac?"metaKey":"ctrlKey";ze.mousedown=function(e,t){e.shiftKey=t.shiftKey;var n=Ye(e),r=Date.now(),o="singleClick";r-e.lastClick.time<500&&function(e,t){var n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}(t,e.lastClick)&&!t[et]&&("singleClick"==e.lastClick.type?o="doubleClick":"doubleClick"==e.lastClick.type&&(o="tripleClick")),e.lastClick={time:r,x:t.clientX,y:t.clientY,type:o};var i=e.posAtCoords(Ke(t));i&&("singleClick"==o?e.mouseDown=new tt(e,i,t,n):("doubleClick"==o?Ue:Xe)(e,i.pos,i.inside,t)?t.preventDefault():Je(e,"pointer"))};var tt=function(e,t,n,r){var i,s,l=this;if(this.view=e,this.startDoc=e.state.doc,this.pos=t,this.event=n,this.flushed=r,this.selectNode=n[et],this.allowDefault=n.shiftKey,t.inside>-1)i=e.state.doc.nodeAt(t.inside),s=t.inside;else{var c=e.state.doc.resolve(t.pos);i=c.parent,s=c.depth?c.before():0}this.mightDrag=null;var u=r?null:n.target,f=u?e.docView.nearestDesc(u,!0):null;this.target=f?f.dom:null,(i.type.spec.draggable&&!1!==i.type.spec.selectable||e.state.selection instanceof o.NodeSelection&&s==e.state.selection.from)&&(this.mightDrag={node:i,pos:s,addAttr:this.target&&!this.target.draggable,setUneditable:this.target&&a.gecko&&!this.target.hasAttribute("contentEditable")}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout((function(){return l.target.setAttribute("contentEditable","false")}),20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),Je(e,"pointer")};function nt(e,t){return!!e.composing||!!(a.safari&&Math.abs(t.timeStamp-e.compositionEndedAt)<500)&&(e.compositionEndedAt=-2e8,!0)}tt.prototype.done=function(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!1),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.view.mouseDown=null},tt.prototype.up=function(e){if(this.done(),this.view.dom.contains(3==e.target.nodeType?e.target.parentNode:e.target)){var t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(Ke(e))),this.allowDefault||!t?(a.ie&&xe(this.view.state)&&this.view.updateState(this.view.state),Je(this.view,"pointer")):Ze(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():!this.flushed&&(!a.chrome||this.view.state.selection instanceof o.TextSelection||t.pos!=this.view.state.selection.from&&t.pos!=this.view.state.selection.to)?Je(this.view,"pointer"):(Qe(this.view,o.Selection.near(this.view.state.doc.resolve(t.pos)),"pointer"),e.preventDefault())}},tt.prototype.move=function(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0),Je(this.view,"pointer")},ze.touchdown=function(e){Ye(e),Je(e,"pointer")},ze.contextmenu=function(e){return Ye(e)};var rt=a.android?5e3:-1;function ot(e,t){clearTimeout(e.composingTimeout),t>-1&&(e.composingTimeout=setTimeout((function(){return it(e)}),t))}function it(e){for(e.composing=!1;e.compositionNodes.length>0;)e.compositionNodes.pop().markParentsDirty();return!!e.docView.dirty&&(e.updateState(e.state),!0)}Be.compositionstart=Be.compositionupdate=function(e){e.composing||(e.domObserver.flush(),it(e),e.composing=!0),ot(e,rt)},Be.compositionend=function(e,t){e.composing&&(e.composing=!1,e.compositionEndedAt=t.timeStamp,ot(e,20))};var at=a.ie&&a.ie_version<15||a.ios&&a.webkit_version<604;function st(e,t,n,o){var i=Pe(e,t,n,e.shiftKey,e.state.selection.$from);if(e.someProp("handlePaste",(function(t){return t(e,o,i||r.Slice.empty)}))||!i)return!0;var a=function(e){return 0==e.openStart&&0==e.openEnd&&1==e.content.childCount?e.content.firstChild:null}(i),s=a?e.state.tr.replaceSelectionWith(a,e.shiftKey):e.state.tr.replaceSelection(i);return e.dispatch(s.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}ze.copy=Be.cut=function(e,t){var n=e.state.selection,r="cut"==t.type;if(!n.empty){var o=at?null:t.clipboardData,i=Ee(e,n.content()),a=i.dom,s=i.text;o?(t.preventDefault(),o.clearData(),o.setData("text/html",a.innerHTML),o.setData("text/plain",s)):function(e,t){var n=t.ownerDocument,r=n.body.appendChild(n.createElement("div"));r.appendChild(t),r.style.cssText="position: fixed; left: -10000px; top: 10px";var o=getSelection(),i=n.createRange();i.selectNodeContents(t),e.dom.blur(),o.removeAllRanges(),o.addRange(i),setTimeout((function(){n.body.removeChild(r),e.focus()}),50)}(e,a),r&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))}},Be.paste=function(e,t){var n=at?null:t.clipboardData;n&&(st(e,n.getData("text/plain"),n.getData("text/html"),t)||n.files.length>0)?t.preventDefault():function(e,t){var n=e.dom.ownerDocument,r=e.shiftKey||e.state.selection.$from.parent.type.spec.code,o=n.body.appendChild(n.createElement(r?"textarea":"div"));r||(o.contentEditable="true"),o.style.cssText="position: fixed; left: -10000px; top: 10px",o.focus(),setTimeout((function(){e.focus(),n.body.removeChild(o),r?st(e,o.value,null,t):st(e,o.textContent,o.innerHTML,t)}),50)}(e,t)};var lt=function(e,t){this.slice=e,this.move=t},ct=a.mac?"altKey":"ctrlKey";for(var ut in ze.dragstart=function(e,t){var n=e.mouseDown;if(n&&n.done(),t.dataTransfer){var r=e.state.selection,i=r.empty?null:e.posAtCoords(Ke(t));if(i&&i.pos>=r.from&&i.pos<=(r instanceof o.NodeSelection?r.to-1:r.to));else if(n&&n.mightDrag)e.dispatch(e.state.tr.setSelection(o.NodeSelection.create(e.state.doc,n.mightDrag.pos)));else if(t.target&&1==t.target.nodeType){var a=e.docView.nearestDesc(t.target,!0);if(!a||!a.node.type.spec.draggable||a==e.docView)return;e.dispatch(e.state.tr.setSelection(o.NodeSelection.create(e.state.doc,a.posBefore)))}var s=e.state.selection.content(),l=Ee(e,s),c=l.dom,u=l.text;t.dataTransfer.clearData(),t.dataTransfer.setData(at?"Text":"text/html",c.innerHTML),at||t.dataTransfer.setData("text/plain",u),e.dragging=new lt(s,!t[ct])}},ze.dragend=function(e){window.setTimeout((function(){return e.dragging=null}),50)},Be.dragover=Be.dragenter=function(e,t){return t.preventDefault()},Be.drop=function(e,t){var n=e.dragging;if(e.dragging=null,t.dataTransfer){var r=e.posAtCoords(Ke(t));if(r){var a=e.state.doc.resolve(r.pos);if(a){var s=n&&n.slice||Pe(e,t.dataTransfer.getData(at?"Text":"text/plain"),at?null:t.dataTransfer.getData("text/html"),!1,a);if(s&&(t.preventDefault(),!e.someProp("handleDrop",(function(r){return r(e,t,s,n&&n.move)})))){var l=s?i.dropPoint(e.state.doc,a.pos,s):a.pos;null==l&&(l=a.pos);var c=e.state.tr;n&&n.move&&c.deleteSelection();var u=c.mapping.map(l),f=0==s.openStart&&0==s.openEnd&&1==s.content.childCount,p=c.doc;if(f?c.replaceRangeWith(u,u,s.content.firstChild):c.replaceRange(u,u,s),!c.doc.eq(p)){var d=c.doc.resolve(u);f&&o.NodeSelection.isSelectable(s.content.firstChild)&&d.nodeAfter&&d.nodeAfter.sameMarkup(s.content.firstChild)?c.setSelection(new o.NodeSelection(d)):c.setSelection(Se(e,d,c.doc.resolve(c.mapping.map(l)))),e.focus(),e.dispatch(c.setMeta("uiEvent","drop"))}}}}}},ze.focus=function(e){e.focused||(e.domObserver.stop(),e.dom.classList.add("ProseMirror-focused"),e.domObserver.start(),e.focused=!0)},ze.blur=function(e){e.focused&&(e.domObserver.stop(),e.dom.classList.remove("ProseMirror-focused"),e.domObserver.start(),e.focused=!1)},ze.beforeinput=function(e,t){if(a.chrome&&a.android&&"deleteContentBackward"==t.inputType){var n=e.domChangeCount;setTimeout((function(){if(e.domChangeCount==n&&(e.dom.blur(),e.focus(),!e.someProp("handleKeyDown",(function(t){return t(e,w(8,"Backspace"))})))){var t=e.state.selection.$cursor;t&&t.pos>0&&e.dispatch(e.state.tr.delete(t.pos-1,t.pos).scrollIntoView())}}),50)}},Be)ze[ut]=Be[ut];function ft(e,t){if(e==t)return!0;for(var n in e)if(e[n]!==t[n])return!1;for(var r in t)if(!(r in e))return!1;return!0}var pt=function(e,t){this.spec=t||gt,this.side=this.spec.side||0,this.toDOM=e};pt.prototype.map=function(e,t,n,r){var o=e.mapResult(t.from+r,this.side<0?-1:1),i=o.pos;return o.deleted?null:new vt(i-n,i-n,this)},pt.prototype.valid=function(){return!0},pt.prototype.eq=function(e){return this==e||e instanceof pt&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&ft(this.spec,e.spec))};var dt=function(e,t){this.spec=t||gt,this.attrs=e};dt.prototype.map=function(e,t,n,r){var o=e.map(t.from+r,this.spec.inclusiveStart?-1:1)-n,i=e.map(t.to+r,this.spec.inclusiveEnd?1:-1)-n;return o>=i?null:new vt(o,i,this)},dt.prototype.valid=function(e,t){return t.from<t.to},dt.prototype.eq=function(e){return this==e||e instanceof dt&&ft(this.attrs,e.attrs)&&ft(this.spec,e.spec)},dt.is=function(e){return e.type instanceof dt};var ht=function(e,t){this.spec=t||gt,this.attrs=e};ht.prototype.map=function(e,t,n,r){var o=e.mapResult(t.from+r,1);if(o.deleted)return null;var i=e.mapResult(t.to+r,-1);return i.deleted||i.pos<=o.pos?null:new vt(o.pos-n,i.pos-n,this)},ht.prototype.valid=function(e,t){var n=e.content.findIndex(t.from),r=n.index,o=n.offset;return o==t.from&&o+e.child(r).nodeSize==t.to},ht.prototype.eq=function(e){return this==e||e instanceof ht&&ft(this.attrs,e.attrs)&&ft(this.spec,e.spec)};var vt=function(e,t,n){this.from=e,this.to=t,this.type=n},mt={spec:{}};vt.prototype.copy=function(e,t){return new vt(e,t,this.type)},vt.prototype.eq=function(e){return this.type.eq(e.type)&&this.from==e.from&&this.to==e.to},vt.prototype.map=function(e,t,n){return this.type.map(e,this,t,n)},vt.widget=function(e,t,n){return new vt(e,e,new pt(t,n))},vt.inline=function(e,t,n,r){return new vt(e,t,new dt(n,r))},vt.node=function(e,t,n,r){return new vt(e,t,new ht(n,r))},mt.spec.get=function(){return this.type.spec},Object.defineProperties(vt.prototype,mt);var yt=[],gt={},bt=function(e,t){this.local=e&&e.length?e:yt,this.children=t&&t.length?t:yt};bt.create=function(e,t){return t.length?_t(t,e,0,gt):wt},bt.prototype.find=function(e,t,n){var r=[];return this.findInner(null==e?0:e,null==t?1e9:t,r,0,n),r},bt.prototype.findInner=function(e,t,n,r,o){for(var i=0;i<this.local.length;i++){var a=this.local[i];a.from<=t&&a.to>=e&&(!o||o(a.spec))&&n.push(a.copy(a.from+r,a.to+r))}for(var s=0;s<this.children.length;s+=3)if(this.children[s]<t&&this.children[s+1]>e){var l=this.children[s]+1;this.children[s+2].findInner(e-l,t-l,n,r+l,o)}},bt.prototype.map=function(e,t,n){return this==wt||0==e.maps.length?this:this.mapInner(e,t,0,0,n||gt)},bt.prototype.mapInner=function(e,t,n,r,o){for(var i,a=0;a<this.local.length;a++){var s=this.local[a].map(e,n,r);s&&s.type.valid(t,s)?(i||(i=[])).push(s):o.onRemove&&o.onRemove(this.local[a].spec)}return this.children.length?function(e,t,n,r,o,i,a){for(var s=e.slice(),l=function(e,t,n,r){for(var a=0;a<s.length;a+=3){var l=s[a+1],c=void 0;-1==l||e>l+i||(t>=s[a]+i?s[a+1]=-1:(c=r-n-(t-e)+(i-o))&&(s[a]+=c,s[a+1]+=c))}},c=0;c<n.maps.length;c++)n.maps[c].forEach(l);for(var u=!1,f=0;f<s.length;f+=3)if(-1==s[f+1]){var p=n.map(s[f]+i),d=p-o;if(d<0||d>=r.content.size){u=!0;continue}var h=n.map(e[f+1]+i,-1)-o,v=r.content.findIndex(d),m=v.index,y=v.offset,g=r.maybeChild(m);if(g&&y==d&&y+g.nodeSize==h){var b=s[f+2].mapInner(n,g,p+1,s[f]+i+1,a);b!=wt?(s[f]=d,s[f+1]=h,s[f+2]=b):(s[f+1]=-2,u=!0)}else u=!0}if(u){var w=_t(function(e,t,n,r,o,i,a){function s(e,t){for(var i=0;i<e.local.length;i++){var l=e.local[i].map(r,o,t);l?n.push(l):a.onRemove&&a.onRemove(e.local[i].spec)}for(var c=0;c<e.children.length;c+=3)s(e.children[c+2],e.children[c]+t+1)}for(var l=0;l<e.length;l+=3)-1==e[l+1]&&s(e[l+2],t[l]+i+1);return n}(s,e,t||[],n,o,i,a),r,0,a);t=w.local;for(var k=0;k<s.length;k+=3)s[k+1]<0&&(s.splice(k,3),k-=3);for(var O=0,M=0;O<w.children.length;O+=3){for(var S=w.children[O];M<s.length&&s[M]<S;)M+=3;s.splice(M,0,w.children[O],w.children[O+1],w.children[O+2])}}return new bt(t&&t.sort(Ct),s)}(this.children,i,e,t,n,r,o):i?new bt(i.sort(Ct)):wt},bt.prototype.add=function(e,t){return t.length?this==wt?bt.create(e,t):this.addInner(e,t,0):this},bt.prototype.addInner=function(e,t,n){var r,o=this,i=0;e.forEach((function(e,a){var s,l=a+n;if(s=Mt(t,e,l)){for(r||(r=o.children.slice());i<r.length&&r[i]<a;)i+=3;r[i]==a?r[i+2]=r[i+2].addInner(e,s,l+1):r.splice(i,0,a,a+e.nodeSize,_t(s,e,l+1,gt)),i+=3}}));var a=Ot(i?St(t):t,-n);return new bt(a.length?this.local.concat(a).sort(Ct):this.local,r||this.children)},bt.prototype.remove=function(e){return 0==e.length||this==wt?this:this.removeInner(e,0)},bt.prototype.removeInner=function(e,t){for(var n=this.children,r=this.local,o=0;o<n.length;o+=3){for(var i=void 0,a=n[o]+t,s=n[o+1]+t,l=0,c=void 0;l<e.length;l++)(c=e[l])&&c.from>a&&c.to<s&&(e[l]=null,(i||(i=[])).push(c));if(i){n==this.children&&(n=this.children.slice());var u=n[o+2].removeInner(i,a+1);u!=wt?n[o+2]=u:(n.splice(o,3),o-=3)}}if(r.length)for(var f=0,p=void 0;f<e.length;f++)if(p=e[f])for(var d=0;d<r.length;d++)r[d].type.eq(p.type)&&(r==this.local&&(r=this.local.slice()),r.splice(d--,1));return n==this.children&&r==this.local?this:r.length||n.length?new bt(r,n):wt},bt.prototype.forChild=function(e,t){var n,r;if(this==wt)return this;if(t.isLeaf)return bt.empty;for(var o=0;o<this.children.length;o+=3)if(this.children[o]>=e){this.children[o]==e&&(n=this.children[o+2]);break}for(var i=e+1,a=i+t.content.size,s=0;s<this.local.length;s++){var l=this.local[s];if(l.from<a&&l.to>i&&l.type instanceof dt){var c=Math.max(i,l.from)-i,u=Math.min(a,l.to)-i;c<u&&(r||(r=[])).push(l.copy(c,u))}}if(r){var f=new bt(r.sort(Ct));return n?new kt([f,n]):f}return n||wt},bt.prototype.eq=function(e){if(this==e)return!0;if(!(e instanceof bt)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(var t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(var n=0;n<this.children.length;n+=3)if(this.children[n]!=e.children[n]||this.children[n+1]!=e.children[n+1]||!this.children[n+2].eq(e.children[n+2]))return!1;return!0},bt.prototype.locals=function(e){return xt(this.localsInner(e))},bt.prototype.localsInner=function(e){if(this==wt)return yt;if(e.inlineContent||!this.local.some(dt.is))return this.local;for(var t=[],n=0;n<this.local.length;n++)this.local[n].type instanceof dt||t.push(this.local[n]);return t};var wt=new bt;bt.empty=wt,bt.removeOverlap=xt;var kt=function(e){this.members=e};function Ot(e,t){if(!t||!e.length)return e;for(var n=[],r=0;r<e.length;r++){var o=e[r];n.push(new vt(o.from+t,o.to+t,o.type))}return n}function Mt(e,t,n){if(t.isLeaf)return null;for(var r=n+t.nodeSize,o=null,i=0,a=void 0;i<e.length;i++)(a=e[i])&&a.from>n&&a.to<r&&((o||(o=[])).push(a),e[i]=null);return o}function St(e){for(var t=[],n=0;n<e.length;n++)null!=e[n]&&t.push(e[n]);return t}function _t(e,t,n,r){var o=[],i=!1;t.forEach((function(t,a){var s=Mt(e,t,a+n);if(s){i=!0;var l=_t(s,t,n+a+1,r);l!=wt&&o.push(a,a+t.nodeSize,l)}}));for(var a=Ot(i?St(e):e,-n).sort(Ct),s=0;s<a.length;s++)a[s].type.valid(t,a[s])||(r.onRemove&&r.onRemove(a[s].spec),a.splice(s--,1));return a.length||o.length?new bt(a,o):wt}function Ct(e,t){return e.from-t.from||e.to-t.to}function xt(e){for(var t=e,n=0;n<t.length-1;n++){var r=t[n];if(r.from!=r.to)for(var o=n+1;o<t.length;o++){var i=t[o];if(i.from!=r.from){i.from<r.to&&(t==e&&(t=e.slice()),t[n]=r.copy(r.from,i.from),At(t,o,r.copy(i.from,r.to)));break}i.to!=r.to&&(t==e&&(t=e.slice()),t[o]=i.copy(i.from,r.to),At(t,o+1,i.copy(r.to,i.to)))}}return t}function At(e,t,n){for(;t<e.length&&Ct(n,e[t])>0;)t++;e.splice(t,0,n)}function Tt(e){var t=[];return e.someProp("decorations",(function(n){var r=n(e.state);r&&r!=wt&&t.push(r)})),e.cursorWrapper&&t.push(bt.create(e.state.doc,[e.cursorWrapper.deco])),kt.from(t)}kt.prototype.forChild=function(e,t){if(t.isLeaf)return bt.empty;for(var n=[],r=0;r<this.members.length;r++){var o=this.members[r].forChild(e,t);o!=wt&&(o instanceof kt?n=n.concat(o.members):n.push(o))}return kt.from(n)},kt.prototype.eq=function(e){if(!(e instanceof kt)||e.members.length!=this.members.length)return!1;for(var t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0},kt.prototype.locals=function(e){for(var t,n=!0,r=0;r<this.members.length;r++){var o=this.members[r].localsInner(e);if(o.length)if(t){n&&(t=t.slice(),n=!1);for(var i=0;i<o.length;i++)t.push(o[i])}else t=o}return t?xt(n?t:t.sort(Ct)):yt},kt.from=function(e){switch(e.length){case 0:return wt;case 1:return e[0];default:return new kt(e)}};var Vt=function(e,t){this._props=t,this.state=t.state,this.dispatch=this.dispatch.bind(this),this._root=null,this.focused=!1,this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):e.apply?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=Nt(this),this.cursorWrapper=null,Pt(this),this.nodeViews=Lt(this),this.docView=J(this.state.doc,Et(this),Tt(this),this.dom,this),this.lastSelectedViewDesc=null,this.dragging=null,function(e){e.shiftKey=!1,e.mouseDown=null,e.lastKeyCode=null,e.lastKeyCodeTime=0,e.lastClick={time:0,x:0,y:0,type:""},e.lastSelectionOrigin=null,e.lastSelectionTime=0,e.composing=!1,e.composingTimeout=null,e.compositionNodes=[],e.compositionEndedAt=-2e8,e.domObserver=new Fe(e,(function(t,n,r){return Te(e,t,n,r)})),e.domObserver.start(),e.domChangeCount=0,e.eventHandlers=Object.create(null);var t=function(t){var n=ze[t];e.dom.addEventListener(t,e.eventHandlers[t]=function(t){!function(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(var n=t.target;n!=e.dom;n=n.parentNode)if(!n||11==n.nodeType||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}(e,t)||qe(e,t)||!e.editable&&t.type in Be||n(e,t)})};for(var n in ze)t(n);a.safari&&e.dom.addEventListener("input",(function(){return null})),We(e)}(this),this.pluginViews=[],this.updatePluginViews()},jt={props:{},root:{}};function Et(e){var t=Object.create(null);return t.class="ProseMirror",t.contenteditable=String(e.editable),e.someProp("attributes",(function(n){if("function"==typeof n&&(n=n(e.state)),n)for(var r in n)"class"==r?t.class+=" "+n[r]:t[r]||"contenteditable"==r||"nodeName"==r||(t[r]=String(n[r]))})),[vt.node(0,e.state.doc.content.size,t)]}function Pt(e){var t=xe(e.state);if(!t||a.ie&&e.mouseDown)e.cursorWrapper=null;else{var n,o=e.state.selection.visible,i=e.state.storedMarks||t.marks();e.cursorWrapper&&r.Mark.sameSet(e.cursorWrapper.deco.spec.marks,i)&&"\ufeff"==e.cursorWrapper.dom.textContent&&e.cursorWrapper.deco.spec.visible==o?e.cursorWrapper.deco.pos!=t.pos&&(n=e.cursorWrapper.dom):n=function(e){var t=document.createElement("span");return t.textContent="\ufeff",e||(t.style.position="absolute",t.style.left="-100000px"),t}(o),n&&(e.cursorWrapper={dom:n,deco:vt.widget(t.pos,n,{isCursorWrapper:!0,marks:i,raw:!0,visible:o})})}}function Nt(e){return!e.someProp("editable",(function(t){return!1===t(e.state)}))}function Ht(e){var t=e.getSelection(),n=t.focusOffset,r=t.focusNode;return r&&3!=r.nodeType?[r,n,1==r.nodeType?r.childNodes[n-1]:null,1==r.nodeType?r.childNodes[n]:null]:null}function Lt(e){var t={};return e.someProp("nodeViews",(function(e){for(var n in e)Object.prototype.hasOwnProperty.call(t,n)||(t[n]=e[n])})),t}jt.props.get=function(){if(this._props.state!=this.state){var e=this._props;for(var t in this._props={},e)this._props[t]=e[t];this._props.state=this.state}return this._props},Vt.prototype.update=function(e){e.handleDOMEvents!=this._props.handleDOMEvents&&We(this),this._props=e,this.updateStateInner(e.state,!0)},Vt.prototype.setProps=function(e){var t={};for(var n in this._props)t[n]=this._props[n];for(var r in t.state=this.state,e)t[r]=e[r];this.update(t)},Vt.prototype.updateState=function(e){this.updateStateInner(e,this.state.plugins!=e.plugins)},Vt.prototype.updateStateInner=function(e,t){var n=this,r=this.state,i=!1;if(this.state=e,t){var s=Lt(this);(function(e,t){var n=0,r=0;for(var o in e){if(e[o]!=t[o])return!0;n++}for(var i in t)r++;return n!=r})(s,this.nodeViews)&&(this.nodeViews=s,i=!0),We(this)}this.editable=Nt(this),Pt(this);var l,c,u,f=Tt(this),p=Et(this),h=t?"reset":e.scrollToSelection>r.scrollToSelection?"to selection":"preserve",m=i||!this.docView.matchesNode(e.doc,p,f),y=m||!e.selection.eq(r.selection),g="preserve"==h&&y&&null==this.dom.style.overflowAnchor&&function(e){for(var t,n,r=e.dom.getBoundingClientRect(),o=Math.max(0,r.top),i=e.dom.ownerDocument,a=(r.left+r.right)/2,s=o+1;s<Math.min(innerHeight,r.bottom);s+=5){var l=e.root.elementFromPoint(a,s);if(l!=e.dom&&e.dom.contains(l)){var c=l.getBoundingClientRect();if(c.top>=o-20){t=l,n=c.top;break}}}for(var u=[],f=e.dom;f&&(u.push({dom:f,top:f.scrollTop,left:f.scrollLeft}),f!=i.body);f=d(f));return{refDOM:t,refTop:n,stack:u}}(this);if(y){this.domObserver.stop();var b=!1;if(m){var w=a.chrome&&Ht(this.root);!i&&this.docView.update(e.doc,p,f,this)||(this.docView.destroy(),this.docView=J(e.doc,p,f,this.dom,this)),w&&(b=function(e,t){var n=Ht(t);if(!n||3==n[0].nodeType)return!1;for(var r=0;r<e.length;r++)if(n[r]!=e[r])return!0;return!1}(w,this.root))}b||!(this.mouseDown&&this.domObserver.currentSelection.eq(this.root.getSelection())&&(l=this,c=l.docView.domFromPos(l.state.selection.anchor),u=l.root.getSelection(),v(c.node,c.offset,u.anchorNode,u.anchorOffset)))?be(this,!1,b):(Oe(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}if(this.updatePluginViews(r),"reset"==h)this.dom.scrollTop=0;else if("to selection"==h){var k=this.root.getSelection().focusNode;this.someProp("handleScrollToSelection",(function(e){return e(n)}))||(e.selection instanceof o.NodeSelection?M(this,this.docView.domAfterPos(e.selection.from).getBoundingClientRect(),k):M(this,this.coordsAtPos(e.selection.head),k))}else g&&function(e){for(var t=e.refDOM,n=e.refTop,r=e.stack,o=t?t.getBoundingClientRect().top:0,i=0==o?0:o-n,a=0;a<r.length;a++){var s=r[a],l=s.dom,c=s.top,u= (…)
/plugin/sequencediagram/bower_components/js-sequence-diagrams/dist/
H A Dsequence-diagram-raphael-min.js.map1 …7","parseError","str","recoverable","parse","lex","token","lexer","self","stack","vstack","lstack"…
H A Dsequence-diagram-min.js.map1 …7","parseError","str","recoverable","parse","lex","token","lexer","self","stack","vstack","lstack"…
/plugin/datatables/assets/pdfmake/build/
H A Dpdfmake.min.js
/plugin/ckgedit/ckeditor/
H A Dckeditor.js1235stack=[]};m.prototype={push:function(a){a=this.stack.push({keyCode:a,inputs:0});return this.stack[…
1236stack[a]:null},increment:function(a){this.getLast(a).inputs++},remove:function(a){a=this.getLastIn…
H A Dckeditor.js.unc24553 this.stack = []
24557 a = this.stack.push({
24561 return this.stack[a - 1]
24564 if ("number" != typeof a) return this.stack.length - 1;
24565 for (var b = this.stack.length; b--;)
24566 if (this.stack[b].keyCode ==
24572 return -1 != a ? this.stack[a] : null
24578 a = this.getLastIndex(a); - 1 != a && this.stack.splice(a, 1)
24583 for (a = this.stack.length; a--;) this.stack[a].inputs = 0
24586 for (var a = this.stack.length, b = 0; a--;) b += this.stack[a].inputs;
/plugin/highlightjs/highlight/
H A Dhighlight.pack.js1 …tream:1,istringstream:1,ostringstream:1,auto_ptr:1,deque:1,list:1,queue:1,stack:1,vector:1,map:1,s… property in hljs.LANGUAGES.cpp.a.built_in
/plugin/sequencediagram/bower_components/lodash/doc/
H A DREADME.md3887 Defers invoking the `func` until the current call stack has cleared. Any
4610 up to four arguments; *(value [, index|key, object, stack])*.
5153 six arguments: *(objValue, othValue [, index|key, object, other, stack])*.
7955 *(objValue, srcValue, key, object, source, stack)*.
9736 // line numbers in error messages and stack traces.
/plugin/davcal/fullcalendar-3.10.5/
H A Dmoment.js324 …rn(msg + '\nArguments: ' + Array.prototype.slice.call(args).join('') + '\n' + (new Error()).stack);
/plugin/dirtylittlehelper/mermaid/editor/
H A Dbundle.js1stack;return setTimeout(()=>{e[o]||console.log(t)},3e3),e}class l extends Error{constructor(e){sup…
396stack||e.stacktrace)?l.a("stackTrace.format","{0}: {1}",E(e),D(e.stack)||D(e.stacktrace)):E(e)}fun…
426stack),n=!1}return t.apply(this,arguments)}),t)}var M,D={};function E(e,t){null!=r.deprecationHand…
/plugin/dirtylittlehelper/mermaid/editor/docs/
H A Dbundle.js1stack;return setTimeout(()=>{e[o]||console.log(t)},3e3),e}class l extends Error{constructor(e){sup…
396stack||e.stacktrace)?l.a("stackTrace.format","{0}: {1}",E(e),D(e.stack)||D(e.stacktrace)):E(e)}fun…
426stack),n=!1}return t.apply(this,arguments)}),t)}var M,D={};function E(e,t){null!=r.deprecationHand…
H A D3.3.js.map1stack\n\n if ((parser_token.tag_name === 'script' || parser_token.tag_name === 'style') &&\n …
/plugin/pdfjs/pdfjs/web/
H A Dviewer.js1111 if (moreInfo.stack) {
1113 stack: moreInfo.stack
/plugin/jmol2/jmol/
H A DJmolApplet.jarMETA-INF/ META-INF/MANIFEST.MF org/ org/jmol/ org/ ...
H A DJmolAppletSigned.jarMETA-INF/MANIFEST.MF META-INF/SELFSIGN.SF META-INF/SELFSIGN ...
H A DCHANGES.txt484 # new feature: SHOW TRACE -- reports stack trace
487 # new feature: SHOW VARIABLES now gives variable trace through function stack
2580 # new feature: ZAP clears undo stack
/plugin/processing/
H A Dscript.js11777 var stack = [];
11781 stack.push(result); result = item;
11785 result = stack.pop() + '"' + kind + (index + 1) + '"';
/plugin/findologicxmlexport/vendor/phpunit/php-code-coverage/src/Report/Html/Renderer/Template/js/
H A Dnv.d3.min.js5 …ion(a){return{x:a.x,y:0,series:a.series,size:.01}})}]),u){var H=d3.layout.stack().offset(v).values…
6 …t,C=l-j.top-j.bottom;n=d3.select(this),a.utils.initSVG(n),w&&(b=d3.layout.stack().offset("zero").v…
8 …sIndex=b,a})});var x=m.filter(function(a){return!a.disabled});m=d3.layout.stack().order(o).offset(…
/plugin/abc2/abc-libraries/abc-ui/
H A Dabc-ui-1.0.0.min.js8 function external_eval(param){return eval(param)}function isQuoted(e){return e.q}function quote(e){return e.q=!0,e}function unquote(e){return delete e.q,e}function Symbol(e){return this.nm=e,this}function isSymbol(e){return e&&e.constructor===Symbol}function symbolName(e){return e.nm}function isArray(e){return e&&e.constructor===Array}function inDs(e,t){for(var n=e.length-1;0<=n;--n)if("undefined"!=typeof e[n][t])return e[n];return!1}function member(e,t){return 0<=t.indexOf(e)}function PsParser(){function t(t){e.L=t,e.N=t.length,e.I=0,e.D=0}function n(){return e.I<e.N&&e.L[e.I]}function r(){return e.I<e.N&&e.L[e.I++]}function i(){while(e.I<e.N&&member(e.L[e.I]," \n"))e.I++}function s(){while("%"==n()){while(n()&&"\n"!=n())r();i()}}function o(){r();var e=[],t=1;while(0<t&&n()){var i=r();switch(i){case"(":t++;break;case")":t--,t<=0&&(i=!1);break;case"\\":i=r();switch(i){case"(":break;case")":break;case"\\":break;case"n":i="\n";break;case"r":i="\r";break;case"t":i=" ";break;default:i=!1}}i!==!1&&e.push(i)}return e.join("")}function u(){var e=r();if(member(e,"()<>/% \n"))throw new Error("Symbol expected, got "+e);var t=member(e,"+-0123456789."),i="."==e,s=[e];while(n()&&!member(n(),"()<>[]{}/% \n"))e=r(),s.push(e),t&&!member(e,"0123456789")&&(!i&&"."==e?i=!0:t=!1);return s=s.join(""),1==s.length&&member(s,"+-.")&&(t=!1),t?i?parseFloat(s):parseInt(s,10):new Symbol(s)}function a(){i();switch(n()){case!1:return undefined;case"%":return s();case"[":return new Symbol(r());case"]":return new Symbol(r());case"{":return e.D++,new Symbol(r());case"}":return e.D--,new Symbol(r());case"/":r();var t=u();return quote(t);case"(":return o();case"<":r();if("<"!=n())throw new Error("Encoded strings not implemented yet");return r(),new Symbol("<<");case">":r();if(">"!=n())throw new Error("Unexpected >");return r(),new Symbol(">>");default:return u()}}var e=this;return PsParser.prototype.init=t,PsParser.prototype.peek=n,PsParser.prototype.token=a,this}function Ps0(e,t,n){function r(i,s){if(isSymbol(i)&&!isQuoted(i)){var o=symbolName(i),u=inDs(t,o);if(!u)throw new Error("bind error '"+o+"'");n.push([!1,u[o]])}else if(s&&isArray(i)&&isQuoted(i)){if(0<i.length){var a=i[0],f=quote(i.slice(1));0<f.length&&n.push([!1,f]),r(a,!1)}}else"function"==typeof i?i():e.push(i)}function i(){var t=e.pop();r(t,!1)}function s(){var t=n.pop(),i=t.shift(),s=t.pop();for(var o=0;o<t.length;o++)e.push(t[o]);r(s,!0)}function u(t){o.init(t);while(o.peek()){var r=o.token();if(r||r===0){e.push(r);if(o.D<=0||isSymbol(r)&&(member(symbolName(r),"[]{}")||"<<"==symbolName(r)||">>"==symbolName(r))){i();while(0<n.length)s()}}}return e}var o=new PsParser;return Ps0.prototype.run=r,Ps0.prototype.exec=i,Ps0.prototype.step=s,Ps0.prototype.parse=u,this}function Wps(e){function f(e){if(isSymbol(e)&&!isQuoted(e))return e;if(isArray(e)&&isQuoted(e)){var t=e.length,n=[];for(var r=0;r<t;r++){var i=e[r],s=f(i);isArray(i)?n=n.concat(isQuoted(i)?quote([s]):[s]):n=n.concat(s)}return quote(n)}return e}function l(){var e=arguments;if(e.length)for(var t=0;t<e.length;t++)o.parse(e[t]);else o.parse(e);return n}var t=e,n=[],r={},i=[r],s=[],o=new Ps0(n,i,s);r["true"]=function(){n.push(!0)},r["false"]=function(){n.push(!1)},r["null"]=function(){n.push(null)},r.sub=function(){var e=n.pop();n.push(n.pop()-e)},r.mul=function(){n.push(n.pop()*n.pop())},r.div=function(){var e=n.pop();n.push(n.pop()/e)},r.mod=function(){var e=n.pop();n.push(n.pop()%e)};var u={};r.mark=function(){n.push(u)},r.counttomark=function(){var e=0;for(var t=n.length-1;0<=t;t--){if(u===n[t])return n.push(e);e++}throw new Error("Mark not found")},r["<<"]=r.mark,r[">>"]=function(){var e={};while(0<n.length){var t=n.pop();if(u===t)return n.push(e);e[n.pop()]=t}throw new Error("Mark not found")},r.exch=function(){var e=n.pop(),t=n.pop();n.push(e),n.push(t)},r.clear=function(){n.length=0},r.pop=function(){n.pop()},r.index=function(){n.push(n[n.length-2-n.pop()])},r.roll=function(){var e=n.pop(),t=n.pop(),r=[],i=[];e<0&&(e=t+e);for(var s=0;s<t;s++)s<e?r.unshift(n.pop()):i.unshift(n.pop());for(s=0;s<e;s++)n.push(r.shift());for(s=0;s<t-e;s++)n.push(i.shift())},r.copy=function(){var e=n.pop();if("object"==typeof e){var t=n.pop();for(var r in t)e[r]=t[r];n.push(e)}else{var t=n.length-e;for(var r=0;r<e;r++)n.push(n[t+r])}},r.length=function(){n.push(n.pop().length)},r.astore=function(){var e=n.pop(),t=e.length;for(var r=t-1;0<=r;r--)e[r]=n.pop();n.push(e)},r.array=function(){n.push(new Array(n.pop()))},r.eq=function(){var e=n.pop(),t=n.pop();n.push(t==e)},r.lt=function(){var e=n.pop(),t=n.pop();n.push(t<e)},r.ifelse=function(){var e=n.pop(),t=n.pop(),r=n.pop();s.push([!1,r===!0?t:e])},r.and=function(){var e=n.pop(),t=n.pop();if(!0===e||!1===e){n.push(e==1&&t===!0);return}n.push(e&t)},r.repeat=function c(){var e=n.pop(),t=n.pop();1<t&&s.push([!0,t-1,e,c]),0<t&&s.push([!1,e])},r["for"]=function h(){var e=n.pop(),t=n.pop(),r=n.pop(),i=n.pop();r<0?(t<=i+r&&s.push([!0,i+r,r,t,e,h]),t<=i&&s.push([!1,i,e])):(i+r<=t&&s.push([!0,i+r,r,t,e,h]),i<=t&&s.push([!1,i,e]))},r.exec=function(){s.push([!1,n.pop()])},r.cvx=function(){var e=n.pop();isSymbol(e)&&isQuoted(e)?n.push(unquote(e)):isArray(e)&&!isQuoted(e)?n.push(quote(e)):n.push(e)},r.dict=function(){n.pop(),n.push({})},r.get=function(){var e=n.pop(),t=n.pop();isSymbol(e)?n.push(t[symbolName(e)]):n.push(t[e])},r.getinterval=function(){var e=n.pop(),t=n.pop()+e,r=n.pop(),i=[];while(--e>=0)i.push(r[t++]);n.push(i)},r.put=function(){var e=n.pop(),t=n.pop(),r=n.pop();isSymbol(t)?r[symbolName(t)]=e:r[t]=e},r.begin=function(){i.push(n.pop())},r.end=function(){i.pop()},r.currentdict=function(){n.push(i[i.length-1])},r.where=function(){var e=symbolName(n.pop()),t=inDs(i,e);t?(n.push(t),n.push(!0)):n.push(!1)},r.save=function(){var e=i.slice();for(var t=0;t<e.length;t++){var r=e[t],s={};for(var o in r)s[o]=r[o];e[t]=s}n.push(e)},r.restore=function(){var e=n.pop();while(0<i.length)i.pop();while(0<e.length)i.unshift(e.pop())},r.type=function(){var e=n.pop(),t;if(null===e)t="nulltype";else if(!0===e||!1===e)t="booleantype";else if(u===e)t="marktype";else if("string"==typeof e)t="stringtype";else if(isSymbol(e))t=isQuoted(e)?"nametype":"operatortype";else if("function"==typeof e)t="operatortype";else if(isArray(e))t="arraytype";else if("object"==typeof e)t="dicttype";else{if(1*e!=e)throw new Error("Undefined type '"+e+"'");t=e%1==0?"integertype":"realtype"}n.push(t)};var a=!0;return r[".strictBind"]=function(){a=!0===n.pop()},r.bind=function(){n.push(f(n.pop()))},r["="]=function(){var e=n.pop();alert(e&&e.nm||e)},r["=="]=function(){alert(n.pop())},r.stack=function(){alert(n)},r.pstack=function(){alert(n)},r[".call"]=function(){var e=n.pop(),t=n.pop(),r=n.pop(),i=[];for(var s=0;s<e;s++)i.unshift(n.pop());if(!r[t])throw new Error(".call: "+t+" undef");n.push(r[t].apply(r,i))},r[".call0"]=function(){var e=n.pop(),t=n.pop(),r=n.pop(),i=[];for(var s=0;s<e;s++)i.unshift(n.pop());if(!r[t])throw new Error(".call0: "+t+" undef");r[t].apply(r,i)},r[".svg"]=function(){n.push(t)},r[".math"]=function(){n.push(Math)},r[".date"]=function(){n.push(new Date)},r[".window"]=function(){n.push(window)},r[".callback"]=function(){var e=n.pop();n.push(function(){o.run(e,!0);while(0<s.length)o.step()})},r[".minv"]=function(){var e=n.pop(),t=e[0],r=e[1],i=e[2],s=e[3],o=e[4],u=e[5];n.push([s,r,i,t,i*u-s*o,r*o-t*u])},r[".mmul"]=function(){var e=n.pop(),t=n.pop(),r=t[0],i=t[1],s=t[2],o=t[3],u=t[4],a=t[5],f=e[0],l=e[1],c=e[2],h=e[3],p=e[4],d=e[5];n.push([r*f+i*c,r*l+i*h,s*f+o*c,s*l+o*h,u*f+a*c+p,u*l+a*h+d])},r[".xy"]=function(){var e=n.pop(),t=n.pop(),r=n.pop();n.push(e[0]*r+e[2]*t+e[4]),n.push(e[1]*r+e[3]*t+e[5])},r[".rgb"]=function(){var e=n.pop(),t=n.pop(),r=n.pop();n.push("rgb("+r+","+t+","+e+")")},r[".rgba"]=function(){var e=n.pop(),t=n.pop(),r=n.pop(),i=n.pop();n.push("rgba("+i+","+r+","+t+","+e+")")},Wps.prototype.parse=l,this}function Psvg(e){function d(){return w(0),[o.xoffs-o.xorig,o.yoffs-o.yorig]}function v(){s=!1,w(0),t+="<g";if(o.xscale!=1||o.yscale!=1||o.rotate){t+=' transform="';if(o.xscale!=1||o.yscale!=1)o.xscale==o.yscale?t+="scale("+o.xscale.toFixed(3)+")":t+="scale("+o.xscale.toFixed(3)+","+o.yscale.toFixed(3)+")";if(o.rotate){if(o.xoffs||o.yoffs){var e,n=o.xoffs,r=o.yoffs,u=o.sin,l=o.cos;e=n*l-r*u,r=n*u+r*l,t+=" translate("+e.toFixed(2)+","+r.toFixed(2)+")",a=o.xoffs,f=o.yoffs,o.xoffs=0,o.yoffs=0}t+=" rotate("+o.rotate.toFixed(2)+")"}t+='"'}g(!1),o.rgb&&(t+=' style="color:'+o.rgb+'"'),t+=">\n",i=1}function m(e){var t,n=new e.constructor;for(t in e)e.hasOwnProperty(t)&&(n[t]=e[t]);return n}function g(e){var n=o.font_n;if(!n)return;var r="",i=n.indexOf("Italic"),s=100,u=n.indexOf("Oblique"),a=n.indexOf("Bold"),f=0;a>0&&(r=' font-weight="bold"',s=a,f=2);if(i>0||u>0)i>0&&(r+=' font-style="italic"',i<s&&(s=i),f|=4),u>0&&(r+=' font-style="oblique"',u<s&&(s=u),f=8);s!=100&&(n[s-1]=="-"&&s--,n=n.slice(0,s)),e&&(!(f&2)&&c.indexOf("Bold")>=0&&(r+=' font-weight="normal"'),!(f&12)&&(c.indexOf("Italic")>=0||c.indexOf("Oblique")>=0)&&(r+=' font-style="normal"')),t+=' font-family="'+n+'"'+r+' font-size="'+o.font_s+'"'}function y(){if(p)return;w(1),o.px=o.cx,o.py=o.cy,p='<path d="m'+(o.xoffs+o.cx).toFixed(2)+" "+(o.yoffs-o.cy).toFixed(2)+"\n"}function b(){t+=p,p=""}function w(e){i==2&&(t+="</text>\n",i=1),e==0?i&&(i=0,t+="</g>\n",o.rotate&&(o.xoffs=a,o.yoffs=f,a=0,f=0)):s&&v()}function E(e){return e.length*o.font_s*.5}function S(e,t,n,r,i,s){var u,a,f,l;r>=360&&(r-=360),i>=360&&(i-=360),u=e+n*Math.cos(r*Math.PI/180),a=t+n*Math.sin(r*Math.PI/180),o.cx!=undefined?p?(u!=o.cx||a!=o.cy?p+="l":p+="m",p+=(u-o.cx).toFixed(2)+" "+(-(a-o.cy)).toFixed(2)):(o.cx=u,o.cy=a,y()):(p&&(p=""),o.cx=u,o.cy=a,y()),r==i?(i=180-r,f=e+n*Math.cos(i*Math.PI/180),l=t+n*Math.sin(i*Math.PI/180),p+="a"+n.toFixed(2)+" "+n.toFixed(2)+" 0 0 "+(s?"1 ":"0 ")+(f-u).toFixed(2)+" "+(a-l).toFixed(2)+" "+n.toFixed(2)+" "+n.toFixed(2)+" 0 0 "+(s?"1 ":"0 ")+(u-f).toFixed(2)+" "+(l-a).toFixed(2)+"\n",o.cx=u,o.cy=a):(f=e+n*Math.cos(i*Math.PI/180),l=t+n*Math.sin(i*Math.PI/180),p+="a"+n.toFixed(2)+" "+n.toFixed(2)+" 0 0 "+(s?"1 ":"0 ")+(f-u).toFixed(2)+" "+(a-l).toFixed(2)+"\n",o.cx=f,o.cy=l)}function x(e,t){y(),e==0?p+=" v"+(-t).toFixed(2)+"\n":t==0?p+=" h"+e.toFixed(2)+"\n":p+=" l"+e.toFixed(2)+" "+(-t).toFixed(2)+"\n",o.cx+=e,o.cy+=t}function T(e){e&&w(0);if(!t)return;n.out_svg(t),t=""}function N(e,t,i,s){return o.xorig=o.xoffs=n.sx(0),o.yorig=o.yoffs=n.sy(0),o.cx=0,o.cy=0,r.parse(s+(t/n.stv_g().scale).toFixed(2)+" "+i.toFixed(2)+" "+e),T(!0),!0}var t="",n=e,r=new Wps(this),i=0,s,o={cx:0,cy:0,xoffs:0,yoffs:0,xscale:1,yscale:1,rotate:0,sin:0,cos:1,linewidth:.7,dash:""},u=[],a=0,f=0,l="",c="",h=0,p;Psvg.prototype.strw=E,Psvg.prototype.arc=S,Psvg.prototype.arcn=function(e,t,n,r,i){S(e,t,n,r,i,!0)},Psvg.prototype.closepath=function(){p&&o.cx&&x(o.px-o.cx,o.py-o.cy)},Psvg.prototype.cx=function(){return o.cx},Psvg.prototype.cy=function(){return o.cy},Psvg.prototype.curveto=function(e,t,n,r,i,s){y(),p+=" C"+(o.xoffs+e).toFixed(2)+" "+(o.yoffs-t).toFixed(2)+" "+(o.xoffs+n).toFixed(2)+" "+(o.yoffs-r).toFixed(2)+" "+(o.xoffs+i).toFixed(2)+" "+(o.yoffs-s).toFixed(2)+"\n",o.cx=i,o.cy=s},Psvg.prototype.eofill=function(){b(),t+='" fill-rule="evenodd" fill="currentColor"/>\n'},Psvg.prototype.fill=function(){b(),t+='" fill="currentColor"/>\n'},Psvg.prototype.gsave=function(){u.push(m(o))},Psvg.prototype.grestore=function(){o=u.pop(),s=!0},Psvg.prototype.lineto=function(e,t){y(),e==o.cx?p+=" v"+(o.cy-t).toFixed(2)+"\n":t==o.cy?p+=" h"+(e-o.cx).toFixed(2)+"\n":p+=" l"+(e-o.cx).toFixed(2)+" "+(o.cy-t).toFixed(2)+"\n",o.cx=e,o.cy=t},Psvg.prototype.moveto=function(e,n){o.cx=e,o.cy=n,p?p+=" M"+(o.xoffs+o.cx).toFixed(2)+" "+(o.yoffs-o.cy).toFixed(2)+"\n":i==2&&(t+="</text>\n",i=1)},Psvg.prototype.newpath=function(){o.cx=o.cy=undefined},Psvg.prototype.rcurveto=function(e,t,n,r,i,s){y(),p+=" c"+e.toFixed(2)+" "+(-t).toFixed(2)+" "+n.toFixed(2)+" "+(-r).toFixed(2)+" "+i.toFixed(2)+" "+(-s).toFixed(2)+"\n",o.cx+=i,o.cy+=s},Psvg.prototype.rlineto=x,Psvg.prototype.rmoveto=function(e,n){p?p+=" m"+e.toFixed(2)+" "+(-n).toFixed(2)+"\n":i==2&&(t+="</text>\n",i=1),o.cx+=e,o.cy+=n},Psvg.prototype.rotate=function(e){w(0);var t,n=o.xoffs,r=o.yoffs,i=o.sin,u=o.cos;t=n*u-r*i,r=n*i+r*u,o.xoffs=t/o.xscale,o.yoffs=r/o.yscale,n=o.cx,r=o.cy,t=n*u-r*i,r=-n*i+r*u,o.cx=t/o.xscale,o.cy=r/o.yscale,e=360-e,o.rotate+=e,o.rotate>180?o.rotate-=360:o.rotate<=-180&&(o.rotate+=360),e=o.rotate*Math.PI/180,o.sin=i=Math.sin(e),o.cos=u=Math.cos(e),t=o.cx,o.cx=(t*u+o.cy*i)*o.xscale,o.cy=(-t*i+o.cy*u)*o.yscale,t=o.xoffs,o.xoffs=(t*u+o.yoffs*i)*o.xscale,o.yoffs=(-t*i+o.yoffs*u)*o.yscale,s=!0},Psvg.prototype.scale=function(e,t){o.xoffs/=e,o.yoffs/=t,o.cx/=e,o.cy/=t,o.xscale*=e,o.yscale*=t,s=!0},Psvg.prototype.selectfont=function(e,t){e=e.nm;if(h!=t||e!=l)o.font_n_old=o.font_n,o.font_n=e,o.font_s=t,s=!0},Psvg.prototype.setdash=function(e,t){var n=e.length,r;if(n==0){o.dash="";return}o.dash=' stroke-dashoffset="'+t+'" stroke-dasharray="',r=0;for(;;){o.dash+=e[r];if(--n==0)break;o.dash+=" "}o.dash+='"'},Psvg.prototype.setlinewidth=function(e){o.linewidth=e},Psvg.prototype.setrgbcolor=function(e,t,n){var r=16777216+(Math.floor(e*255)<<16)+(Math.floor(t*255)<<8)+Math.floor(n*255);r=r.toString(16),r=r.replace("1","#"),r!=o.rgb&&(o.rgb=r,s=!0)},Psvg.prototype.show=function(e){var n,r,u;s&&(i==2?n=!0:v()),r=o.cx,u=o.cy,n?(t+="<tspan\n ",g(!0),t+=">"):i!=2&&(t+='<text x="'+(r+o.xoffs).toFixed(2)+'" y="'+(o.yoffs-u).toFixed(2)+'">',i=2),t+=e.replace(/<|>|&| /g,function(e){switch(e){case"<":return"&lt;";case">":return"&gt;";case"&":return"&amp;";case" ":return"  "}}),n&&(t+="</tspan>"),o.cx=r+E(e)},Psvg.prototype.stroke=function(){b(),o.linewidth!=.7&&(t+='" stroke-width="'+o.linewidth.toFixed(2)),t+='" stroke="currentColor" fill="none"'+o.dash+"/>\n"},Psvg.prototype.translate=function(e,t){o.xoffs+=e,o.yoffs-=t,o.cx-=e,o.cy-=t},Psvg.prototype.arp=function(e,t,r){var i=d();T(),n.out_arp((t+i[0])*n.stv_g().scale,r-i[1],e)},Psvg.prototype.ltr=function(e,t,r){var i=d();T(),n.out_ltr((t+i[0])*n.stv_g().scale,r-i[1],e)},Psvg.prototype.xygl=function(e,t,r){var i=d();T(),n.xygl((e+i[0])*n.stv_g().scale,t-i[1],r)},Psvg.prototype.xygls=function(e,t,r,i){var s=d();T(),n.out_deco_str((t+s[0])*n.stv_g().scale,r-s[1],i,e)},Psvg.prototype.xyglv=function(e,t,r,i){var s=d();T(),n.out_deco_val((t+s[0])*n.stv_g().scale,r-s[1],i,e)},Psvg.prototype.y0=function(e){var t=n.get_staff_tb();return e+t[0].y},Psvg.prototype.y1=function(e){var t=n.get_staff_tb();return e+t[1].y},Psvg.prototype.ps_flush=T,Psvg.prototype.ps_eval=function(e){r.parse(e),T()},Psvg.prototype.psdeco=function(e,t,i,s){var o,u,a,f,l=r.parse("/"+e+" where"),c=l.pop(),h=n.get_staff_tb();return c?(f=0,s.defl.nost&&(f=1),s.defl.noen&&(f|=2),s.s.stem>=0&&(f|=4),l.pop(),a="/defl "+f+" def ",s.lden&&(a+=t.toFixed(2)+" "+i.toFixed(2)+" ",u=s.start,t=u.x,i=u.y+h[u.st].y,t>s.x-20&&(t=s.x-20)),o=s.dd,s.has_val?a+=s.val+" ":o.str&&(a+="("+o.str+") ",i+=o.h*.2),N(e,t,i,a)):!1},Psvg.prototype.psxygl=function(e,t,n){var i=r.parse("/"+n+" where"),s=i.pop();return s?(i.pop(),N(n,e,t,"dlw ")):!1},Psvg.prototype.svgcall=function(e,t,r,i,s){var o=d();T(),e((t+o[0])*n.stv_g().scale,r-o[1],i,s)},r.parse("currentdict/systemdict currentdict put\nsystemdict/{/mark cvx put\nsystemdict/[/mark cvx put\nsystemdict/]\n/counttomark cvx\n/array cvx\n/astore cvx\n/exch cvx\n/pop cvx\n5 array astore cvx put\nsystemdict/}/] cvx/cvx cvx 2 array astore cvx put\nsystemdict/def{currentdict 2 index 2 index put pop pop}put\n\n/maxlength 1000 def % TODO\n/.bdef{bind def}bind def\n/.xdef{exch def}.bdef\n/dup{0 index}.bdef\n/load{dup where pop exch get}.bdef\n/.ldef{load def}.bdef\n/if{{}ifelse}.bdef\n/cleartomark{array pop}.bdef\n/known{exch begin where{currentdict eq}{false}if end}.bdef\n/store{1 index where{3 1 roll put}{def}ifelse}.bdef\n/not{{false}{true}ifelse}.bdef\n%/.logand{{{true}{false}ifelse}{pop false}ifelse}.bdef\n%/and/.logand .ldef % TODO numeric and\n/.logor{{pop true}{{true}{false}ifelse}ifelse}.bdef\n/or/.logor .ldef % TODO numeric or\n/ne{eq not}.bdef\n/ge{lt not}.bdef\n/le{1 index 1 index eq 3 1 roll lt or}.bdef\n/gt{le not}.bdef\n/.repeat{1 1 4 2 roll for}.bdef\n\n%% math\n\n/floor{.math(floor)1 .call}.bdef\n\n/neg{0 exch sub}.bdef\n/add{neg sub}.bdef\n/idiv{div floor}.bdef\n\n/.pi{.math(PI)get}.bdef\n\n/abs{.math(abs)1 .call}.bdef\n%/.acos{.math(acos)1 .call}.bdef\n%/.asin{.math(asin)1 .call}.bdef\n/atan{.math(atan2)2 .call 180 mul .pi div}.bdef\n%/.atan2{.math(atan2)2 .call}.bdef\n%/ceiling{.math(ceil)1 .call}.bdef\n/cos{.pi mul 180 div .math(cos)1 .call}.bdef\n%/.exp{.math(exp)1 .call}.bdef\n%/log{.math(log)1 .call}.bdef\n%/.max{.math(max)2 .call}.bdef\n%/.min{.math(min)2 .call}.bdef\n%/.pow{.math(pow)2 .call}.bdef\n%/.random{.math(random)0 .call}.bdef\n%/rand{.random}.bdef % TODO follow spec\n%/round{.math(round)1 .call}.bdef\n%/sin{.math(sin)1 .call}.bdef\n%/sqrt{.math(sqrt)1 .call}.bdef\n%/.tan{.math(tan)1 .call}.bdef\n%/truncate{.math(truncate)1 .call}.bdef % TODO Math.truncate does not exist!\n\n% graphic\n/arc{.svg(arc)5 .call0}.bdef\n/arcn{.svg(arcn)5 .call0}.bdef\n/closepath{.svg(closepath)0 .call}.bdef\n/currentpoint{.svg(cx)0 .call .svg(cy)0 .call}.bdef\n/curveto{.svg(curveto)6 .call0}.bdef\n/eofill{.svg(eofill)0 .call0}.bdef\n/fill{.svg(fill)0 .call0}.bdef\n/grestore{.svg(grestore)0 .call0}.bdef\n/gsave{.svg(gsave)0 .call0}.bdef\n/lineto{.svg(lineto)2 .call0}.bdef\n/moveto{.svg(moveto)2 .call0}.bdef\n/newpath{.svg(newpath)0 .call0}.bdef\n/rcurveto{.svg(rcurveto)6 .call0}.bdef\n/rlineto{.svg(rlineto)2 .call0}.bdef\n/rmoveto{.svg(rmoveto)2 .call0}.bdef\n/rotate{.svg(rotate)1 .call0}.bdef\n/scale{.svg(scale)2 .call0}.bdef\n/selectfont{.svg(selectfont)2 .call0}.bdef\n/setdash{.svg(setdash)2 .call0}.bdef\n/setlinewidth{.svg(setlinewidth)1 .call0}.bdef\n/setrgbcolor{.svg(setrgbcolor)3 .call0}.bdef\n/show{.svg(show)1 .call0}.bdef\n/stroke{.svg(stroke)0 .call0}.bdef\n/stringwidth{.svg(strw)1 .call 1}.bdef %fixme: height KO\n/translate{.svg(translate)2 .call0}.bdef\n\n/setgray{255 mul dup dup setrgbcolor}.bdef\n% abcm2ps syms.c\n/!{bind def}bind def\n/T/translate load def\n/M/moveto load def\n/RM/rmoveto load def\n/L/lineto load def\n/RL/rlineto load def\n/C/curveto load def\n/RC/rcurveto load def\n/SLW/setlinewidth load def\n/defl 0 def\n/dlw{0.7 SLW}!\n/xymove{/x 2 index def/y 1 index def M}!\n/showc{dup stringwidth pop .5 mul neg 0 RM show}!\n%\n% abcm2ps internal glyphs\n/arp{.svg(arp)3 .call0}.bdef\n/ltr{.svg(ltr)3 .call0}.bdef\n/ft0{(acc-1).svg(xygl)3 .call0}.bdef\n/nt0{(acc3).svg(xygl)3 .call0}.bdef\n/sh0{(acc1).svg(xygl)3 .call0}.bdef\n/dsh0{(acc2).svg(xygl)3 .call0}.bdef\n/trl{(trl).svg(xygl)3 .call0}.bdef\n/lmrd{(lmrd).svg(xygl)3 .call0}.bdef\n/turn{(turn).svg(xygl)3 .call0}.bdef\n/umrd{(umrd).svg(xygl)3 .call0}.bdef\n/y0{.svg(y0)1 .call}.bdef\n/y1{.svg(y1)1 .call}.bdef\n")}var abc=null,$ABC_UI=function(){"use strict";function $(e,t,n){return e.indexOf(t)!==-1?"":t+" "+n+"\n"}function J(e,t){e=e||{};if(e.zoom===undefined||e.zoom===null)e.zoom=1;if(e.pagewidth===undefined||e.pagewidth===null)e.pagewidth=p;var r=q+" s"+n+"\n";return n++,r+=$(t,"%%pagewidth",e.pagewidth.toString()+"cm"),r+=$(t,"%%staffwidth",e.pagewidth.toString()+"cm"),r+=$(t,"%%scale",e.zoom.toString()),r+=$(t,"%%topmargin","0px"),r+=$(t,"%%botmargin","0px"),r+=$(t,"%%leftmargin","16px"),r+=$(t,"%%rightmargin","8px"),r+=$(t,"%%topspace","0px"),r+=$(t,"%%musicspace","0px"),r+=$(t,"%%vocalspace","0px"),r+=$(t,"%%staffsep","0px"),r+=$(t,"%%sysstaffsep",".7cm"),r+=$(t,"%%vocalfont Time","13"),r}function K(e,t){var n=e.nextSibling.nextSibling;n!==null&&n.nodeName==="#text"&&(n=e.nextSibling.nextSibling);if(n!==null&&n!==undefined&&n.nodeName&&n.nodeName==="DIV"&&n.classList&&n.classList.contains(t))return n;n=e.cloneNode(!0);var r=n.classList;while(r.length>0)r.remove(r.item(0));return n.classList.add(t),e&&e.nextSibling&&e.nextSibling.nodeName=="#text"&&(e=e.nextSibling),e.parentNode.insertBefore(n,e.nextSibling),n}function Q(e,t){var n="",r={read_file:null,errmsg:function(e,t,n){},img_out:function(e){n+=e},page_format:!1},i=J(t,e)+X+V;abc=new Abc(r);try{abc.tosvg("edit",i),abc.tosvg("score.abc",e)}catch(s){var o="%c "+s.message+"\nabc2svg tosvg bug - stack:\n"+s.stack;console.log(o,"color: red;")}return n}function G(e,t){const n={beam:!0,slur:!0,tuplet:!0,deco:!0};var r="",i={read_file:null,errmsg:function(e,t,n){},img_out:function(e){r+=e},anno_start:null,anno_stop:function(e,r,i,s,o,u,a){if(n[e])return;isNaN(u)||(abc.out_svg('<rect class="'+C+" "+t.idScore+" "+r+'" x="'),abc.out_sxsy(s,'" y="',o),abc.out_svg('" width="'+u.toFixed(2)+'" height="'+a.toFixed(2)+'"/>\n'))}},s=J(t,e)+X+V;abc=new Abc(i);try{abc.tosvg("edit",s),abc.tosvg("follower.abc",e)}catch(o){var u="%c "+o.message+"\nabc2svg tosvg bug - stack:\n"+o.stack;console.log(u,"color: red;")}return r}function Y(e,t){if(t===undefined)return;var n=document.getElementById(e);if(n===undefined||n===null)return null;var r=t.indexOf(B,0)===-1,i={errmsg:function(e,t,n){console.log("%c "+e,"color: red;")},get_abcmodel:function(t,i,s,f){var l=i.length;for(var c=0;c<l;c++){var h=i[c],p=h.instr||0;h.midictl&&(h.midictl[32]&&(p+=h.midictl[32]*128),h.midictl[0]&&(p+=h.midictl[0]*128*128),p=128),u.indexOf(p)===-1&&(u.push(p),o=!1)}var d=0;if(r&&l>1){var v=!0;for(c=0;c<l;c++){var m=$ABC_UTIL.remapVoiceName(i[c],a);if($ABC_UTIL.isActiveVoice(m)){d++,v||n.appendChild(document.createElement("br")),v=!1;var g=document.createElement("input");g.type="checkbox",g.id=e+"_V"+c,g.classList.add(A),g.checked=!0,n.appendChild(g);var y=document.createElement("label");y.classList.add(N),y.appendChild(document.createTextNode(" "+m)),n.appendChild(y)}}}n.hidden=d<2}},s=I+"\n"+X;try{abc=new Abc(i),abc.tosvg("player",s),abc.tosvg("audio.abc",t)}catch(f){var l="%c "+f.message+"\nabc2svg tosvg bug - stack:\n"+f.stack;console.log(l,"color: red;")}}function Z(e,n,o){function ot(e){var t=st;e!==undefined&&(t=$ABC_UTIL.updateTempo(st,e));var n={events:$ABC_EVENTS.render(t,g,X),id:v};ut&&(ut.value=JSON.stringify(n));var r={idScore:v,zoom:o.scale,pagewidth:u};rt.innerHTML=$ABC_UTIL.svgMerge(Q(t,r),G(t,r))}if(e===undefined||e===null)return null;var u=parseFloat(e.classList[1]);isNaN(u)&&(u=p);var f=parseFloat(e.classList[2]);isNaN(f)||(o.scale=f),o=o||{};var l=n.indexOf(j,0)===-1&&n.indexOf(F,0)===-1;o.bPlayer===undefined&&(o.bPlayer=l),o.width===undefined&&(o.width=h),o.scale===undefined&&(o.scale=d),o.bHideTempo===undefined&&(o.bHideTempo=!0),o.lang===undefined&&(o.lang=a);var c=O+t,v=M+t,m=_+t,g=D+t,y=P+t;t++;var N=$ABC_UTIL.buildTempoSlider(n,m),C=K(e,b),H='<table id="'+c+'">',B='<div id="'+v+'"></div>';if(o.bPlayer){var I=n.indexOf(R,0)!==-1,q=n.indexOf(U,0)!==-1,z=n.indexOf(W,0)!==-1,V=!(I||q||z),$='<button id="'+y+'" class="'+k+'" value="80"></button>',J='<button id="'+m+'" class="'+w+'"></button>',Z='<div id="'+g+'" class="'+T+'"></div>',et="<div>"+N.html+"</div>";V?C.innerHTML=H+"<tr>"+'<td valign="center">'+"<table>"+'<tr><td align="center">'+$+J+et+"</td></tr>"+"<tr><td>"+Z+"</td></tr>"+"</table>"+"</td>"+"<td>"+B+"</td>"+"</tr><table>":z?C.innerHTML=H+"<tr>"+"<td>"+B+"</td>"+'<td valign="center">'+"<table>"+'<tr><td align="center">'+$+J+et+"</td></tr>"+"<tr><td>"+Z+"</td></tr>"+"</table>"+"</td>"+"</tr><table>":I?C.innerHTML=H+"<tr>"+'<td align="center">'+"<table>"+'<tr valign="center">'+'<td align="center">'+$+J+et+"</td>"+'<td width="10px"></td>'+"<td>"+Z+"</td>"+"</tr>"+"</table>"+"</td>"+"</tr>"+"<tr><td>"+B+"</td></tr>"+"<table>":q&&(C.innerHTML=H+"<tr><td>"+B+"</td></tr>"+"<tr>"+'<td align="center">'+"<table>"+'<tr valign="center">'+'<td align="center">'+$+J+et+"</td>"+'<td width="10px"></td>'+"<td>"+Z+"</td>"+"</tr>"+"</table>"+"</td>"+"</tr>"+"<table>")}else C.innerHTML=H+"<tr><td>"+B+"</td></tr><table>";var tt=document.getElementById(c),nt=document.getElementById(m),rt=document.getElementById(v),it=document.getElementById(y),st=$ABC_UTIL.normalize(n,o);if(o.bPlayer){var ut=document.getElementById(m);Y(g,st);var at=N.selection;it.value=at,ot(at);var ft="."+L,lt=tt.querySelectorAll(ft);for(var ct=0,ht=lt.length;ct<ht;ct++)lt[ct].addEventListener("click",function(){var e="."+m+"."+L+"."+E,t=parseInt(this.classList[2]),n=it?it.value:undefined;if(t==n)return;nt.classList.contains(S)&&($EVENT_PLAYER.stop(),nt.classList.toggle(S)),tt.querySelector(e).classList.toggle(E),this.classList.toggle(E),it&&(it.value=t),ot(t)});ft="."+A;var pt=tt.querySelectorAll(ft);for(ct=0,ht=pt.length;ct<ht;ct++)pt[ct].addEventListener("change",function(){nt.classList.contains(S)&&($EVENT_PLAYER.stop(),nt.classList.toggle(S));var e=it?it.value:undefined;e==="undefined"&&(e=undefined),ot(e)});r?ut.classList.contains(x)||ut.classList.add(x):ut.hidden=!r,ut.addEventListener("click",function(){if(this.classList.contains(x)){$EVENT_PLAYER.stop(),this.classList.toggle(S);if(this.classList.contains(S)){var e=document.querySelectorAll("."+w);for(var t=0,n=e.length;t<n;t++)e[t].classList.contains(S)&&e[t]!=ut&&e[t].classList.toggle(S);if(s!==null){var r=document.getElementsByClassName(s);for(t=0,n=r.length;t<n;t++)r[t].style.setProperty("fill-opacity",0)}i=ut;var o=JSON.parse(ut.value);s=o.id,$EVENT_PLAYER.play(0,1e6,o.events)}}})}else{var dt={idScore:v,zoom:o.scale,pagewidth:u};rt.innerHTML=$ABC_UTIL.svgMerge(Q(st,dt),G(st,dt))}}function et(e,t,n){n===undefined&&(n=!1),t=t||!1,e=e||c;var r="div."+y;n||(r+="."+v);var i=e[0]=="m",s=-1,o,u,a="";if(t===!0){var f=i?m:g;s=f;var l=r+"."+f,h=document.querySelectorAll(l);h.forEach(function(e){var t=K(e,b);t.hidden=!0}),f=i?g:m;var p=r+"."+f,d=document.querySelectorAll(p);d.forEach(function(e){var t=K(e,b);t.hidden=!1})}var w=document.querySelectorAll(r);for(o=0,u=w.length;o<u;o++){a="";var E="",S=w[o];if(s===-1||s!==-1&&!S.classList.contains(s)){var x=S.childNodes.length===0?"":S.childNodes[0].nodeValue,T=1,N=e,C=S.classList.contains(v);x.trim()===""?E=external_eval(S.id):S.id!==""?(T=parseFloat(x),isNaN(T)?(T=1,x.indexOf("\n")==-1?(x.charAt(0)!=="<"&&(N=x,C=!0,x.indexOf("m")!=-1?N="m"+x.replace("m",""):x.indexOf("M")==-1&&(N="M"+x)),E=external_eval(S.id)):E=x):E=external_eval(S.id)):E=x;var k={scale:T};C&&(k.transpose=N),Z(S,a+E,k)}}}function tt(e){var t=e||{};t.lang&&(a=t.lang),t.instruments&&t.instruments.length>0&&(u=t.instruments),et(t.tonality,t.bMajorOrMinor,!0),u.length===0&&!o&&u.push(0),u.length>0&&nt(u)}function nt(e){var t=e.length;$EVENT_PLAYER.init(e,function(){$EVENT_PLAYER.stop(),i.classList.contains(S)&&i.classList.toggle(S)},function(e,t){var n=document.getElementsByClassName(s+" "+e);if(n!==undefined&&n.length>0){var r=t?.2:0;n[0].style.setProperty("fill-opacity",r)}},function(e){t--;if(t===0){r=!0;var n=document.querySelectorAll("."+w);for(var i=0,s=n.length;i<s;i++)n[i].classList.toggle(x),n[i].hidden=!1}},function(e){console.warn("Failure loading Soundfont instrument "+e)})}var e={},t=0,n=0,r=!1,i=null,s="",o=!0,u=[],a="en";const f="C",l="M",c=l+f,h=600,p=16,d=1,v="transposable",m="major",g="minor",y="abc-source",b="abc-render",w="abc-player",E="selected",S="playing",x="ready",T="abc-voices",N="abc-voice",C="abc-follow",k="abc-hidden",L="abc-dot",A="check-voice",O="abc-container",M=b,_=w,D=T,P="abc-tempo",H="%%voicecombine",B="%%player_no_voice",j="%%no_player",F="%%player_off",I="%%play",q="%%fullsvg",R="%%player_top",U="%%player_bottom",z="%%player_left",W="%%player_right",X="%%deco red 10 @ 0 0 0\n%%deco blue 10 @ 0 0 0\n%%deco green 10 @ 0 0 0\n%%deco brown 10 @ 0 0 0\n%%deco orange 10 @ 0 0 0\n%%deco yellow 10 @ 0 0 0\n%%deco gray 10 @ 0 0 0\n%%deco cyan 10 @ 0 0 0\n%%deco coral 10 @ 0 0 0\n%%deco gold 10 @ 0 0 0\n%%deco khaki 10 @ 0 0 0\n%%deco indigo 10 @ 0 0 0\n%%deco lime 10 @ 0 0 0\n%%deco navy 10 @ 0 0 0\n%%deco orchid 10 @ 0 0 0\n%%deco pink 10 @ 0 0 0\n%%deco peru 10 @ 0 0 0\n%%deco plum 10 @ 0 0 0\n%%deco purple 10 @ 0 0 0\n%%deco tan 10 @ 0 0 0\n%%deco teal 10 @ 0 0 0\n%%deco o>( 1 arrow_orange 0 0 0\n%%deco o>) 1 arrow_orange 0 0 0\n%%deco r>( 1 arrow_red 0 0 0\n%%deco r>) 1 arrow_red 0 0 0\n%%deco g>( 1 arrow_green 0 0 0\n%%deco g>) 1 arrow_green 0 0 0\n%%deco b>( 1 arrow_blue 0 0 0\n%%deco b>) 1 arrow_blue 0 0 0\n%%deco n>( 1 arrow_black 0 0 0\n%%deco n>) 1 arrow_black 0 0 0\n%%deco ->( 1 arrow_gray 0 0 0\n%%deco ->) 1 arrow_gray 0 0 0\n",V='%%beginsvg\n<defs>\n <marker id="arrow_orange" fill="orange" markerWidth="6" markerHeight="6" refX="6" refY="3" orient="auto"><path d="M1,1 L1,5 L6,3 L1,1"/></marker>\n <marker id="arrow_red" fill="red" markerWidth="6" markerHeight="6" refX="6" refY="3" orient="auto"><path d="M1,1 L1,5 L6,3 L1,1"/></marker>\n <marker id="arrow_blue" fill="blue" markerWidth="6" markerHeight="6" refX="6" refY="3" orient="auto"><path d="M1,1 L1,5 L6,3 L1,1"/></marker>\n <marker id="arrow_green" fill="green" markerWidth="6" markerHeight="6" refX="6" refY="3" orient="auto"><path d="M1,1 L1,5 L6,3 L1,1"/></marker>\n <marker id="arrow_gray" fill="gray" markerWidth="6" markerHeight="6" refX="6" refY="3" orient="auto"><path d="M1,1 L1,5 L6,3 L1,1"/></marker>\n <marker id="arrow_black" fill="black" markerWidth="6" markerHeight="6" refX="6" refY="3" orient="auto"><path d="M1,1 L1,5 L6,3 L1,1"/></marker>\n <path id="x_notehead" d="m-3 -3l6 6m0 -6l-6 6" class="stroke" style="stroke-width:1.2"/>\n <path id="xcircle_notehead" d="m-3 -3 l6 6 m0 -6 l-6 6 M 0, 0 m -4, 0 a 4,4 0 1,0 8,0 a 4,4 0 1,0 -8,0" class="stroke" style="stroke-width:1.2"></path>\n <path id="triangle_notehead" d="M0 -5 L-4 4 H4 Z"/>\n <path id="square_notehead" d="M0 -4 L-4 0 L0 4 L4 0Z"/>\n</defs>\n%%endsvg\n%%beginjs\nvar dsx=12,dex=14;\nuser.arrow_red = function (x, y, de) {\n var de1 = de.start;\n def_use("arrow_red");\n abc.xypath(de1.s.x + dsx, de1.y + staff_tb[de1.st].y);\n var s = \'" stroke-width="1.5" style="marker-end: url(#arrow_red); color: red"/>\';\n abc.out_svg("L" + abc.sx(de.s.x - dex).toFixed(2) + " " + abc.sy(de.y + staff_tb[de.st].y).toFixed(2) + s);\n}\nuser.arrow_green = function (x, y, de) {\n var de1 = de.start;\n def_use("arrow_green");\n abc.xypath(de1.s.x + dsx, de1.y + staff_tb[de1.st].y);\n var s = \'" stroke-width="1.5" style="marker-end: url(#arrow_green); color: green"/>\';\n abc.out_svg("L" + abc.sx(de.s.x - dex).toFixed(2) + " " + abc.sy(de.y + staff_tb[de.st].y).toFixed(2) + s);\n}\nuser.arrow_blue = function (x, y, de) {\n var de1 = de.start;\n def_use("arrow_blue");\n abc.xypath(de1.s.x + dsx, de1.y + staff_tb[de1.st].y);\n var s = \'" stroke-width="1.5" style="marker-end: url(#arrow_blue); color: blue"/>\';\n abc.out_svg("L" + abc.sx(de.s.x - dex).toFixed(2) + " " + abc.sy(de.y + staff_tb[de.st].y).toFixed(2) + s);\n}\nuser.arrow_orange = function (x, y, de) {\n var de1 = de.start;\n def_use("arrow_orange");\n abc.xypath(de1.s.x + dsx, de1.y + staff_tb[de1.st].y);\n var s = \'" stroke-width="1.5" style="marker-end: url(#arrow_orange); color: orange"/>\';\n abc.out_svg("L" + abc.sx(de.s.x - dex).toFixed(2) + " " + abc.sy(de.y + staff_tb[de.st].y).toFixed(2) + s);\n}\nuser.arrow_gray = function (x, y, de) {\n var de1 = de.start;\n def_use("arrow_gray");\n abc.xypath(de1.s.x + dsx, de1.y + staff_tb[de1.st].y);\n var s = \'" stroke-width="1.5" style="marker-end: url(#arrow_gray); color: gray"/>\';\n abc.out_svg("L" + abc.sx(de.s.x - dex).toFixed(2) + " " + abc.sy(de.y + staff_tb[de.st].y).toFixed(2) + s);\n}\nuser.arrow_black = function (x, y, de) {\n var de1 = de.start;\n def_use("arrow_black");\n abc.xypath(de1.s.x + dsx, de1.y + staff_tb[de1.st].y);\n var s = \'" stroke-width="1.5" style="marker-end: url(#arrow_black); color: black"/>\';\n abc.out_svg("L" + abc.sx(de.s.x - dex).toFixed(2) + " " + abc.sy(de.y + staff_tb[de.st].y).toFixed(2) + s);\n}\n%%endjs\n';return e.init=function(e){tt(e)},e.updateTonality=function(e,t){et(e,t)},e.buildScore=function(e,t,n){return Z(e,t,n)},e}(),$ABC_UTIL=function(){"use strict";function N(e){var t=!0;e.bEditors===!1&&(t=!1);var n=document.querySelectorAll(s);for(var i=0,o=n.length;i<o;i++){var u=n[i],a=u.innerHTML;a=a.replace(/&gt;/g,">");var f=I(a),l="";if(t){var c="?abc=",h=T.encode(f),p=encodeURI(m+c+h),d=encodeURI(g+c+h),y=B(a,{bStandard:!0,bKeepSpace:!0}),b=T.encode(y),w=encodeURI(v+c+b);l+="See in editors <a href='"+w+"' target='_blank'>abc2svg</a>, "+"<a href='"+p+"' target='_blank'>abc-ui</a>, "+"<a href='"+d+"' target='_blank'>dev.music</a>."}var E=u.classList.contains(r);E&&(f=k(f,e),l+="<pre class='abc-text'>"+f+"</pre>");var S=document.createElement("div");S.innerHTML=l;var x=u.parentNode;x.insertBefore(S,u)}}function C(e,t,n,r){r=r||{};var i=e,s;return t.forEach(function(e){r.bMacro?e="%%"+e:r.bDeco&&(e="!"+e+"!"),s='<span class="'+n+'">'+e+"</span>",e=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),i=i.replace(new RegExp(e,"g"),s)}),i}function k(e,t){t=t||{};var n=e,r;if(t.bMacro){var i={bMacro:!0};n=C(n,y,"abc-macro",i),n=C(n,b,"abc-ui-macro",i),w.forEach(function(e){e="%%"+e;var t=n.indexOf(e);if(t!==-1){var r=n.indexOf("\n",t),i=n.substring(0,t),s=n.substring(t,r),o='<span class="abc-ui-macro">'+s+"</span>",u=n.substring(r,n.length);n=i+o+u}})}if(t.bDeco){var s={bDeco:!0};n=C(n,E,"abc-deco",s),n=C(n,S,"color-deco",s),n=C(n,x,"arrow-deco",s)}return n}function L(e,t,n,r){if(r!=undefined)return r+e[0];if(t===!0)return"="+e[0];if(n===!0)return e[0];var i=e;return e.indexOf("#")!==-1?i="^"+e[0]:e.indexOf("b")!==-1&&(i="_"+e[0]),i}function A(e,t){var n=t.substring(1,t.length),r=L(n);if(r==="C")return e;if(r.indexOf("B")!==-1||r.indexOf("A")!==-1)r+=",";var i=e,s=0,o;for(;;){s=i.indexOf("K:",s+1);if(s===-1)break;o=i.indexOf("\n",s+1);var u=i.substring(s,o),a=u+" shift=C"+r+"\n";if(o===-1)break;i=i.substring(0,s)+a+i.substring(o+1,i.length)}return i}function O(e){var t="",n=e.split("\n");for(var r=0,i=n.length;r<i;r++){var s=n[r].replace(/^\s+|\s+$/gm,"");s=s.replace(/\s+/g," "),s=s.replace(/^\t+|\t+$/gm,""),s!==""&&(t+=s+"\n")}return t}function M(e,t){t=t||"en";var n="",r="",i="",s="",u="",a="",f="",h="",d="",v="",m="",g="",y="",b="";return e.indexOf("+name")!==-1?(f=' name="'+p[t].soprano+'" sname="'+p[t].sopranoShort+'"',d=' name="'+p[t].alto+'" sname="'+p[t].altoShort+'"',m=' name="'+p[t].tenor+'" sname="'+p[t].tenorShort+'"',y=' name="'+p[t].bass+'" sname="'+p[t].bassShort+'"'):e.indexOf("+shortname")!==-1&&(f=' name="'+p[t].sopranoShort+'" sname="'+p[t].sopranoShort+'"',d=' name="'+p[t].altoShort+'" sname="'+p[t].altoShort+'"',m=' name="'+p[t].tenorShort+'" sname="'+p[t].tenorShort+'"',y=' name="'+p[t].bassShort+'" sname="'+p[t].bassShort+'"'),e.indexOf("T")!==-1?(a="clef=C1",h="clef=C3",v="clef=C4",g="clef=F4"):e.indexOf("G")!==-1?(a=l,h=l,v="clef=treble_8",g=c):(a=l,h=l,v="clef=C",g=c),e.indexOf("D")!==-1&&(s="V:D "+a+"\n",r+="D "),e.indexOf("C")!==-1&&(u="V:C "+a+"\n",r+="C "),e.indexOf("N")!==-1&&(b="V:N "+g+"\n",i+=" N"),n+=s+u+"V:S "+a+f+"\n"+"V:A "+h+d+"\n"+"V:T "+v+m+"\n"+"V:B "+g+y+"\n"+b+o+"[("+r+"S) | A | T | (B"+i+")]\n",n}function _(e){var t=e.indexOf("D")!==-1,n=e.indexOf("C")!==-1,r=e.indexOf("N")!==-1,i=e.indexOf("2+2")!==-1||e.indexOf("4")!==-1,s=e.indexOf("3+1")!==-1,u=e.indexOf("4+1")!==-1,a=e.indexOf("3+2")!==-1,f=e.indexOf("2+3")!==-1,h=e.indexOf("3+3")!==-1,p=e.indexOf("4+2")!==-1,d=e.indexOf("5+1")!==-1,v="",m="",g="";return t&&(v+="V:D "+l+"\n",m+="D "),n&&(v+="V:C "+l+"\n",m+="C "),r&&(v+="V:N "+c+"\n",g+=" N"),h?v+="V:1 "+l+"\nV:2 "+l+"\nV:3 "+l+"\nV:4 "+c+"\nV:5 "+c+"\nV:6 "+c+"\n"+o+" {("+m+"1 2 3)|(4 5 6"+g+")}\n":d?v+="V:1 "+l+"\nV:2 "+l+"\nV:3 "+l+"\nV:4 "+l+"\nV:5 "+l+"\nV:6 "+c+"\n"+o+" {("+m+"1 2 3 4 5)|(6"+g+")}\n":p?v+="V:1 "+l+"\nV:2 "+l+"\nV:3 "+l+"\nV:4 "+l+"\nV:5 "+c+"\nV:6 "+c+"\n"+o+" {("+m+"1 2 3 4)|(5 6"+g+")}\n":u?v+="V:1 "+l+"\nV:2 "+l+"\nV:3 "+l+"\nV:4 "+l+"\nV:5 "+c+"\n"+o+" {("+m+"1 2 3 4)|(5"+g+")}\n":a?v+="V:1 "+l+"\nV:2 "+l+"\nV:3 "+l+"\nV:4 "+c+"\nV:5 "+c+"\n"+o+" {("+m+"1 2 3)|(4 5"+g+")}\n":f?v+="V:1 "+l+"\nV:2 "+l+"\nV:3 "+c+"\nV:4 "+c+"\nV:5 "+c+"\n"+o+" {("+m+"1 2)|(3 4 5"+g+")}\n":i?v+="V:S "+l+"\nV:A "+l+"\nV:T "+c+"\nV:B "+c+"\n"+o+" {("+m+"S A)|(T B"+g+")}\n":s?v+="V:S "+l+"\nV:A "+l+"\nV:T "+l+"\nV:B "+c+"\n"+o+" {("+m+"S A T)|(B"+g+")}\n":v+="V:KG "+l+"\nV:KF "+c+"\n"+o+" {("+m+"KG)|(KF"+g+")}\n",v}function D(e,t){var n,r,i,s=e.indexOf(a,0);if(s!==-1){n=e.indexOf("\n",s+1);if(n!==-1)return r=e.substring(s,n),i=_(r,t),e.indexOf("K:")===-1&&(i+="K:C\n"),e=e.substring(0,s)+i+e.substring(n+1,e.length),e}s=e.indexOf(f,0);if(s!==-1){n=e.indexOf("\n",s+1);if(n!==-1)return r=e.substring(s,n),i=M(r,t),e.indexOf("K:")===-1&&(i+="K:C\n"),e=e.substring(0,s)+i+e.substring(n+1,e.length),e}return e}function P(e){var t=undefined,n=[],r=e.indexOf(u,0);if(r!==-1){var i=e.indexOf("\n",r+1);if(i!==-1){r=e.indexOf("{",r+1)+1,i=e.indexOf("}",r);var s=e.substring(r,i);s=s.replace(/\s/g,"");var o=!1,a;r=0;do i=s.indexOf(",",r),i!==-1?a=s.substring(r,i):(a=s.substring(r,s.length),o=!0),a.trim(),a.indexOf("*")!==-1&&(t=a.replace(/\*/g,""),a=t),n.push(a),r=i+1;while(!o)}}return t===undefined&&(t=n[0]),{tempos:n,selection:t}}function H(e,t){var n=P(e);if(n.selection===undefined)return{html:"",selection:undefined};var r=n.tempos,i=parseInt(r[0]),s=parseInt(r[r.length-1]),o=4,u=9,a=(u-o)/(s-i),f=o-a*i,l='<div class=" + class_abc_tempo + ">';for(var c=0,h=r.length;c<h;c++){var p=parseInt(r[c]),d=Math.round(a*p+f),v=" dot"+d,m=r[c]===n.selection?" selected":"";l+='<span class="'+t+" abc-dot "+r[c]+m+v+'"></span>'}return l+="</div>",{html:l,selection:n.selection}}function B(e,t){t=t||{};var n=!1;t.bKeepSpace!==undefined&&t.bKeepSpace===!0&&(n=!0);var r=n?I(e):O(e),i=-1,s=-1;r.indexOf("X:")!==-1&&(i=r.indexOf("X:",0),i!==-1&&(s=r.indexOf("\n",i+1),s!==-1&&(r=r.substring(0,i)+r.substring(s+1,r.length))));var o="";t.bHideTempo!==undefined&&(t.bHideTempo===!0?(i=r.indexOf("Q:",0),i!==-1&&(o="%%writefields Q 0\n")):t.bHideTempo===!1&&(o="%%writefields Q 1\n"));var u=o+"X:1\n";r.indexOf("L:")===-1&&(u+="L:1/1\n"),r=u+D(r,t.lang),r.indexOf("K:")===-1&&(i=r.indexOf("\n",r.indexOf("L:"))+1,r=r.substring(0,i)+"K:C\n"+r.substring(i,r.length)),t.transpose&&(r=A(r,t.transpose));if(t.bStandard===!0){r=r.replace(/%%MIDI program 128/g,"%%MIDI channel 10"),r=r.replace(/%%no_player\n/g,""),r=r.replace(/%%player_no_voice\n/g,"");var a=S.concat(x);a.forEach(function(e){e="!"+e+"!";var t=" ".repeat(e.length);e=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),r=r.replace(new RegExp(e,"g"),t)})}return q(r)}function j(e,t){var n=e,r="Q:1/4="+t+"\n",i=e.indexOf("X:1\n");return i!==-1&&(i+=4,n=e.substring(0,i)+r+e.substring(i,e.length)),n}function F(e,t){var n=e,r=e.indexOf(t);if(r!==-1){var i=e.indexOf("\n",r+1);if(i!==-1)return n=e.substring(0,r)+e.substring(i+1,e.length),F(n,t)}return n}function I(e){var t="",n=e.split("\n");for(var r=0,i=n.length;r<i;r++){var s=n[r].trim();s!==""&&(t+=s+"\n")}return q(t)}function q(e){var t=e.lastIndexOf("\n"),n=e.length;return t===n-1?e.substring(0,t):e}function R(e){var t="",n=e.split("\n");for(var r=0,i=n.length;r<i;r++){var s=n[r].trim();s=s.replace(/\s+/g," "),s!==""&&(t+=s+"\n")}return t}function U(e){var t=document.createElement("div");t.innerHTML=e;var n=t.querySelectorAll("style, defs, path, text, use");for(var r=0,i=n.length;r<i;r++){var s=n[r];s.parentNode.removeChild(s)}return R(t.innerHTML)}function z(e,t){var n=e.split(h),r=t.split(h),i=n.length,s=r.length;if(i!==s)return e;var o="";for(var u=0,a=i;u<a;u++){var f=n[u],l=U(r[u]),c=l.indexOf('<g class="music"');o+=f+l.substring(c,l.length)+h}return o}var e={};const t="abc-tempo",n="abc-source",r="view-source",i="view-editor",s="div."+n+"."+r+", div."+n+"."+i,o="%%score",u="%%tempo",a="%%piano",f="%%chorus",l="clef=treble",c="clef=bass",h="</svg>",p={en:{soprano:"Soprano",sopranoShort:"S",alto:"Alto",altoShort:"A",tenor:"Tenor",tenorShort:"T",bass:"Bass",bassShort:"B",KG:"G key",KGShort:"GK",KF:"F key",KFShort:"FG"},fr:{soprano:"Soprano",sopranoShort:"S",alto:"Alto",altoShort:"A",tenor:"Ténor",tenorShort:"T",bass:"Basse",bassShort:"B",KG:"Clé de sol",KGShort:"Sol",KF:"Clé de fa",KFShort:"Fa"}};var d="en";const v="../../../../editors/abc2svg/index.html",m="../../../../editors/abc_ui/index.html",g="http://dev.music.free.fr/editors/abc_ui/index.html",y=["scores","score","staves","keywarn","timewarn","stemheight","bstemdown","flatbeams","slurheight","squarebreve","voicecombine","singleline","dblrepbar","graceslurs","gracespace","graceword","stafflines","cancelkey","ambitus","straightflags","MIDI","voicemap","diagram","chordnames","measurenb","measurebox ","setbarnb","contbarnb","equalbars","barsperstaff","break","stretchlast","stretchstaff","leftmargin","pagewidth","soloffs","musicspace","shiftunison","textoption","begintext","endtext","center","infoline","aligncomposer","composerfont","composerspace","hyphencont","text","clef","pos","map","sth"],b=["no_player","player_off","player_no_voice","tempo"],w=["piano","chorus"],E=["beambr1","beambr2","ped","ped-up","ped(","ped)","1","2","3","4","5","/","//","///","-(","-)","roll","snap","thumb","open","+","0","breath","shortphrase","mediumphrase","longphrase","tenuto","wedge","accent","^","upbow","downbow","emphasis","marcato","arpeggio","mordent","uppermordent","lowermordent","trill","pralltriller","trill(","trill)","diminuendo(","diminuendo)","crescendo(","crescendo)","fermata","invertedfermata","D.C.","coda","D.S.","segno","fine","turn","turnx","invertedturn","invertedturnx","mf","f","ff","fff","ffff","mp","p","pp","ppp","pppp","8va(","8va)","8vb(","8vb)"],S=["red","blue","green","brown","orange","yellow","gray","cyan","coral","gold","khaki","indigo","lime","navy","orchid","pink","peru","plum","purple","tan","teal"],x=["o>(","o>)","b>(","b>)","g>(","g>)","r>(","r>)","n>(","n>)",">(",">)"];var T={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",_utf8_encode:function(e){e=e.replace(/\r\n/g,"\n");for(var t="",n=0;n<e.length;n++){var r=e.charCodeAt(n);r<128?t+=String.fromCharCode(r):r>127&&r<2048?(t+=String.fromCharCode(r>>6|192),t+=String.fromCharCode(63&r|128)):(t+=String.fromCharCode(r>>12|224),t+=String.fromCharCode(r>>6&63|128),t+=String.fromCharCode(63&r|128))}return t},encode:function(e){var t,n,r,i,s,o,u,a="",f=0;for(e=T._utf8_encode(e);f<e.length;)i=(t=e.charCodeAt(f++))>>2,s=(3&t)<<4|(n=e.charCodeAt(f++))>>4,o=(15&n)<<2|(r=e.charCodeAt(f++))>>6,u=63&r,isNaN(n)?o=u=64:isNaN(r)&&(u=64),a=a+this._keyStr.charAt(i)+this._keyStr.charAt(s)+this._keyStr.charAt(o)+this._keyStr.charAt(u);return a}};return e.remapVoiceName=function(e,t){t=t||"en";const n={KG:p[t].KG,KF:p[t].KF,S:p[t].soprano,A:p[t].alto,T:p[t].tenor,B:p[t].bass};var r=e.id.toUpperCase();return e.nm?n[e.nm]?n[e.nm]:e.nm:n[r]?n[r]:e.id},e.isActiveVoice=function(e){const t=["D","C","N"];return t.indexOf(e.toUpperCase())===-1},e.updateTempo=function(e,t){return j(e,t)},e.buildTempoSlider=function(e,t){return H(e,t)},e.normalize=function(e,t){return B(e,t)},e.addHtmlVievers=function(e){return N(e)},e.remove=function(e,t){return F(e,t)},e.svgMerge=function(e,t){return z(e,t)},e}(),$ABC_EVENTS=function(){"use strict";function u(e){o&&console.log("$ABC_EVENTS."+e)}function a(){u("init"),t=null,n=0,r=0,i=0,s=0}function f(e,n,o){function L(e){const t=e.v;for(var n=0;n<10;n++)m[t].set(v,n*7);g[t].set(m[t])}function A(e){v=[0,0,0,0,0,0,0];switch(e.k_sf){case 7:v[6]=1;case 6:v[2]=1;case 5:v[5]=1;case 4:v[1]=1;case 3:v[4]=1;case 2:v[0]=1;case 1:v[3]=1;break;case-7:v[3]=-1;case-6:v[0]=-1;case-5:v[4]=-1;case-4:v[1]=-1;case-3:v[5]=-1;case-2:v[2]=-1;case-1:v[6]=-1}L(e)}function O(){for(var e=0;e<a;e++){var t=n[e].clef;y[e]=!t.clef_octave||t.clef_oct_transp?0:t.clef_octave;var r=n[e],i=r.instr||0;r.midictl&&(r.midictl[32]&&(i+=r.midictl[32]*128),r.midictl[0]&&(i+=r.midictl[0]*128*128)),b[e]=i,m[e]=new Float32Array(70),g[e]=new Float32Array(70),r.key.v=e,A(r.key)}}function M(e,t){var n=e.notes[t],r=n.pit+19-7,i=n.acc;y[e.v]&&(r+=y[e.v]),i?(i==3?i=0:n.micro_n&&(console.log("micro tone not supported"),i=(i<0?-n.micro_n:n.micro_n)/n.micro_d*2),d[r]=i):i=d[r];var s=r/7|0;return r=h[r%7]+i,r>=12?(r-=12,s++):r<0&&(r+=12,s--),c[r]+l[s]}function _(t){if(t.v!=w)return null;var n;if(t.bar_type[0]===":"){u("_handle_bar with ':|' or ':]'"),t.bar_type="|"+t.bar_type.slice(1),N=t,C||(C=t);if(T){t=T;for(n=0;n<a;n++)g[n].set(S[n]),y[n]=E[n];r=x}else t=e,O();return s=t.time,t}if(!t.invis)for(n=0;n<a;n++)g[n].set(m[n]);if(t.bar_type[t.bar_type.length-1]==":"){u("_handle_bar with '|:'"),T=t,C=null;for(n=0;n<a;n++)S||(S=[]),S[n]||(S[n]=new Float32Array(70)),S[n].set(g[n]),E||(E=[]),E[n]=y[n];x=r}else t.text&&t.text[0]=="1"&&(u("_handle_bar with 1st time repeat"),C=t);return null}function D(e,t,n){u("_do_tie");var i,s,o,a=e.time+e.dur,f=e.notes[t],l=f.pit;for(o=e.next;;o=o.next){if(!o||o.time!=a)return n;if(o==C){var c=o.v;o=N.ts_next;while(o&&o.v!==c)e=e.ts_next;if(!e)return n;a=o.time}if(o.time!=a)return n;if(o.type==abc2svg.C.NOTE)break}s=o.notes.length;for(i=0;i<s;i++){f=o.notes[i];if(f.pit==l)return n+=o.dur/r,f.ti2=!0,f.ti1?D(o,i,n):n}return n}function P(e,n,r){for(var i=0;i<=e.nhd;i++){var s=e.notes[i];if(s.ti2)continue;var a=!0;o&&(a=o.indexOf(e.v)===-1);if(a){s=M(e,i);var f=e.istart,l=e.notes[i].ti1?D(e,i,r):r,c=b[e.v];t.push([f,n,c,s,l]),u("add event: index="+f+", time="+n+", instrument="+c+", note='"+s+"', duration="+l)}}}function H(e){u("_gen_grace");var t=e.next;if(e.time==0&&s===0){var n=0;if(e.sappo)n=abc2svg.C.BLEN/16;else if(!t||t.type!=abc2svg.C.NOTE)n=k/2;s-=n}var o,a,l,c;if(e.sappo)c=f/16;else if((!t||t.type!=abc2svg.C.NOTE)&&e.prev&&e.prev.type==abc2svg.C.NOTE)c=e.prev.dur/2;else{t.ts_prev.ts_next=t.ts_next,t.ts_next.ts_prev=t.ts_prev;for(var h=t.ts_next;h;h=h.ts_next)if(h.time!=t.time){t.ts_next=h,t.ts_prev=h.ts_prev,t.ts_prev.ts_next=t,h.ts_prev=t;break}t.dots?t.dots==1?c=t.dur/3:c=t.dur*2/7:c=t.dur/2,t.time+=c,t.dur-=c}a=0;for(o=e.extra;o;o=o.next)o.type==abc2svg.C.NOTE&&a++;c/=a*r,l=i;for(o=e.extra;o;o=o.next){if(o.type!=abc2svg.C.NOTE)continue;P(o,l,c),l+=c}}const a=n.length,f=1536,l="012345678",c=["C","Db","D","Eb","E","F","Gb","G","Ab","A","Bb","B"],h=[0,2,4,5,7,9,11];var p=e,d,v=[],m=[],g=[],y=[],b=[],w=null,E=null,S=null,x=null,T=null,N=null,C=null,k=null;O(),t?p.time<s&&(s=p.time):(t=[],s=i=0,r=f/4*80/60);while(p){if(p.tempo){var B=0;for(var j=0,F=p.tempo_notes.length;j<F;j++)B+=p.tempo_notes[j];r=B*p.tempo/60}var I=p.time-s;I>0&&(i+=I/r,s=p.time),p==C&&(p=N,s=p.time),d=g[p.v];switch(p.type){case abc2svg.C.BAR:var q=_(p);q!==null&&(p=q);break;case abc2svg.C.CLEF:y[p.v]=!p.clef_octave||p.clef_oct_transp?0:p.clef_octave;break;case abc2svg.C.GRACE:H(p);break;case abc2svg.C.KEY:A(p);break;case abc2svg.C.REST:case abc2svg.C.NOTE:k=p.dur;var R=p.next;if(R&&R.type===abc2svg.C.GRACE){I=0;if(R.sappo)I=abc2svg.C.BLEN/16;else if(!R.next||R.next.type!==abc2svg.C.NOTE)I=k/2;R.time-=I,k-=I}k/=r,p.type==abc2svg.C.NOTE?P(p,i,k):t.push([p.istart,i,-1,0,k]);break;case abc2svg.C.STAVES:w=p.sy.top_voice}p=p.ts_next}}function l(e,n,r){if(e===undefined)return;var i="",s={errmsg:function(e,t,n){console.log("%c "+e,"color: red;")},get_abcmodel:function(e,t){const r=t.length;if(r!==1)for(var s=0;s<r;s++){var o=n+"_V"+s,a=document.getElementById(o);if(a===undefined||a!==null&&a.checked===!1)i+=s+" "}u("voice_no_play="+i),f(e,t,i)}},o=$ABC_UTIL.remove(e,"%%voicecombine");a();var l="%%play\n"+r;try{abc=new Abc(s),abc.tosvg("play",l),abc.tosvg("follower.abc",o)}catch(c){var h="%c "+c.message+"\nabc2svg tosvg bug - stack:\n"+c.stack;console.log(h,"color: red;")}return t}var e={},t=null,n=0,r=0,i=0,s=0;const o=!1;return e.render=function(e,t,n){return u("render"),l(e,t,n)},e}(),$EVENT_PLAYER=function(){"use strict";function p(e){c&&console.log("$EVENT_PLAYER."+e)}function d(e,t,r){n[e]&&(p("_playNote("+e+", '"+t+"', "+r+")"),n[e].play(t,l,{duration:r}))}function v(){var e,n,c,p;if(u===0){r&&r();return}c=s[o++];if(!c||c[0]>u){r&&r();return}n=c[1]-a;for(;;){var m=c[2],g=c[3],y=c[4];d(m,g,y);if(i){var b=c[0],w=(c[1]+f-t.currentTime)*h,E=w+y*h;setTimeout(i,w,b,!0),setTimeout(i,E,b,!1)}p=s[o];if(!p){e=n+y;break}c=p,e=c[1]-a;if(e!=n)break;o++}l+=e-n,setTimeout(v,(l-t.currentTime-1)*h)}function m(e,n,i){p("_play("+e+", "+n+")"),s=i;if(!s||!s.length){r&&r();return}o=0,u=n,a=0;while(s[o]&&o<e&&e!=0)a=s[o][1],o++;s[o]&&(l=t.currentTime+s[o][1]-a),f=t.currentTime+.05,v()}function g(){return p("_stop() at index="+o),u=0,a=0,o}function y(e,s,o,u,a){r=s,i=o;if("AudioContext"in window)console.log("%cSound being generated with window.AudioContext.","color: green;"),t=new window.AudioContext;else{if(!("webkitAudioContext"in window)){alert("Web Audio API is not available!\nCan't generate sound!");return}console.log("%cSound being generated with window.webkitAudioContext.","color: green;"),t=new window.webkitAudioContext}if(t===null&&a){a("Web Audio API is not available!");return}$SF_PLAYER.init(t,e,function(e){n[e.index]=e,u&&u(e)},function(e){a&&a(e)})}var e={},t=null,n={},r=null,i=null,s=null,o=0,u=0,a=0,f=0,l=0;const c=!1,h=1e3;return e.init=function(e,t,n,r,i){p("init"),y(e,t,n,r,i)},e.play=function(e,t,n){p("play"),m(e,t,n)},e.stop=function(){return p("stop"),g()},e.playNote=function(e,t,n){p("playNote"),d(e,t,n)},e}();if(typeof MIDI=="undefined")var MIDI={};typeof MIDI.Soundfont=="undefined"&&(MIDI.Soundfont={});var $SF_PLAYER=function(){"use strict";function i(e,n){t&&console.log("$SF_PLAYER."+e)}function s(e,t){n&&console.log("$SF_PLAYER - "+e,t)}function o(e,t,n,r){i("_load");var s=null;l(t)?s=c:w(t)?s=E:h(t)?s=p:y(t)?s=b:u(t)&&(s=a);var o=n||{};return s?s(e,t,o):r?Promise.resolve(r):Promise.reject("Source not valid ("+t+")")}function a(e,t,n){i("_loadMidiJSFile");var r=g(n.from,t);return o(e,o.fetch(r,"text").then(f),n)}function f(e){i("_midiJsToJson");var t=e.indexOf("MIDI.Soundfont.");if(t<0)throw Error("Invalid MIDI.js Soundfont format");t=e.indexOf("=",t)+2;var n=e.lastIndexOf(",");return JSON.parse(e.slice(t,n)+"}")}function l(e){return e instanceof ArrayBuffer}function c(e,t,n){return i("_loadArrayBuffer"),new Promise(function(n,r){e.decodeAudioData(t,function(e){n(e)},function(){r("Can't decode audio data ("+t.slice(0,30)+"...)")})})}function h(e){return e&&typeof e=="object"}function p(e,t,n){i("_loadObjectData");var r="",s={},u=Object.keys(t).map(function(i){if(n.only&&n.only.indexOf(i)===-1)return null;r+=i+", ";var u=t[i];return o(e,u,n,u).then(function(e){s[i]=e})});return Promise.all(u).then(function(){return i(r),s})}function d(e){return e>64&&e<91?e-65:e>96&&e<123?e-71:e>47&&e<58?e+4:e===43?62:e===47?63:0}function v(e,t){var n=e.replace(/[^A-Za-z0-9\+\/]/g,""),r=n.length,i=t?Math.ceil((r*3+1>>2)/t)*t:r*3+1>>2,s=new Uint8Array(i);for(var o,u,a=0,f=0,l=0;l<r;l++){u=l&3,a|=d(n.charCodeAt(l))<<18-6*u;if(u===3||r-l===1){for(o=0;o<3&&f<i;o++,f++)s[f]=a>>>(16>>>o&24)&255;a=0}}return s}function m(e){return function(t){return typeof t=="string"&&e.test(t)}}function g(e,t){return typeof e=="string"?e+t:typeof e=="function"?e(t):t}function b(e,t,n){i("_loadBase64Audio");var r=t.indexOf(",");return o(e,v(t.slice(r+1)).buffer,n)}function w(e){return e&&typeof e.then=="function"}function E(e,t,n){return i("_loadPromise"),t.then(function(t){return o(e,t,n)})}function S(e){i("ADSR");var t=e.createGain(),n=t._voltage=N(e),r=C(n),s=C(n),o=C(n);return t._startAmount=C(s),t._endAmount=C(o),t._multiplier=C(r),t._multiplier.connect(t),t._startAmount.connect(t),t._endAmount.connect(t),t.value=r.gain,t.startValue=s.gain,t.endValue=o.gain,t.startValue.value=0,t.endValue.value=0,Object.defineProperties(t,x),t}function N(e){i("getVoltage");var t=e.createBufferSource(),n=e.createBuffer(1,2,e.sampleRate);return n.getChannelData(0).set(T),t.buffer=n,t.loop=!0,t}function C(e){i("scale");var t=e.context.createGain();return e.connect(t),t}function k(e){return Math.log(e+1)/Math.log(100)}function L(e,t,n,r,i){var s=t-e,o=r-n,u=i-n,a=u/o,f=e+a*s;return f<=e&&(f=e),f>=t&&(f=t),f}function M(e,t,n){function f(t,n){return n.id=i++,s[n.id]=n,n.source.onended=function(){var t=e.currentTime;n.source.disconnect(),n.env.disconnect(),n.disconnect(),a.emit("ended",t,n.id,n)},n.id}function l(t,n,r){var i=e.createGain();return i.gain.value=0,i.connect(o),i.env=P(e,r,u),i.env.connect(i.gain),i.source=e.createBufferSource(),i.source.buffer=n,i.source.connect(i),i.source.loop=r.loop||u.loop,i.source.playbackRate.value=H(r.cents||u.cents),i.source.loopStart=r.loopStart||u.loopStart,i.source.loopEnd=r.loopEnd||u.loopEnd,i.stop=function(n){var r=n||e.currentTime;a.emit("stop",r,t);var s=i.env.stop(r);i.source.stop(s)},i}var r=!1,i=0,s={},o=e.createGain(),u=Object.assign({},O,n),a={context:e,out:o,opts:u};return t instanceof AudioBuffer?a.buffer=t:a.buffers=t,a.start=function(t,n,i){if(a.buffer&&t!==null)return a.start(null,t,n);var s=t?a.buffers[t]:a.buffer;if(!s){console.warn("Buffer "+t+" not found.");return}if(!r){console.warn("SamplePlayer not connected to any node.");return}var o=i||A;n=Math.max(e.currentTime,n||0),a.emit("start",n,t,o);var u=l(t,s,o);return u.id=f(t,u),u.env.start(n),u.source.start(n),a.emit("started",n,u.id,u),o.duration&&u.stop(n+o.duration),u},a.play=function(e,t,n){return a.start(e,t,n)},a.stop=function(e,t){var n;return t=t||Object.keys(s),t.map(function(t){return n=s[t],n?(n.stop(e),n.id):null})},a.connect=function(e){return r=!0,o.connect(e),a},a.emit=function(e,t,n,r){a.onevent&&a.onevent(e,t,n,r);var i=a["on"+e];i&&i(t,n,r)},a}function _(e){return typeof e=="number"}function P(e,t,n){i("envelope");var r=S(e),s=t.adsr||n.adsr;return D.forEach(function(e,i){s?r[e]=s[i]:r[e]=t[e]||n[e]}),r.value.value=_(t.gain)?t.gain:_(n.gain)?n.gain:1,r}function H(e){return e?Math.pow(2,e/1200):1}function B(e){return/\.js(\?.*)?$/i.test(e)}function j(e,t,n){return n=n==="ogg"?n:"mp3",t=t==="FluidR3_GM"?t:"MusyngKite","https://gleitz.github.io/midi-js-soundfonts/"+t+"/"+e+"-"+n+".js"}function F(e){return r.indexOf(e)}function I(e,t,n){var r=n||{};s("_initInstrument",t);if(MIDI.Soundfont[t])return s("Already loaded, decode Soundfont ",t),o(e,MIDI.Soundfont[t],{only:r.only||r.notes}).then(function(n){var i=M(e,n,r).connect(e.destination);return i.name=t,i.index=F(t),i});var i=r.isSoundfontURL||B,u=r.nameToUrl||j,a=i(t)?t:u(t,r.soundfont,r.format);return o(e,a,{only:r.only||r.notes}).then(function(n){s("Load and decode ",a);var i=M(e,n,r).connect(e.destination);return i.url=a,i.name=t,i.index=F(t),i})}function q(e){function t(e){var t=[];for(var n=0,r=e.length;n<r;n++){var i=-1;typeof e[n]=="number"?i=e[n]:typeof e[n]=="string"&&(i=F(e[n])),i<=128&&i!=-1&&t.push(i)}return t}function n(e){return e.sort().filter(function(e,t,n){return!t||e!=n[t-1]})}return n(t(e))}var e={};const t=!1,n=!1,r=["acoustic_grand_piano","bright_acoustic_piano","electric_grand_piano","honky-tonk_piano","electric_piano_1","electric_piano_2","harpsichord","clavinet","celesta","glockenspiel","music_box","vibraphone","marimba","xylophone","tubular_bells","dulcimer","drawbar_organ","percussive_organ","rock_organ","church_organ","reed_organ","accordion","harmonica","tango_accordion","acoustic_guitar_nylon","acoustic_guitar_steel","electric_guitar_jazz","electric_guitar_clean","electric_guitar_muted","overdriven_guitar","distortion_guitar","guitar_harmonics","acoustic_bass","electric_bass_finger","electric_bass_pick","fretless_bass","slap_bass_1","slap_bass_2","synth_bass_1","synth_bass_2","violin","viola","cello","contrabass","tremolo_strings","pizzicato_strings","orchestral_harp","timpani","string_ensemble_1","string_ensemble_2","synth_strings_1","synth_strings_2","choir_aahs","voice_oohs","synth_choir","orchestra_hit","trumpet","trombone","tuba","muted_trumpet","french_horn","brass_section","synth_brass_1","synth_brass_2","soprano_sax","alto_sax","tenor_sax","baritone_sax","oboe","english_horn","bassoon","clarinet","piccolo","flute","recorder","pan_flute","blown_bottle","shakuhachi","whistle","ocarina","lead_1_square","lead_2_sawtooth","lead_3_calliope","lead_4_chiff","lead_5_charang","lead_6_voice","lead_7_fifths","lead_8_bass__lead","pad_1_new_age","pad_2_warm","pad_3_polysynth","pad_4_choir","pad_5_bowed","pad_6_metallic","pad_7_halo","pad_8_sweep","fx_1_rain","fx_2_soundtrack","fx_3_crystal","fx_4_atmosphere","fx_5_brightness","fx_6_goblins","fx_7_echoes","fx_8_sci-fi","sitar","banjo","shamisen","koto","kalimba","bagpipe","fiddle","shanai","tinkle_bell","agogo","steel_drums","woodblock","taiko_drum","melodic_tom","synth_drum","reverse_cymbal","guitar_fret_noise","breath_noise","seashore","bird_tweet","telephone_ring","helicopter","applause","gunshot","percussion"];o.fetch=function(e,t){return i("_load.fetch"),new Promise(function(n,r){var i=new XMLHttpRequest;t&&(i.responseType=t),i.open("GET",e),i.onload=function(){i.status===200?n(i.response):r(Error(i.statusText))},i.onerror=function(){r(Error("Network Error"))},i.send()})};var u=m(/\.js(\?.*)?$/i),y=m(/^data:audio/),x={attack:{value:0,writable:!0},decay:{value:0,writable:!0},sustain:{value:1,writable:!0},release:{value:0,writable:!0},getReleaseDuration:{value:function(){return this.release}},start:{value:function(e){i("start");var t=this._multiplier.gain,n=this._startAmount.gain,r=this._endAmount.gain;this._voltage.start(e),this._decayFrom=this._decayFrom=e+this.attack,this._startedAt=e;var s=this.sustain;t.cancelScheduledValues(e),n.cancelScheduledValues(e),r.cancelScheduledValues(e),r.setValueAtTime(0,e),this.attack?(t.setValueAtTime(0,e),t.linearRampToValueAtTime(1,e+this.attack),n.setValueAtTime(1,e),n.linearRampToValueAtTime(0,e+this.attack)):(t.setValueAtTime(1,e),n.setValueAtTime(0,e)),this.decay&&t.setTargetAtTime(s,this._decayFrom,k(this.decay))}},stop:{value:function(e,t){i("stop"),t&&(e-=this.release);var n=e+this.release;if(this.release){var r=this._multiplier.gain,s=this._startAmount.gain,o=this._endAmount.gain;r.cancelScheduledValues(e),s.cancelScheduledValues(e),o.cancelScheduledValues(e);var u=k(this.release);if(this.attack&&e<this._decayFrom){var a=L(0,1,this._startedAt,this._decayFrom,e);r.linearRampToValueAtTime(a,e),s.linearRampToValueAtTime(1-a,e),s.setTargetAtTime(0,e,u)}o.setTargetAtTime(1,e,u),r.setTargetAtTime(0,e,u)}return this._voltage.stop(n),n}},onended:{get:function(){return this._voltage.onended},set:function(e){this._voltage.onended=e}}},T=new Float32Array([1,1]),A={},O={gain:1,attack:.01,decay:.1,sustain:.9,release:.3,loop:!1,cents:0,loopStart:0,loopEnd:0},D=["attack","decay","sustain","release"];return e.init=function(e,t,n,i,o){if(typeof u=="undefined")var u={};typeof u.Soundfont=="undefined"&&(u.Soundfont={}),t=q(t);var a=t.length;s(a,"instrument(s) to initialize.");for(var f=0;f<a;f++){var l=t[f],c=r[l];s("#"+l,c),I(e,c).then(function(e){console.log('%cSoundfont instrument "'+e.name+'" loaded. (MIDI program '+e.index+")","color: green;"),n&&n(e)},function(e){i&&i(e)})}},e}();abc2svg={C:{BLEN:1536,BAR:0,CLEF:1,CUSTOS:2,GRACE:4,KEY:5,METER:6,MREST:7,NOTE:8,PART:9,REST:10,SPACE:11,STAVES:12,STBRK:13,TEMPO:14,BLOCK:16,REMARK:17,FULL:0,EMPTY:1,OVAL:2,OVALBARS:3,SQUARE:4,SL_ABOVE:1,SL_BELOW:2,SL_AUTO:3,SL_HIDDEN:4,SL_DOTTED:8},Abc:function(user){"use strict";function clone(e,t){if(!e)return e;var n=new e.constructor;for(var r in e)e.hasOwnProperty(r)&&(t&&typeof e[r]=="object"?n[r]=clone(e[r],t-1):n[r]=e[r]);return n}function errbld(e,t,n,r){var i,s,o,u,a;if(user.errbld){switch(e){case 0:e="warn";break;case 1:e="error";break;default:e="fatal"}user.errbld(e,t,n,r);return}if(r!=undefined&&r>=0){i=o=0;for(;;){s=parse.file.indexOf("\n",i);if(s<0||s>r)break;o++,i=s+1}u=r-i}a="",n&&(a=n,o&&(a+=":"+(o+1)+":"+(u+1)),a+=" ");switch(e){case 0:a+="Warning: ";break;case 1:a+="Error: ";break;default:a+="Internal bug: "}user.errmsg(a+t,o,u)}function error(e,t,n,r,i,s,o){var u,a,f,l;user.textrans&&(l=user.textrans[n],l&&(n=l)),arguments.length>3&&(n=n.replace(/\$./g,function(e){switch(e){case"$1":return r;case"$2":return i;case"$3":return s;default:return o}})),t&&t.fname?errbld(e,n,t.fname,t.istart):errbld(e,n)}function scanBuf(){this.index=0,scanBuf.prototype.char=function(){return this.buffer[this.index]},scanBuf.prototype.next_char=function(){return this.buffer[++this.index]},scanBuf.prototype.get_int=function(){var e=0,t=this.buffer[this.index];while(t>="0"&&t<="9")e=e*10+Number(t),t=this.next_char();return e}}function syntax(e,t,n,r,i,s){var o={fname:parse.fname,istart:parse.istart+parse.line.index};error(e,o,t,n,r,i,s)}function js_inject(js){/eval *\(|Function|setTimeout|setInterval/.test(js)?syntax(1,"Unsecure code"):eval('"use strict"\n'+js)}function y_get(e,t,n,r){var i,s=staff_tb[e],o=n/realwidth*YSTEP|0,u=(n+r)/realwidth*YSTEP|0;o<0&&(o=0),u>=YSTEP&&(u=YSTEP-1,o>u&&(o=u));if(t){i=s.top[o++];while(o<=u)i<s.top[o]&&(i=s.top[o]),o++}else{i=s.bot[o++];while(o<=u)i>s.bot[o]&&(i=s.bot[o]),o++}return i}function y_set(e,t,n,r,i){var s=staff_tb[e],o=n/realwidth*YSTEP|0,u=(n+r)/realwidth*YSTEP|0;o<0&&(o=0),u>=YSTEP&&(u=YSTEP-1,o>u&&(o=u));if(t)while(o<=u)s.top[o]<i&&(s.top[o]=i),o++;else while(o<=u)s.bot[o]>i&&(s.bot[o]=i),o++}function up_p(e,t){switch(t){case C.SL_ABOVE:return!0;case C.SL_BELOW:return!1}return e.multi&&e.multi!=0?e.multi>0:e.p_v.have_ly?e.pos.voc!=C.SL_ABOVE:!1}function d_arp(e){var t,n,r,i=e.s,s=e.dd,o=5;if(i.type==C.NOTE)for(t=0;t<=i.nhd;t++){if(i.notes[t].acc)r=5+i.notes[t].shac;else{r=6-i.notes[t].shhd;switch(i.head){case C.SQUARE:r+=3.5;break;case C.OVALBARS:case C.OVAL:r+=2}}r>o&&(o=r)}n=3*(i.notes[i.nhd].pit-i.notes[0].pit)+4,t=s.h,n<t&&(n=t),e.has_val=!0,e.val=n,e.x-=o,e.y=3*(i.notes[0].pit-18)-3}function d_cresc(e){if(e.ldst)return;var t,n,r,i,s,o,u,a,f=e.s,l=e.start,c,h;t=l.s,s=t.x+3,a=l.ix,a>0&&(c=a_de[a-1]),e.st=f.st,e.lden=!1,e.has_val=!0,i=up_p(f,f.pos.dyn),i&&(e.up=!0),c&&c.s==t&&(e.up&&!c.up||!e.up&&c.up)&&(r=c.dd,f_staff[r.func]&&(u=c.x+c.val+4,u>s&&(s=u))),e.defl.noen?(o=e.x-s,o<20&&(s=e.x-20-3,o=20)):(u=f.x,h=a_de[e.ix+1],h&&h.s==t&&(e.up&&!h.up||!e.up&&h.up)&&(r=h.dd,f_staff[r.func]&&(u-=5)),o=u-s-4,o<20&&(s-=(20-o)*.5,o=20)),e.val=o,e.x=s,e.y=y_get(e.st,i,s,o),i||(n=e.dd,e.y-=n.h)}function d_near(e){var t,n,r=e.s,i=e.dd;if(i.str)return;r.multi?n=r.multi>0:n=r.stem<0,n?t=r.ymx|0:t=r.ymn-i.h|0,t>-6&&t<24&&(n&&(t+=3),t=((t+6)/6|0)*6-6),n?r.ymx=t+i.h:r.ymn=t,e.y=t,r.type==C.NOTE&&(e.x+=r.notes[r.stem>=0?0:r.nhd].shhd),i.name[0]=="d"&&r.nflags>=-1&&(n?r.stem>0&&(e.x+=3.5):r.stem<0&&(e.x-=3.5))}function d_pf(e){var t,n,r,i,s=e.s,o=e.dd,u;e.val=o.wl+o.wr,i=up_p(s,s.pos.vol),i&&(e.up=!0),r=s.x-o.wl,e.ix>0&&(u=a_de[e.ix-1],u.s==s&&(e.up&&!u.up||!e.up&&u.up)&&(t=u.dd,f_staff[t.func]&&(n=u.x+u.val+4,n>r&&(r=n)))),e.x=r,e.y=y_get(s.st,i,r,e.val),i||(e.y-=o.h)}function d_slide(e){var t,n,r=e.s,i=r.notes[0].pit,s=5;for(t=0;t<=r.nhd;t++){if(r.notes[t].acc)n=4+r.notes[t].shac;else{n=5-r.notes[t].shhd;switch(r.head){case C.SQUARE:n+=3.5;break;case C.OVALBARS:case C.OVAL:n+=2}}r.notes[t].pit<=i+3&&n>s&&(s=n)}e.x-=s,e.y=3*(i-18)}function d_trill(e){if(e.ldst)return;var t,n,r,i,s,o=e.s,u=o.st,a=e.start.s,f=a.x;e.prev&&(f=e.prev.x+10,r=e.prev.y),e.st=u;if(e.dd.func!=4)switch(e.dd.glyph){case"8va":case"15ma":n=1;break;default:n=o.multi>=0}e.defl.noen?(i=e.x-f,i<20&&(f=e.x-20-3,i=20)):(i=o.x-f-6,o.type==C.NOTE&&(i-=6),i<20&&(f-=(20-i)*.5,i=20)),t=e.dd,r||(r=y_get(u,n,f,i)),n?(s=staff_tb[a.st].topbar+2,r<s&&(r=s)):(r-=t.h,s=staff_tb[a.st].botbar-2,r>s&&(r=s)),e.lden=!1,e.has_val=!0,e.val=i,e.x=f,e.y=r,n&&(r+=t.h),y_set(u,n,f,i,r),n?a.ymx=o.ymx=r:a.ymn=o.ymn=r}function d_upstaff(e){if(e.ldst)return;if(e.start){d_trill(e);return}var t,n,r,i=e.s,s=e.dd,o=i.x,u=s.wl+s.wr,a=staff_tb[i.st].topbar+2,f=staff_tb[i.st].botbar-2;i.nhd&&(o+=i.notes[i.stem>=0?0:i.nhd].shhd),n=-1;if(s.func==4)n=0;else if(i.pos)switch(i.pos.orn){case C.SL_ABOVE:n=1;break;case C.SL_BELOW:n=0}switch(s.glyph){case"accent":case"roll":!n||n<0&&(i.multi<0||!i.multi&&i.stem>0)?(t=y_get(i.st,!1,i.x-s.wl,u)-2,t>f&&(t=f),t-=s.h,y_set(i.st,!1,i.x,0,t),r=!0,i.ymn=t):(t=y_get(i.st,!0,i.x-s.wl,u)+2,t<a&&(t=a),y_set(i.st,!0,i.x-s.wl,u,t+s.h),i.ymx=t+s.h);break;case"brth":case"lphr":case"mphr":case"sphr":t=a+1,s.glyph=="brth"&&t<i.ymx&&(t=i.ymx);for(i=i.ts_next;i;i=i.ts_next)if(i.seqst)break;o+=((i?i.x:realwidth)-o)*.45;break;default:s.name.indexOf("invert")==0&&(r=!0),s.name!="invertedfermata"&&(n>0||n<0&&i.multi>=0)?(t=y_get(i.st,!0,i.x-s.wl,u)+2,t<a&&(t=a),y_set(i.st,!0,i.x-s.wl,u,t+s.h),i.ymx=t+s.h):(t=y_get(i.st,!1,i.x-s.wl,u)-2,t>f&&(t=f),t-=s.h,y_set(i.st,!1,i.x-s.wl,u,t),s.name=="fermata"&&(r=!0),i.ymn=t)}r&&(t+=s.h,e.inv=!0),e.x=o,e.y=t}function deco_add(e){var t=e.match(/(\S*)\s+(.*)/);decos[t[1]]=t[2]}function deco_def(e){var t,n,r,i,s,o,u,a,f=decos[e];if(!f){cfmt.decoerr&&error(1,null,"Unknown decoration '$1'",e);return}t=f.match(/(\d+)\s+(.+?)\s+([0-9.]+)\s+([0-9.]+)\s+([0-9.]+)/);if(!t){error(1,null,"Invalid decoration '$1'",e);return}var l=Number(t[1]),c=parseFloat(t[3]),h=parseFloat(t[4]),p=parseFloat(t[5]);if(isNaN(l)){error(1,null,"%%deco: bad C function value '$1'",t[1]);return}if((l<0||l>10)&&(l<32||l>41)){error(1,null,"%%deco: bad C function index '$1'",l);return}if(c<0||h<0||p<0){error(1,null,"%%deco: cannot have a negative value '$1'",f);return}if(c>50||h>80||p>80){error(1,null,"%%deco: abnormal h/wl/wr value '$1'",f);return}n=dd_tb[e],n||(n={name:e},dd_tb[e]=n),n.func=n.name.indexOf("head-")==0?9:l,n.glyph=t[2],n.h=c,n.wl=h,n.wr=p,a=f.replace(t[0],"").trim(),a&&(a[0]=='"'&&(a=a.slice(1,-1)),n.str=a),n.func==6&&n.str==undefined&&(n.str=n.name),s=n.name.slice(-1);if(s=="("||s==")"&&n.name.indexOf("(")<0){i=n.name.slice(0,-1)+(s=="("?")":"("),r=dd_tb[i];if(r)s=="("?(n.dd_en=r,r.dd_st=n):(n.dd_st=r,r.dd_en=n);else{r=deco_def(i);if(!r)return}}return n}function deco_cnv(e,t,n){var r,i,s,o,u,a=e.length;for(r=0;r<a;r++){o=e[r],s=dd_tb[o];if(!s){s=deco_def(o);if(!s)continue}switch(s.func){case 0:if(t.type==C.BAR&&s.name=="dot"){t.bar_dotted=!0;break};case 1:case 2:if(!t.notes){error(1,t,errs.must_note_rest,s.name);continue}break;case 8:if(t.type!=C.NOTE){error(1,t,errs.must_note,s.name);continue}u=t.notes[t.nhd],u.a_dcn||(u.a_dcn=[]),u.a_dcn.push(s.name);continue;case 9:if(!t.notes){error(1,t,errs.must_note_rest,s.name);continue}for(i=0;i<=t.nhd;i++)u=t.notes[i],u.a_dcn||(u.a_dcn=[]),u.a_dcn.push(s.name);continue;default:break;case 10:if(t.notes)for(i=0;i<=t.nhd;i++)t.notes[i].color=s.name;else t.color=s.name;continue;case 32:t.invis=!0;continue;case 33:if(t.type!=C.BAR){error(1,t,"!beamon! must be on a bar");continue}t.beam_on=!0;continue;case 34:if(t.type!=C.NOTE||!n||n.type!=C.NOTE||t.nflags!=n.nflags){error(1,t,"!$1! must be on the last of a couple of notes",s.name);continue}t.trem2=!0,t.beam_end=!0,n.trem2=!0,n.beam_st=!0,t.ntrem=n.ntrem=Number(s.name[4]),n.nflags=--t.nflags,n.head=++t.head,t.nflags>0?t.nflags+=t.ntrem:(t.nflags<=-2&&(t.stemless=!0,n.stemless=!0),t.nflags=t.ntrem),n.nflags=t.nflags;for(i=0;i<=t.nhd;i++)t.notes[i].dur*=2;for(i=0;i<=n.nhd;i++)n.notes[i].dur*=2;continue;case 35:if(t.type!=C.NOTE){error(1,t,"!xstem! must be on a note");continue}t.xstem=!0,t.nflags=0;continue;case 36:if(t.type!=C.NOTE){error(1,t,errs.must_note,s.name);continue}s.name[6]=="1"?t.beam_br1=!0:t.beam_br2=!0;continue;case 37:t.rbstop=1;continue;case 38:if(t.type!=C.NOTE){error(1,t,errs.must_note,s.name);continue}t.trem1=!0,t.ntrem=s.name.length,t.nflags>0?t.nflags+=t.ntrem:t.nflags=t.ntrem;continue;case 39:if(t.type!=C.NOTE){error(1,t,errs.must_note,s.name);continue}t.feathered_beam=s.name[5]=="a"?1:-1;continue;case 40:t.stemless=!0;continue;case 41:t.rbstop=2;continue}t.a_dd||(t.a_dd=[]),t.a_dd.push(s)}}function deco_update(e,t){var n,r,i=a_de.length;for(n=0;n<i;n++)r=a_de[n],r.s==e&&(r.x+=t)}function deco_width(e){var t,n,r=0,i=e.a_dd,s=i.length;for(n=0;n<s;n++){t=i[n];switch(t.func){case 1:r<7&&(r=7);break;case 2:r<14&&(r=14);break;case 3:switch(t.glyph){case"brth":case"lphr":case"mphr":case"sphr":e.wr<20&&(e.wr=20)}}}return r!=0&&e.prev&&e.prev.type==C.BAR&&(r-=3),r}function draw_all_deco(){if(a_de.length==0)return;var e,t,n,r,i,s,o,u,a,f,l,c,h,p,d,v=[],m=[];if(!cfmt.dynalign){o=nstaff,a=staff_tb[o].y;while(--o>=0)f=staff_tb[o].y,m[o]=(a+24+f)*.5,a=f}for(;;){e=a_de.shift();if(!e)break;n=e.dd;if(!n)continue;if(n.dd_en)continue;r=e.s,s=n.glyph,h=s.indexOf("/"),h>0&&(r.stem>=0?s=s.slice(0,h):s=s.slice(h+1)),f_staff[n.func]?set_sscale(r.st):set_scale(r),o=e.st;if(!staff_tb[o].topbar)continue;u=e.x,a=e.y+staff_tb[o].y;if(e.m!=undefined)i=r.notes[e.m],u+=i.shhd*stv_g.scale;else if(f_staff[n.func]&&!cfmt.dynalign&&(e.up&&o>0||!e.up&&o<nstaff)){e.up?l=m[--o]:l=m[o++],l-=n.h*.5;if(e.up&&a<l||!e.up&&a>l){f=y_get(o,!e.up,e.x,e.val)+staff_tb[o].y,e.up&&(f-=n.h);if(e.up&&f>l||!e.up&&f<l)a=l}}c=user[s];if(c&&typeof c=="function"){c(u,a,e);continue}if(self.psdeco(s,u,a,e))continue;anno_start(r,"deco"),e.inv&&(g_open(u,a,0,1,-1),u=a=0),e.has_val?(n.func!=2||stv_g.st<0?out_deco_val(u,a,s,e.val/stv_g.scale,e.defl):out_deco_val(u,a,s,e.val,e.defl),e.defl.noen&&v.push(e.start)):n.str!=undefined&&n.str!="sfz"?(p=n.str,p[0]=="@"&&(d=p.match(/^@([0-9.-]+),([0-9.-]+);?/),u+=Number(d[1]),a+=Number(d[2]),p=p.replace(d[0],"")),out_deco_str(u,a,s,p)):e.lden?out_deco_long(u,a,e):xygl(u,a,s),stv_g.g&&g_close(),anno_stop(r,"deco")}a_de=v}function draw_deco_near(){function n(e){var t,n,r=e.x-e.wl,i=a_de.length;for(t=0;t<i;t++)n=a_de[t],n.ix=t,n.s.x=n.x=r,n.defl.nost=!0}function r(e){var t,n,r,i,s,o,u=e.a_dd.length;for(n=0;n<u;n++){t=e.a_dd[n];switch(t.func){default:i=0;break;case 3:case 4:case 5:if(ottava[t.name]){o=t.name.slice(0,-1)+e.st.toString();if(od[o]){if(t.name[t.name.length-1]=="("){od[o]++;continue}od[o]--;if(e.v+1!=od[o]>>8||!od[o])continue;od[o]&=255}else t.name[t.name.length-1]=="("&&(od[o]=1+(e.v+1<<8))}i=e.pos.orn;break;case 6:i=e.pos.vol;break;case 7:i=e.pos.dyn}if(i==C.SL_HIDDEN)continue;s={s:e,dd:t,st:e.st,ix:a_de.length,defl:{},x:e.x,y:e.y},a_de.push(s),t.dd_en?s.ldst=!0:t.dd_st&&(s.lden=!0,s.defl.nost=!0);if(!f_near[t.func])continue;func_tb[t.func](s)}}function i(e,t){var n,r,i,s,o,u,a,f=e.notes[t],l=f.a_dcn.length;for(o=0;o<l;o++){u=f.a_dcn[o],a=dd_tb[u];if(!a){a=deco_def(u);if(!a)continue}switch(a.func){case 0:case 1:case 3:case 4:case 8:break;default:error(1,null,"Cannot have !$1! on a head",a.name);continue;case 9:f.invis=!0;break;case 10:f.color=a.name;continue;case 32:f.invis=!0;continue;case 40:e.stemless=!0;continue}i={s:e,dd:a,st:e.st,m:t,ix:0,defl:{},x:e.x,y:3*(f.pit-18)},a_de.push(i),a.dd_en?i.ldst=!0:a.dd_st&&(i.lden=!0,i.defl.nost=!0)}}function s(e){var t;e.a_dd&&r(e);if(e.notes)for(t=0;t<e.notes.length;t++)e.notes[t].a_dcn&&i(e,t)}function o(){var e,t,n,r,i,s,o,u,a,f=a_de.length;for(e=0;e<f;e++){n=a_de[e];if(!n.ldst)continue;i=n.dd,s=i.dd_en,u=n.s,o=u.v;for(t=e+1;t<f;t++){r=a_de[t];if(!r.start&&r.dd==s&&r.s.v==o)break}if(t==f){a=u.st;for(t=e+1;t<f;t++){r=a_de[t];if(!r.start&&r.dd==s&&r.s.st==a)break}}t==f&&(r={s:n.s,st:n.st,dd:s,ix:a_de.length-1,x:realwidth-6,y:n.s.y,lden:!0,defl:{noen:!0}},r.x<u.x+10&&(r.x=u.x+10),n.m!=undefined&&(r.m=n.m),a_de.push(r)),r.start=n,r.defl.nost=n.defl.nost,i.name=="trill("&&e>0&&a_de[e-1].dd.name=="trill"&&(r.prev=a_de[e-1])}for(e=0;e<f;e++){r=a_de[e];if(!r.lden||r.start)continue;u=r.s,n={s:prev_scut(u),st:r.st,dd:r.dd.dd_st,ix:a_de.length-1,y:u.y,ldst:!0},n.x=n.s.x,r.m!=undefined&&(n.m=r.m),a_de.push(n),r.start=n}}var e,t;for(e=tsfirst;e;e=e.ts_next){switch(e.type){case C.CLEF:case C.KEY:case C.METER:continue}break}a_de.length!=0&&n(e);for(;e;e=e.ts_next){switch(e.type){case C.BAR:case C.MREST:case C.NOTE:case C.REST:case C.SPACE:break;case C.GRACE:for(t=e.extra;t;t=t.next)s(t);default:continue}s(e)}o()}function draw_deco_note(){var e,t,n,r,i=a_de.length;for(e=0;e<i;e++)t=a_de[e],n=t.dd,r=n.func,f_note[r]&&t.m==undefined&&func_tb[r](t)}function draw_deco_staff(){function g(e){var t,n,i,s,o,u,a,f,l;i=staff_tb[e.st].topbar+25;for(t=e.sym;t;t=t.next){if(t.type!=C.BAR)continue;if(!t.rbstart||t.norepbra)continue;if(!t.next)break;l||(l=t,set_font("repeat")),n=t;for(;;){if(!t.next)break;t=t.next;if(t.rbstop)break}s=y_get(e.st,!0,n.x,t.x-n.x),i<s&&(i=s),n.text&&(f=strwh(n.text),s=y_get(e.st,!0,n.x+4,f[0]),s+=f[1],i<s&&(i=s)),t.rbstart&&(t=t.prev)}t=l;if(!t)return;set_dscale(e.st,!0),s=i*staff_tb[e.st].staffscale;for(;t;t=t.next){if(!t.rbstart||t.norepbra)continue;n=t;for(;;){if(!t.next)break;t=t.next;if(t.rbstop)break}if(n==t)break;r=n.x,t.type!=C.BAR?a=t.rbstop?0:t.x-realwidth+4:t.bar_type.length>1&&t.bar_type!="[]"||t.bar_type=="]"?n.st>0&&!(cur_sy.staves[n.st-1].flags&STOP_BAR)?a=t.wl:t.bar_type.slice(-1)==":"?a=12:t.bar_type[0]!=":"?a=0:a=8:a=t.rbstop?0:8,a=t.x-r-a,!t.next&&!t.rbstop&&!e.bar_start&&(e.bar_start=clone(t),e.bar_start.type=C.BAR,e.bar_start.bar_type="[",delete e.bar_start.text,e.bar_start.rbstart=1,delete e.bar_start.a_gch),n.text&&xy_str(r+4,s-gene.curfont.size-3,n.text),xypath(r,s),n.rbstart==2&&(output+="m0 20v-20"),output+="h"+a.toFixed(2),t.rbstop==2&&(output+="v20"),output+='"/>\n',y_set(n.st,!0,r,a,i+2),t.rbstart&&(t=t.prev)}}var e,t,n,r,i,s,o,u,a,f,l,c,h,p,d,v=new Array(nstaff),m=a_de.length;for(o=0;o<=nstaff;o++)v[o]={ymin:0,ymax:0};for(o=0;o<m;o++){a=a_de[o],f=a.dd;if(!f)continue;if(!f_staff[f.func]||a.m!=undefined)continue;func_tb[f.func](a);if(f.dd_en)continue;cfmt.dynalign&&(a.up?a.y>v[a.st].ymax&&(v[a.st].ymax=a.y):a.y<v[a.st].ymin&&(v[a.st].ymin=a.y))}for(o=0;o<m;o++){a=a_de[o],f=a.dd;if(!f)continue;if(f.dd_en||!f_staff[f.func])continue;cfmt.dynalign?(a.up?i=v[a.st].ymax:i=v[a.st].ymin,a.y=i):i=a.y,a.up&&(i+=f.h),y_set(a.st,a.up,a.x,a.val,i)}for(o=0;o<=nstaff;o++)v[o]={ymin:0,ymax:24};for(e=tsfirst;e;e=e.ts_next){if(!e.a_gch)continue;t||(t=e),c=null;for(h=0;h<e.a_gch.length;h++){l=e.a_gch[h];if(l.type!="g")continue;c=l;if(l.y<0)break}c&&(s=c.w,c.y>=0?(i=y_get(e.st,!0,e.x,s),i>v[e.st].ymax&&(v[e.st].ymax=i)):(i=y_get(e.st,!1,e.x,s),i<v[e.st].ymin&&(v[e.st].ymin=i)))}if(t){for(o=0;o<=nstaff;o++)d=staff_tb[o].botbar,v[o].ymin>d-4&&(v[o].ymin=d-4),p=staff_tb[o].topbar,v[o].ymax<p+4&&(v[o].ymax=p+4);set_dscale(-1);for(e=t;e;e=e.ts_next){if(!e.a_gch)continue;self.draw_gchord(e,v[e.st].ymin,v[e.st].ymax)}}for(u=0;u<voice_tb.length;u++){n=voice_tb[u];if(n.second||!n.sym)continue;g(n)}}function draw_measnb(){var e,t,n,r,i,s,o,u,a=cur_sy;for(t=0;t<=nstaff;t++)if(a.st_print[t])break;if(t>nstaff)return;set_dscale(t),staff_tb[t].staffscale!=1&&(u=get_font("measure").size,param_set_font("measurefont","* "+(u/staff_tb[t].staffscale).toString())),set_font("measure"),e=tsfirst,n=gene.nbar;if(n>1)if(cfmt.measurenb==0)o=!0,i=y_get(t,!0,0,20),i<staff_tb[t].topbar+14&&(i=staff_tb[t].topbar+14),cfmt.measurebox?xy_str_b(0,i,n.toString()):xy_str(0,i,n.toString()),y_set(t,!0,0,20,i+gene.curfont.size+2);else if(n%cfmt.measurenb==0){for(;;e=e.ts_next){switch(e.type){case C.METER:case C.CLEF:case C.KEY:case C.STBRK:continue}break}while(e.st!=t)e=e.ts_next;if(e.type!=C.BAR||!e.bar_num)e.prev&&e.prev.type!=C.CLEF&&(e=e.prev),r=e.x-e.wl,o=!0,s=cwid("0")*gene.curfont.swfac,n>=10&&(s*=n>=100?3:2),cfmt.measurebox&&(s+=4),i=y_get(t,!0,r,s),i<staff_tb[t].topbar+6&&(i=staff_tb[t].topbar+6),i+=2,cfmt.measurebox?(xy_str_b(r,i,n.toString()),i+=2,s+=3):xy_str(r,i,n.toString()),i+=gene.curfont.size,y_set(t,!0,r,s,i),e.ymx=i}for(;e;e=e.ts_next){switch(e.type){case C.STAVES:a=e.sy;for(t=0;t<nstaff;t++)if(a.st_print[t])break;set_sscale(t);continue;default:continue;case C.BAR:if(!e.bar_num)continue}n=e.bar_num;if(cfmt.measurenb==0||n%cfmt.measurenb!=0||!e.next)continue;o||(o=!0),s=cwid("0")*gene.curfont.swfac,n>=10&&(s*=n>=100?3:2),cfmt.measurebox&&(s+=4),r=e.x-s*.4,i=y_get(t,!0,r,s),i<staff_tb[t].topbar+6&&(i=staff_tb[t].topbar+6),e.next.type==C.NOTE&&(e.next.stem>0?i<e.next.ys-gene.curfont.size&&(i=e.next.ys-gene.curfont.size):i<e.next.y&&(i=e.next.y)),i+=2,cfmt.measurebox?(xy_str_b(r,i,n.toString()),i+=2,s+=3):xy_str(r,i,n.toString()),i+=gene.curfont.size,y_set(t,!0,r,s,i),e.ymx=i}gene.nbar=n,u&&param_set_font("measurefont","* "+u.toString())}function draw_notempo(e,t,n,r,i){var s,o,u,a=identify_note(e,r),f=a[0],l=a[1],c=a[2];out_XYAB('<g transform="translate(X,Y) scale(F)">\n',t+4,n+5,i);switch(f){case C.OVAL:o="HD";break;case C.EMPTY:o="Hd";break;default:o="hd"}xygl(-posx,posy,o),s=4;if(l){u=9,c>0&&(u+=4);switch(f){case C.SQUARE:u+=3;break;case C.OVALBARS:case C.OVAL:u+=2;break;case C.EMPTY:u+=1}s=u*l,u-=posx;while(--l>=0)xygl(u,posy,"dot"),u+=3.5}return r<C.BLEN&&(c<=0?out_stem(-posx,posy,21):(out_stem(-posx,posy,21,!1,c),s<6&&(s=6))),output+="</g>\n",(s+15)*i}function tempo_width(e){var t=0;return set_font("tempo"),e.tempo_str1&&(t=strwh(e.tempo_str1)[0]),e.tempo_ca&&(t+=strwh(e.tempo_ca)[0]),e.tempo_notes&&(t+=10*e.tempo_notes.length+6+cwid(" ")*gene.curfont.swfac*6+10),e.tempo_str2&&(t+=strwh(e.tempo_str2)[0]),t}function write_tempo(e,t,n){var r,i,s=.6*gene.curfont.size/15;set_font("tempo"),e.tempo_str1&&(xy_str(t,n,e.tempo_str1),t+=strwh(e.tempo_str1)[0]+3);if(e.tempo_notes){for(r=0;r<e.tempo_notes.length;r++)t+=draw_notempo(e,t,n,e.tempo_notes[r],s);xy_str(t,n,"="),t+=strwh("= ")[0],e.tempo_ca&&(xy_str(t,n,e.tempo_ca),t+=strwh(e.tempo_ca)[0]),e.tempo?(xy_str(t,n,e.tempo.toString()),i=cwid("0")*gene.curfont.swfac,t+=i+5,e.tempo>=10&&(t+=i,e.tempo>=100&&(t+=i))):t+=draw_notempo(e,t,n,e.new_beat,s)}e.tempo_str2&&xy_str(t,n,e.tempo_str2),e.del=!0}function draw_partempo(e,t){var n,r,i,s,o,u,a=0,f=0,l=staff_tb[e].topbar+8,c=0,h=1,p=0;for(n=tsfirst;n;n=n.ts_next){if(n.type!=C.TEMPO||n.del)continue;i||(i=n),o=tempo_width(n),n.time==0&&n.x>40&&(n.x=40),u=y_get(e,!0,n.x-16,o),u>l&&(l=u),p>=n.x-16&&!(c&h>>1)&&(c|=h),h<<=1,p=n.x-16+o}if(i){set_sscale(-1),set_font("tempo"),f=gene.curfont.size+2+2,u=2-f,s=u-f,c!=0&&(f*=2),t<l+f&&(a=l+f-t);for(n=i;n;n=n.ts_next){if(n.type!=C.TEMPO||n.del)continue;if(user.anno_start||user.anno_stop)n.wl=16,n.wr=30,n.ymn=c&1?s:u,n.ymx=n.ymn+14,anno_start(n);write_tempo(n,n.x-16,c&1?s:u),anno_stop(n),c>>=1}}l=staff_tb[e].topbar+8;for(n=tsfirst;n;n=n.ts_next){if(n.type!=C.PART)continue;r||(r=n,set_font("parts"),s=gene.curfont.size+2+2),o=strwh(n.text)[0],u=y_get(e,!0,n.x-10,o+3),l<u&&(l=u)}if(r){set_sscale(-1),t<l+s+f&&(a=l+s+f-t);for(n=r;n;n=n.ts_next){if(n.type!=C.PART)continue;n.x-=10;if(user.anno_start||user.anno_stop)o=strwh(n.text)[0],n.wl=0,n.wr=o,n.ymn=-f-s,n.ymx=n.ymn+s,anno_start(n);cfmt.partsbox?xy_str_b(n.x,2-f-s,n.text):xy_str(n.x,2-f-s,n.text),anno_stop(n)}}return a}function b_pos(e,t,n,r){function l(e){var t=Math.round((e+12)/6)*6-12;return t-e}var i,s,o,u,a=e?3.5:BEAM_SHIFT,f=e?1.8:BEAM_DEPTH;if(t>0){s=r-(n-1)*a-f;if(s>26)return 0;i=r}else{i=r+(n-1)*a+f;if(i<-2)return 0;s=r}return o=l(i-BEAM_OFFSET),u=l(s+BEAM_OFFSET),o*o>u*u?u:o}function sym_dup(e){var t,n,r=clone(e);r.invis=!0,delete r.text,delete r.a_gch,delete r.a_ly,delete r.a_dd,r.notes=clone(e.notes);for(t=0;t<=r.nhd;t++)n=r.notes[t]=clone(e.notes[t]),delete n.a_dcn;return r}function calculate_beam(e,t){var n,r,i,s,o,u,a,f,l,c,h,p,d,v,m,g,y,b,w,E,S,x,T;t.beam_st||(n=sym_dup(t),lkvsym(n,t),lktsym(n,t),n.x-=12,n.x>t.prev.x+12&&(n.x=t.prev.x+12),n.beam_st=!0,delete n.beam_end,n.tmp=!0,delete n.slur_start,delete n.slur_end,t=n),s=o=0,f=l=!1,u=t.st,a=t.v,E=t.grace?GSTEM_XOFF:3.5;for(r=t;;r=r.next){if(r.type==C.NOTE){r.nflags>o&&(o=r.nflags),s++,r.st!=u&&(f=!0),r.stem!=t.stem&&(l=!0),!x&&!r.invis&&(!r.stemless||r.trem2)&&(x=!0);if(r.beam_end)break}if(!r.next){for(;;r=r.prev)if(r.type==C.NOTE)break;n=sym_dup(r),n.next=r.next,n.next&&(n.next.prev=n),r.next=n,n.prev=r,n.ts_next=r.ts_next,n.ts_next&&(n.ts_next.ts_prev=n),r.ts_next=n,n.ts_prev=r,delete n.beam_st,n.beam_end=!0,n.tmp=!0,delete n.slur_start,delete n.slur_end,n.x+=12,n.x<realwidth-12&&(n.x=realwidth-12),r=n,s++;break}}if(!x)return!1;e.s2=r;if(staff_tb[u].y==0){if(f)return!1}else if(!f)return e.s1=t,e.a=(t.ys-r.ys)/(t.xs-r.xs),e.b=t.ys-t.xs*e.a+staff_tb[u].y,e.nflags=o,!0;w=t,y=100,b=0;for(n=t;;n=n.next){if(n.type!=C.NOTE)continue;(S=n.p_v.scale)==1&&(S=staff_tb[n.st].staffscale),n.stem>=0?(c=E+n.notes[0].shhd,n.notes[n.nhd].pit>b&&(b=n.notes[n.nhd].pit,w=n)):(c=-E+n.notes[n.nhd].shhd,n.notes[0].pit<y&&(y=n.notes[0].pit,w=n)),n.xs=n.x+c*S;if(n==r)break}cfmt.flatbeams?d=0:!l&&s>=3&&w!=t&&w!=r&&(d=0),h=t.ys+staff_tb[u].y,d==undefined&&(d=(r.ys+staff_tb[r.st].y-h)/(r.xs-t.xs)),d!=0&&(d>0?d=BEAM_SLOPE*d/(BEAM_SLOPE+d):d=BEAM_SLOPE*d/(BEAM_SLOPE-d)),v=(h+r.ys+staff_tb[r.st].y)/2-d*(r.xs+t.xs)/2,g=0,n=t;if(l)p=((t.grace?3.5:BEAM_SHIFT)*(o-1)+BEAM_DEPTH)*.5,t.stem!=r.stem&&t.nflags<r.nflags?v+=p*r.stem:v+=p*t.stem;else if(!t.grace){var N=BEAM_DEPTH+BEAM_SHIFT*(o-1);while(n.ts_prev&&n.ts_prev.type==C.NOTE&&n.ts_prev.time==n.time&&n.ts_prev.x>t.xs)n=n.ts_prev;for(;n&&n.time<=r.time;n=n.ts_next){if(n.type!=C.NOTE||n.invis||n.st!=u&&n.v!=a)continue;c=n.v==a?n.xs:n.x,p=d*c+v-staff_tb[n.st].y;if(n.v==a)m=min_tb[n.nhd==0?0:1][n.nflags],n.stem>0?(n.notes[n.nhd].pit>26&&(m-=2,n.notes[n.nhd].pit>28&&(m-=2)),m-=p-3*(n.notes[n.nhd].pit-18)):(n.notes[0].pit<18&&(m-=2,n.notes[0].pit<16&&(m-=2)),m-=3*(n.notes[0].pit-18)-p),m+=BEAM_DEPTH+BEAM_SHIFT*(n.nflags-1);else{if(t.stem>0)if(n.stem>0){if(n.ymn>p+4||n.ymx<p-N-2)continue;n.v>a?m=n.ymx-p:m=n.ymn+8-p}else m=n.ymx-p;else if(n.stem<0){if(n.ymx<p-4||n.ymn>p-N-2)continue;n.v<a?m=p-n.ymn:m=p-n.ymx+8}else m=p-n.ymn;m+=2+N}m>g&&(g=m)}}else for(;;n=n.next){p=d*n.xs+v-staff_tb[n.st].y,m=GSTEM-2,n.stem>0?m-=p-3*(n.notes[n.nhd].pit-18):m+=p-3*(n.notes[0].pit-18),m+=3*(n.nflags-1),m>g&&(g=m);if(n==r)break}g>0&&(v+=t.stem*g);if(!f&&!l)for(n=t.next;;n=n.next){switch(n.type){case C.REST:i=n.ts_next;if(!i||i.st!=u||i.type!=C.NOTE&&i.type!=C.REST)break;case C.BAR:if(n.invis)break;case C.CLEF:h=d*n.x+v,t.stem>0?(h=n.ymx-h+BEAM_DEPTH+BEAM_SHIFT*(o-1)+2,h>0&&(v+=h)):(h=n.ymn-h-BEAM_DEPTH-BEAM_SHIFT*(o-1)-2,h<0&&(v+=h));break;case C.GRACE:for(i=n.extra;i;i=i.next)h=d*i.x+v,t.stem>0?(h=i.ymx-h+BEAM_DEPTH+BEAM_SHIFT*(o-1)+2,h>0&&(v+=h)):(h=i.ymn-h-BEAM_DEPTH-BEAM_SHIFT*(o-1)-2,h<0&&(v+=h))}if(n==r)break}d==0&&(v+=b_pos(t.grace,t.stem,o,v-staff_tb[u].y));for(n=t;;n=n.next){switch(n.type){case C.NOTE:n.ys=d*n.xs+v-staff_tb[n.st].y,n.stem>0?(n.ymx=n.ys+2.5,n.ts_prev&&n.ts_prev.stem>0&&n.ts_prev.st==n.st&&n.ts_prev.ymn<n.ymx&&n.ts_prev.x==n.x&&n.notes[0].shhd==0&&(n.ts_prev.x-=3,n.ts_prev.xs-=3)):n.ymn=n.ys-2.5;break;case C.REST:h=d*n.x+v-staff_tb[n.st].y,T=BEAM_DEPTH+BEAM_SHIFT*(o-1)+(n.head!=C.FULL?4:9);if(t.stem>0){h-=T,t.multi==0&&h>12&&(h=12);if(n.y<=h)break}else{h+=T,t.multi==0&&h<12&&(h=12);if(n.y>=h)break}n.head!=C.FULL&&(h=((h+3+12)/6|0)*6-12),n.y=h}if(n==r)break}return staff_tb[u].y==0?!1:(e.s1=t,e.a=d,e.b=v,e.nflags=o,!0)}function draw_beams(e){function v(e,t,n,r,i,s){var o,u,a=i.s1,f=a.nflags;a.ntrem&&(f-=a.ntrem),a.trem2&&s>f&&(a.dur>=C.BLEN/2?(e=a.x+6,t=i.s2.x-6):a.dur<C.BLEN/4&&(e+=5,t-=6)),o=i.a*e+i.b-n,t-=e,t/=stv_g.scale,u=i.a*t*stv_g.scale,xypath(e,o,!0),output+="l"+t.toFixed(2)+" "+(-u).toFixed(2)+"v"+r.toFixed(2)+"l"+(-t).toFixed(2)+" "+u.toFixed(2)+'z"/>\n'}var t,n,r,i,s,o,u,a,f,l,c,h,p=e.s1,d=e.s2;anno_start(p,"beam"),p.grace?(s=3.5,o=3.2,i=.29,u=1.8):(s=BEAM_SHIFT,o=BEAM_STUB,i=.34,u=BEAM_DEPTH),r=p.stem,p.stem!=d.stem&&p.nflags<d.nflags&&(r=d.stem),r<0&&(u=-u),v(p.xs-i,d.xs+i,0,u,e,1),a=0;for(t=p;;t=t.next){t.type==C.NOTE&&t.stem!=r&&(t.ys=e.a*t.xs+e.b-staff_tb[t.st].y+s*(t.nflags-1)*t.stem-u);if(t==d)break}p.feathered_beam&&(a=s/(d.xs-p.xs),p.feathered_beam>0?(a=-a,s=a*p.xs):s=a*d.xs,a*=r),i=0;for(n=2;n<=e.nflags;n++){i+=s,a!=0&&(e.a+=a);for(t=p;;t=t.next){if(t.type!=C.NOTE||t.nflags<n){if(t==d)break;continue}if(t.trem1&&n>t.nflags-t.ntrem){h=t.dur>=C.BLEN/2?t.x:t.xs,v(h-5,h+5,(i+2.5)*r,u,e,n);if(t==d)break;continue}l=t;for(;;){if(t==d)break;f=t.next;if(f.type==C.NOTE||f.type==C.REST)if(f.trem1){if(f.nflags-f.ntrem<n)break}else if(f.nflags<n)break;if(f.beam_br1||f.beam_br2&&n>2)break;t=f}c=t;while(c.type!=C.NOTE)c=c.prev;h=l.xs;if(l==c)if(l==p)h+=o;else if(l==d)h-=o;else if(l.beam_br1||l.beam_br2&&n>2)h+=o;else{f=l.next;while(f.type!=C.NOTE)f=f.next;if(f.beam_br1||f.beam_br2&&n>2)h-=o;else{l=l.prev;while(l.type!=C.NOTE)l=l.prev;l.nflags<f.nflags||l.nflags==f.nflags&&l.dots<f.dots?h+=o:h-=o}}v(h,c.xs,i*r,u,e,n);if(t==d)break}}p.tmp?unlksym(p):d.tmp&&unlksym(d),anno_stop(p,"beam")}function draw_lstaff(e){function u(e,t,n){var r,i,s,o;while(!cur_sy.st_print[t]){if(cur_sy.staves[t].flags&n)return;t++}r=i=t;for(;;){cur_sy.st_print[r]&&(i=r);if(cur_sy.staves[r].flags&n)break;r++}s=staff_tb[t].y+staff_tb[t].topbar*staff_tb[t].staffscale,o=staff_tb[i].y+staff_tb[i].botbar*staff_tb[i].staffscale,n&(CLOSE_BRACE|CLOSE_BRACE2)?out_brace(e,o,s-o):out_bracket(e,s,s-o)}var t,n,r,i,s=cur_sy.nstaff,o=0;for(t=0;;t++){cur_sy.staves[t].flags&(OPEN_BRACE|OPEN_BRACKET)&&o++;if(cur_sy.st_print[t])break;cur_sy.staves[t].flags&(CLOSE_BRACE|CLOSE_BRACKET)&&o--;if(t==s)break}for(n=s;n>t;n--)if(cur_sy.st_print[n])break;if(t==n&&o==0)return;r=staff_tb[n].y+staff_tb[n].botbar*staff_tb[n].staffscale,i=staff_tb[t].y+staff_tb[t].topbar*staff_tb[t].staffscale-r,xypath(e,r),output+="v"+(-i).toFixed(2)+'"/>\n';for(t=0;t<=s;t++)cur_sy.staves[t].flags&OPEN_BRACE&&u(e,t,CLOSE_BRACE),cur_sy.staves[t].flags&OPEN_BRACKET&&u(e,t,CLOSE_BRACKET),cur_sy.staves[t].flags&OPEN_BRACE2&&u(e-6,t,CLOSE_BRACE2),cur_sy.staves[t].flags&OPEN_BRACKET2&&u(e-6,t,CLOSE_BRACKET2)}function draw_meter(e,t){if(!t.a_meter)return;var n,r,i,s,o=t.st,u=staff_tb[o],a=u.y;u.stafflines!="|||||"&&(a+=(u.topbar+u.botbar)/2-12);for(r=0;r<t.a_meter.length;r++)s=t.a_meter[r],e=t.x+t.x_meter[r],s.bot?out_XYAB('<g transform="translate(X,Y)" text-anchor="middle">\n <text y="-12">A</text>\n <text>B</text>\n</g>\n',e,a+6,m_gl(s.top),m_gl(s.bot)):out_XYAB('<text x="X" y="Y" text-anchor="middle">A</text>\n',e,a+12,m_gl(s.top))}function draw_acc(e,t,n,r,i){if(r)if(r==i)n=n==-1?-2:2;else if(r*2!=i){xygl(e,t,"acc"+n+"_"+r+"_"+i);return}xygl(e,t,"acc"+n)}function draw_hl(e,t,n,r,i){var s,o,u=staff_tb[r],a=u.y,f=u.stafflines,l=(f.length-1)*6,c=u.botline;if(!/[\[|]/.test(f))return;t%6&&(t+=3),n%6&&(n-=3);if(f.indexOf("-")>=0&&(t>c&&t<l||n>c&&n<l||t<=c&&n>=l)){s=t,o=n;while(s>c&&f[s/6]=="-")s-=6;while(o<l&&f[o/6]=="-")o+=6;for(;s<o;s+=6)f[s/6]=="-"&&xygl(e,a+s,i)}for(;t<c;t+=6)xygl(e,a+t,i);for(;n>l;n-=6)xygl(e,a+n,i)}function draw_keysig(e,t,n){if(n.k_none)return;var r=n.k_old_sf,i=e.st,s=staff_tb[i].y,o,u,a,f=n.k_y_clef;f&1&&(f+=7),f/=2;while(f<0)f+=7;f%=7;if(!n.k_a_acc){if(cfmt.cancelkey||n.k_sf==0)if(n.k_sf==0||r*n.k_sf<0){u=sharp_cl[f],a=u>9?sharp1:sharp2;for(o=0;o<r;o++)xygl(t,s+u,"acc3"),u+=a[o],t+=5.5;u=flat_cl[f],a=u<18?flat1:flat2;for(o=0;o>r;o--)xygl(t,s+u,"acc3"),u+=a[-o],t+=5.5;n.k_sf!=0&&(t+=3)}if(n.k_sf>0){u=sharp_cl[f],a=u>9?sharp1:sharp2;for(o=0;o<n.k_sf;o++)xygl(t,s+u,"acc1"),u+=a[o],t+=5.5;if(cfmt.cancelkey&&o<r){t+=2;for(;o<r;o++)xygl(t,s+u,"acc3"),u+=a[o],t+=5.5}}if(n.k_sf<0){u=flat_cl[f],a=u<18?flat1:flat2;for(o=0;o>n.k_sf;o--)xygl(t,s+u,"acc-1"),u+=a[-o],t+=5.5;if(cfmt.cancelkey&&o>r){t+=2;for(;o>r;o--)xygl(t,s+u,"acc3"),u+=a[-o],t+=5.5}}}else if(n.k_a_acc.length){var l,c=n.k_a_acc[0].acc,h=100;for(o=0;o<n.k_a_acc.length;o++)l=n.k_a_acc[o],u=(n.k_y_clef+l.pit-18)*3,o!=0&&(u>h+18||u<h-18)?t-=5.5:l.acc!=c&&(t+=3),c=l.acc,draw_hl(t,u,u,i,"hl"),h=u,draw_acc(t,s+u,l.acc,l.micro_n,l.micro_d),t+=5.5}}function bar_cnv(e){switch(e){case"[":case"[]":return"";case"|:":case"|::":case"|:::":return"["+e;case":|":case"::|":case":::|":return e+"]";case"::":return cfmt.dblrepbar;case"||:":return"[|:"}return e}function draw_bar(e,t,n){var r,i,s,o=e.bar_type,u=e.st,a=staff_tb[u],f=e.x;if(!o)return;u!=0&&e.ts_prev&&e.ts_prev.type!=C.BAR&&(n=a.topbar*a.staffscale),e.ymx=e.ymn+n,set_sscale(-1),anno_start(e),s=a.y+12,a.stafflines!="|||||"&&(s+=(a.topbar+a.botbar)/2-12);if(e.bar_mrep){set_sscale(u);if(e.bar_mrep==1){for(i=e.prev;i.type!=C.REST;i=i.prev);xygl(i.x,s,"mrep")}else xygl(f,s,"mrep2"),e.v==cur_sy.top_voice&&(set_font("annotation"),xy_str(f,s+a.topbar-9,e.bar_mrep.toString(),"c"))}for(r=o.length;--r>=0;){switch(o[r]){case"|":set_sscale(-1),out_bar(f,t,n,e.bar_dotted?a.staffscale:0);break;default:f-=3,set_sscale(-1),out_thbar(f,t,n);break;case":":f-=2,set_sscale(u),xygl(f+1,s-12,"rdots")}f-=3}set_sscale(-1),anno_stop(e)}function draw_rest(e){var t,n,r,i,s,o,u,a,f,l=staff_tb[e.st];if(!l.topbar)return;if(e.dur==e.p_v.meter.wmeasure||e.rep_nb&&e.rep_nb>=0){t=e.ts_next;while(t&&t.time!=e.time+e.dur)t=t.ts_next;i=t?t.x:realwidth,t=e;while(!t.seqst)t=t.ts_prev;t=t.ts_prev,i=(i+t.x)/2,e.a_dd&&deco_update(e,i-e.x),e.x=i}else i=e.x,e.notes[0].shhd&&(i+=e.notes[0].shhd*stv_g.scale);if(e.invis)return;u=l.y;if(e.rep_nb){set_sscale(e.st),anno_start(e),l.stafflines=="|||||"?u+=12:u+=(l.topbar+l.botbar)/2,e.rep_nb<0?xygl(i,u,"srep"):(xygl(i,u,"mrep"),e.rep_nb>2&&e.v==cur_sy.top_voice&&(set_font("annotation"),xy_str(i,u+l.topbar-9,e.rep_nb.toString(),"c"))),anno_stop(e);return}set_scale(e),anno_start(e),s=e.y,n=5-e.nflags,n==7&&s==12&&l.stafflines.length<=2&&(s-=6),xygl(i,s+u,e.notes[0].head?e.notes[0].head:rest_tb[n]);if(n>=6){r=s/6;switch(n){default:switch(l.stafflines[r+1]){case"|":case"[":break;default:xygl(i,s+6+u,"hl1")}n==9&&(s-=6,r--);break;case 7:s+=6,r++;case 6:}switch(l.stafflines[r]){case"|":case"[":break;default:xygl(i,s+u,"hl1")}}if(e.dots){i+=8,s+=u+3;for(n=0;n<e.dots;n++)xygl(i,s,"dot"),i+=3.5}anno_stop(e)}function draw_gracenotes(e){var t,n,r,i,s,o,u,a,f,l,c,h,p,d,v,m,g={};for(d=e.extra;d;d=d.next){d.beam_st&&!d.beam_end&&self.calculate_beam(g,d)&&draw_beams(g),anno_start(d),draw_note(d,!g.s2),d==g.s2&&(g.s2=null),anno_stop(d);if(!d.next)break}e.sappo&&(d=e.extra,d.next?(i=(d.next.x-d.x)*.5+4,s=(d.ys+d.next.ys)*.5-d.y,d.stem>0?s-=1:s+=1):(i=9,s=d.stem>0?5:-5),m=d.notes[d.stem<0?0:d.nhd],out_acciac(x_head(d,m),y_head(d,m),i,s,d.stem>0));if(e.p_v.key.k_bagpipe||!cfmt.graceslurs||e.slur_start||!e.next||e.next.type!=C.NOTE)return;v=d;if(v.stem>=0){t=127;for(d=e.extra;d;d=d.next)d.y<t&&(t=d.y,v=d);n=v.x,r=v.y-5,e.extra!=v&&(n-=4,r+=1),e=e.next,a=e.x-1,e.stem<0&&(a-=4),f=3*(e.notes[0].pit-18)-5,h=(a-n)*.4,h>3&&(h=3),p=h,l=.2,c=.8,r>f+7?(n=v.x-1,r+=.5,f+=6.5,a=e.x-5.5,h=(r-f)*.8,p=(r-f)*.2,l=0):f>r+4&&(f=r+4,n=v.x+2,r=v.y-4)}else{t=-127;for(d=e.extra;d;d=d.next)d.y>t&&(t=d.y,v=d);n=v.x,r=v.y+5,e.extra!=v&&(n-=4,r-=1),e=e.next,a=e.x-1,e.stem>=0&&(a-=2),f=3*(e.notes[e.nhd].pit-18)+5,h=(n-a)*.4,h<-3&&(h=-3),p=h,l=.2,c=.8,r<f-7?(n=v.x-1,r-=.5,f-=6.5,a=e.x-5.5,h=(r-f)*.8,p=(r-f)*.2,l=0):f<r-4&&(f=r-4,n=v.x+2,r=v.y+4)}i=l*a+(1-l)*n-n,s=l*f+(1-l)*r-h-r,o=c*a+(1-c)*n-n,u=c*f+(1-c)*r-p-r,anno_start(e,"slur"),xypath(n,r+staff_tb[e.st].y),output+="c"+i.toFixed(2)+" "+(-s).toFixed(2)+" "+o.toFixed(2)+" "+(-u).toFixed(2)+" "+(a-n).toFixed(2)+" "+(-f+r).toFixed(2)+'"/>\n',anno_stop(e,"slur")}function setdoty(e,t){var n,r,i;for(n=0;n<=e.nhd;n++)i=3*(e.notes[n].pit-18),i%6==0&&(e.dot_low?i-=3:i+=3),t[n]=i;for(n=0;n<e.nhd;n++){if(t[n+1]>t[n])continue;r=n;while(r>0){if(t[r]>t[r-1]+6)break;r--}if(3*(e.notes[r].pit-18)-t[r]<t[n+1]-3*(e.notes[n+1].pit-18))while(r<=n)t[r++]-=6;else t[n+1]=t[n]+6}}function x_head(e,t){return e.x+t.shhd*stv_g.scale}function y_head(e,t){return staff_tb[e.st].y+3*(t.pit-18)}function draw_basic_note(e,t,n,r){var i,s,o,u,a,f,l,c=!1,h=t.notes[n],p=staff_tb[t.st].y,d=3*(h.pit-18),v=h.shhd*stv_g.scale,m=e+v,g=d+p,y=identify_note(t,h.dur),b=y[0],w=y[1],E=y[2];d%6==0&&v!=(t.stem>0?t.notes[0].shhd:t.notes[t.nhd].shhd)&&(u=0,d>=30?(u=d,u%6&&(u-=3)):d<=-6&&(u=d,u%6&&(u+=3)),u&&xygl(m,u+p,"hl"));if(!h.invis)if(t.grace)o="ghd",m-=4.5*stv_g.scale;else if(h.map&&h.map[0])i=t.head,o=h.map[0][i],o||(o=h.map[0][h.map[0].length-1]),i=o.indexOf("/"),i>=0&&(t.stem>=0?o=o.slice(0,i):o=o.slice(i+1));else if(t.type==C.CUSTOS)o="custos";else switch(b){case C.OVAL:o="HD";break;case C.OVALBARS:if(t.head!=C.SQUARE){o="HDD";break};case C.SQUARE:h.dur<C.BLEN*4?o="breve":(o="longa",l=t.stem>0),!tsnext&&t.next&&t.next.type==C.BAR&&!t.next.next&&(w=0);break;case C.EMPTY:o="Hd";break;default:o="hd"}h.color!=undefined?c=set_color(h.color):h.map&&h.map[2]&&(c=set_color(h.map[2])),o&&(l&&(g_open(m,g,0,1,-1),m=g=0),self.psxygl(m,g,o)||xygl(m,g,o),l&&g_close());if(w){a=e+(7.7+t.xmx)*stv_g.scale,r[n]==undefined&&(r[n]=3*(t.notes[n].pit-18),(t.notes[n].pit&1)==0&&(r[n]+=3)),f=r[n]+p;while(--w>=0)xygl(a,f,"dot"),a+=3.5}h.acc&&(e-=h.shac*stv_g.scale,t.grace?(g_open(e,d+p,0,.75),draw_acc(0,0,h.acc,h.micro_n,h.micro_d),g_close()):draw_acc(e,d+p,h.acc,h.micro_n,h.micro_d)),c!=0&&set_color(c)}function draw_note(e,t){var n,r,i,s,o,u,a,f,l,c,s,h,p=new Array(e.nhd+1);e.dots&&setdoty(e,p),h=e.notes[e.stem<0?e.nhd:0],c=x_head(e,h),o=staff_tb[e.st].y;if(e.grace)f="ghl";else switch(e.head){default:f="hl";break;case C.OVAL:case C.OVALBARS:f="hl1";break;case C.SQUARE:f="hl2"}draw_hl(c,3*(e.notes[0].pit-18),3*(e.notes[e.nhd].pit-18),e.st,f),s=y_head(e,h),e.stemless?e.xstem&&(n=e.ts_prev,u=(n.stem>0?n.y:n.ys)-e.y,u+=staff_tb[n.st].y-o,u/=e.p_v.scale,out_stem(c,s,u)):(u=e.ys-e.y,l=e.nflags,e.ntrem&&(l-=e.ntrem),!t||l<=0?(e.nflags>0&&(e.stem>=0?u-=1:u+=1),out_stem(c,s,u,e.grace)):out_stem(c,s,u,e.grace,l,cfmt.straightflags));if(t&&e.trem1){var d=e.ntrem||0,v=c;u=3*(e.notes[e.stem>0?e.nhd:0].pit-18),e.head==C.FULL||e.head==C.EMPTY?(v+=(e.grace?GSTEM_XOFF:3.5)*e.stem,e.stem>0?u+=6+5.4*d:u-=11.4):e.stem>0?u+=5+5.4*d:u-=10.4,u/=e.p_v.scale,out_trem(v,o+u,d)}c=e.x;for(i=0;i<=e.nhd;i++)draw_basic_note(c,e,i,p)}function next_scut(e){var t=e;for(e=e.next;e;e=e.next){if(e.rbstop)return e;t=e}return t}function prev_scut(e){while(e.prev){e=e.prev;if(e.rbstart)return e}e=e.p_v.sym;while(e.type!=C.CLEF)e=e.ts_prev;return e.next&&e.next.type==C.KEY&&(e=e.next),e.next&&e.next.type==C.METER?e.next:e}function slur_direction(e,t){var n,r,i;if(e.grace&&e.stem>0)return-1;for(n=e;;n=n.next){if(n.type==C.NOTE){if(!n.stemless){if(n.stem<0)return 1;r=!0}n.notes[0].pit<22&&(i=!0)}if(n==t)break}return!r&&!i?1:-1}function slur_out(e,t,n,r,i,s,o){var u,a,f,l=.3,c=.45;a=r-t,a<0&&(a=-a),u=n-e,u>40&&a/u<.7&&(l=.3+.002*(u-40),l>.7&&(l=.7));var h=.5*(e+n),p=.5*(t+r),d=h+l*(e-h),v=p+l*(t-p)+s;d=e+c*(d-e),v=t+c*(v-t);var m=h+l*(n-h),g=p+l*(r-p)+s;m=n+c*(m-n),g=r+c*(g-r),u=.03*(n-e),a=2*i,f=.2+.001*(n-e),f>.6&&(f=.6),f*=i;var y=stv_g.v?stv_g.scale:1;o?output+='<path class="stroke" stroke-dasharray="5,5" d="M':output+='<path class="fill" d="M',out_sxsy(e," ",t),output+="c"+((d-e)/stv_g.scale).toFixed(2)+" "+((t-v)/y).toFixed(2)+" "+((m-e)/stv_g.scale).toFixed(2)+" "+((t-g)/y).toFixed(2)+" "+((n-e)/stv_g.scale).toFixed(2)+" "+((t-r)/y).toFixed(2),o||(output+="\n v"+(-f).toFixed(2)+"c"+((m-u-n)/stv_g.scale).toFixed(2)+" "+((r+f-g-a)/y).toFixed(2)+" "+((d+u-n)/stv_g.scale).toFixed(2)+" "+((r+f-v-a)/y).toFixed(2)+" "+((e-n)/stv_g.scale).toFixed(2)+" "+((r+f-t)/y).toFixed(2)),output+='"/>\n'}function slur_multi(e,t){for(;;){if(e.multi)return e.multi;if(e==t)break;e=e.next}return 0}function draw_slur(e,t,n,r,i){var s=e,o,u,a,f,l,c,h,p,d,v,m,g,y,b,w;while(s.v!=t.v)s=s.ts_next;switch(i&7){case C.SL_ABOVE:w=1;break;case C.SL_BELOW:w=-1;break;default:w=slur_multi(s,t),w||(w=slur_direction(s,t))}var E=1,S=s.st,x=!1;if(s!=t){o=s.next;for(;;){if(o.type==C.NOTE||o.type==C.REST)E++,o.st!=S&&(x=!0,o.st<S&&(S=o.st));if(o==t)break;o=o.next}}x&&error(2,s,"*** multi-staves slurs not treated yet"),a=e.x,e.notes&&e.notes[0].shhd&&(a+=e.notes[0].shhd);if(e!=t)l=t.x,t.notes&&(l+=t.notes[0].shhd);else{for(o=t.ts_next;o;o=o.ts_next)if(o.type==C.STAVES)break;l=o?o.x:realwidth}n>=0?f=3*(s.notes[n].pit-18)+5*w:(f=w>0?s.ymx+2:s.ymn-2,s.type==C.NOTE&&(w>0?s.stem>0&&(a+=5,s.beam_end&&s.nflags>=-1&&!s.in_tuplet&&(s.nflags>0?(a+=2,f=s.ys-3):f=s.ys-6)):s.stem<0&&(a-=1,t.grace?f=s.y-8:s.beam_end&&s.nflags>=-1&&(!s.in_tuplet||s.ys<f+3)&&(s.nflags>0?(a+=2,f=s.ys+3):f=s.ys+6)))),r>=0?c=3*(t.notes[r].pit-18)+5*w:(c=w>0?t.ymx+2:t.ymn-2,t.type==C.NOTE&&(w>0?t.stem>0&&(l+=1,t.beam_st&&t.nflags>=-1&&!t.in_tuplet&&(c=t.ys-6)):t.stem<0&&(l-=5,t.beam_st&&t.nflags>=-1&&!t.in_tuplet&&(c=t.ys+6)))),s.type!=C.NOTE&&(f=c+1.2*w,a=s.x+s.wr*.5,a>l-12&&(a=l-12)),t.type!=C.NOTE&&(s.type==C.NOTE?c=f+1.2*w:c=f,s!=t&&(l=t.x-t.wl*.3)),E>=3&&(s.next.type!=C.BAR&&s.next.x<a+48&&(w>0?(v=s.next.ymx-2,f<v&&(f=v)):(v=s.next.ymn+2,f>v&&(f=v))),t.prev&&t.prev.type!=C.BAR&&t.prev.x>l-48&&(w>0?(v=t.prev.ymx-2,c<v&&(c=v)):(v=t.prev.ymn+2,c>v&&(c=v)))),d=(c-f)/(l-a);if(d>SLUR_SLOPE||d<-SLUR_SLOPE)d=d>SLUR_SLOPE?SLUR_SLOPE:-SLUR_SLOPE,d*w>0?f=c-d*(l-a):c=f+d*(l-a);v=c-f,v>8?v=8:v<-8&&(v=-8),m=v,m<0&&(m=-m),y=.5*m,b=.3*v,v*w>0?(l-=y,c-=b):(a+=y,f+=b),s.grace&&(a=s.x-GSTEM_XOFF*.5),t.grace&&(l=t.x+GSTEM_XOFF*1.5),g=0,d=(c-f)/(l-a);if(s!=t&&s.v==t.v){p=f-d*a;for(o=s.next;o!=t;o=o.next){if(o.st!=S)continue;switch(o.type){case C.NOTE:case C.REST:w>0?(v=3*(o.notes[o.nhd].pit-18)+6,v<o.ymx&&(v=o.ymx),v-=d*o.x+p,v>g&&(g=v)):(v=3*(o.notes[0].pit-18)-6,v>o.ymn&&(v=o.ymn),v-=d*o.x+p,v<g&&(g=v));break;case C.GRACE:for(u=o.extra;u;u=u.next)w>0?(v=3*(u.notes[u.nhd].pit-18)+6,v<u.ymx&&(v=u.ymx),v-=d*u.x+p,v>g&&(g=v)):(v=3*(u.notes[0].pit-18)-6,v>u.ymn&&(v=u.ymn),v-=d*u.x+p,v<g&&(g=v))}}f+=.45*g,c+=.45*g,g*=.65}E>3?h=(.08*(l-a)+12)*w:h=(.03*(l-a)+8)*w,w>0?(h<3*g&&(h=3*g),h>40&&(h=40)):(h>3*g&&(h=3*g),h<-40&&(h=-40)),v=c-f,v<0&&(v=-v),w>0?h<.8*v&&(h=.8*v):h>-0.8*v&&(h=-0.8*v),h*=cfmt.slurheight,slur_out(a,f,l,c,w,h,i&C.SL_DOTTED),y=l-a,d=(c-f)/y,p=f-d*a+.4*h;if(s.v==t.v)for(o=s;o!=t;o=o.next){if(o.st!=S)continue;v=d*o.x+p,o.ymx<v?o.ymx=v:o.ymn>v&&(o.ymn=v),o.next==t?(y=l,t.sl1&&(y-=5)):y=o.next.x,o!=s&&(a=o.x),y-=a,y_set(S,w>0,a,y,v)}return(w>0?C.SL_ABOVE:C.SL_BELOW)|i&C.SL_DOTTED}function draw_slurs(e,t){var n,r,i,s,o,u,a,f,l,c=e;for(;;){if(!c||c==t){if(!i||!(c=i.next)||c==t)break;i=null}if(c.type==C.GRACE){i=c,c=c.extra;continue}if(c.type!=C.NOTE&&c.type!=C.REST&&c.type!=C.SPACE||!c.slur_start&&!c.sl1){c=c.next;continue}r=null,n=c.next;var h=!1;for(;;){if(!n){if(s){n=s.next,s=null;continue}if(!i||h)break;n=i.next,h=!0;continue}if(n.type==C.GRACE){s=n,n=n.extra;continue}if(n.type==C.BAR&&(n.bar_type[0]==":"||n.bar_type=="|]"||n.bar_type=="[|"||n.text&&n.text[0]!="1")){r=n;break}if(n.type!=C.NOTE&&n.type!=C.REST&&n.type!=C.SPACE){n=n.next;continue}if(n.slur_end||n.sl2){r=n;break}if(n.slur_start||n.sl1){if(s){for(r=n;r.next;r=r.next);r.next=s.next,s.next&&(s.next.prev=r),r=null}draw_slurs(n,t),s&&s.next&&(s.next.prev.next=null,s.next.prev=s)}if(n==t)break;n=n.next}if(!n)r=next_scut(c);else if(!r){c=n;if(c==t)break;continue}if(i){for(n=c;n.next;n=n.next);n.next=i.next,i.next&&(i.next.prev=n),i.slur_start=C.SL_AUTO}s&&(s.prev.next=s.extra,s.extra.prev=s.prev,s.slur_start=C.SL_AUTO);if(c.slur_start)f=c.slur_start&15,c.slur_start>>=4,u=-1;else{for(u=0;u<=c.nhd;u++)if(c.notes[u].sl1)break;f=c.notes[u].sl1&15,c.notes[u].sl1>>=4,c.sl1--}a=-1,l=0;if(r.type!=C.NOTE&&r.type!=C.REST&&r.type!=C.SPACE||!r.slur_end&&!r.sl2){if(r.type!=C.BAR||r.bar_type[0]!=":"&&r.bar_type!="|]"&&r.bar_type!="[|"&&(!r.text||r.text[0]=="1"))l=1}else if(r.slur_end)r.slur_end--;else{for(a=0;a<=r.nhd;a++)if(r.notes[a].sl2)break;r.notes[a].sl2--,r.sl2--}f=draw_slur(c,r,u,a,f),l&&(r.p_v.slur_start||(r.p_v.slur_start=0),r.p_v.slur_start<<=4,r.p_v.slur_start+=f),i&&i.next&&(i.next.prev.next=null,i.next.prev=i),s&&(s.prev.next=s,s.extra.prev=null);if(c.slur_start||c.sl1)continue;if(c==t)break;c=c.next}}function draw_tuplet(e,t){var n,r,i,s,o,u,a,f,l,c,h,p,d,v,m,g,y,d,b,w,E,S,x;s=e.st;for(n=e;n;n=n.next){if(n.type!=C.NOTE&&n.type!=C.REST){if(n.type==C.GRACE)for(i=n.extra;i;i=i.next)if(i.slur_start||i.sl1)u=!0;continue}if(n.slur_start||n.slur_end||n.sl1||n.sl2)u=!0;n.st<s&&(s=n.st);if(t==0){n.tp1&&draw_tuplet(n,1);if(n.te0)break}else if(n.te1)break}if(!n){error(1,e,"No end of tuplet in this music line"),t==0?e.tp0=0:e.tp1=0;return}if(u){draw_slurs(e,n);if(e.slur_start||e.sl1)return;for(r=e.next;r!=n;r=r.next)if(r.slur_start||r.slur_end||r.sl1||r.sl2)return;if(n.slur_end||n.sl2)return}t==0?(E=e.tp0,e.tp0=0,S=e.tq0):(E=e.tp1,e.tp1=0,S=e.tq1);if(e.tf[0]==1)return;w=e.tf[3],w||(w=e.stem>0?C.SL_ABOVE:C.SL_BELOW);if(e==n)o=!0;else if(e.tf[1]==1)o=!0,draw_slur(e,n,-1,-1,w);else if(e.tf[0]==2||e.type!=C.NOTE||n.type!=C.NOTE)o=!1;else{o=!0;for(r=e;;r=r.next){if(r.type!=C.NOTE&&r.type!=C.REST){if(r.type==C.GRACE||r.type==C.SPACE)continue;o=!1;break}if(r==n)break;if(r.beam_end){o=!1;break}}if(o&&!e.beam_st&&!e.beam_br1&&!e.beam_br2)for(r=e.prev;r;r=r.prev)if(r.type==C.NOTE||r.type==C.REST){r.nflags>=e.nflags&&(o=!1);break}if(o&&!n.beam_end)for(r=n.next;r;r=r.next)if(r.type==C.NOTE||r.type==C.REST){!r.beam_br1&&!r.beam_br2&&r.nflags>=n.nflags&&(o=!1);break}}if(o){if(e.tf[2]==1)return;h=(n.x+e.x)/2,e==n?d=0:d=(n.ys-e.ys)/(n.x-e.x),b=e.ys-d*e.x,m=d*h+b,w==C.SL_ABOVE?(p=y_get(s,1,h-4,8),p>m&&(b+=p-m),b+=2):(p=y_get(s,0,h-4,8),p<m&&(b+=p-m),b-=10);for(r=e;;r=r.next)if(r.x>=h)break;e.stem*n.stem>0&&(e.stem>0?h+=1.5:h-=1.5),p=d*h+b,e.tf[2]==0?out_bnum(h,p,E):out_bnum(h,p,E+":"+S),w==C.SL_ABOVE?(p+=10,r.ymx<p&&(r.ymx=p),y_set(s,!0,h-3,6,p)):(r.ymn>p&&(r.ymn=p),y_set(s,!1,h-3,6,p));return}e.tf[1]!=0&&error(2,e,"'what' value of %%tuplets not yet coded"),w=e.tf[3],w||(w=e.multi>=0?C.SL_ABOVE:C.SL_BELOW);if(w==C.SL_ABOVE){e.st==n.st?l=c=staff_tb[s].topbar+4:(l=e.ymx,c=n.ymx),a=e.x-4;if(e.st==s){for(r=e;!r.dur;r=r.next);p=y_get(s,1,r.x-4,8),p>l&&(l=p),e.stem>0&&(a+=3)}if(n.st==s){for(r=n;!r.dur;r=r.prev);p=y_get(s,1,r.x-4,8),p>c&&(c=p)}n.dur>n.prev.dur?n.next?f=n.next.x-n.next.wl-5:f=realwidth-6:(f=n.x+4,x=n.stem>=0?0:n.nhd,n.notes[x].shhd>0&&(f+=n.notes[x].shhd),n.st==s&&n.stem>0&&(f+=3.5)),h=.5*(a+f),p=.5*(l+c),d=(c-l)/(f-a),v=3*(n.notes[n.nhd].pit-e.notes[e.nhd].pit)/(f-a),v>0?d<0?d=0:d>v&&(d=v):d>0?d=0:d<v&&(d=v),d*d<.1*.1&&(d=0),y=0;for(r=e;;r=r.next){if(!r.dur||r.st!=s){if(r==n)break;continue}m=p+(r.x-h)*d,g=y_get(s,1,r.x-4,8)+2,g-m>y&&(y=g-m);if(r==n)break}p+=y,l=p+d*(a-h),c=p+d*(f-h),p+=8;for(r=e;;r=r.next)if(r.st==s){m=p+(r.x-h)*d,r.ymx<m&&(r.ymx=m);if(r==n)break;y_set(s,!0,r.x,r.next.x-r.x,m)}else if(r==n)break}else{a=e.x-7,n.dur>n.prev.dur?n.next?f=n.next.x-n.next.wl-8:f=realwidth-6:(f=n.x+2,n.notes[n.nhd].shhd>0&&(f+=n.notes[n.nhd].shhd)),e.stem>=0&&(a+=2,f+=2);if(e.st==s){for(r=e;!r.dur;r=r.next);l=y_get(s,0,r.x-4,8)}else l=0;if(n.st==s){for(r=n;!r.dur;r=r.prev);c=y_get(s,0,r.x-4,8)}else c=0;h=.5*(a+f),p=.5*(l+c),d=(c-l)/(f-a),v=3*(n.notes[0].pit-e.notes[0].pit)/(f-a),v>0?d<0?d=0:d>v&&(d=v):d>0?d=0:d<v&&(d=v),d*d<.1*.1&&(d=0),y=0;for(r=e;;r=r.next){if(!r.dur||r.st!=s){if(r==n)break;continue}m=p+(r.x-h)*d,g=y_get(s,0,r.x-4,8),g-m<y&&(y=g-m);if(r==n)break}p+=y-10,l=p+d*(a-h),c=p+d*(f-h),p-=2;for(r=e;;r=r.next){if(r.st==s){if(r==n)break;m=p+(r.x-h)*d,r.ymn>m&&(r.ymn=m),y_set(s,!1,r.x,r.next.x-r.x,m)}if(r==n)break}}if(e.tf[2]==1){out_tubr(a,l+4,f-a,c-l,w==C.SL_ABOVE);return}out_tubrn(a,l,f-a,c-l,w==C.SL_ABOVE,e.tf[2]==0?E.toString():E+":"+S),m=.5*(l+c),w==C.SL_ABOVE?y_set(s,!0,h-3,6,m+9):y_set(s,!1,h-3,6,m)}function draw_note_ties(e,t,n,r,i){var s,o,u,a,f,l,c,h,p,d,v,m,g,y;for(s=0;s<n.length;s++){u=n[s],f=e.notes[u].pit,a=r[s],l=i!=2?t.notes[a].pit:f,o=(e.notes[u].ti1&7)==C.SL_ABOVE?1:-1,d=e.x,g=e.notes[u].shhd,o>0?u<e.nhd&&f+1==e.notes[u+1].pit&&e.notes[u+1].shhd>g&&(g=e.notes[u+1].shhd):u>0&&f==e.notes[u-1].pit+1&&e.notes[u-1].shhd>g&&(g=e.notes[u-1].shhd),d+=g*.6,v=t.x,i!=2&&(g=t.notes[a].shhd,o>0?a<t.nhd&&l+1==t.notes[a+1].pit&&t.notes[a+1].shhd<g&&(g=t.notes[a+1].shhd):a>0&&l==t.notes[a-1].pit+1&&t.notes[a-1].shhd<g&&(g=t.notes[a-1].shhd),v+=g*.6),h=e.st;switch(i){case 0:f!=l&&!(f&1)&&(f=l);break;case 3:o=-o;case 1:d=e.x,d>v-20&&(d=v-20),f=l,h=t.st;break;default:if(e!=t)v-=t.wl,t.type==C.BAR&&(v+=5);else{y=e.time+e.dur;for(p=e.ts_next;p;p=p.ts_next)if(p.time>y)break;v=p?p.x:realwidth}v<d+16&&(v=d+16)}v-d>20?(d+=3.5,v-=3.5):(d+=1.5,v-=1.5),c=3*(f-18),m=(.04*(v-d)+10)*o,slur_out(d,staff_tb[h].y+c,v,staff_tb[h].y+c,o,m,e.notes[u].ti1&C.SL_DOTTED)}}function draw_ties(e,t,n){var r,i,s,o,u,a,f,l=[],c=[],h=[],p=e.nhd,d=e.time+e.dur;if(n==2){for(i=0;i<=p;i++)e.notes[i].ti1&&h.push(i);draw_note_ties(e,t||e,h,h,n);return}for(i=0;i<=p;i++){if(!e.notes[i].ti1)continue;f=-1,u=e.notes[i].opit||e.notes[i].pit;for(o=t.nhd;o>=0;o--){a=t.notes[o].opit||t.notes[o].pit;switch(a-u){case 1:case-1:e.notes[i].acc!=t.notes[o].acc&&(f=o);default:continue;case 0:f=o}break}f>=0?(l.push(i),c.push(f)):h.push(i)}draw_note_ties(e,t,l,c,n);if(!h.length)return;r=e.ts_next;while(r&&r.time<d)r=r.ts_next;while(r&&r.time==d){if(r.type!=C.NOTE||r.st!=e.st){r=r.ts_next;continue}l.length=0,c.length=0;for(i=h.length;--i>=0;){s=h[i],u=e.notes[s].opit||e.notes[s].pit;for(o=r.nhd;o>=0;o--){a=r.notes[o].opit||r.notes[o].pit;if(a==u){l.push(s),c.push(o),h[i]=h.pop();break}}}if(l.length>0){draw_note_ties(e,r,l,c,n==1?1:0);if(h.length==0)return}r=r.ts_next}h.length!=0&&error(1,e,"Bad tie")}function tie_comb(e){var t,n,r;n=e.time+e.dur,r=e.st;for(t=e.ts_next;t;t=t.ts_next){if(t.st!=r)continue;if(t.time==n){if(t.type==C.NOTE)return t;continue}if(t.time>n)return e}return}function draw_all_ties(e){function l(e,t,n){var r;if(e.type==C.GRACE)for(r=e.extra;r;r=r.next)r.ti1&&draw_ties(r,t,n);else draw_ties(e,t,n)}var t,n,r,i,s,o,u,a,f;for(t=e.sym;t;t=t.next){switch(t.type){case C.CLEF:case C.KEY:case C.METER:continue}break}o=e.s_rtie;for(n=t;n;n=n.next){if(n.dur||n.type==C.GRACE)break;if(n.type!=C.BAR||!n.text)continue;n.text[0]=="1"?o=e.s_tie:e.s_tie=o}if(!n)return;e.s_tie&&(e.s_tie.x=t.x+t.wr,t=e.s_tie,e.s_tie=null,t.st=n.st,t.ts_next=n.ts_next,t.time=n.time-t.dur,draw_ties(t,n,1));for(;;){for(t=n;t;t=t.next){if(t.ti1)break;if(!o)continue;if(t.type!=C.BAR||!t.text)continue;if(t.text[0]=="1"){o=null;continue}if(t.bar_type=="|")continue;for(n=t.next;n;n=n.next)if(n.type==C.NOTE)break;if(!n){t=null;break}u=clone(o),u.x=t.x,u.next=n,u.st=n.st,u.time=n.time-u.dur,draw_ties(u,n,1)}if(!t)break;s=t.time+t.dur;for(n=t.next;n;n=n.next){if(n.dur)break;if(n.type==C.BAR&&n.text){if(n.text[0]!="1")break;o=t}}if(!n){for(n=t.ts_next;n;n=n.ts_next){if(n.st!=t.st)continue;if(n.time<s)continue;if(n.time>s){n=null;break}if(n.dur)break}if(!n){l(t,null,2),e.s_tie=t;break}}else{if(n.type!=C.NOTE&&n.type!=C.BAR){error(1,t,"Bad tie");continue}if(n.time!=s){r=tie_comb(t);if(r==t){error(1,t,"Bad tie");continue}n=r}}for(r=t.ts_next;r;r=r.ts_next){if(r.st!=t.st)continue;if(r.time>s)break;if(r.type==C.CLEF){i=!0;continue}}if(i||t.st!=n.st){i=!1,f=(n.x-t.x)*.4,a=n.x,n.x-=f,n.x>t.x+32&&(n.x=t.x+32),l(t,n,2),n.x=a,a=t.x,t.x+=f,t.x<n.x-24&&(t.x=n.x-24),draw_ties(t,n,3),t.x=a;continue}l(t,n,n.type==C.NOTE?0:2)}e.s_rtie=o}function draw_all_slurs(e){var t,n,r,i=e.sym,s=e.slur_start,o=0;if(!i)return;if(s){e.slur_start=0;while(s!=0)o<<=4,o|=s&15,s>>=4}draw_slurs(i,undefined);for(;i;i=i.next)while(i.slur_end||i.sl2){if(i.slur_end)i.slur_end--,r=-1;else{for(r=0;r<=i.nhd;r++)if(i.notes[r].sl2)break;i.notes[r].sl2--,i.sl2--}s=o&15,t=prev_scut(i),draw_slur(t,i,-1,r,s);if(t.type!=C.BAR||t.bar_type[0]!=":"&&t.bar_type!="|]"&&t.bar_type!="[|"&&(!t.text||t.text[0]=="1"))o>>=4}i=e.sym;while(o!=0){s=o&15,o>>=4,t=next_scut(i),draw_slur(i,t,-1,-1,s);if(t.type!=C.BAR||t.bar_type[0]!=":"&&t.bar_type!="|]"&&t.bar_type!="[|"&&(!t.text||t.text[0]=="1"))e.slur_start||(e.slur_start=0),e.slur_start<<=4,e.slur_start+=s}}function draw_sym_near(){var e,t,n,r,i,s,o,u,a,i,f,l,c,h;h=output,output="";for(r=0;r<voice_tb.length;r++){var p={},d=!0;e=voice_tb[r];for(n=e.sym;n;n=n.next)switch(n.type){case C.GRACE:for(o=n.extra;o;o=o.next)o.beam_st&&!o.beam_end&&self.calculate_beam(p,o);break;case C.NOTE:if(n.beam_st&&!n.beam_end||d&&!n.beam_st)d=!1,self.calculate_beam(p,n)}}for(i=0;i<=nstaff;i++){t=staff_tb[i],t.top||(t.top=new Float32Array(YSTEP),t.bot=new Float32Array(YSTEP));for(a=0;a<YSTEP;a++)t.top[a]=0,t.bot[a]=24}set_tie_room(),draw_deco_near();for(n=tsfirst;n;n=n.ts_next){if(n.invis)continue;switch(n.type){case C.GRACE:for(o=n.extra;o;o=o.next)y_set(n.st,!0,o.x-2,4,o.ymx+1),y_set(n.st,!1,o.x-2,4,o.ymn-1);continue;case C.MREST:y_set(n.st,!0,n.x+16,32,n.ymx+2);continue;default:y_set(n.st,!0,n.x-n.wl,n.wl+n.wr,n.ymx+2),y_set(n.st,!1,n.x-n.wl,n.wl+n.wr,n.ymn-2);continue;case C.NOTE:}n.stem>0?(n.beam_st?(f=3,u=n.beam_end?4:10):(f=-8,u=n.beam_end?11:16),y_set(n.st,!0,n.x+f,u,n.ymx),y_set(n.st,!1,n.x-n.wl,n.wl+n.wr,n.ymn)):(y_set(n.st,!0,n.x-n.wl,n.wl+n.wr,n.ymx),n.beam_st?(f=-6,u=n.beam_end?4:10):(f=-8,u=n.beam_end?5:16),f+=n.notes[0].shhd,y_set(n.st,!1,n.x+f,u,n.ymn)),n.notes[n.nhd].acc&&(s=n.y+8,n.ymx<s&&(n.ymx=s),y_set(n.st,!0,n.x,0,s)),n.notes[0].acc&&(s=n.y,n.notes[0].acc==1||n.notes[0].acc==3?s-=7:s-=5,n.ymn>s&&(n.ymn=s),y_set(n.st,!1,n.x,0,s))}for(r=0;r<voice_tb.length;r++){e=voice_tb[r],n=e.sym;if(!n)continue;set_color(n.color),i=e.st,set_dscale(i);for(;n;n=n.next)n.tp0&&draw_tuplet(n,0);draw_all_slurs(e);for(n=e.sym;n;n=n.next)n.tp0&&draw_tuplet(n,0)}for(i=0;i<=nstaff;i++){t=staff_tb[i],l=t.topbar+2,c=t.botbar-2;for(a=0;a<YSTEP;a++)l>t.top[a]&&(t.top[a]=l),c<t.bot[a]&&(t.bot[a]=c)}set_color(undefined),draw_deco_note(),draw_deco_staff(),set_dscale(-1);for(r=0;r<voice_tb.length;r++){e=voice_tb[r];if(e.have_ly){draw_all_lyrics();break}}cfmt.measurenb>=0&&draw_measnb(),set_dscale(-1),output=h}function draw_vname(e){var t,n,r,i,s,o,u,a,f=[];for(r=cur_sy.nstaff;r>=0;r--)if(cur_sy.st_print[r])break;if(r<0)return;for(i=0;i<voice_tb.length;i++){t=voice_tb[i];if(!t.sym)continue;r=cur_sy.voices[i].st;if(!cur_sy.st_print[r])continue;if(t.new_name){a=2;break}t.snm&&(a=1)}if(!a)return;for(i=0;i<voice_tb.length;i++){t=voice_tb[i];if(!t.sym)continue;r=cur_sy.voices[i].st;if(!cur_sy.st_print[r])continue;t.new_name&&delete t.new_name,o=a==2?t.nm:t.snm;if(!o)continue;if(cur_sy.staves[r].flags&CLOSE_BRACE2)while(!(cur_sy.staves[r].flags&OPEN_BRACE2))r--;else if(cur_sy.staves[r].flags&CLOSE_BRACE)while(!(cur_sy.staves[r].flags&OPEN_BRACE))r--;f[r]?f[r]+="\\n"+o:f[r]=o}if(f.length==0)return;set_font("voice"),e=-e*.5;for(r=0;r<f.length;r++){if(!f[r])continue;s=f[r].split("\\n"),u=staff_tb[r].y+staff_tb[r].topbar*.5*staff_tb[r].staffscale+9*(s.length-1)-gene.curfont.size*.3,n=r;if(cur_sy.staves[r].flags&OPEN_BRACE2)while(!(cur_sy.staves[n].flags&CLOSE_BRACE2))n++;else if(cur_sy.staves[r].flags&OPEN_BRACE)while(!(cur_sy.staves[n].flags&CLOSE_BRACE))n++;n!=r&&(u-=(staff_tb[r].y-staff_tb[n].y)*.5);for(n=0;n<s.length;n++)o=s[n],xy_str(e,u,o,"c"),u-=18}}function set_staff(){var e,t,n,r,i,s,o,u,a,f,l,c,h;for(i=0;i<voice_tb.length;i++)c=voice_tb[i],c.scale!=1&&(c.scale_str='transform="scale('+c.scale.toFixed(2)+')"');for(n=0;n<=nstaff;n++)if(gene.st_print[n])break;s=0;if(n>nstaff)n--,h=staff_tb[n];else{h=staff_tb[n];for(t=0;t<YSTEP;t++)l=h.top[t],s<l&&(s=l)}s+=draw_partempo(n,s);if(!gene.st_print[n])return s;s*=h.staffscale,o=cfmt.staffsep*.5+h.topbar*h.staffscale,s<o&&(s=o),s<h.ann_top&&(s=h.ann_top),h.y=-s,r=n;var p=cur_sy.staves[r];for(n++;n<=nstaff;n++){h=staff_tb[n];if(!gene.st_print[n])continue;o=p.sep||cfmt.sysstaffsep,a=p.maxsep||cfmt.maxsysstaffsep,u=0;if(h.staffscale==staff_tb[r].staffscale){for(t=0;t<YSTEP;t++)l=h.top[t]-staff_tb[r].bot[t],u<l&&(u=l);u*=h.staffscale}else for(t=0;t<YSTEP;t++)l=h.top[t]*h.staffscale-staff_tb[r].bot[t]*staff_tb[r].staffscale,u<l&&(u=l);o+=h.topbar*h.staffscale,u<o&&(u=o),a+=h.topbar*h.staffscale,u>a&&(u=a),s+=u,h.y=-s,r=n,p=cur_sy.staves[r]}f=0;for(t=0;t<YSTEP;t++)l=staff_tb[r].bot[t],f>l&&(f=l);f>h.ann_bot&&(f=h.ann_bot),f*=staff_tb[r].staffscale;for(n=0;n<=nstaff;n++)h=staff_tb[n],u=h.y,h.staffscale!=1&&(h.scale_str='transform="translate(0,'+(posy-u).toFixed(2)+") "+"scale("+h.staffscale.toFixed(2)+')"');if(f==0){for(n=nstaff;n>=0;n--)if(gene.st_print[n])break;if(n<0)return s}return u=-f,o=cfmt.staffsep*.5,u<o&&(u=o),a=cfmt.maxstaffsep*.5,u>a&&(u=a),s+u}function draw_systems(e){function p(){var e,t,n,r,i=0;for(e=0;e<=cur_sy.nstaff;e++){if(l[e]<0){c[e]=h[e]=0;continue}t=staff_tb[e].staffscale,n=staff_tb[e].topbar*t,r=staff_tb[e].botbar*t,i==0&&(i=staff_tb[e].y+n),c[e]=staff_tb[e].y+r,h[e]=i-c[e],i=cur_sy.staves[e].flags&STOP_BAR?0:c[e]}}function d(e,t,n){var r,i,s,o,u,a=0,f="",l=cur_sy.staves[e].stafflines,c=l.length;if(!/[\[|]/.test(l))return;r=n-t,set_sscale(e),i=r/stv_g.scale;if(cache&&cache.st_l==l&&cache.st_ws==i){xygl(t,staff_tb[e].y,"stdef"+cfmt.fullsvg);return}for(s=0;s<c;s++,a-=6){if(l[s]==".")continue;o=0;for(;s<c;s++,a-=6,o-=6){switch(l[s]){case".":case"-":continue;case u:f+="m-"+i.toFixed(2)+" "+o+"h"+i.toFixed(2),o=0;continue}u!=undefined&&(f+='"/>\n'),u=l[s],f+='<path class="stroke"',u=="["&&(f+=' stroke-width="1.5"'),f+=' d="m0 '+a+"h"+i.toFixed(2),o=0}f+='"/>\n'}a=staff_tb[e].y;if(!cache&&r==get_lwidth()){cache={st_l:l,st_ws:i},s="stdef"+cfmt.fullsvg,glyphs[s]='<g id="'+s+'">\n'+f+"</g>",xygl(t,a,s);return}out_XYAB('<g transform="translate(X, Y)">\n'+f+"</g>\n",t,a)}var t,n,r,i,s,o,u,a,f,l=[],c=[],h=[];draw_vname(e);for(r=0;r<=nstaff;r++)l[r]=cur_sy.st_print[r]?0:-1;p(),draw_lstaff(0);for(t=tsfirst;t;t=t.ts_next){if(f&&t.time!=f){f=0;for(r=0;r<=nstaff;r++)cur_sy.st_print[r]||(l[r]=-1);p()}switch(t.type){case C.STAVES:a=t.ts_prev.type==C.BAR?t.ts_prev.x:0;if(!a){for(n=t.ts_next;n;n=n.ts_next){if(n.time!=t.time)break;switch(n.type){case C.BAR:case C.CLEF:case C.KEY:case C.METER:a=n.x;continue}break}n||(a=realwidth)}u=t.sy;for(r=0;r<=nstaff;r++){i=l[r];if(i<0){u.st_print[r]&&(l[r]=a?a:t.x-t.wl-2);continue}if(u.st_print[r]&&u.staves[r].stafflines==cur_sy.staves[r].stafflines)continue;a?(s=a,f=t.time):(s=t.x-t.wl-2,l[r]=-1),d(r,i,s),u.st_print[r]&&(l[r]=s)}cur_sy=u,p();continue;case C.BAR:r=t.st;if(t.second||t.invis)break;draw_bar(t,c[r],h[r]);break;case C.STBRK:if(cur_sy.voices[t.v].range==0&&t.xmx>14){var v=0;for(var m=0;m<voice_tb.length;m++)cur_sy.voices[m].range>0&&v++;for(n=t.ts_next;n;n=n.ts_next){if(n.type!=C.STBRK)break;v--}v==0&&draw_lstaff(t.x)}n=t.prev;if(!n)break;s=n.x,n.type!=C.BAR&&(s+=n.wr),r=t.st,i=l[r];if(i>=0){if(i>=s)continue;d(r,i,s)}l[r]=t.x}}for(r=0;r<=nstaff;r++){if(f&&!cur_sy.st_print[r])continue;i=l[r];if(i<0||i>=realwidth)continue;d(r,i,realwidth)}}function draw_symbols(e){var t={},n,r,i,s,o;for(n=e.sym;n;n=n.next){if(n.invis)switch(n.type){case C.KEY:e.key=n;default:continue;case C.NOTE:}i=n.x,set_color(n.color);switch(n.type){case C.NOTE:set_scale(n),n.beam_st&&!n.beam_end&&self.calculate_beam(t,n)&&draw_beams(t),n.invis||(anno_start(n),draw_note(n,!t.s2),anno_stop(n)),n==t.s2&&(t.s2=null);break;case C.REST:draw_rest(n);break;case C.BAR:break;case C.CLEF:o=n.st,n.time>staff_tb[o].clef.time&&(staff_tb[o].clef=n);if(n.second)break;if(!staff_tb[n.st].topbar)break;set_color(undefined),set_sscale(o),anno_start(n),s=staff_tb[o].y,n.clef_name?xygl(i,s+n.y,n.clef_name):n.clef_small?xygl(i,s+n.y,"s"+n.clef_type+"clef"):xygl(i,s+n.y,n.clef_type+"clef"),n.clef_octave&&(n.clef_octave>0?(s+=n.ymx-10,n.clef_small&&(s-=1)):(s+=n.ymn+6,n.clef_small&&(s+=1)),xygl(i-2,s,"oct")),anno_stop(n);break;case C.METER:e.meter=n;if(n.second||!staff_tb[n.st].topbar)break;if(cfmt.alignbars&&n.st!=0)break;set_color(undefined),set_sscale(n.st),anno_start(n),draw_meter(i,n),anno_stop(n);break;case C.KEY:e.key=n;if(n.second||!staff_tb[n.st].topbar)break;set_color(undefined),set_sscale(n.st),anno_start(n),draw_keysig(e,i,n),anno_stop(n);break;case C.MREST:set_scale(n),i+=32,anno_start(n),xygl(i,staff_tb[n.st].y+12,"mrest"),out_XYAB('<text style="font:bold 15px serif"\n x ="X" y="Y" text-anchor="middle">A</text>\n',i,staff_tb[n.st].y+28,n.nmes),anno_stop(n);break;case C.GRACE:set_scale(n),draw_gracenotes(n);break;case C.SPACE:case C.STBRK:break;case C.CUSTOS:set_scale(n),draw_note(n,0);break;case C.BLOCK:case C.PART:case C.REMARK:case C.STAVES:case C.TEMPO:break;default:error(2,n,"draw_symbols - Cannot draw symbol "+n.type)}}set_scale(e.sym),draw_all_ties(e),set_color(undefined)}function draw_all_sym(){var e,t,n=voice_tb.length;for(t=0;t<n;t++)e=voice_tb[t],e.sym&&e.sym.x!=undefined&&self.draw_symbols(e);draw_all_deco(),set_sscale(-1)}function set_tie_dir(e){var t,n,r,i,s,o,u;for(t=e;t;t=t.next){if(!t.ti1)continue;if(t.multi!=0){i=t.multi>0?C.SL_ABOVE:C.SL_BELOW;for(n=0;n<=t.nhd;n++){u=t.notes[n].ti1;if((u&7)!=C.SL_AUTO)continue;t.notes[n].ti1=u&C.SL_DOTTED|i}continue}s=r=0,o=128;for(n=0;n<=t.nhd;n++)t.notes[n].ti1&&(r++,o<128&&t.notes[n].pit<=o+1&&s++,o=t.notes[n].pit);if(r<=1){i=t.stem<0?C.SL_ABOVE:C.SL_BELOW;for(n=0;n<=t.nhd;n++){u=t.notes[n].ti1;if(u){(u&7)==C.SL_AUTO&&(t.notes[n].ti1=u&C.SL_DOTTED|i);break}}continue}if(s==0){if(r&1){r=(r-1)/2,i=C.SL_BELOW;for(n=0;n<=t.nhd;n++){u=t.notes[n].ti1;if(u==0)continue;r==0&&t.notes[n].pit>=22&&(i=C.SL_ABOVE),(u&7)==C.SL_AUTO&&(t.notes[n].ti1=u&C.SL_DOTTED|i),r--==0&&(i=C.SL_ABOVE)}continue}r/=2,i=C.SL_BELOW;for(n=0;n<=t.nhd;n++){u=t.notes[n].ti1;if(u==0)continue;(u&7)==C.SL_AUTO&&(t.notes[n].ti1=u&C.SL_DOTTED|i),--r==0&&(i=C.SL_ABOVE)}continue}o=128;for(n=0;n<=t.nhd;n++)if(t.notes[n].ti1){if(o<128&&t.notes[n].pit<=o+1){r=n;break}o=t.notes[n].pit}i=C.SL_BELOW;for(n=0;n<=t.nhd;n++){u=t.notes[n].ti1;if(u==0)continue;r==n&&(i=C.SL_ABOVE),(u&7)==C.SL_AUTO&&(t.notes[n].ti1=u&C.SL_DOTTED|i)}}}function set_tie_room(){var e,t,n,r,i,s,o;for(r=0;r<voice_tb.length;r++){e=voice_tb[r],t=e.sym;if(!t)continue;t=t.next;if(!t)continue;set_tie_dir(t);for(;t;t=t.next){if(!t.ti1)continue;if(!(t.notes[0].pit<20&&(t.notes[0].ti1&7)==C.SL_BELOW||t.notes[t.nhd].pit>24&&(t.notes[t.nhd].ti1&7)==C.SL_ABOVE))continue;n=t.next;while(n&&n.type!=C.NOTE)n=n.next;if(n){if(n.st!=t.st)continue;i=n.x-t.x-10}else i=realwidth-t.x-10;i<100?o=9:i<300?o=12:o=16,t.notes[t.nhd].pit>24&&(s=3*(t.notes[t.nhd].pit-18)+o,t.ymx<s&&(t.ymx=s),n&&n.ymx<s&&(n.ymx=s),y_set(t.st,!0,t.x+5,i,s)),t.notes[0].pit<20&&(s=3*(t.notes[0].pit-18)-o,t.ymn>s&&(t.ymn=s),n&&n.ymn>s&&(n.ymn=s),y_set(t.st,!1,t.x+5,i,s))}}}function get_bool(e){return!e||!/^(0|n|f)/i.test(e)}function get_font_scale(e){var t=e.split(/\s+/);if(t.length<=1)return;var n=parseFloat(t[t.length-1]);if(isNaN(n)||t<=0){syntax(1,"Bad scale value in %%font");return}font_scale_tb[t[0]]=n;for(var r in font_tb){if(!font_tb.hasOwnProperty(r))continue;var i=font_tb[r];i.name==t[0]&&(i.swfac=i.size*n)}}function param_set_font(e,t){var n,r,i,s,o,u,a,f,l,c;if(e[e.length-2]=="-"){s=e[e.length-1];if(s<"1"||s>"9")return;e="u"+s+"font"}r=cfmt[e],r&&(n=font_tb[r],n&&(i=n.name+"."+n.size,n.class&&(i+="."+n.class))),s=t.indexOf("class="),s>=0&&(s+=6,o=t.indexOf(" ",s),o>0?c=t.slice(s,o):c=t.slice(s),t=t.replace(new RegExp("class="+c),"").trim()),o=t.split(/\s+/),u=o[0],u=="*"&&n?u=n.name:(u=u.replace("Times-Roman","serif"),u=u.replace("Times","serif"),u=u.replace("Helvetica","sans-serif"),u=u.replace("Courier","monospace")),o.length>1?(f=o[o.length-1],f=="*"&&n&&(f=n.size)):n&&(f=n.size);if(!f)return;a=u+"."+f,c&&(a+="."+c);if(a==i)return;n=font_tb[a],n||(l=font_scale_tb[u],l||(l=1.1),n={name:u,size:Number(f),swfac:f*l},font_tb[a]=n),c&&(n.class=c),cfmt[e]=a}function get_unit(e){var t=parseFloat(e);switch(e.slice(-2)){case"CM":case"cm":t*=CM;break;case"IN":case"in":t*=IN;break;case"PT":case"pt":t*=.75}return t}function set_infoname(e){var t=cfmt.infoname.split("\n"),n=e[0];for(var r=0;r<t.length;r++){var i=t[r];if(i[0]!=n)continue;e.length==1?t.splice(r,1):t[r]=e,cfmt.infoname=t.join("\n");return}cfmt.infoname+="\n"+e}function get_textopt(e){return textopt[e]}function set_pos(e,t){e=e.slice(0,3),e=="ste"&&(e="stm"),self.set_v_param("pos",e+" "+t)}function set_writefields(e){var t,n,r=e.split(/\s+/);if(get_bool(r[1]))for(n=0;n<r[0].length;n++)t=r[0][n],cfmt.writefields.indexOf(t)<0&&(cfmt.writefields+=t);else for(n=0;n<r[0].length;n++)t=r[0][n],cfmt.writefields.indexOf(t)>=0&&(cfmt.writefields=cfmt.writefields.replace(t,""))}function set_v_param(e,t){if(curvoice){self.set_vp([e+"=",t]);return}e=[e+"=",t];var n="*";info.V||(info.V={}),info.V[n]?Array.prototype.push.apply(info.V[n],e):info.V[n]=e}function set_page(){if(!img.chg)return;img.chg=!1,img.lm=cfmt.leftmargin-cfmt.printmargin,img.lm<0&&(img.lm=0),img.rm=cfmt.rightmargin-cfmt.printmargin,img.rm<0&&(img.rm=0),img.width=cfmt.pagewidth-2*cfmt.printmargin,img.width-img.lm-img.rm<100&&(error(0,undefined,"Bad staff width"),img.width=img.lm+img.rm+150),set_posx()}function set_format(e,t,n){var r,i,s,o,u;if(n)fmt_lock[e]=!0;else if(fmt_lock[e])return;if(/.+font(-[\d])?$/.test(e)){t.slice(-4)==" box"&&(o=!0,t=t.slice(0,-4)),param_set_font(e,t);switch(e){case"gchordfont":cfmt.gchordbox=o;break;case"measurefont":cfmt.measurebox=o;break;case"partsfont":cfmt.partsbox=o}return}switch(e){case"aligncomposer":case"barsperstaff":case"infoline":case"measurefirst":case"measurenb":case"rbmax":case"rbmin":case"shiftunison":s=parseInt(t);if(isNaN(s)){syntax(1,"Bad integer value");break}cfmt[e]=s;break;case"microscale":r=parseInt(t);if(isNaN(r)||r<4||r>256||r%1){syntax(1,errs.bad_val,"%%"+e);break}self.set_v_param("uscale",r);break;case"bgcolor":case"dblrepbar":case"titleformat":cfmt[e]=t;break;case"breaklimit":case"lineskipfac":case"maxshrink":case"pagescale":case"parskipfac":case"scale":case"slurheight":case"stemheight":case"stretchlast":r=parseFloat(t);if(isNaN(r)){syntax(1,errs.bad_val,"%%"+e);break}switch(e){case"scale":r/=.75;case"pagescale":e="scale",img.chg=!0}cfmt[e]=r;break;case"bstemdown":case"breakoneoln":case"cancelkey":case"contbarnb":case"custos":case"decoerr":case"dynalign":case"flatbeams":case"gchordbox":case"graceslurs":case"graceword":case"hyphencont":case"keywarn":case"linewarn":case"measurebox":case"partsbox":case"rbdbstop":case"singleline":case"squarebreve":case"straightflags":case"stretchstaff":case"timewarn":case"titlecaps":case"titleleft":cfmt[e]=get_bool(t);break;case"chordnames":s=t.split(","),cfmt.chordnames={};for(u=0;u<s.length;u++)cfmt.chordnames["CDEFGAB"[u]]=s[u];break;case"composerspace":case"indent":case"infospace":case"maxstaffsep":case"maxsysstaffsep":case"musicspace":case"partsspace":case"staffsep":case"subtitlespace":case"sysstaffsep":case"textspace":case"titlespace":case"topspace":case"vocalspace":case"wordsspace":r=get_unit(t),isNaN(r)?syntax(1,errs.bad_val,"%%"+e):cfmt[e]=r;break;case"print-leftmargin":syntax(0,"$1 is deprecated - use %%printmargin instead","%%"+e),e="printmargin";case"printmargin":case"leftmargin":case"pagewidth":case"rightmargin":r=get_unit(t);if(isNaN(r)){syntax(1,errs.bad_val,"%%"+e);break}cfmt[e]=r,img.chg=!0;break;case"concert-score":cfmt.sound!="play"&&(cfmt.sound="concert");break;case"writefields":set_writefields(t);break;case"dynamic":case"gchord":case"gstemdir":case"ornament":case"stemdir":case"vocal":case"volume":set_pos(e,t);break;case"font":get_font_scale(t);break;case"fullsvg":if(parse.state!=0){syntax(1,"Cannot have %%fullsvg inside a tune");break}cfmt[e]=t;break;case"gracespace":s=t.split(/\s+/);for(u=0;u<3;u++)if(isNaN(Number(s[u]))){syntax(1,errs.bad_val,"%%gracespace");break}for(u=0;u<3;u++)cfmt[e]=Number(s[u]);break;case"tuplets":cfmt[e]=t.split(/\s+/),s=cfmt[e][3],s&&posval[s]&&(cfmt[e][3]=posval[s]);break;case"infoname":set_infoname(t);break;case"notespacingfactor":r=parseFloat(t);if(isNaN(r)||r<1||r>2){syntax(1,errs.bad_val,"%%"+e);break}u=5,i=space_tb[u];for(;--u>=0;)i/=r,space_tb[u]=i;u=5,i=space_tb[u];for(;++u<space_tb.length;)i*=r,space_tb[u]=i;break;case"play":cfmt.sound="play";break;case"pos":e=t.split(/\s+/),set_pos(e[0],e[1]);break;case"sounding-score":cfmt.sound!="play"&&(cfmt.sound="sounding");break;case"staffwidth":s=get_unit(t);if(isNaN(s)){syntax(1,errs.bad_val,"%%"+e);break}if(s<100){syntax(1,"%%staffwidth too small");break}s=cfmt.pagewidth-s-cfmt.leftmargin;if(s<2){syntax(1,"%%staffwidth too big");break}cfmt.rightmargin=s,img.chg=!0;break;case"textoption":cfmt[e]=get_textopt(t);break;case"titletrim":s=Number(t),isNaN(s)?cfmt[e]=get_bool(t):cfmt[e]=s;break;case"combinevoices":syntax(1,"%%combinevoices is deprecated - use %%voicecombine instead");break;case"voicemap":self.set_v_param("map",t);break;case"voicescale":self.set_v_param("scale",t);break;default:parse.state==0&&(cfmt[e]=t)}}function font_init(){param_set_font("annotationfont","sans-serif 12"),param_set_font("composerfont","serifItalic 14"),param_set_font("footerfont","serif 16"),param_set_font("gchordfont","sans-serif 12"),param_set_font("headerfont","serif 16"),param_set_font("historyfont","serif 16"),param_set_font("infofont","serifItalic 14"),param_set_font("measurefont","serifItalic 14"),param_set_font("partsfont","serif 15"),param_set_font("repeatfont","serif 13"),param_set_font("subtitlefont","serif 16"),param_set_font("tempofont","serifBold 15"),param_set_font("textfont","serif 16"),param_set_font("titlefont","serif 20"),param_set_font("vocalfont","serifBold 13"),param_set_font("voicefont","serifBold 13"),param_set_font("wordsfont","serif 16")}function style_font(e){var t=e.split("."),n=t[1],r,i;return e=t[0].toLowerCase(),t="",r=e.indexOf("-"),r<0&&(r=e.length),i=e.indexOf("italic"),i>=0&&(t+="italic ",i<r&&(r=i)),i=e.indexOf("oblique"),i>=0&&(t+="oblique ",i<r&&(r=i)),i=e.indexOf("bold"),i>=0&&(t+="bold ",i<r&&(r=i)),r>0&&(e=e.slice(0,r)),"font:"+t+n+"px "+e}function font_class(e){return e.class?"f"+e.fid+cfmt.fullsvg+" "+e.class:"f"+e.fid+cfmt.fullsvg}function style_add_font(e){font_style+="\n.f"+e.fid+cfmt.fullsvg+" {"+style_font(e.name+"."+e.size)+"}"}function use_font(e){defined_font[e.fid]||(defined_font[e.fid]=!0,style_add_font(e))}function get_font(e){e+="font";var t=cfmt[e],n=font_tb[t];return n||(syntax(1,"Unknown font $1",e),n=gene.curfont),n.fid||(n.fid=fid++),use_font(n),n}function cnv_escape(e){var t,n,r="",i,s=0,o;for(;;){i=e.indexOf("\\",s);if(i<0)break;r+=e.slice(s,i),t=e[++i];if(!t)return r+"\\";switch(t){case"0":case"2":if(e[i+1]!="0")break;n=oct_acc[e[i+2]];if(n){r+=n,s=i+3;continue}break;case"u":s=Number("0x"+e.slice(i+1,i+5));if(isNaN(s)||s<32){r+=e[++i]+"̆",s=i+1;continue}o=[s];if(s>=55296&&s<=57343){s=Number("0x"+e.slice(i+7,i+11));if(isNaN(s))break;o.push(s),s=i+11}else s=i+5;r+=String.fromCharCode.apply(null,o);continue;case"t":r+=" ",s=i+1;continue;default:n=abc_utf[e.slice(i,i+2)];if(n){r+=n,s=i+2;continue}switch(t){case"`":r+=e[++i]+"̀",s=i+1;continue;case"'":r+=e[++i]+"́",s=i+1;continue;case"^":r+=e[++i]+"̂",s=i+1;continue;case"~":r+=e[++i]+"̃",s=i+1;continue;case"=":r+=e[++i]+"̄",s=i+1;continue;case"_":r+=e[++i]+"̅",s=i+1;continue;case".":r+=e[++i]+"̇",s=i+1;continue;case'"':r+=e[++i]+"̈",s=i+1;continue;case"o":r+=e[++i]+"̊",s=i+1;continue;case"H":r+=e[++i]+"̋",s=i+1;continue;case"v":r+=e[++i]+"̌",s=i+1;continue;case"c":r+=e[++i]+"̧",s=i+1;continue;case";":r+=e[++i]+"̨",s=i+1;continue}}r+="\\"+t,s=i+1}return r+e.slice(s)}function do_include(e){var t,n;if(!user.read_file){syntax(1,"No read_file support");return}if(include>2){syntax(1,"Too many include levels");return}include++,t=user.read_file(e);if(!t){syntax(1,"Cannot read file '$1'",e);return}n=clone(parse),tosvg(e,t),parse=n,include--}function tosvg(e,t,n,r){function C(){var e,i,s=t.indexOf("K:",n);return s<0?!1:(s=t.indexOf("\n",s),parse.select.test(t.slice(parse.bol,s))?!0:(e=/\n\w*\n/,e.lastIndex=s,i=e.exec(t),i?o=e.lastIndex:o=r,!1))}function k(e,t){var n;return e.indexOf("%")>=0&&(e=e.replace(/([^\\])%.*/,"$1").replace(/\\%/g,"%")),e=e.replace(/\s+$/,""),t&&e.indexOf("\\")>=0?cnv_escape(e):e}function L(){generate(),info.W&&put_words(info.W),put_history(),blk_flush(),parse.state=0,cfmt=g,info=y,char_tb=b,glovar=w,maps=E,mac=S,maci=x,init_tune(),img.chg=!0,set_page()}var i,s,n,o,u,a,f,l,c,h,p,d,v,m,g,y,b,w,E,S,x,T,N="\n";abc2svg.modules&&(abc2svg.modules.hooks.length||abc2svg.modules.g_hooks.length)&&set_hooks(),parse.file=t,parse.fname=e,n==undefined&&(n=0),r||(r=t.length);for(;n<r;n=parse.eol+1){o=t.indexOf("\n",n);if(o<0||o>r)o=r;parse.eol=o;for(;;){o--;switch(t[o]){case" ":case" ":continue}break}o++;if(o==n){parse.state==1?(parse.istart=n,syntax(1,"Empty line in tune header - ignored")):parse.state>=2&&(L(),parse.select&&(o=t.indexOf("\nX:",parse.eol),o<0&&(o=r),parse.eol=o));continue}parse.istart=parse.bol=n,parse.iend=o,parse.line.index=0,f=t[n],l=t[n+1];if(f=="%"){if(parse.prefix.indexOf(l)<0)continue;t[n+2]=="a"&&t[n+3]=="b"&&t[n+4]=="c"&&t[n+5]==" "?(n+=6,f=t[n],l=t[n+1]):T=!0}else f=="I"&&l==":"&&(T=!0);if(T){T=!1,n+=2;for(;;){switch(t[n]){case" ":case" ":n++;continue}break}p=t.slice(n,o);if(!p||p[0]=="%")continue;d=p.split(/\s+/,2),d[0]||d.shift();switch(d[0]){case"abcm2ps":case"ss-pref":parse.prefix=d[1];continue;case"abc-include":do_include(d[1]);continue}if(d[0].slice(0,5)=="begin"){v=d[0].substr(5),u="\n"+f+l+"end"+v,i=t.indexOf(u,o);if(i<0){syntax(1,"No $1 after %%$2",u.slice(1),d[0]),parse.eol=r;continue}self.do_begin_end(v,d[1],t.slice(o+1,i).replace(new RegExp("^"+f+l,"gm"),"")),parse.eol=t.indexOf("\n",i+6),parse.eol<0&&(parse.eol=r);continue}switch(d[0]){case"select":if(parse.state!=0){syntax(1,"%%select ignored");continue}a=k(p.slice(7),!1),a[0]=='"'&&(a=a.slice(1,-1));if(!a){delete parse.select;continue}a=a.replace(/\(/g,"\\("),a=a.replace(/\)/g,"\\)"),parse.select=new RegExp(a,"m");continue;case"tune":syntax(1,"%%tune not treated yet");continue;case"voice":if(parse.state!=0){syntax(1,"%%voice ignored");continue}a=k(p.slice(6),!1);if(!a){parse.cur_tune_opts?parse.cur_tune_opts.voice_opts=null:parse.voice_opts=null;continue}if(a=="end")continue;parse.cur_tune_opts?(parse.cur_tune_opts.voice_opts||(parse.cur_tune_opts.voice_opts={}),h=parse.cur_tune_opts.voice_opts):(parse.voice_opts||(parse.voice_opts={}),h=parse.voice_opts),h[a]=[];for(;;){n=++o;if(t[n]!="%")break;o=t.indexOf("\n",o);if(t[n+1]!=l)continue;n+=2,o<0?p=t.slice(n):p=t.slice(n,o),d=p.match(/\S+/);switch(d[0]){default:h[a].push(k(p,!0));continue;case"score":case"staves":case"tune":case"voice":n-=2}break}parse.eol=n-1;continue}self.do_pscom(k(p,!0));continue}if(l!=":"||!/[A-Za-z+]/.test(f)){c=undefined;if(parse.state<2)continue;parse.line.buffer=k(t.slice(n,o),!0),parse_music_line();continue}n+=2;for(;;){switch(t[n]){case" ":case" ":n++;continue}break}p=k(t.slice(n,o),!0);if(f=="+"){if(!c){syntax(1,"+: without previous info field");continue}N=" ",f=c}switch(f){case"X":if(parse.state!=0){syntax(1,errs.ignored,f);continue}if(parse.select&&!C()){o=t.indexOf("\nX:",parse.eol),o<0&&(o=r),parse.eol=o;continue}g=clone(cfmt),cfmt.pos=clone(cfmt.pos),y=clone(info,1),b=clone(char_tb),w=clone(glovar),E=clone(maps,1),S=clone(mac),x=new Int8Array(maci),info.X=p,parse.state=1;continue;case"T":switch(parse.state){case 0:continue;case 1:info.T==undefined?info.T=p:info.T+="\n"+p;continue}m=new_block("title"),m.text=p;continue;case"K":switch(parse.state){case 0:continue;case 1:info.K=p}do_info(f,p);continue;case"W":if(parse.state==0||cfmt.writefields.indexOf(f)<0)break;info.W==undefined?info.W=p:info.W+=N+p;break;case"m":if(parse.state>=2){syntax(1,errs.ignored,f);continue}if((!cfmt.sound||cfmt.sound!="play")&&cfmt.writefields.indexOf(f)<0)break;d=p.match(/(.*?)[= ]+(.*)/);if(!d||!d[2]){syntax(1,errs.bad_val,"m:");continue}mac[d[1]]=d[2],maci[d[1].charCodeAt(0)]=1;break;case"s":if(parse.state!=3||cfmt.writefields.indexOf(f)<0)break;get_sym(p,N==" ");break;case"w":if(parse.state!=3||cfmt.writefields.indexOf(f)<0)break;get_lyrics(p,N==" ");if(p.slice(-1)=="\\"){N=" ",c=f;continue}break;case"|":if(parse.state<2)continue;parse.line.buffer=k(t.slice(n,o),!0),parse_music_line();continue;default:if("ABCDFGHOSZ".indexOf(f)>=0){if(parse.state>=2){syntax(1,errs.ignored,f);continue}info[f]?info[f]+=N+p:info[f]=p;break}do_info(f,p);continue}N="\n",c=f}if(include)return;parse.state>=2&&L(),parse.state=0}function set_head_shift(e){var t,n,r,i,s,o,u=dx_tb[e.head],a=e.stem,f=e.nhd;if(f==0)return;o=u*.78,e.grace&&(o*=.5),a>=0?(n=1,r=f+1,s=e.notes[0].pit):(o=-o,n=f-1,r=-1,s=e.notes[f].pit);var l=!1,c=0;for(t=n;t!=r;t+=a){i=e.notes[t].pit-s,s=e.notes[t].pit;if(i==0){if(l){var h=e.notes[t].shhd=e.notes[t-a].shhd+o;c<h&&(c=h);continue}if(t+a!=r&&s+a==e.notes[t+a].pit){e.notes[t].shhd=-o,c<-o&&(c=-o);continue}}i<0&&(i=-i),i>3||i>=2&&e.head!=C.SQUARE?l=!1:(l=!l,l&&(e.notes[t].shhd=o,c<o&&(c=o)))}e.xmx=c}function acc_shift(e,t){var n,r,i,s,o,u,a,f=e.length;for(n=f-1;--n>=0;){i=e[n].shhd;if(!i||i>0)continue;i=t-i,o=e[n].pit;for(r=f;--r>=0;){if(!e[r].acc)continue;u=e[r].pit;if(u<o-3)break;if(u>o+3)continue;e[r].shac<i&&(e[r].shac=i)}}for(n=f;--n>=0;){a=e[n].acc;if(!a)continue;i=e[n].shac,i||(i=e[n].shhd,i<0?i=t-i:i=t),o=e[n].pit;for(r=f;--r>n;){if(!e[r].acc)continue;u=e[r].pit;if(u>=o+4)if(u>o+4||a<0||e[r].acc<0)continue;i>e[r].shac-6&&(s=e[r].shac+7,s>i&&(i=s))}e[n].shac=i}}function set_acc_shft(){var e,t,n,r,i,n,s,o;e=tsfirst;while(e){if(e.type!=C.NOTE||e.invis){e=e.ts_next;continue}n=e.st,s=e.time,i=!1;for(t=e;t;t=t.ts_next){if(t.time!=s||t.type!=C.NOTE||t.st!=n)break;if(i)continue;for(r=0;r<=t.nhd;r++)if(t.notes[r].acc){i=!0;break}}if(!i){e=t;continue}o=dx_tb[e.head],n={notes:[]};for(;e!=t;e=e.ts_next)n.notes=n.notes.concat(e.notes);sort_pitch(n),acc_shift(n.notes,o)}}function lkvsym(e,t){e.next=t,e.prev=t.prev,e.prev?e.prev.next=e:e.p_v.sym=e,t.prev=e}function lktsym(e,t){t?(e.ts_next=t,e.ts_prev=t.ts_prev,e.ts_prev&&(e.ts_prev.ts_next=e),t.ts_prev=e):e.ts_next=e.ts_prev=null}function unlksym(e){e.next&&(e.next.prev=e.prev),e.prev?e.prev.next=e.next:e.p_v.sym=e.next,e.ts_next&&(e.seqst&&!e.ts_next.seqst&&(e.ts_next.seqst=!0,e.ts_next.shrink=e.shrink,e.ts_next.space=e.space),e.ts_next.ts_prev=e.ts_prev),e.ts_prev&&(e.ts_prev.ts_next=e.ts_next),tsfirst==e&&(tsfirst=e.ts_next),tsnext==e&&(tsnext=e.ts_next)}function insert_clef(e,t,n){var r=e.p_v,i,s=e.st;e.type==C.BAR&&e.prev&&e.prev.type==C.BAR&&(e=e.prev),r.last_sym=e.prev,r.last_sym||(r.sym=null),r.time=e.time,i=sym_add(r,C.CLEF),i.next=e,e.prev=i,i.clef_type=t,i.clef_line=n,i.st=s,i.clef_small=!0,delete i.second,i.notes=[],i.notes[0]={pit:e.notes[0].pit},i.nhd=0;while(!e.seqst)e=e.ts_prev;return lktsym(i,e),i.ts_prev.type!=C.CLEF&&(i.seqst=!0),i}function set_float(){var e,t,n,r,i,s,o,u;for(r=0;r<voice_tb.length;r++){e=voice_tb[r],n=!1,t=e.st;for(i=e.sym;i;i=i.next){if(!i.floating){while(i&&!i.floating)i=i.next;if(!i)break;n=!1}if(!i.dur){n&&i.st++;continue}if(i.notes[0].pit>=19){n=!1;continue}if(i.notes[i.nhd].pit<=12){n=!0,i.st++;continue}o=127;for(s=i.ts_prev;s;s=s.ts_prev){if(s.st!=t||s.v==i.v)break;s.type==C.NOTE&&s.notes[0].pit<o&&(o=s.notes[0].pit)}if(o==127){n&&i.st++;continue}if(i.notes[i.nhd].pit>o-3){n=!1;continue}u=-127;for(s=i.ts_next;s;s=s.ts_next){if(s.st!=t+1||s.v==i.v)break;s.type==C.NOTE&&s.notes[s.nhd].pit>u&&(u=s.notes[s.nhd].pit)}if(u==-127){n&&i.st++;continue}if(i.notes[0].pit<u+3){n=!0,i.st++;continue}o-=i.notes[i.nhd].pit,u=i.notes[0].pit-u;if(!n){if(o<u+3)continue;n=!0}else if(o<u-3){n=!1;continue}i.st++}}}function set_graceoffs(e){var t,n,r,i,s=cfmt.gracespace[0],o=cfmt.gracespace[1],u=cfmt.gracespace[2],a=e.extra;e.prev&&e.prev.type==C.BAR&&(s-=3),i=s,a.beam_st=!0;for(;;a=a.next){set_head_shift(a),acc_shift(a.notes,7),r=0;for(n=a.nhd;n>=0;n--)a.notes[n].shac>r&&(r=a.notes[n].shac);i+=r,a.x=i,a.nflags<=0&&(a.beam_st=!0,a.beam_end=!0),t=a.next;if(!t){a.beam_end=!0;break}t.nflags<=0&&(a.beam_end=!0),a.beam_end&&(t.beam_st=!0,i+=o/4),a.nflags<=0&&(i+=o/4),a.y>t.y+8&&(i-=1.5),i+=o}return t=e.next,t&&t.type==C.NOTE&&(a.y>=3*(t.notes[t.nhd].pit-18)?u-=1:a.beam_st&&a.y<3*(t.notes[t.nhd].pit-18)-4&&(u+=2)),i+=u,i}function gchord_width(e,t,n){var r,i,s,o,u,a=0,f=0,l=0,c=0;for(u=0;u<e.a_gch.length;u++){i=e.a_gch[u];switch(i.type){default:o=-i.x,o>a&&(a=o),s=i.w+2-o,s>f&&(f=s);break;case"<":s=i.w+t,s>l&&(l=s);break;case">":s=i.w+e.wr,s>c&&(c=s)}}r=e.prev;if(r){if(r.a_gch)for(r=e.ts_prev;;r=r.ts_prev){if(r==e.prev){n<a&&(n=a);break}r.seqst&&(a-=r.shrink)}l!=0&&n<l&&(n=l)}r=e.next;if(r){if(r.a_gch)for(r=e.ts_next;;r=r.ts_next){if(r==e.next){e.wr<f&&(e.wr=f);break}r.seqst&&(f-=8)}c!=0&&e.wr<c&&(e.wr=l)}return n}function set_width(e){var t,n,r,i,s,o,u,a,f,l,c,h,p,d,v;switch(e.type){case C.NOTE:case C.REST:e.wr=o=hw_tb[e.head],e.xmx>0&&(e.wr+=e.xmx+4);for(t=e.prev;t;t=t.prev)if(w_tb[t.type]!=0)break;if(t)switch(t.type){case C.BAR:case C.CLEF:case C.KEY:case C.METER:o+=3}for(r=0;r<=e.nhd;r++)i=e.notes[r].shhd,i<0&&o<-i+5&&(o=-i+5),e.notes[r].acc&&(v=e.notes[r].shac+(e.notes[r].micro?5.5:3.5),o<v&&(o=v));if(t)switch(t.type){case C.BAR:case C.CLEF:case C.KEY:case C.METER:o-=3}e.a_dd&&(o+=deco_width(e)),e.beam_st&&e.beam_end&&e.stem>0&&e.nflags>0&&e.wr<e.xmx+9&&(e.wr=e.xmx+9);if(e.dots){if(e.wl==undefined)switch(e.head){case C.SQUARE:e.xmx+=4;break;case C.OVALBARS:case C.OVAL:e.xmx+=2;break;case C.EMPTY:e.xmx+=1}e.wr<e.xmx+8&&(e.wr=e.xmx+8),e.dots>=2&&(e.wr+=3.5*(e.dots-1))}e.trem2&&e.beam_end&&o<20&&(o=20),u=o;if(t)switch(t.type){case C.NOTE:t.stem>0&&e.stem<0&&u<7&&(u=7),(e.y>27&&t.y>27||e.y<-3&&t.y<-3)&&u<6&&(u=6),t.ti1&&u<14&&(u=14);break;case C.CLEF:if(t.second||t.clef_small)break;u+=8;break;case C.KEY:u+=4}e.a_gch&&(u=gchord_width(e,o,u)),e.a_ly&&(u=ly_width(e,u)),t&&t.type==C.GRACE?e.wl=o-4.5:e.wl=u;return;case C.SPACE:i=e.width/2,e.wr=i,e.a_gch&&(i=gchord_width(e,i,i)),e.a_dd&&(i+=deco_width(e)),e.wl=i;return;case C.BAR:if(e.norepbra)break;f=e.bar_type;switch(f){case"|":s=7;break;default:s=4+3*f.length;for(n=0;n<f.length;n++)switch(f[n]){case"[":case"]":s+=3;break;case":":s+=2}}e.wl=s,e.next&&e.next.type!=C.METER?e.wr=7:e.wr=5;for(t=e.prev;t;t=t.prev)if(w_tb[t.type]!=0){t.type==C.GRACE&&(e.wl-=8);break}e.a_dd&&(e.wl+=deco_width(e)),e.text&&e.text.length<4&&e.next&&e.next.a_gch&&(set_font("repeat"),e.wr+=strwh(e.text)[0]+2);return;case C.CLEF:if(e.invis){e.wl=e.wr=1;return}e.wl=e.wr=e.clef_small?8:12;return;case C.KEY:e.wl=3,d=4;if(!e.k_a_acc)h=e.k_sf,e.k_old_sf&&(cfmt.cancelkey||h==0)?p=e.k_old_sf:p=0,h*p>=0?(h<0&&(h=-h),p<0&&(p=-p),p>h&&(h=p)):(h-=p,h<0&&(h=-h),d+=3);else{h=p=e.k_a_acc.length,p&&(c=e.k_a_acc[0].acc);for(n=1;n<p;n++)a=e.k_a_acc[n],a.pit>e.k_a_acc[n-1].pit+6||a.pit<e.k_a_acc[n-1].pit-6?h--:a.acc!=c&&(d+=3),c=a.acc}e.wr=5.5*h+d;return;case C.METER:u=0,e.x_meter=[];for(n=0;n<e.a_meter.length;n++){l=e.a_meter[n];switch(l.top[0]){case"C":case"c":case"o":e.x_meter[n]=u+6,u+=12;break;case".":case"|":e.x_meter[n]=e.x_meter[n-1];break;default:s=0,!l.bot||l.top.length>l.bot.length?l=l.top:l=l.bot;for(r=0;r<l.length;r++)switch(l[r]){case"(":u+=4;case")":case"1":s+=4;break;default:s+=12}e.x_meter[n]=u+s/2,u+=s}}e.wl=0,e.wr=u+6;return;case C.MREST:e.wl=6,e.wr=66;return;case C.GRACE:e.wl=set_graceoffs(e),e.wr=0,e.a_ly&&ly_width(e,u);return;case C.STBRK:e.wl=e.xmx,e.next&&e.next.type==C.CLEF?(e.wr=2,delete e.next.clef_small):e.wr=8;return;case C.CUSTOS:e.wl=e.wr=4;return;case C.BLOCK:case C.PART:case C.REMARK:case C.STAVES:case C.TEMPO:break;default:error(2,e,"set_width - Cannot set width for symbol $1",e.type)}e.wl=e.wr=0}function time2space(e,t){var n,r,i;return smallest_duration>=C.BLEN/2?smallest_duration>=C.BLEN?t/=4:t/=2:!e.next&&t>=C.BLEN&&(t/=2),t>=C.BLEN/4?t<C.BLEN/2?n=5:t<C.BLEN?n=6:t<C.BLEN*2?n=7:t<C.BLEN*4?n=8:n=9:t>=C.BLEN/8?n=4:t>=C.BLEN/16?n=3:t>=C.BLEN/32?n=2:t>=C.BLEN/64?n=1:n=0,r=t-(C.BLEN/16/8<<n),i=space_tb[n],r!=0&&(r<0?i=space_tb[0]*t/(C.BLEN/16/8):(n>=9&&(n=8),i+=(space_tb[n+1]-space_tb[n])*r/t)),i}function set_space(e){var t,n,r=e.ts_prev.time,i=e.time-r;if(i==0){switch(e.type){case C.MREST:return e.wl}return 0}if(e.ts_prev.type==C.MREST)return 71;n=time2space(e,i);while(!e.dur){switch(e.type){case C.BAR:return n*.9-7;case C.CLEF:return n-e.wl-e.wr;case C.BLOCK:case C.PART:case C.REMARK:case C.STAVES:case C.TEMPO:e=e.ts_next;if(!e)return n;continue}break}e.beam_st||(n*=.9);if(e.type==C.NOTE&&e.nflags>=-1&&e.stem>0){var s=!0;for(t=e.ts_prev;t&&t.time==r;t=t.ts_prev)if(t.type==C.NOTE&&(t.nflags<-1||t.stem>0)){s=!1;break}if(s){for(t=e.ts_next;t&&t.time==e.time;t=t.ts_next)if(t.type==C.NOTE&&(t.nflags<-1||t.stem<0)){s=!1;break}s&&(n*=.9)}}return n}function set_sp_tup(e,t){var n,r,i=e.time,s=t.time+t.dur,o=s-i,u=time2space(e,o/e.tq0)*e.tq0/o;do e=e.ts_next;while(!e.seqst);while(!e.dur)e=e.ts_next;while(!e.seqst)e=e.ts_prev;do t.ts_next?t=t.ts_next:(r=add_end_bar(t),t=r);while(!t.seqst);r=e;for(;;){r.dur&&r.dur*u<r.shrink&&(u=r.shrink/r.dur);if(r==t)break;r=r.ts_next}for(;;){e.seqst&&(n=(e.time-i)*u,i=e.time),e.space=n;if(e==t)break;e=e.ts_next}}function add_end_bar(e){var t={type:C.BAR,bar_type:"|",fname:e.fname,istart:e.istart,iend:e.iend,v:e.v,p_v:e.p_v,st:e.st,dur:0,seqst:!0,invis:!0,time:e.time+e.dur,nhd:0,notes:[{pit:e.notes[0].pit}],wl:0,wr:0,prev:e,ts_prev:e,shrink:e.wr+3};return e.next=e.ts_next=t,t}function set_allsymwidth(){var e,t,n,r,i,s=tsfirst,o=s,u=0,a=[],f=[],l=0;for(;;){e=u;do self.set_width(s),i=s.st,a[i]==undefined&&(a[i]=0),f[i]==undefined&&(f[i]=0),t=a[i]+f[i]+s.wl,t>e&&(e=t),s=s.ts_next;while(s&&!s.seqst);o.shrink=e-u,l||(o.space=o.ts_prev?set_space(o):0),o.shrink==0&&o.space==0&&o.type==C.CLEF&&(delete o.seqst,o.time=o.ts_prev.time);if(!s)break;for(i=0;i<f.length;i++)f[i]=0;u=e;do i=o.st,a[i]=u,o.wr>f[i]&&(f[i]=o.wr),o.tp0&&++l==1&&!n&&(n=o),o.te0&&l--,o=o.ts_next;while(!o.seqst)}s=n;if(!s)return;do{o=s,l=1;do s=s.ts_next,s.tp0&&l++,s.te0&&l--;while(l!=0);set_sp_tup(o,s);do s=s.ts_next;while(s&&!s.tp0)}while(s)}function to_rest(e){e.type=C.REST,delete e.in_tuplet,delete e.sl1,delete e.sl2,delete e.a_dd,delete e.a_gch,e.slur_start=e.slur_end=0}function set_repeat(e){var t,n,r,i,s,o=e.repeat_n,u=e.repeat_k,a=e.st,f=e.v;e.repeat_n=0;if(o<0){o=-o,r=o;for(n=e.prev;n;n=n.prev){if(!n.dur){if(n.type==C.BAR){error(1,n,"Bar in repeat sequence");return}continue}if(--r<=0)break}if(!n){error(1,e,errs.not_enough_n);return}s=e.time-n.time,r=u*o;for(t=e;t;t=t.next){if(!t.dur){if(t.type==C.BAR){error(1,t,"Bar in repeat sequence");return}continue}if(--r<=0)break}if(!t||!t.next){error(1,e,errs.not_enough_n);return}for(t=e.prev;t!=n;t=t.prev)if(t.type==C.NOTE){t.beam_end=!0;break}for(i=u;--i>=0;){r=o,e.dur&&r--,t=e.ts_next;while(r>0)t.st==a&&(unlksym(t),t.v==f&&t.dur&&r--),t=t.ts_next;to_rest(e),e.dur=e.notes[0].dur=s,e.rep_nb=-1,e.beam_st=!0,self.set_width(e),e.seqst&&(e.space=set_space(e)),e.head=C.SQUARE;for(e=t;e;e=e.ts_next)if(e.st==a&&e.v==f&&e.dur)break}return}r=o;for(t=e.prev.prev;t;t=t.prev)if(t.type==C.BAR||t.time==tsfirst.time)if(--r<=0)break;if(!t){error(1,e,errs.not_enough_m);return}s=e.time-t.time,o==1?r=u:r=o;for(t=e;t;t=t.next)if(t.type==C.BAR&&--r<=0)break;if(!t){error(1,e,errs.not_enough_m);return}r=u;if(o==2&&r>1){t=t.next;if(!t){error(1,e,errs.not_enough_m);return}t.repeat_n=o,t.repeat_k=--r}s/=o;if(o==2){n=e;for(t=e.ts_next;;t=t.ts_next){if(t.st!=a)continue;if(t.v==f&&t.type==C.BAR)break;unlksym(t)}to_rest(n),n.dur=n.notes[0].dur=s,n.invis=!0,n.seqst&&(n.space=set_space(n)),t.bar_mrep=2,t.seqst&&(t.space=set_space(t)),n=t.next;for(t=n.ts_next;;t=t.ts_next){if(t.st!=a)continue;if(t.v==f&&t.type==C.BAR)break;unlksym(t)}to_rest(n),n.dur=n.notes[0].dur=s,n.invis=!0,self.set_width(n),n.seqst&&(n.space=set_space(n)),t.seqst&&(t.space=set_space(t));return}n=e;for(i=u;--i>=0;){for(t=n.ts_next;;t=t.ts_next){if(t.st!=a)continue;if(t.v==f&&t.type==C.BAR)break;unlksym(t)}to_rest(n),n.dur=n.notes[0].dur=s,n.beam_st=!0,n.seqst&&(n.space=set_space(n)),t.seqst&&(t.space=set_space(t));if(u==1){n.rep_nb=1;break}n.rep_nb=u-i+1,n=t.next}}function custos_add(e){var t,n,r,i=e;for(;;){if(i.type==C.NOTE)break;i=i.next;if(!i)return}t=e.p_v,t.last_sym=e.prev,t.time=e.time,n=sym_add(t,C.CUSTOS),n.next=e,e.prev=n,lktsym(n,e),n.seqst=!0,n.shrink=e.shrink,n.shrink<12&&(n.shrink=12),n.space=i.space,n.wl=0,n.wr=4,n.nhd=i.nhd,n.notes=[];for(r=0;r<e.notes.length;r++)n.notes[r]={pit:i.notes[r].pit,shhd:0,dur:C.BLEN/4};n.stemless=!0}function set_nl(e){function i(e){cfmt.custos&&voice_tb.length==1&&custos_add(e);for(var t=e.ts_next;t;t=t.ts_next)if(t.seqst){e.nl=!0;break}}function s(e){if(!e.next)return i(e),e;for(e=e.ts_next;e;e=e.ts_next)if(e.seqst){i(e);break}return e}var t,n,r;if(e.eoln&&!cfmt.keywarn&&!cfmt.timewarn)return s(e);switch(e.type){case C.CLEF:case C.BAR:case C.STAVES:break;case C.KEY:if(cfmt.keywarn&&!e.k_none)break;return s(e);case C.METER:if(cfmt.timewarn)break;return s(e);case C.GRACE:e=e.next;if(!e)return e;default:return s(e)}for(;e;e=e.ts_prev){if(!e.seqst)continue;switch(e.type){case C.KEY:case C.CLEF:case C.METER:continue}break}r=0;for(;;e=e.ts_next){if(!e)return e;if(!e.seqst)continue;if(r<0)break;switch(e.type){case C.STAVES:if(e.ts_prev&&e.ts_prev.type==C.BAR)break;while(e.ts_next){if(w_tb[e.ts_next.type]!=0&&e.ts_next.type!=C.CLEF)break;e=e.ts_next}if(!e.ts_next||e.ts_next.type!=C.BAR)continue;e=e.ts_next;case C.BAR:if(r)break;r=1;continue;case C.STBRK:e.stbrk_forced?r=-1:unlksym(e);continue;case C.METER:if(!cfmt.timewarn)break;continue;case C.CLEF:if(r)break;continue;case C.KEY:if(!cfmt.keywarn||e.k_none)break;continue;default:if(!r||e.prev&&e.prev.type==C.GRACE)continue}break}return i(e),e}function get_ck_width(){var e,t,n=voice_tb[0];return self.set_width(n.clef),self.set_width(n.key),self.set_width(n.meter),[n.clef.wl+n.clef.wr+n.key.wl+n.key.wr,n.meter.wl+n.meter.wr]}function get_width(e,t){var n,r,i=0,s=1-cfmt.maxshrink;do{e.seqst&&(n=e.shrink,(r=e.space)<n?i+=n:i+=n*cfmt.maxshrink+r*s,e.x=i);if(e==t)break;e=e.ts_next}while(e);return i}function set_lines(e,t,n,r){var i,s,o,u,a,f,l,c,h,p,d,v;for(;t;t=t.ts_next)if(t.eoln)break;c=get_width(e,t)+r;for(;;){d=Math.ceil(c/n);if(d<=1)return t&&(t=set_nl(t)),t;s=i=e,a=e.x-e.shrink-r,l=a+n,f=a+c/d,a+=c/d*cfmt.breaklimit;for(e=e.ts_next;e!=t;e=e.ts_next){if(!e.x)continue;e.type==C.BAR&&(s=e);if(e.x>=a)break}if(e==t)return t&&(t=set_nl(t)),t;v=!1,o=null;for(;e!=t;e=e.ts_next){u=e.x;if(!u)continue;if(u>l)break;if(e.type!=C.BAR)continue;if(u<f){o=e;continue}if(!o||e.x<f){o=e;continue}if(o>f)break;if(f-o.x<e.x-f)break;o=e;break}o&&(e=o,v=!0);if(!v){var m=0,g=s.time;l-=8,e=s,o=null;for(;e!=t;e=e.ts_next){e.beam_st&&m++,e.beam_end&&m>0&&m--,u=e.x;if(!u)continue;if(u+e.wr>=l)break;if(m||e.in_tuplet)continue;if((e.time-g)%(C.BLEN/4)==0){o=e;continue}if(!o||e.x<f){o=e;continue}if(o>f)break;if(f-o.x<e.x-f)break;o=e;break}o&&(e=o,v=!0)}if(!v){o=e=s;for(;e!=t;e=e.ts_next){u=e.x;if(!u)continue;if(e.x<f){o=e;continue}if(o>f)break;if(f-o.x<e.x-f)break;o=e;break}e=o}if(e.nl){error(0,e,"Line split problem - adjust maxshrink and/or breaklimit"),d=2;for(e=e.ts_next;e!=t;e=e.ts_next){if(!e.x)continue;if(--d<=0)break}}e=set_nl(e);if(!e||t&&e.time>=t.time)break;c-=e.x-i.x,r=0}return e}function cut_tune(e,t){var n,r,i,s,o,n=tsfirst;t!=0&&(s=set_indent(),e-=s,t-=s),s=get_ck_width(),e-=s[0],t+=s[1],cfmt.custos&&voice_tb.length==1&&(e-=12);if(cfmt.barsperstaff){s=cfmt.barsperstaff;for(r=n;r;r=r.ts_next){if(r.type!=C.BAR||!r.bar_num||--s>0)continue;r.eoln=!0,s=cfmt.barsperstaff}}o=t,r=n;for(;n;n=n.ts_next){if(!n.seqst&&!n.eoln)continue;o+=n.shrink;if(o>e)r=set_lines(r,n,e,t);else{if(!n.eoln)continue;delete n.eoln;if(n.dur){for(i=n.ts_next;i;i=i.ts_next)if(i.seqst||i.dur<n.dur)break;i&&!i.seqst?r=set_lines(r,n,e,t):r=set_nl(n)}else r=set_nl(n)}if(!r)break;if(!r.ts_prev){delete r.nl;continue}o=r.shrink,n=r.ts_prev,t=0}}function set_yval(e){switch(e.type){case C.CLEF:if(e.second||e.invis){e.ymx=e.ymn=12;break}e.y=(e.clef_line-1)*6;switch(e.clef_type){default:e.ymx=e.y+28,e.ymn=e.y-14;break;case"c":e.ymx=e.y+13,e.ymn=e.y-11;break;case"b":e.ymx=e.y+7,e.ymn=e.y-12}e.clef_small&&(e.ymx-=2,e.ymn+=2),e.ymx<26&&(e.ymx=26),e.ymn>-1&&(e.ymn=-1),e.clef_octave&&(e.clef_octave>0?e.ymx+=12:e.ymn-=12);break;case C.KEY:e.k_sf>2?e.ymx=34:e.k_sf>0?e.ymx=30:e.ymx=26,e.ymn=-2;break;default:e.ymx=24,e.ymn=0}}function set_auto_clef(e,t,n){var r,i,s,o,u,a;s=12,i=20;for(r=t;r;r=r.ts_next){if(r.type==C.STAVES&&r!=t)break;if(r.st!=e)continue;if(r.type!=C.NOTE){if(r.type==C.CLEF){if(r.clef_type!="a")break;unlksym(r)}continue}r.notes[0].pit<i?i=r.notes[0].pit:r.notes[r.nhd].pit>s&&(s=r.notes[r.nhd].pit)}if(i>=19||i>=13&&n!="b")return"t";if(s<=13||s<=19&&n!="t")return"b";n=="a"&&((s+i)/2>=16?n="t":n="b");var f=n,l=r,c=null;for(r=t;r!=l;r=r.ts_next){if(r.type==C.STAVES&&r!=t)break;if(r.st!=e||r.type!=C.NOTE)continue;o=r.time;if(f=="t"){if(r.notes[0].pit>12||r.notes[r.nhd].pit>20){r.notes[0].pit>20&&(c=r);continue}u=r.ts_prev;if(u&&u.time==o&&u.st==e&&u.type==C.NOTE&&u.notes[0].pit>=19)continue;u=r.ts_next;if(u&&u.st==e&&u.time==o&&u.type==C.NOTE&&u.notes[0].pit>=19)continue}else{if(r.notes[0].pit<12||r.notes[r.nhd].pit<20){r.notes[r.nhd].pit<12&&(c=r);continue}u=r.ts_prev;if(u&&u.time==o&&u.st==e&&u.type==C.NOTE&&u.notes[0].pit<=13)continue;u=r.ts_next;if(u&&u.st==e&&u.time==o&&u.type==C.NOTE&&u.notes[0].pit<=13)continue}if(!c){f=n=f=="t"?"b":"t",c=r;continue}a=r;for(u=r.ts_prev;u!=c;u=u.ts_prev){if(u.st!=e)continue;if(u.type==C.BAR&&u.v==r.v){a=u;break}if(u.type!=C.NOTE)continue;u.beam_st&&!u.p_v.second&&(a=u)}if(a.time==c.time){c=r;continue}c=r,f=f=="t"?"b":"t",u=insert_clef(a,f,f=="t"?2:4),u.clef_auto=!0}return n}function set_clefs(){var e,t,n,r,i,s,o,u,a,f,l=new Array(nstaff),c=cur_sy,h=[];staff_tb=new Array(nstaff);for(n=0;n<=nstaff;n++)l[n]={autoclef:!0},staff_tb[n]={output:"",sc_out:""};for(r=0;r<voice_tb.length;r++){i=voice_tb[r];if(c.voices[r].range<0)continue;n=c.voices[r].st,c.voices[r].second||(i.staffnonote!=undefined&&(c.staves[n].staffnonote=i.staffnonote),i.staffscale&&(c.staves[n].staffscale=i.staffscale),c.voices[r].sep&&(c.staves[n].sep=c.voices[r].sep),c.voices[r].maxsep&&(c.staves[n].maxsep=c.voices[r].maxsep)),!c.voices[r].second&&!i.clef.clef_auto&&(l[n].autoclef=!1)}for(r=0;r<voice_tb.length;r++){i=voice_tb[r];if(c.voices[r].range<0||c.voices[r].second)continue;n=c.voices[r].st,e=i.clef,l[n].autoclef&&(e.clef_type=set_auto_clef(n,tsfirst,e.clef_type),e.clef_line=e.clef_type=="t"?2:4),l[n].clef=staff_tb[n].clef=e}for(n=0;n<=c.nstaff;n++)h[n]=(c.staves[n].stafflines.length-1)*3;for(e=tsfirst;e;e=e.ts_next){e.repeat_n&&set_repeat(e);switch(e.type){case C.STAVES:c=e.sy;for(n=0;n<=nstaff;n++)l[n].autoclef=!0;for(r=0;r<voice_tb.length;r++){if(c.voices[r].range<0)continue;i=voice_tb[r],n=c.voices[r].st,c.voices[r].second||(i.staffnonote!=undefined&&(c.staves[n].staffnonote=i.staffnonote),i.staffscale&&(c.staves[n].staffscale=i.staffscale),c.voices[r].sep&&(c.staves[n].sep=c.voices[r].sep),c.voices[r].maxsep&&(c.staves[n].maxsep=c.voices[r].maxsep)),t=i.clef,t.clef_auto||(l[n].autoclef=!1)}for(n=0;n<=c.nstaff;n++)h[n]=(c.staves[n].stafflines.length-1)*3;for(r=0;r<voice_tb.length;r++){if(c.voices[r].range<0||c.voices[r].second)continue;i=voice_tb[r],n=c.voices[r].st,t=i.clef,t.clef_auto?(o=set_auto_clef(n,e,l[n].clef?l[n].clef.clef_type:"a"),u=o=="t"?2:4):(o=t.clef_type,u=t.clef_line);if(!l[n].clef){t.clef_auto&&(t.type!="a"&&(i.clef=clone(i.clef)),i.clef.clef_type=o,i.clef.clef_line=u),staff_tb[n].clef=l[n].clef=i.clef;continue}if(o==l[n].clef.clef_type&&u==l[n].clef.clef_line)continue;s=e.ts_next;while(s&&(s.v!=r||s.st!=n))s=s.ts_next;if(!s)continue;s.type!=C.CLEF&&(s=insert_clef(s,o,u),t.clef_auto&&(s.clef_auto=!0)),l[n].clef=i.clef=s}continue;default:e.mid=h[e.st];continue;case C.CLEF:}e.clef_type=="a"&&(e.clef_type=set_auto_clef(e.st,e.ts_next,l[e.st].clef.clef_type),e.clef_line=e.clef_type=="t"?2:4),i=e.p_v,i.clef=e;if(e.second){unlksym(e);continue}n=e.st;if(l[n].clef){if(e.clef_type==l[n].clef.clef_type&&e.clef_line==l[n].clef.clef_line)continue}else staff_tb[n].clef=e;l[n].clef=e}c=cur_sy;for(r=0;r<voice_tb.length;r++){if(c.voices[r].range<0)continue;t=voice_tb[r].sym;if(!t||t.notes[0].pit!=127)continue;n=c.voices[r].st;switch(staff_tb[n].clef.clef_type){default:f=22;break;case"c":f=16;break;case"b":f=10}for(e=t;e;e=e.next)e.notes[0].pit=f}}function set_pitch(e){var t,n,r,i,s,o,u,a,f=C.BLEN,l=new Array(nstaff),c=cur_sy;for(i=0;i<=nstaff;i++)t=staff_tb[i].clef,l[i]=delta_tb[t.clef_type]+t.clef_line*2,t.clefpit&&(l[i]+=t.clefpit),cfmt.sound?t.clef_octave&&!t.clef_oct_transp&&(l[i]+=t.clef_octave):t.clef_oct_transp&&(l[i]-=t.clef_octave);for(t=tsfirst;t!=e;t=t.ts_next){i=t.st;switch(t.type){case C.CLEF:l[i]=delta_tb[t.clef_type]+t.clef_line*2,t.clefpit&&(l[i]+=t.clefpit),cfmt.sound?t.clef_octave&&!t.clef_oct_transp&&(l[i]+=t.clef_octave):t.clef_oct_transp&&(l[i]-=t.clef_octave),set_yval(t);break;case C.GRACE:for(r=t.extra;r;r=r.next){s=l[r.st];if(s!=0&&!t.p_v.key.k_drum)for(o=0;o<=r.nhd;o++)a=r.notes[o],a.pit+=s;r.ymn=3*(r.notes[0].pit-18)-2,r.ymx=3*(r.notes[r.nhd].pit-18)+2}set_yval(t);break;case C.KEY:t.k_y_clef=l[i];default:set_yval(t);break;case C.MREST:if(t.invis)break;t.y=12,t.ymx=39,t.ymn=-2;break;case C.REST:if(voice_tb.length==1){t.y=12,t.ymx=24,t.ymn=0;break};case C.NOTE:s=l[i];if(s!=0&&!t.p_v.key.k_drum)for(o=t.nhd;o>=0;o--)t.notes[o].opit=t.notes[o].pit,t.notes[o].pit+=s;t.type==C.NOTE?(t.ymx=3*(t.notes[t.nhd].pit-18)+4,t.ymn=3*(t.notes[0].pit-18)-4):(t.y=((t.notes[0].pit-18)/2|0)*6,t.ymx=t.y+rest_sp[5-t.nflags][0],t.ymn=t.y-rest_sp[5-t.nflags][1]),t.dur<f&&(f=t.dur)}}e||(smallest_duration=f)}function set_stem_dir(){var e,t,n,r,i,s,o,u,a,f,l=[],c=tsfirst,h=cur_sy,p=h.nstaff;while(c){for(r=0;r<=p;r++)l[r]=[];f=[];for(t=c;t;t=t.ts_next){if(t.type==C.BAR)break;if(t.type==C.STAVES){if(t!=c)break;h=c.sy;for(r=p;r<=h.nstaff;r++)l[r]=[];p=h.nstaff;continue}if(t.type!=C.NOTE&&t.type!=C.REST||t.invis)continue;r=t.st;if(r>p){var d="*** fatal set_stem_dir(): bad staff number "+r+" max "+p;throw error(2,null,d),new Error(d)}s=t.v,o=f[s],o||(o={st1:-1,st2:-1},f[s]=o),o.st1<0?o.st1=r:o.st1!=r&&(r>o.st1?r>o.st2&&(o.st2=r):(o.st1>o.st2&&(o.st2=o.st1),o.st1=r)),u=l[r],i=h.voices[s].range;for(n=u.length;--n>=0;){a=u[n];if(a.v==i)break}if(n<0){a={v:i,ymx:0,ymn:24};for(n=0;n<u.length;n++)if(i<u[n].v){u.splice(n,0,a);break}n==u.length&&u.push(a)}if(t.type!=C.NOTE)continue;t.ymx>a.ymx&&(a.ymx=t.ymx),t.ymn<a.ymn&&(a.ymn=t.ymn),t.xstem&&(t.ts_prev.st!=r-1||t.ts_prev.type!=C.NOTE?(error(1,c,"Bad !xstem!"),t.xstem=!1):(t.ts_prev.multi=1,t.multi=1,t.stemless=!0))}for(;c!=t;c=c.ts_next){if(c.multi)continue;switch(c.type){default:continue;case C.REST:if(c.combine!=undefined&&c.combine<0||!c.ts_next||c.ts_next.type!=C.REST||c.ts_next.st!=c.st||c.time!=c.ts_next.time||c.dur!=c.ts_next.dur||c.invis)break;unlksym(c.ts_next);break;case C.NOTE:case C.GRACE:}r=c.st,s=c.v,o=f[s],u=l[r];if(o&&o.st2>=0){r==o.st1?c.multi=-1:r==o.st2&&(c.multi=1);continue}if(u.length<=1){c.floating&&(c.multi=r==voice_tb[s].st?-1:1);continue}i=h.voices[s].range;for(n=u.length;--n>=0;)if(u[n].v==i)break;if(n<0)continue;n==u.length-1?c.multi=-1:(c.multi=1,n!=0&&n+2==u.length&&(u[n].ymn-cfmt.stemheight>u[n+1].ymx&&(c.multi=-1),e=c.ts_next,c.ts_prev&&c.ts_prev.time==c.time&&c.ts_prev.st==c.st&&c.notes[c.nhd].pit==c.ts_prev.notes[0].pit&&c.beam_st&&c.beam_end&&(!e||e.st!=c.st||e.time!=c.time)&&(c.multi=-1)))}while(c&&c.type==C.BAR)c=c.ts_next}}function set_rest_offset(){var e,t,n,r,i,s,o,u,a,f,l,c,h=[],p=cur_sy;for(e=tsfirst;e;e=e.ts_next){if(e.invis)continue;e.type==C.STAVES&&(p=e.sy);if(!e.dur)continue;s=h[e.v],s||(s={},h[e.v]=s),s.s=e,s.st=e.st,s.end_time=e.time+e.dur;if(e.type!=C.REST)continue;a=-127,u=127,i=l=!1;for(n=0;n<=h.length;n++){s=h[n];if(!s||!s.s||s.st!=e.st||n==e.v)continue;if(s.end_time<=e.time)continue;i=!0,t=s.s,p.voices[n].range<p.voices[e.v].range?t.time==e.time?t.ymn<u&&(u=t.ymn,t.dots&&(l=!0)):t.y<u&&(u=t.y):t.time==e.time?t.ymx>a&&(a=t.ymx,t.dots&&(l=!0)):t.y>a&&(a=t.y)}r=e.time+e.dur;for(t=e.ts_next;t;t=t.ts_next){if(t.time>=r)break;if(t.st!=e.st||!t.dur||t.invis)continue;i=!0,p.voices[t.v].range<p.voices[e.v].range?t.time==e.time?t.ymn<u&&(u=t.ymn,t.dots&&(l=!0)):t.y<u&&(u=t.y):t.time==e.time?t.ymx>a&&(a=t.ymx,t.dots&&(l=!0)):t.y>a&&(a=t.y)}if(!i){e.y=12,e.ymx=24,e.ymn=0;continue}u==127&&e.y<12&&(f=12-e.y,e.y+=f,e.ymx+=f,e.ymn+=f),a==-127&&e.y>12&&(f=e.y-12,e.y-=f,e.ymx-=f,e.ymn-=f),f=u-e.ymx;if(f<0){f=Math.ceil(-f/6)*6;if(e.ymn-f>=a){e.y-=f,e.ymx-=f,e.ymn-=f;continue}c=l?15:10,e.notes[0].shhd=c,e.xmx=c;continue}f=a-e.ymn;if(f>0){f=Math.ceil(f/6)*6;if(e.ymx+f<=u){e.y+=f,e.ymx+=f,e.ymn+=f;continue}c=l?15:10,e.notes[0].shhd=c,e.xmx=c;continue}}}function new_sym(e,t,n){var r={type:e,fname:n.fname,v:t.v,p_v:t,st:t.st,time:n.time,next:t.last_sym.next};return r.next&&(r.next.prev=r),t.last_sym.next=r,r.prev=t.last_sym,t.last_sym=r,lktsym(r,n),r.ts_prev.type!=e&&(r.seqst=!0),n.type==e&&r.v!=n.v&&(delete n.seqst,n.shrink=0),r}function init_music_line(){var e,t,n,r,i,s,o,u,a,f=voice_tb.length;for(s=0;s<f;s++){if(cur_sy.voices[s].range<0)continue;e=voice_tb[s],e.second=cur_sy.voices[s].second,e.last_sym=e.sym,o=cur_sy.voices[s].st;while(o<nstaff&&!cur_sy.st_print[o])o++;e.st=o}i=tsfirst;while(i.type==C.CLEF)s=i.v,cur_sy.voices[s].range>=0&&!cur_sy.voices[s].second&&(delete i.clef_small,e=i.p_v,e.last_sym=e.sym=i),i=i.ts_next;for(s=0;s<f;s++){e=voice_tb[s];if(e.sym&&e.sym.type==C.CLEF)continue;if(cur_sy.voices[s].range<0||cur_sy.voices[s].second&&!e.bar_start)continue;o=cur_sy.voices[s].st;if(!staff_tb[o]||!staff_tb[o].clef)continue;t=clone(staff_tb[o].clef),t.v=s,t.p_v=e,t.st=o,t.time=tsfirst.time,t.prev=null,t.next=e.sym,t.next&&(t.next.prev=t),e.sym=t,e.last_sym=t,t.ts_next=i,i?t.ts_prev=i.ts_prev:t.ts_prev=null,t.ts_prev?(t.ts_prev.ts_next=t,delete t.seqst):(tsfirst=t,t.seqst=!0),i&&(i.ts_prev=t,i.type==C.CLEF&&delete i.seqst),delete t.clef_small,t.second=cur_sy.voices[s].second,cur_sy.st_print[o]||(t.invis=!0)}for(s=0;s<f;s++){if(cur_sy.voices[s].range<0||cur_sy.voices[s].second||!cur_sy.st_print[cur_sy.voices[s].st])continue;e=voice_tb[s];if(i&&i.v==s&&i.type==C.KEY){e.last_sym=i,i.k_old_sf=i.k_sf,i=i.ts_next;continue}n=e.key;if(n.k_sf||n.k_a_acc)t=new_sym(C.KEY,e,i),t.k_sf=n.k_sf,t.k_old_sf=n.k_sf,t.k_none=n.k_none,t.k_a_acc=n.k_a_acc,t.istart=n.istart,t.iend=n.iend,n.k_bagpipe&&(t.k_bagpipe=n.k_bagpipe,t.k_bagpipe=="p"&&(t.k_old_sf=3))}if(insert_meter&1){for(s=0;s<f;s++){e=voice_tb[s],n=e.meter;if(cur_sy.voices[s].range<0||cur_sy.voices[s].second||!cur_sy.st_print[cur_sy.voices[s].st]||n.a_meter.length==0)continue;if(i&&i.v==s&&i.type==C.METER){e.last_sym=i,i=i.ts_next;continue}t=new_sym(C.METER,e,i),t.istart=n.istart,t.iend=n.iend,t.wmeasure=n.wmeasure,t.a_meter=n.a_meter}insert_meter&=-2}for(s=0;s<f;s++){e=voice_tb[s],n=e.bar_start,e.bar_start=null;if(i&&i.v==s&&i.type==C.BAR){e.last_sym=i,i=i.ts_next;continue}if(!n)continue;if(cur_sy.voices[s].range<0||!cur_sy.st_print[cur_sy.voices[s].st])continue;n.next=e.last_sym.next,n.next&&(n.next.prev=n),e.last_sym.next=n,n.prev=e.last_sym,e.last_sym=n,lktsym(n,i),n.time=tsfirst.time,n.ts_prev.type!=n.type&&(n.seqst=!0),i&&i.type==n.type&&n.v!=i.v&&delete i.seqst}self.set_pitch(i);for(t=i;t;t=t.ts_next)if(t.seqst){for(t=t.ts_next;t;t=t.ts_next)if(t.seqst)break;break}while(i){if(i.seqst){do i=i.ts_next;while(i&&!i.seqst);break}i=i.ts_next}t=tsfirst;for(;;){n=t,a=0;do{self.set_width(t),u=t.wl;for(r=t.prev;r;r=r.prev)if(w_tb[r.type]!=0){u+=r.wr;break}u>a&&(a=u),t=t.ts_next}while(t!=i&&!t.seqst);n.shrink=a,n.space=0;if(t==i)break}}function set_words(e){var t,n,r,i,s=!0,o=127;for(t=e.sym;t;t=t.next)if(t.type==C.NOTE){o=t.notes[0].pit;break}for(t=e.sym;t;t=t.next){switch(t.type){case C.MREST:s=!0;break;case C.BAR:t.bar_type=bar_cnv(t.bar_type),t.beam_on||(s=!0),!t.next&&t.prev&&t.prev.head==C.OVALBARS&&(t.prev.head=C.SQUARE);break;case C.NOTE:case C.REST:if(t.trem2)break;r=t.nflags,t.ntrem&&(r+=t.ntrem),t.type==C.REST&&t.beam_end&&(t.beam_end=!1,s=!0);if(s||r<=0)i&&(i.beam_end=!0,i=null),r<=0?(t.beam_st=!0,t.beam_end=!0):t.type==C.NOTE&&(t.beam_st=!0,s=!1);t.beam_end&&(s=!0),t.type==C.NOTE&&(i=t)}if(t.type==C.NOTE){t.nhd!=0&&sort_pitch(t),o=t.notes[0].pit;for(n=t.prev;n;n=n.prev){if(n.type!=C.REST)break;n.notes[0].pit=o}}else t.notes||(t.notes=[],t.notes[0]={},t.nhd=0),t.notes[0].pit=o}i&&(i.beam_end=!0)}function set_rb(e){var t,n,r,i=e.sym;while(i){if(i.type!=C.BAR||!i.rbstart||i.norepbra){i=i.next;continue}n=cfmt.rbmax;if(i.text&&i.text[0]=="1"){r=0,t=null;for(i=i.next;i;i=i.next){if(i.type!=C.BAR)continue;r++;if(i.rbstop){r<=cfmt.rbmax&&(n=r,t=null);break}r==cfmt.rbmin&&(t=i)}t&&(t.rbstop=1,n=cfmt.rbmin)}while(i){if(i.rbstart!=2){i=i.next;if(!i)break;if(i.rbstart!=2){i=i.next;if(!i)break;if(i.rbstart!=2)break}}r=0,t=null;for(i=i.next;i;i=i.next){if(i.type!=C.BAR)continue;r++;if(i.rbstop)break;i.next?r==n&&(i.rbstop=1):i.rbstop=2}}}}function set_global(){var e,t,n,r,i;i=cur_sy,t=i.nstaff;for(;;){i=i.next;if(!i)break;i.nstaff>t&&(t=i.nstaff)}nstaff=t,r=voice_tb.length;for(n=0;n<r;n++)e=voice_tb[n],set_words(e),set_rb(e);set_float(),set_clefs(),self.set_pitch(null)}function set_indent(e){var t,n,r,i,s,o,u,a,f=voice_tb.length,l=0;for(n=0;n<f;n++){i=voice_tb[n];if(cur_sy.voices[n].range<0)continue;t=cur_sy.voices[n].st,s=(e||i.new_name)&&i.nm?i.nm:i.snm;if(!s)continue;a||(a=get_font("voice"),set_font(a)),o=0;for(;;){u=s.indexOf("\\n",o),u<0?r=strwh(s.slice(o)):r=strwh(s.slice(o,u)),r=r[0],r>l&&(l=r);if(u<0)break;o=u+1}}a&&(l+=4*cwid(" ")*a.swfac),r=.5;for(t=0;t<=cur_sy.nstaff;t++){if(cur_sy.staves[t].flags&(OPEN_BRACE2|OPEN_BRACKET2)){r=12;break}cur_sy.staves[t].flags&(OPEN_BRACE|OPEN_BRACKET)&&(r=6)}return l+=r,e&&(l+=cfmt.indent),l}function set_beams(e){var t,n,r,i,s,o,u,a,f,l,c,h,p=-1;for(t=e;t;t=t.next){if(t.type!=C.NOTE){if(t.type!=C.GRACE)continue;r=t.extra;if(r.stem==2){s=t;continue}!t.stem&&(t.stem=t.multi)==0&&(t.stem=1);for(;r;r=r.next)r.stem=t.stem,r.multi=t.multi;continue}if(!t.stem&&(t.stem=t.multi)==0){l=t.mid/3+18;if(i)t.stem=p;else if(t.beam_st&&!t.beam_end){i=!0,c=t.notes[t.nhd].pit,h=t.notes[0].pit;for(r=t.next;r;r=r.next){if(r.type!=C.NOTE)continue;if(r.stem||r.multi){t.stem=r.stem||r.multi;break}r.notes[r.nhd].pit>c&&(c=r.notes[r.nhd].pit),r.notes[0].pit<h&&(h=r.notes[0].pit);if(r.beam_end)break}r.beam_end&&((c+h)/2<l?t.stem=1:(c+h)/2>l?t.stem=-1:cfmt.bstemdown&&(t.stem=-1)),t.stem||(t.stem=p)}else{a=(t.notes[t.nhd].pit+t.notes[0].pit)/2;if(a==l){a=0;for(f=0;f<=t.nhd;f++)a+=t.notes[f].pit;a/=t.nhd+1}a<l?t.stem=1:a>l?t.stem=-1:cfmt.bstemdown?t.stem=-1:t.stem=p}}else t.beam_st&&!t.beam_end&&(i=!0);t.beam_end&&(i=!1),p=t.stem;if(s){for(r=s.extra;r;r=r.next)r.stem=-p;s.stem=-p,s=null}}}function same_head(e,t){var n,r,i,s,o,u,a,f,l,c,h;if(e.shiftunison&&e.shiftunison>=3)return!1;if((i=e.dur)>=C.BLEN)return!1;if((s=t.dur)>=C.BLEN)return!1;if(e.stemless&&t.stemless)return!1;if(e.dots!=t.dots)if(e.shiftunison&&e.shiftunison&1||e.dots*t.dots!=0)return!1;if(e.stem*t.stem>0)return!1;n=r=0;if(e.notes[0].pit>t.notes[0].pit){if(e.stem<0)return!1;while(t.notes[r].pit!=e.notes[0].pit)if(++r>t.nhd)return!1}else if(e.notes[0].pit<t.notes[0].pit){if(t.stem<0)return!1;while(t.notes[0].pit!=e.notes[n].pit)if(++n>e.nhd)return!1}if(t.notes[r].acc!=e.notes[n].acc)return!1;u=n,f=r,c=e.notes[n].shhd,h=t.notes[r].shhd;do{n++,r++;if(n>e.nhd)break;if(r>t.nhd)break;if(t.notes[r].acc!=e.notes[n].acc)return!1;c<e.notes[n].shhd&&(c=e.notes[n].shhd),h<t.notes[r].shhd&&(h=t.notes[r].shhd)}while(t.notes[r].pit==e.notes[n].pit);if(n<=e.nhd){if(r<=t.nhd)return!1;if(t.stem>0)return!1}else if(r<=t.nhd&&e.stem>0)return!1;a=n,l=r,o=0;if(i!=s){i<s&&(i=s,s=e.dur);if(i<C.BLEN/2)t.dots?o=2:e.dots&&(o=1);else{if(!(s<C.BLEN/4))return!1;if(e.shiftunison&&e.shiftunison&2)return!1;o=t.dur>=C.BLEN/2?2:1}}o==0&&(o=e.p_v.scale<t.p_v.scale?2:1);if(o==1){for(r=f;r<l;r++)t.notes[r].invis=!0,delete t.notes[r].acc;for(r=0;r<=t.nhd;r++)t.notes[r].shhd+=c}else{for(n=u;n<a;n++)e.notes[n].invis=!0,delete e.notes[n].acc;for(n=0;n<=e.nhd;n++)e.notes[n].shhd+=h}return!0}function unison_acc(e,t,n,r){var i,s;if(!t.notes[r].acc){s=w_note[t.head]*2+t.xmx+e.notes[n].shac+2,e.notes[n].micro&&(s+=2),t.dots&&(s+=6);for(i=0;i<=e.nhd;i++)e.notes[i].shhd+=s,e.notes[i].shac-=s;e.xmx+=s}else{s=w_note[e.head]*2+e.xmx+t.notes[r].shac+2,t.notes[r].micro&&(s+=2),e.dots&&(s+=6);for(i=0;i<=t.nhd;i++)t.notes[i].shhd+=s,t.notes[i].shac-=s;t.xmx+=s}}function set_left(e){var t,n,r,i,s=w_note[e.head],o=s,u=[];for(n=0;n<MAXPIT;n++)u.push(-100);if(e.nflags>-2){e.stem>0?(o=-o,n=e.notes[0].pit*2,r=(Math.ceil((e.ymx-2)/3)+18)*2):(n=(Math.ceil((e.ymn+2)/3)+18)*2,r=e.notes[e.nhd].pit*2),n<0&&(n=0),r>=MAXPIT&&(r=MAXPIT-1);while(n<=r)u[n++]=o}i=e.notes[e.stem>0?0:e.nhd].shhd;for(t=0;t<=e.nhd;t++)o=-e.notes[t].shhd+s+i,n=e.notes[t].pit*2,n<0?n=0:n>=MAXPIT-1&&(n=MAXPIT-2),o>u[n]&&(u[n]=o),e.head!=C.SQUARE&&(o-=1),o>u[n-1]&&(u[n-1]=o),o>u[n+1]&&(u[n+1]=o);return u}function set_right(e){var t,n,r,i,s,o=w_note[e.head],u=o,a=e.nflags>0&&e.beam_st&&e.beam_end,f=[];for(n=0;n<MAXPIT;n++)f.push(-100);if(e.nflags>-2){e.stem<0?(u=-u,n=(Math.ceil((e.ymn+2)/3)+18)*2,r=e.notes[e.nhd].pit*2,i=n+4):(n=e.notes[0].pit*2,r=(Math.ceil((e.ymx-2)/3)+18)*2),n<0&&(n=0),r>MAXPIT&&(r=MAXPIT);while(n<r)f[n++]=u}if(a)if(e.stem>0){e.xmx==0?n=e.notes[e.nhd].pit*2:n=e.notes[0].pit*2,n+=4,n<0&&(n=0);for(;n<MAXPIT&&n<=r-4;n++)f[n]=11}else{n=i,n<0&&(n=0);for(;n<MAXPIT&&n<=e.notes[0].pit*2-4;n++)f[n]=3.5}s=e.notes[e.stem>0?0:e.nhd].shhd;for(t=0;t<=e.nhd;t++)u=e.notes[t].shhd+o-s,n=e.notes[t].pit*2,n<0?n=0:n>=MAXPIT-1&&(n=MAXPIT-2),u>f[n]&&(f[n]=u),e.head!=C.SQUARE&&(u-=1),u>f[n-1]&&(f[n-1]=u),u>f[n+1]&&(f[n+1]=u);return f}function set_overlap(){function x(){t=n,n=e,c=h,E=m,S=g,d=p}var e,t,n,r,i,s,o,u,a,f,l,c,h,p,d,v,m,g,y,b,w,E,S;for(e=tsfirst;e;e=e.ts_next){if(e.type!=C.NOTE||e.invis)continue;if(e.xstem&&e.ts_prev.stem<0)for(u=0;u<=e.nhd;u++)e.notes[u].shhd-=7,e.notes[u].shac+=16;n=e;for(;;){n=n.ts_next;if(!n)break;if(n.time!=e.time){n=null;break}if(n.type==C.NOTE&&!n.invis&&n.st==e.st)break}if(!n)continue;t=e,cur_sy.voices[t.v].range<cur_sy.voices[n.v].range?n.dot_low=!0:t.dot_low=!0;if(t.ymn>n.ymx||t.ymx<n.ymn)continue;if(same_head(t,n))continue;g=set_right(t),y=set_left(n),r=t.ts_prev;if(r&&r.time==t.time&&r.st==t.st&&r.type==C.NOTE&&!r.invis){w=set_right(r);for(i=0;i<MAXPIT;i++)w[i]>g[i]&&(g[i]=w[i])}else r=null;c=-10;for(i=0;i<MAXPIT;i++)y[i]+g[i]>c&&(c=y[i]+g[i]);if(c<-3)if(!t.dots||!n.dots||!n.dot_low||t.stem>0||n.stem<0||t.notes[t.nhd].pit+2!=n.notes[0].pit||n.notes[0].pit&1)continue;b=set_right(n),m=set_left(t);if(r){w=set_left(r);for(i=0;i<MAXPIT;i++)w[i]>m[i]&&(m[i]=w[i])}h=p=d=-100;for(i=0;i<MAXPIT;i++)m[i]+b[i]>h&&(h=m[i]+b[i]),b[i]>d&&(d=b[i]),g[i]>p&&(p=g[i]);f=0,s=t.nhd,o=n.nhd;for(;;){l=t.notes[s].pit-n.notes[o].pit;switch(l){case 0:if(t.notes[s].acc!=n.notes[o].acc){f=-1;break}n.notes[o].acc&&(n.notes[o].acc=0),t.dots&&n.dots&&t.notes[s].pit&1&&(f=1);break;case-1:t.dots&&n.dots&&(t.notes[s].pit&1?(t.dot_low=!1,n.dot_low=!1):(t.dot_low=!0,n.dot_low=!0));break;case-2:if(t.dots&&n.dots&&!(t.notes[s].pit&1)){t.dot_low=!1,n.dot_low=!1;break}}if(f<0)break;if(l>=0&&--s<0)break;if(l<=0&&--o<0)break}if(f<0){unison_acc(t,n,s,o);continue}a=0,t.dots?n.dots&&(f||(a=1)):n.dots&&h+p<c+d&&(a=1),E=y,S=b,!r&&h+p<c+d&&x(),c+=3,c<0&&(c=0),u=t.stem>=0?0:t.nhd,c+=t.notes[u].shhd,u=n.stem>=0?0:n.nhd,c-=n.notes[u].shhd;if(t.dots){v=7.7+t.xmx+3.5*t.dots-3.5+3;if(!a){h=-100;for(s=0;s<=t.nhd;s++)i=t.notes[s].pit,i&1||(t.dot_low?i--:i++),i*=2,i<1?i=1:i>=MAXPIT-1&&(i=MAXPIT-2),E[i]>h&&(h=E[i]),E[i-1]+1>h&&(h=E[i-1]+1),E[i+1]+1>h&&(h=E[i+1]+1);v+h+2>c&&(c=v+h+2)}else if(v<c+d+n.xmx){h=0;for(s=0;s<=t.nhd;s++)i=t.notes[s].pit,i&1||(t.dot_low?i--:i++),i*=2,i<1?i=1:i>=MAXPIT-1&&(i=MAXPIT-2),S[i]>h&&(h=S[i]),S[i-1]+1>h&&(h=S[i-1]=1),S[i+1]+1>h&&(h=S[i+1]+1);h>4.5&&7.7+t.xmx+2<c+h+n.xmx&&(n.xmx=h+3-7.7)}}for(u=n.nhd;u>=0;u--)n.notes[u].shhd+=c;n.xmx+=c,a&&(t.xmx=n.xmx)}}function set_stems(){var e,t,n,r,i,s,o,u,a,f;for(e=tsfirst;e;e=e.ts_next){if(e.type!=C.NOTE){if(e.type!=C.GRACE)continue;a=f=e.mid;for(n=e.extra;n;n=n.next)r=GSTEM,n.nflags>1&&(r+=1.2*(n.nflags-1)),s=3*(n.notes[0].pit-18),o=3*(n.notes[n.nhd].pit-18),e.stem>=0?(n.y=s,n.ys=o+r,o=Math.round(n.ys)):(n.y=o,n.ys=s-r,s=Math.round(n.ys)),o+=2,s-=2,s<a?a=s:o>f&&(f=o),n.ymx=o,n.ymn=s;e.ymx=f,e.ymn=a;continue}set_head_shift(e),u=e.nflags;if(e.beam_st&&!e.beam_end){e.feathered_beam&&(u=++e.nflags);for(t=e.next;;t=t.next)if(t.type==C.NOTE){e.feathered_beam&&t.nflags++;if(t.beam_end)break}t.nflags>u&&(u=t.nflags)}else if(!e.beam_st&&e.beam_end){for(t=e.prev;;t=t.prev)if(t.beam_st)break;t.nflags>u&&(u=t.nflags)}r=cfmt.stemheight;switch(u){case 2:r+=2;break;case 3:r+=5;break;case 4:r+=10;break;case 5:r+=16}(i=e.p_v.scale)!=1&&(r*=(i+1)*.5),s=3*(e.notes[0].pit-18),e.nhd>0?(r-=2,o=3*(e.notes[e.nhd].pit-18)):o=s,e.ntrem&&(r+=2*e.ntrem),e.stemless?(e.stem>=0?(e.y=s,e.ys=o):(e.ys=s,e.y=o),u==-4&&(s-=6),e.ymx=o+4,e.ymn=s-4):e.stem>=0?(u>=2&&(r-=1),e.notes[e.nhd].pit>26&&(u<=0||!e.beam_st||!e.beam_end)&&(r-=2,e.notes[e.nhd].pit>28&&(r-=2)),e.y=s,e.notes[0].ti1&&(s-=3),e.ymn=s-4,e.ys=o+r,e.ys<e.mid&&(e.ys=e.mid),e.ymx=e.ys+2.5|0):(e.notes[0].pit<18&&(u<=0||!e.beam_st||!e.beam_end)&&(r-=2,e.notes[0].pit<16&&(r-=2)),e.ys=s-r,e.ys>e.mid&&(e.ys=e.mid),e.ymn=e.ys-2.5|0,e.y=o,e.notes[e.nhd].ti1&&(o+=3),e.ymx=o+4)}}function check_bar(e){var t,n,r,i,s=e.p_v;while(e.type==C.CLEF||e.type==C.KEY||e.type==C.METER){e.type==C.METER&&e.time>s.sym.time&&(insert_meter|=1),e=e.prev;if(!e)return}if(e.type!=C.BAR)return;e.text!=undefined&&(s.bar_start=clone(e),s.bar_start.bar_type="",delete e.text,delete e.a_gch),t=e.bar_type;if(t==":")return;if(t.slice(-1)!=":")return;s.bar_start||(s.bar_start=clone(e));if(t[0]!=":"){if(t=="||:")return s.bar_start.bar_type="[|:",e.bar_type="||",!0;s.bar_start.bar_type=t,e.prev&&e.prev.type==C.BAR?unlksym(e):e.bar_type="|";return}if(t=="||:")return s.bar_start.bar_type="[|:",e.bar_type="||",!0;n=0;while(t[n]==":")n++;if(n<t.length){e.bar_type=t.slice(0,n)+"|]",n=t.length-1;while(t[n]==":")n--;s.bar_start.bar_type="[|"+t.slice(n+1)}else n=t.length/2|0,e.bar_type=t.slice(0,n)+"|]",s.bar_start.bar_type="[|"+t.slice(n);return!0}function sym_staff_move(e){for(var t=tsfirst;t;t=t.ts_next){if(t.nl)break;t.st==e&&t.type!=C.CLEF&&(t.st++,t.invis=!0)}}function block_gen(e){switch(e.subtype){case"leftmargin":case"rightmargin":case"pagescale":case"pagewidth":case"scale":case"staffwidth":svg_flush(),self.set_format(e.subtype,e.param);break;case"ml":svg_flush(),user.img_out(e.text);break;case"newpage":blk_flush(),block.newpage=!0,blk_out();break;case"sep":set_page(),vskip(e.sk1),output+='<path class="stroke"\n d="M',out_sxsy(e.x," ",0),output+="h"+e.l.toFixed(2)+'"/>\n',vskip(e.sk2);break;case"text":write_text(e.text,e.opt);break;case"title":write_title(e.text,!0);break;case"vskip":vskip(e.sk);break;default:error(2,e,"Block $1 not treated",e.subtype)}}function set_piece(){function c(e){var t=staff_tb[e],n=l.staves[e];t||(t=staff_tb[e]={}),t.y=0,t.stafflines=n.stafflines,t.staffscale=n.staffscale,t.ann_top=t.ann_bot=0}function h(){var e,t,n,r=l.staves.length;for(e=0;e<r;e++){if(!(l.staves[e].flags&(OPEN_BRACE|OPEN_BRACE2)))continue;n=0,t=e;while(e<r){n|=a[e]?1:2;if(l.staves[e].flags&(CLOSE_BRACE|CLOSE_BRACE2))break;e++}if(n==3)while(t<=e)a[t]=!0,f[t++]=!0}}function p(){var e,t,n,r,i;for(e=0;e<=nstaff;e++){t=staff_tb[e];if(!f[e]){t.botbar=t.topbar=0;continue}r=t.stafflines.length,t.topbar=6*(r-1);for(n=0;n<r-1;n++)if(t.stafflines[n]!=".")break;t.botline=t.botbar=n*6,n>=r-2&&(t.stafflines[n]!="."?(t.botbar-=6,t.topbar+=6):(t.botbar-=12,t.topbar+=12))}}var e,t,n,r,i,s,o,u,a=[],f=[],l=cur_sy;nstaff=s=l.nstaff;for(r=0;r<=s;r++)c(r);for(e=tsfirst;e;e=e.ts_next){if(e.nl)break;e.ts_next||(t=e);switch(e.type){case C.STAVES:h(),l.st_print=new Uint8Array(a),l=e.sy,s=l.nstaff;if(nstaff<s){for(r=nstaff+1;r<=s;r++)c(r);nstaff=s}a=[];continue;case C.BLOCK:blocks.push(e),unlksym(e),t&&(t=e.ts_prev);continue}r=e.st;if(a[r])continue;switch(e.type){case C.CLEF:r>nstaff&&(staff_tb[r].clef=e,unlksym(e));break;case C.BAR:if(!l.staves[r].staffnonote||l.staves[r].staffnonote<=1)break;case C.GRACE:f[r]=a[r]=!0;break;case C.NOTE:case C.REST:case C.SPACE:case C.MREST:l.staves[r].staffnonote>1?f[r]=a[r]=!0:!e.invis&&(l.staves[r].staffnonote!=0||e.type==C.NOTE)&&(f[r]=a[r]=!0)}}tsnext=e,h(),l.st_print=new Uint8Array(a),p();for(r=0;r<nstaff;r++)f[r]||sym_staff_move(r);f[nstaff]||(staff_tb[nstaff].topbar=0),init_music_line(),gene.st_print=new Uint8Array(f);if(tsnext){e=tsnext,delete e.nl,t=e.ts_prev,t.ts_next=null,o=voice_tb.length;for(i=0;i<o;i++){n=voice_tb[i];if(n.sym&&n.sym.time<=tsnext.time){for(e=tsnext.ts_prev;e;e=e.ts_prev)if(e.v==i){n.s_next=e.next,e.next=null,check_bar(e)&&(u=e.wl,self.set_width(e),e.shrink+=e.wl-u);break}if(e)continue}n.s_next=n.sym,n.sym=null}}t.type!=C.BAR&&(e=add_end_bar(t),e.space=set_space(e),e.space<e.shrink&&t.type!=C.KEY&&(e.space=e.shrink))}function set_sym_glue(e){var t,n,r,i,s,o=0,u=0,a=0,f=0,l=0;for(t=tsfirst;t;t=t.ts_next)t.type==C.GRACE&&!i&&(i=t),t.seqst&&(o+=t.shrink,t.space?t.space<t.shrink?(l+=t.shrink,u+=t.shrink):u+=t.space:f+=t.shrink);if(u==0){realwidth=0;return}r=!tsnext||tsnext.type==C.BLOCK||blocks.length;if(o>=e||u==l){o>e&&error(1,t,"Line too much shrunk $1 $2 $3",o.toFixed(2),u.toFixed(2),e.toFixed(2)),a=0;for(t=tsfirst;t;t=t.ts_next)t.seqst&&(a+=t.shrink),t.x=a;spf_last=0}else if(r&&u+f>e*(1-cfmt.stretchlast)||!r&&(u+f>e||cfmt.stretchstaff)){for(var c=4;--c>=0;){s=(e-f-l)/(u-l),u=0,l=0,a=0;for(t=tsfirst;t;t=t.ts_next)t.seqst&&(t.space?t.space*s<=t.shrink?(l+=t.shrink,u+=t.shrink,a+=t.shrink):(u+=t.space,a+=t.space*s):a+=t.shrink),t.x=a;if(Math.abs(a-e)<.1)break}spf_last=s}else{s=(e-f-l)/u,spf_last<s&&(s=spf_last);for(t=tsfirst;t;t=t.ts_next)t.seqst&&(a+=t.space*s<=t.shrink?t.shrink:t.space*s),t.x=a}realwidth=a;for(t=i;t;t=t.ts_next){if(t.type!=C.GRACE)continue;t.gr_shift?a=t.prev.x+t.prev.wr:a=t.x-t.wl;for(n=t.extra;n;n=n.next)n.x+=a}}function set_sym_line(){var e,t,n,r=voice_tb.length;for(n=0;n<r;n++)e=voice_tb[n],t=e.s_next,e.sym=t,t&&(t.prev=null)}function set_posx(){posx=img.lm/cfmt.scale}function gen_init(){var e=tsfirst,t=e.time;for(;e;e=e.ts_next){if(e.time!=t){set_page();return}switch(e.type){case C.NOTE:case C.REST:case C.MREST:set_page();return;default:continue;case C.STAVES:cur_sy=e.sy;break;case C.BLOCK:block_gen(e)}unlksym(e),e.p_v.s_next==e&&(e.p_v.s_next=e.next)}tsfirst=null}function output_music(){var e,t,n,r;gen_init();if(!tsfirst)return;set_global(),voice_tb.length>1&&self.set_stem_dir();for(e=0;e<voice_tb.length;e++)set_beams(voice_tb[e].sym);self.set_stems(),voice_tb.length>1&&(set_rest_offset(),set_overlap()),set_acc_shft(),set_allsymwidth(),n=set_indent(!0),cfmt.singleline?(e=get_ck_width(),t=n+e[0]+e[1]+get_width(tsfirst,null),img.width=t*cfmt.scale+img.lm+img.rm+2):(t=get_lwidth(),cut_tune(t,n)),spf_last=1.2;for(;;){set_piece(),self.set_sym_glue(t-n);if(realwidth!=0){n!=0&&(posx+=n),draw_sym_near(),r=set_staff(),delayed_update(),draw_systems(n),draw_all_sym(),vskip(r),n!=0&&(posx-=n,insert_meter&=-3);while(blocks.length!=0)block_gen(blocks.shift())}tsfirst=tsnext,svg_flush();if(!tsnext)break;gen_init();if(!tsfirst)break;tsfirst.ts_prev=null,set_sym_line(),t=get_lwidth(),n=set_indent()}}function reset_gen(){insert_meter=cfmt.writefields.indexOf("M")>=0?3:2}function set_ref(e){e.fname=parse.fname,e.istart=parse.istart,e.iend=parse.iend}function new_clef(e){var t={type:C.CLEF,clef_line:2,clef_type:"t",v:curvoice.v,p_v:curvoice,time:curvoice.time,dur:0},n=1;set_ref(t);switch(e[0]){case'"':n=e.indexOf('"',1),t.clef_name=e.slice(1,n),n++;break;case"a":if(e[1]=="u"){t.clef_type="a",t.clef_auto=!0,n=4;break}n=4;case"C":t.clef_type="c",t.clef_line=3;break;case"b":n=4;case"F":t.clef_type="b",t.clef_line=4;break;case"n":n=4,t.invis=!0;break;case"t":if(e[1]=="e"){t.clef_type="c",t.clef_line=4;break}n=6;case"G":break;case"p":n=4;case"P":t.clef_type="p",t.clef_line=3,curvoice.key.k_sf=0,curvoice.ckey.k_drum=!0;break;default:syntax(1,"Unknown clef '$1'",e);return}e[n]>="1"&&e[n]<="9"&&(t.clef_line=Number(e[n]),n++);if(e[n+1]!="8")return t;switch(e[n]){case"^":t.clef_oct_transp=!0;case"+":t.clef_octave=7;break;case"_":t.clef_oct_transp=!0;case"-":t.clef_octave=-7}return t}function get_transp(e,t){var n,r,i,s,o=[];if(e[0]=="0")return 0;if("123456789-+".indexOf(e[0])>=0){r=parseInt(e)*3;if(isNaN(r)||r<-108||r>108){syntax(1,"Bad transpose value");return}switch(e.slice(-1)){default:return r;case"#":r++;break;case"b":r+=2}return r>0?r:r-3}if(t=="instr"){i=e.indexOf("/");if(!cfmt.sound){if(i<0)return 0;e=e.replace("/","")}else i<0?e="c"+e:e=e.replace(/.*\//,"c")}i=new scanBuf,i.buffer=e;for(n=0;n<2;n++){s=i.buffer[i.index]?parse_acc_pit(i):null;if(!s){syntax(1,"Bad transpose value");return}s.pit+=124,r=(s.pit/7|0)*12+note_pit[s.pit%7],s.acc&&s.acc!=3&&(r+=s.acc),o[n]=r}r=(o[1]-o[0])*3;if(s)switch(s.acc){default:return r;case 2:case 1:r++;break;case-1:case-2:r+=2}return r>0?r:r-3}function set_linebreak(e){var t,n;for(t=0;t<128;t++)char_tb[t]=="\n"&&(char_tb[t]=nil);e=e.split(/\s+/);for(t=0;t<e.length;t++){n=e[t];switch(n){case"!":case"$":case"*":case";":case"?":case"@":break;case"<none>":continue;case"<EOL>":n="\n";break;default:syntax(1,"Bad value '$1' in %%linebreak - ignored",n);continue}char_tb[n.charCodeAt(0)]="\n"}}function set_user(e){var t,n,r,i=e.match(/(.*?)[= ]*([!"].*[!"])/);if(!i){syntax(1,'Lack of starting ! or " in U: / %%user');return}n=i[1],r=i[2];if(r.slice(-1)!=r[0]){syntax(1,"Lack of ending $1 in U:/%%user",r[0]);return}n[0]=="\\"&&(n[1]=="t"?n=" ":n[1]||(n=" ")),t=n.charCodeAt(0);if(t>=128){syntax(1,errs.not_ascii);return}switch(char_tb[t][0]){case"0":case"d":case"i":case" ":break;case'"':case"!":if(char_tb[t].length>1)break;default:syntax(1,"Bad user character '$1'",n);return}switch(r){case"!beambreak!":r=" ";break;case"!ignore!":r="i";break;case"!nil!":case"!none!":r="d"}char_tb[t]=r}function get_st_lines(e){var t,n;if(!e)return;if(/^[\]\[|.-]+$/.test(e))return e.replace(/\]/g,"[");t=parseInt(e);switch(t){case 0:return"...";case 1:return"..|";case 2:return".||";case 3:return".|||"}if(isNaN(t)||t<0||t>16)return;n="|";while(--t>0)n+="|";return n}function new_block(e){var t={type:C.BLOCK,subtype:e,dur:0};parse.state==2&&goto_tune();var n=curvoice;return curvoice=voice_tb[par_sy.top_voice],sym_link(t),curvoice=n,t}function set_vp(e){var t,n,r,i,s;for(;;){n=e.shift();if(!n)break;if(n[n.length-1]=="="&&e.length==0){syntax(1,errs.bad_val,n);break}switch(n){case"clef=":t=e.shift();break;case"clefpitch=":n=e.shift();if(n){i=ntb.indexOf(n[0]);if(i>=0){switch(n[1]){case"'":i+=7;break;case",":i-=7,n[2]==","&&(i-=7)}s=4-i;break}}syntax(1,errs.bad_val,n);break;case"octave=":case"uscale=":i=parseInt(e.shift()),isNaN(i)?syntax(1,errs.bad_val,n):curvoice[n.slice(0,-1)]=i;break;case"cue=":curvoice.scale=e.shift()=="on"?.7:1;break;case"instrument=":curvoice.transp=get_transp(e.shift(),"instr");break;case"map=":curvoice.map=e.shift();break;case"name=":case"nm=":curvoice.nm=e.shift(),curvoice.nm[0]=='"'&&(curvoice.nm=curvoice.nm.slice(1,-1)),curvoice.new_name=!0;break;case"stem=":case"pos=":n=="pos="?n=e.shift().split(" "):n=["stm",e.shift()],i=posval[n[1]];if(i==undefined){syntax(1,errs.bad_val,n[0]);break}r||(r={}),r[n[0]]=i;break;case"scale=":i=parseFloat(e.shift()),isNaN(i)||i<.6||i>1.5?syntax(1,errs.bad_val,"%%voicescale"):curvoice.scale=i;break;case"score=":if(cfmt.sound)break;n=e.shift(),n.indexOf("/")<0&&(n+="/c"),curvoice.transp=get_transp(n);break;case"shift=":curvoice.shift=get_transp(e.shift());break;case"sound=":case"transpose=":if(!cfmt.sound)break;curvoice.transp=get_transp(e.shift());break;case"subname=":case"sname=":case"snm=":curvoice.snm=e.shift(),curvoice.snm[0]=='"'&&(curvoice.snm=curvoice.snm.slice(1,-1));break;case"stafflines=":i=get_st_lines(e.shift()),i==undefined?syntax(1,"Bad %%stafflines value"):curvoice.st!=undefined?par_sy.staves[curvoice.st].stafflines=i:curvoice.stafflines=i;break;case"staffnonote=":i=parseInt(e.shift()),isNaN(i)?syntax(1,"Bad %%staffnonote value"):curvoice.staffnonote=i;break;case"staffscale=":i=parseFloat(e.shift()),isNaN(i)||i<.3||i>2?syntax(1,"Bad %%staffscale value"):curvoice.staffscale=i;break;default:switch(n.slice(0,4)){case"treb":case"bass":case"alto":case"teno":case"perc":t=n;break;default:"GFC".indexOf(n[0])>=0?t=n:n.slice(-1)=="="&&e.shift()}}}if(r){curvoice.pos=clone(curvoice.pos);for(n in r)r.hasOwnProperty(n)&&(curvoice.pos[n]=r[n])}t&&(t=new_clef(t),t&&(s&&(t.clefpit=s),get_clef(t)))}function set_kv_parm(e){curvoice.init||(curvoice.init=!0,info.V&&(info.V["*"]&&(e=info.V["*"].concat(e)),info.V[curvoice.id]&&(e=info.V[curvoice.id].concat(e)))),e.length!=0&&self.set_vp(e)}function memo_kv_parm(e,t){if(t.length==0)return;info.V||(info.V={}),info.V[e]?Array.prototype.push.apply(info.V[e],t):info.V[e]=t}function new_key(e){var t,n,r,i,s,o=0,u={type:C.KEY,k_delta:0,dur:0};set_ref(u),t=1;switch(e[0]){case"A":u.k_sf=3;break;case"B":u.k_sf=5;break;case"C":u.k_sf=0;break;case"D":u.k_sf=2;break;case"E":u.k_sf=4;break;case"F":u.k_sf=-1;break;case"G":u.k_sf=1;break;case"H":switch(e[1]){case"P":case"p":u.k_bagpipe=e[1],u.k_sf=e[1]=="P"?0:2,t++;break;default:syntax(1,"Unknown bagpipe-like key")}break;case"P":syntax(1,"K:P is deprecated"),u.k_drum=!0,r=!0;break;case"n":e.indexOf("none")==0&&(u.k_sf=0,u.k_none=!0,t=4);default:r=!0}if(!r){switch(e[t]){case"#":u.k_sf+=7,t++;break;case"b":u.k_sf-=7,t++}e=e.slice(t).trim();switch(e.slice(0,3).toLowerCase()){default:if(e[0]!="m"||e[1]!=" "&&e[1]!=" "&&e[1]!="\n"){r=!0;break};case"aeo":case"m":case"min":u.k_sf-=3,o=5;break;case"dor":u.k_sf-=2,o=1;break;case"ion":case"maj":break;case"loc":u.k_sf-=5,o=6;break;case"lyd":u.k_sf+=1,o=3;break;case"mix":u.k_sf-=1,o=4;break;case"phr":u.k_sf-=4,o=2}r||(e=e.replace(/\w+\s*/,"")),e.indexOf("exp ")==0&&(e=e.replace(/\w+\s*/,""),e||syntax(1,"No accidental after 'exp'"),u.k_exp=!0),i=e[0];if(i=="^"||i=="_"||i=="="){u.k_a_acc=[],s=new scanBuf,s.buffer=e;do{var a=parse_acc_pit(s);if(!a)return[u,null];u.k_a_acc.push(a),i=e[s.index];while(i==" ")i=e[++s.index]}while(i=="^"||i=="_"||i=="=");e=e.slice(s.index)}else u.k_exp&&e.indexOf("none")==0&&(u.k_sf=0,e=e.replace(/\w+\s*/,""))}return u.k_delta=cgd2cde[(u.k_sf+7)%7],u.k_mode=o,[u,info_split(e,0)]}function new_meter(e){var t={type:C.METER,dur:0,a_meter:[]},n={},r,i,s=0,o,u=0,a,f,l=e,c;set_ref(t);if(l.indexOf("none")==0)u=4,f=1;else{f=0;while(u<e.length){if(l[u]=="=")break;switch(l[u]){case"C":n.top=l[u++],s||(s=4,o=4);break;case"c":case"o":n.top=l[u++];if(!s){l[-1]=="c"?(s=2,o=4):(s=3,o=4);switch(l[u]){case"|":o/=2;break;case".":s*=3,o*=2}}break;case".":case"|":n.top=l[u++];break;case"(":l[u+1]=="("&&(c=!0,n.top=l[u++],t.a_meter.push(n),n={}),a=u+1;while(a<e.length){if(l[a]==")"||l[a]=="/")break;a++}if(l[a]==")"&&l[a+1]=="/"){u++;continue};case")":c=l[u]=="(",n.top=l[u++],t.a_meter.push(n),n={};continue;default:if(l[u]<="0"||l[u]>"9"){syntax(1,"Bad char '$1' in M:",l[u]);return}o=2,n.top=l[u++];for(;;){while(l[u]>="0"&&l[u]<="9")n.top+=l[u++];if(l[u]==")"){if(l[u+1]!="/")break;u++}if(l[u]=="/"){u++;if(l[u]<="0"||l[u]>"9"){syntax(1,"Bad char '$1' in M:",l[u]);return}n.bot=l[u++];while(l[u]>="0"&&l[u]<="9")n.bot+=l[u++];break}if(l[u]!=" "&&l[u]!="+")break;if(u>=e.length||l[u+1]=="(")break;n.top+=l[u++]}s=parseInt(n.top)}c||(n.bot&&(o=parseInt(n.bot)),f+=s*C.BLEN/o),t.a_meter.push(n),n={};while(l[u]==" ")u++;l[u]=="+"&&(n.top=l[u++],t.a_meter.push(n),n={})}}if(l[u]=="="){r=l.substring(++u).match(/^(\d+)\/(\d+)$/);if(!r){syntax(1,"Bad duration '$1' in M:",l.substring(u));return}f=C.BLEN*r[1]/r[2]}t.wmeasure=f;if(parse.state!=3){info.M=e,glovar.meter=t;if(parse.state>=1){glovar.ulen||(f<=1||f>=C.BLEN*3/4?glovar.ulen=C.BLEN/8:glovar.ulen=C.BLEN/16);for(i=0;i<voice_tb.length;i++)voice_tb[i].meter=t,voice_tb[i].wmeasure=f}}else curvoice.wmeasure=f,is_voice_sig()?(curvoice.meter=t,reset_gen()):sym_link(t)}function new_tempo(e){var t=0,n,r,i,s,o={type:C.TEMPO,dur:0};set_ref(o),cfmt.writefields.indexOf("Q")<0&&(o.del=!0);if(e[0]=='"'){t=e.indexOf('"',1);if(t<0){syntax(1,"Unterminated string in Q:");return}o.tempo_str1=e.slice(1,t),t++;while(e[t]==" ")t++}s=new scanBuf,s.buffer=e,s.index=t;for(;;){r=e[s.index];if(r==undefined||r<="0"||r>"9")break;i=parse_dur(s),o.tempo_notes||(o.tempo_notes=[]),o.tempo_notes.push(C.BLEN*i[0]/i[1]);for(;;){r=e[s.index];if(r!=" ")break;s.index++}}if(r=="="){r=e[++s.index];while(r==" ")r=e[++s.index];t=s.index,r=="c"&&e[t+1]=="a"&&e[t+2]=="."&&e[t+3]==" "&&(o.tempo_ca="ca. ",s.index+=4),e[s.index+1]!="/"?o.tempo=s.get_int():(i=parse_dur(s),o.new_beat=C.BLEN*i[0]/i[1]),r=e[s.index];while(r==" ")r=e[++s.index]}if(r=='"'){s.index++,t=e.indexOf('"',s.index+1);if(t<0){syntax(1,"Unterminated string in Q:");return}o.tempo_str2=e.slice(s.index,t)}if(parse.state!=3){if(parse.state==1){info.Q=e,glovar.tempo=o;return}goto_tune()}curvoice.v==par_sy.top_voice&&(sym_link(o),glovar.tempo&&curvoice.time==0&&(glovar.tempo.del=!0))}function do_info(e,t){var n,r,i,s,o;switch(e){case"I":self.do_pscom(t);break;case"L":parse.state==2&&goto_tune(),s=t.match(/^1\/(\d+)(=(\d+)\/(\d+))?$/);if(s){r=Number(s[1]);if(!r||(r&r-1)!=0)break;r=C.BLEN/r;if(s[2]){i=Number(s[4]);if(!i||(i&i-1)!=0){i=0;break}i=Number(s[3])/i*C.BLEN}else i=r}else t=="auto"&&(r=i=-1);if(!i){syntax(1,"Bad L: value");break}parse.state<2?glovar.ulen=r:(curvoice.ulen=r,curvoice.dur_fact=i/r);break;case"M":new_meter(t);break;case"U":set_user(t);break;case"P":if(parse.state==0)break;if(parse.state==1){info.P=t;break}parse.state==2&&goto_tune();if(cfmt.writefields.indexOf(e)<0)break;n={type:C.PART,text:t,dur:0};var u=voice_tb[par_sy.top_voice];if(curvoice.v!=u.v){if(curvoice.time!=u.time)break;if(u.last_sym&&u.last_sym.type==C.PART)break;var a=curvoice;curvoice=u,sym_link(n),curvoice=a}else sym_link(n);break;case"Q":if(parse.state==0)break;new_tempo(t);break;case"V":get_voice(t);break;case"K":if(parse.state==0)break;get_key(t);break;case"N":case"R":info[e]?info[e]+="\n"+t:info[e]=t;break;case"r":if(!user.keep_remark||parse.state!=3)break;n={type:C.REMARK,text:t,dur:0},sym_link(n);break;default:syntax(0,"'$1:' line ignored",e)}}function adjust_dur(e){var t,n,r,i,s;t=curvoice.last_sym;if(!t)return;if(t.type==C.MREST||t.type==C.BAR)return;while(t.type!=C.BAR&&t.prev)t=t.prev;n=t.time,r=curvoice.time-n;if(n==0){while(t&&!t.dur)t=t.next;t&&t.type==C.REST&&t.invis&&(n+=t.dur*curvoice.wmeasure/r,t.prev?t.prev.next=t.next:curvoice.sym=t.next,t.next&&(t.next.prev=t.prev),t=t.next)}if(curvoice.wmeasure==r)return;for(;t;t=t.next){t.time=n;if(!t.dur||t.grace)continue;t.dur=t.dur*curvoice.wmeasure/r,t.dur_orig=t.dur_orig*curvoice.wmeasure/r,n+=t.dur;if(t.type!=C.NOTE&&t.type!=C.REST)continue;for(i=0;i<=t.nhd;i++)t.notes[i].dur=t.notes[i].dur*curvoice.wmeasure/r;s=identify_note(t,t.dur_orig),t.head=s[0],t.dots=s[1],t.nflags=s[2],t.nflags<=-2?t.stemless=!0:delete t.stemless}curvoice.time=e.time=n}function new_bar(){var e,t,n,r=parse.line,i={type:C.BAR,fname:parse.fname,istart:parse.bol+r.index,dur:0,multi:0};vover&&vover.bar&&get_vover("|"),glovar.new_nbar&&(i.bar_num=glovar.new_nbar,glovar.new_nbar=0),n=r.char();for(;;){t=r.next_char();switch(t){case"|":case"[":case"]":case":":n+=t;continue}break}n[0]==":"&&(n.length==1?(n="|",i.bar_dotted=!0):i.rbstop=2),a_gch&&self.gch_build(i),a_dcn&&(deco_cnv(a_dcn,i),a_dcn=null);switch(n.slice(-1)){case"[":if(/[0-9" ]/.test(t))break;n=n.slice(0,-1),r.index--,t="[";break;case":":i.rbstop=2}if(t>"0"&&t<="9"){n.slice(-1)=="["&&(n=n.slice(0,-1)),i.text=t;for(;;){t=r.next_char();if("0123456789,.-".indexOf(t)<0)break;i.text+=t}i.rbstop=2,i.rbstart=2}else if(t=='"'&&n.slice(-1)=="["){n=n.slice(0,-1),i.text="";for(;;){t=r.next_char();if(!t){syntax(1,"No end of repeat string");return}if(t=='"'){r.index++;break}t=="\\"&&(i.text+=t,t=r.next_char()),i.text+=t}i.text=cnv_escape(i.text),i.rbstop=2,i.rbstart=2}n[0]=="]"&&(i.rbstop=2,n.length!=1?n=n.slice(1):i.invis=!0),i.iend=parse.bol+r.index,i.rbstart&&curvoice.norepbra&&!curvoice.second&&(i.norepbra=!0),curvoice.ulen<0&&adjust_dur(i),e=curvoice.last_sym;if(e&&e.type==C.SPACE)e.time--;else if(e&&e.type==C.BAR){if(n=="["&&!e.text&&(curvoice.st==0||par_sy.staves[curvoice.st-1].flags&STOP_BAR||i.norepbra)){i.text&&(e.text=i.text),i.a_gch&&(e.a_gch=i.a_gch),i.norepbra&&(e.norepbra=i.norepbra),i.rbstart&&(e.rbstart=i.rbstart),i.rbstop&&(e.rbstop=i.rbstop);return}if(n=="|:"){if(e.bar_type==":|"){e.bar_type="::",e.rbstop=2;return}if(e.bar_type=="||"){e.bar_type="||:",e.rbstop=2;return}}}switch(n){case"[":i.rbstop=2;case"[]":case"[|]":i.invis=!0,n="[]";break;case":|:":case":||:":n="::";break;case"||":if(!cfmt.rbdbstop)break;case"[|":case"|]":i.rbstop=2}i.bar_type=n,curvoice.lyric_restart||(curvoice.lyric_restart=i),curvoice.sym_restart||(curvoice.sym_restart=i),e&&e.type==C.KEY&&(!e.prev||e.prev.type!=C.BAR)?(curvoice.last_sym=e.prev,e.prev||(curvoice.sym=e.prev),sym_link(i),i.next=e,e.prev=i,curvoice.last_sym=e):sym_link(i),i.st=curvoice.st,i.rbstart&&!curvoice.norepbra&&curvoice.st>0&&!(par_sy.staves[curvoice.st-1].flags&STOP_BAR)&&(e={type:C.BAR,fname:i.fname,istart:i.istart,iend:i.iend,bar_type:"[",multi:0,invis:!0,text:i.text,rbstart:2},sym_link(e),e.st=curvoice.st,delete i.text,i.rbstart=0)}function parse_staves(e){var t,n,r=[],i=!1,s=0,o=0,u=0,a=0,f=0,l=0;while(l<e.length){switch(e[l]){case" ":case" ":break;case"[":if(a||o+u>=2){syntax(1,errs.misplaced,"["),i=!0;break}s|=o+u==0?OPEN_BRACKET:OPEN_BRACKET2,u++,f<<=8,f|=OPEN_BRACKET;break;case"{":if(a||o||u>=2){syntax(1,errs.misplaced,"{"),i=!0;break}s|=u?OPEN_BRACE2:OPEN_BRACE,o++,f<<=8,f|=OPEN_BRACE;break;case"(":if(a){syntax(1,errs.misplaced,"("),i=!0;break}s|=OPEN_PARENTH,a++,f<<=8,f|=OPEN_PARENTH;break;case"*":o&&!a&&!(s&(OPEN_BRACE|OPEN_BRACE2))&&(s|=FL_VOICE);break;case"+":s|=MASTER_VOICE;break;default:if(!/\w/.test(e[l])){syntax(1,"Bad voice ID in %%staves"),i=!0;break}n="";while(l<e.length){if(" ()[]{}|*".indexOf(e[l])>=0)break;n+=e[l++]}for(;l<e.length;l++){switch(e[l]){case" ":case" ":continue;case"]":if(!(f&OPEN_BRACKET)){syntax(1,errs.misplaced,"]"),i=!0;break}u--,s|=o+u==0?CLOSE_BRACKET:CLOSE_BRACKET2,f>>=8;continue;case"}":if(!(f&OPEN_BRACE)){syntax(1,errs.misplaced,"}"),i=!0;break}o--,s|=u?CLOSE_BRACE2:CLOSE_BRACE,s&=~FL_VOICE,f>>=8;continue;case")":if(!(f&OPEN_PARENTH)){syntax(1,errs.misplaced,")"),i=!0;break}a--,s|=CLOSE_PARENTH,f>>=8;continue;case"|":s|=STOP_BAR;continue}break}r.push([n,s]),s=0;continue}l++}f!=0&&(syntax(1,"'}', ')' or ']' missing in %%staves"),i=!0);if(i||r.length==0)return;return r}function info_split(e){if(!e)return[];var t=e.match(/(".+?"|.+?)(\s+|=|$)/g);if(!t)return syntax(1,"Unterminated string"),[];for(var n=0;n<t.length;n++)t[n]=t[n].trim();return t}function identify_note(e,t){var n,r,i,r=0,s=t;s%12!=0&&syntax(1,"Invalid note duration $1",s),s/=12,s==0&&syntax(1,"Note too short");for(i=5;s!=0;s>>=1,i--)if(s&1)break;s>>=1;switch(s){case 0:break;case 1:r=1;break;case 3:r=2;break;case 7:r=3;break;default:syntax(1,"Invalid note duration $1",t),i+=(11-s)/4|0,r=4}i-=r;if(i>=0)n=C.FULL;else switch(i){default:syntax(1,"Note too long"),i=-4;case-4:n=C.SQUARE;break;case-3:n=cfmt.squarebreve?C.SQUARE:C.OVALBARS;break;case-2:n=C.OVAL;break;case-1:n=C.EMPTY}return[n,r,i]}function parse_dur(e){var t,n,r;return reg_dur.lastIndex=e.index,t=reg_dur.exec(e.buffer),t[0]?(n=t[1]||1,r=t[3]||1,t[3]||(r*=1<<t[2].length),e.index=reg_dur.lastIndex,[n,r]):[1,1]}function parse_acc_pit(e){var t,n,r,i,s,o,u=e.char();switch(u){case"^":u=e.next_char(),u=="^"?(n=2,u=e.next_char()):n=1;break;case"=":n=3,u=e.next_char();break;case"_":u=e.next_char(),u=="_"?(n=-2,u=e.next_char()):n=-1}if(n&&n!=3&&u>="1"&&u<="9"||u=="/")o=parse_dur(e),r=o[0],i=o[1],i==1?i=curvoice?curvoice.uscale:1:i*=2,u=e.char();s=ntb.indexOf(u)+16,u=e.next_char();if(s<16){syntax(1,"'$1' is not a note",e.buffer[e.index-1]);return}while(u=="'")s+=7,u=e.next_char();while(u==",")s-=7,u=e.next_char();return t={pit:s,shhd:0,shac:0,ti1:0},n&&(t.acc=n,r&&(t.micro_n=r,t.micro_d=i)),t}function note2abc(e){var t,n="abcdefg"[(e.pit+77)%7];e.acc&&(n=["__","_","","^","^^","="][e.acc+2]+n);for(t=e.pit;t>=30;t-=7)n+="'";for(t=e.pit;t<23;t+=7)n+=",";return n}function set_map(e){var t=maps[curvoice.map],n=note2abc(e);if(!t[n]){n="octave,"+n.replace(/[',]/g,"");if(!t[n]){n="key,"+"abcdefg"[(e.pit+77-curvoice.ckey.k_delta)%7];if(!t[n]){n="all";if(!t[n])return}}}e.map=t[n],e.map[1]&&(e.pit=e.map[1].pit,e.acc=e.map[1].acc)}function parse_basic_note(e,t){var n,r=parse_acc_pit(e);if(!r)return;return e.char()=="0"&&(parse.stemless=!0,e.index++),n=parse_dur(e),r.dur=t*n[0]/n[1],r}function parse_vpos(){var e,t=parse.line,n=0;t.buffer[t.index-1]=="."&&!a_dcn&&(n=C.SL_DOTTED);switch(t.next_char()){case"'":return t.index++,n+C.SL_ABOVE;case",":return t.index++,n+C.SL_BELOW}return n+C.SL_AUTO}function note_transp(e){var t,n,r,i,s,o,u,a,f,l,c=e.nhd,h=curvoice.okey.k_sf,p=curvoice.ckey.k_sf-h,d=cgd2cde[(p+28)%7],v=curvoice.vtransp;v<0&&d!=0&&(d-=7),d+=(v/3/12|0)*7;for(t=0;t<=c;t++){l=e.notes[t],r=l.pit,l.pit+=d,u=cde2fcg[(r+5+112)%7],s=l.acc;if(!s)if(!curvoice.okey.a_acc)h>0?u<h-1&&(s=1):h<0&&u>=h+6&&(s=-1);else for(n=0;n<curvoice.okey.a_acc.length;n++){o=curvoice.okey.a_acc[n];if((r+16*7-o.pit)%7==0){s=o.acc;break}}a=u+p,s&&s!=3&&(a+=s*7),u=(((a+1+21)/7|0)+2-3+160)%5,s=acc2[u];if(!l.acc)if(curvoice.ckey.k_none){if(s==3||acc_same_pitch(l.pit))continue}else{if(!curvoice.ckey.a_acc)continue;f=cgd2cde[(a+112)%7];for(n=0;n<curvoice.ckey.a_acc.length;n++)if((f+16*7-curvoice.ckey.a_acc[n].pits)%7==0)break;if(n<curvoice.ckey.a_acc.length)continue}u=l.acc,i=l.micro_d;if(i&&u!=s){r=l.micro_n;switch(s){case 3:r>i/2?(r-=i/2,l.micro_n=r,s=u):s=-u;break;case 2:r>i/2?(l.pit+=1,r-=i/2):r+=i/2,s=u,l.micro_n=r;break;case-2:r>=i/2?(l.pit-=1,r-=i/2):r+=i/2,s=u,l.micro_n=r}}l.acc=s}}function sort_pitch(e){e.notes=e.notes.sort(function(e,t){return e.pit-t.pit})}function new_note(e,t){var n,r,i,s,o,u,a,f,l,c,h,p,d,v=0,m=parse.line,g=a_dcn;a_dcn=null,parse.stemless=!1,r={type:C.NOTE,fname:parse.fname,stem:0,multi:0,nhd:0,xmx:0},r.istart=parse.bol+m.index,curvoice.color&&(r.color=curvoice.color),e?r.grace=!0:(a_gch&&self.gch_build(r),parse.repeat_n&&(r.repeat_n=parse.repeat_n,r.repeat_k=parse.repeat_k,parse.repeat_n=0)),s=m.char();switch(s){case"X":r.invis=!0;case"Z":r.type=C.MREST,s=m.next_char(),r.nmes=s>"0"&&s<="9"?m.get_int():1,r.dur=curvoice.wmeasure*r.nmes;if(curvoice.second){curvoice.time+=r.dur;return}r.nmes==1&&(r.type=C.REST,r.dur_orig=r.dur,r.notes=[{pit:18,dur:r.dur}]);break;case"y":r.type=C.SPACE,r.invis=!0,r.dur=0,s=m.next_char(),s>="0"&&s<="9"?r.width=m.get_int():r.width=10;break;case"x":r.invis=!0;case"z":r.type=C.REST,m.index++,c=parse_dur(m),r.dur_orig=(curvoice.ulen<0?15120:curvoice.ulen)*c[0]/c[1],r.dur=r.dur_orig*curvoice.dur_fact,r.notes=[{pit:18,dur:r.dur_orig}];break;case"[":i=!0,s=m.next_char();default:curvoice.uscale&&(r.uscale=curvoice.uscale),r.notes=[];for(;;){if(i)for(;;){if(!s)break;a=s.charCodeAt(0);if(a>=128){syntax(1,errs.not_ascii);return}u=char_tb[a];switch(u[0]){case"(":v<<=4,v+=parse_vpos(),s=m.char();continue;case"!":a_dcn||(a_dcn=[]);if(u.length>1)a_dcn.push(u.slice(1,-1));else{o="";for(;;){s=m.next_char();if(!s){syntax(1,"No end of decoration");return}if(s=="!")break;o+=s}a_dcn.push(o)}s=m.next_char();continue}break}n=parse_basic_note(m,r.grace?C.BLEN/4:curvoice.ulen<0?15120:curvoice.ulen);if(!n)return;curvoice.octave&&(n.pit+=curvoice.octave*7),curvoice.ottava&&(n.pit+=curvoice.ottava),v&&(n.sl1=v,r.sl1?r.sl1++:r.sl1=1,v=0),a_dcn&&(n.a_dcn=a_dcn,a_dcn=null),r.notes.push(n);if(!i)break;s=m.char();for(;;){switch(s){case")":n.sl2?n.sl2++:n.sl2=1,r.sl2?r.sl2++:r.sl2=1,s=m.next_char();continue;case"-":n.ti1=parse_vpos(),r.ti1=!0,s=m.char();continue;case".":s=m.next_char();if(s!="-"){syntax(1,"Misplaced dot");break}continue}break}if(s=="]"){m.index++,c=parse_dur(m),r.nhd=r.notes.length-1;for(a=0;a<=r.nhd;a++)n=r.notes[a],n.dur=n.dur*c[0]/c[1];break}}r.dur_orig=r.notes[0].dur,r.dur=r.notes[0].dur*curvoice.dur_fact}if(r.grace&&r.type!=C.NOTE){syntax(1,"Not a note in grace note sequence");return}if(r.notes){if(!r.grace){switch(curvoice.pos.stm){case C.SL_ABOVE:r.stem=1;break;case C.SL_BELOW:r.stem=-1;break;case C.SL_HIDDEN:r.stemless=!0}r.dur*=t,p=curvoice.brk_rhythm;if(p){curvoice.brk_rhythm=0,l=curvoice.last_note;if(p>0){f=p*2-1,r.dur=r.dur*f/p,r.dur_orig=r.dur_orig*f/p;for(a=0;a<=r.nhd;a++)r.notes[a].dur=r.notes[a].dur*f/p;l.dur/=p,l.dur_orig/=p;for(a=0;a<=l.nhd;a++)l.notes[a].dur/=p}else{p=-p,f=p*2-1,r.dur/=p,r.dur_orig/=p;for(a=0;a<=r.nhd;a++)r.notes[a].dur/=p;l.dur=l.dur*f/p,l.dur_orig=l.dur_orig*f/p;for(a=0;a<=l.nhd;a++)l.notes[a].dur=l.notes[a].dur*f/p}curvoice.time=l.time+l.dur,h=identify_note(l,l.dur_orig),l.head=h[0],l.dots=h[1],l.nflags=h[2],l.nflags<=-2?l.stemless=!0:delete l.stemless;for(l=l.next;l;l=l.next)l.time=curvoice.time}}else{var y=curvoice.ckey.k_bagpipe?8:4;for(a=0;a<=r.nhd;a++)r.notes[a].dur/=y;r.dur/=y,r.dur_orig/=y,e.stem&&(r.stem=e.stem)}r.type==C.NOTE?(h=identify_note(r,r.dur_orig),r.head=h[0],r.dots=h[1],r.nflags=h[2],r.nflags<=-2&&(r.stemless=!0)):(d=r.dur_orig,d==curvoice.wmeasure&&(d<C.BLEN*2?d=C.BLEN:d<C.BLEN*4?d=C.BLEN*2:d=C.BLEN*4),h=identify_note(r,d),r.head=h[0],r.dots=h[1],r.nflags=h[2]),curvoice.last_note=r}sym_link(r);if(r.type==C.NOTE){curvoice.vtransp&&note_transp(r);if(curvoice.map&&maps[curvoice.map])for(a=0;a<=r.nhd;a++)set_map(r.notes[a])}return cfmt.shiftunison&&(r.shiftunison=cfmt.shiftunison),e||(curvoice.lyric_restart||(curvoice.lyric_restart=r),curvoice.sym_restart||(curvoice.sym_restart=r)),g&&deco_cnv(g,r,r.prev),parse.stemless&&(r.stemless=!0),r.iend=parse.bol+m.index,r}function parse_music_line(){function h(e){var t,n,r;for(t=1,n=c.index+1;t<e.length;t++,n++){if(e[t]==c.buffer[n])continue;if(e[t]!="n")return;r=ntb.indexOf(c.buffer[n]);if(r<0)return;while(c.buffer[n+1]=="'")r+=7,n++;while(c.buffer[n+1]==",")r-=7,n++}return c.index=n,r}function p(e,t){var n,r,s="",o=e.length;for(i=0;i<o;i++){n=e[i];if(n>="h"&&n<="z"){r=t+n.charCodeAt(0)-"n".charCodeAt(0),n="";while(r<0)r+=7,n+=",";while(r>14)r-=7,n+="'";s+=ntb[r]+n}else s+=n}return s}function d(e,t){var n,r=c,i=parse.istart;parse.line=c=new scanBuf,parse.istart+=r.index,c.buffer=t?p(e,t):e,v(!0),parse.line=c=r,parse.istart=i}function v(i){var s,p,v,m,g,y,b,w,E;for(;;){s=c.char();if(!s)break;if(s==".")switch(c.buffer[c.index+1]){case"(":case"-":case"|":s=c.next_char()}p=s.charCodeAt(0);if(p>=128){syntax(1,errs.not_ascii),c.index++;break}if(!i&&maci[p]){w=0;for(m in mac){if(!mac.hasOwnProperty(m)||m[0]!=s)continue;if(m.indexOf("n")<0){if(c.buffer.indexOf(m,c.index)!=c.index)continue;c.index+=m.length}else{w=h(m);if(!w)continue}d(mac[m],w),w=1;break}if(w)continue}v=char_tb[p];switch(v[0]){case" ":g=curvoice.last_note,g&&(g.beam_end=!0,e&&(e.gr_shift=!0));break;case"\n":if(cfmt.barsperstaff)break;par_sy.voices[curvoice.v].range==0&&curvoice.last_sym&&(curvoice.last_sym.eoln=!0);break;case"&":if(e){syntax(1,errs.bad_char,s);break}s=c.next_char();if(s==")"){get_vover(")");break}get_vover("&");continue;case"(":s=c.next_char();if(s>"0"&&s<="9"){var S=c.get_int(),x=qplet_tb[S],T=S,s=c.char();if(s==":"){s=c.next_char(),s>"0"&&s<="9"&&(x=c.get_int(),s=c.char());if(s==":"){s=c.next_char();if(!(s>"0"&&s<="9")){syntax(1,"Invalid 'r' in tuplet");continue}T=c.get_int(),s=c.char()}}if(x==0||x==undefined)x=curvoice.wmeasure%9==0?3:2;u=o[++a],u||(o[a]=u={}),u.p=S,u.q=x,u.r=T,u.f=cfmt.tuplets,u.fact=f*x/S,f=u.fact;continue}if(s=="&"){if(e){syntax(1,errs.bad_char,s);break}get_vover("(");break}l<<=4,c.index--,l+=parse_vpos();continue;case")":if(curvoice.ignore)break;g=curvoice.last_sym;if(g)switch(g.type){case C.NOTE:case C.REST:case C.SPACE:break;default:g=null}if(!g){syntax(1,errs.bad_char,s);break}g.slur_end?g.slur_end++:g.slur_end=1;break;case"!":a_dcn||(a_dcn=[]);if(v.length>1)y=v.slice(1,-1);else{y="",b=c.index;for(;;){s=c.next_char();if(!s)break;if(s=="!")break;y+=s}if(!s){c.index=b,syntax(1,"No end of decoration");break}}ottava[y]&&set_ottava(y),a_dcn.push(y);break;case'"':parse_gchord(v);break;case"-":var N=0;if(!curvoice.last_note||curvoice.last_note.type!=C.NOTE){syntax(1,"No note before '-'");break}N=parse_vpos(),g=curvoice.last_note;for(b=0;b<=g.nhd;b++)g.notes[b].ti1?g.nhd==0&&syntax(1,"Too many ties"):g.notes[b].ti1=N;g.ti1=!0,e&&(e.ti1=!0);continue;case"[":var k=c.buffer[c.index+1];if('|[]: "'.indexOf(k)>=0||k>="1"&&k<="9"){if(e){syntax(1,errs.bar_grace);break}new_bar();continue}if(c.buffer[c.index+2]==":"){b=c.buffer.indexOf("]",c.index+1);if(b<0){syntax(1,"Lack of ']'");break}E=c.buffer.slice(c.index+3,b).trim(),parse.istart=parse.bol+c.index,parse.iend=parse.bol+ ++b,c.index=0,do_info(k,E),c.index=b;continue};case"n":g=self.new_note(e,f);if(!g)continue;g.type==C.NOTE&&l&&(g.slur_start=l,l=0);if(e){a>=0&&(g.in_tuplet=!0);continue}a>=0&&g.notes&&(g.in_tuplet=!0,a>0?(o[0].p&&(g.tp0=o[0].p,g.tq0=o[0].q,g.tf=o[0].f,o[0].p=0),o[0].r--,u.p&&(g.tp1=u.p,g.tq1=u.q,g.tf=u.f,u.p=0)):u.p&&(g.tp0=u.p,g.tq0=u.q,g.tf=u.f,u.p=0),u.r--,u.r==0&&(a--==0?(g.tp0?g.tp0=!1:g.te0=!0,f=1,curvoice.time=Math.round(curvoice.time),g.dur=curvoice.time-g.time):(g.tp1?g.tp1=!1:g.te1=!0,u=o[0],u.r==0?(a--,g.te0=!0,f=1,curvoice.time=Math.round(curvoice.time),g.dur=curvoice.time-g.time):f=u.fact)));continue;case"<":if(!curvoice.last_note){syntax(1,"No note before '<'");break}if(e){syntax(1,"Cannot have a broken rhythm in grace notes");break}w=s=="<"?1:-1;while(s=="<"||s==">")w*=2,s=c.next_char();curvoice.brk_rhythm=w;continue;case"i":break;case"{":if(e){syntax(1,"'{' in grace note");break}t=curvoice.last_note,curvoice.last_note=null,n=a_dcn,a_dcn=undefined,e={type:C.GRACE,fname:parse.fname,istart:parse.bol+c.index,dur:0,multi:0};switch(curvoice.pos.gst){case C.SL_ABOVE:e.stem=1;break;case C.SL_BELOW:e.stem=-1;break;case C.SL_HIDDEN:e.stem=2}sym_link(e),s=c.next_char();if(s=="/"){e.sappo=!0;break}continue;case"|":if(e){syntax(1,errs.bar_grace);break}s=c.buffer[c.index-1],new_bar(),s=="."&&(curvoice.last_sym.bar_dotted=!0);continue;case"}":g=curvoice.last_note;if(!e||!g){syntax(1,errs.bad_char,s);break}a_dcn&&syntax(1,"Decoration ignored"),g.gr_end=!0,e.extra=e.next,e.extra.prev=null,e.next=null,curvoice.last_sym=e,e=null;if(!g.prev&&!curvoice.ckey.k_bagpipe){for(b=0;b<=g.nhd;b++)g.notes[b].dur*=2;g.dur*=2,g.dur_orig*=2;var L=identify_note(g,g.dur_orig);g.head=L[0],g.dots=L[1],g.nflags=L[2]}curvoice.last_note=t,a_dcn=n;break;case"\\":s=c.buffer[c.index+1];if(!s){r=!0;break};default:syntax(1,errs.bad_char,s)}c.index++}}var e,t,n,r,s,o=[],u,a=-1,f=1,l=0,c=parse.line;if(parse.state!=3){if(parse.state!=2)return;goto_tune()}v();if(a>=0){syntax(1,"No end of tuplet");for(s=curvoice.last_note;s;s=s.prev){s.tp1&&(s.tp1=0);if(s.tp0){s.tp0=0;break}}}e&&(syntax(1,"No end of grace note sequence"),curvoice.last_sym=e.prev,curvoice.last_note=t,e.prev&&(e.prev.next=null)),cfmt.breakoneoln&&curvoice.last_note&&(curvoice.last_note.beam_end=!0);if(r||cfmt.barsperstaff)return;char_tb["\n".charCodeAt(0)]=="\n"&&par_sy.voices[curvoice.v].range==0&&curvoice.last_sym&&(curvoice.last_sym.eoln=!0)}function cwid(e){var t=e.charCodeAt(0);if(t>=128){if(t>=768&&t<880)return 0;t=97}return cw_tb[t]}function strwh(e){var t=gene.curfont,n=t.swfac,r=t.size,i=0,s,o,u,a=e.length;for(s=0;s<a;s++){u=e[s];switch(u){case"$":u=e[s+1];if(u=="0")t=gene.deffont;else{if(!(u>="1"&&u<="9")){u="$";break}t=get_font("u"+u)}s++,n=t.swfac,t.size>r&&(r=t.size);continue;case"&":o=e.indexOf(";",s),o>0&&o-s<10&&(s=o,u="a")}i+=cwid(u)*n}return gene.curfont=t,[i,r]}function set_font(e){typeof e=="string"&&(e=get_font(e)),gene.curfont=gene.deffont=e}function out_str(e){var t,n=gene.curfont,r=n;output+=e.replace(/<|>|&.*?;|&| |\$./g,function(e){switch(e[0]){case"<":return"&lt;";case">":return"&gt;";case"&":if(e=="&")return"&amp;";return e;case" ":return"  ";case"$":if(e[1]=="0")t=gene.deffont,use_font(t);else{if(!(e[1]>="1"&&e[1]<="9"))return e;t=get_font("u"+e[1])}e="";if(t==r)return e;r!=n&&(e="</tspan>"),r=t;if(r==n)return e;return e+'<tspan\n class="'+font_class(t)+'">'}}),r!=n&&(output+="</tspan>",gene.curfont=r)}function xy_str(e,t,n,r,i){var s=strwh(n)[1];t+=s*.2,output+='<text class="'+font_class(gene.curfont)+'" x="',out_sxsy(e,'" y="',t);switch(r){case"c":output+='" text-anchor="middle">';break;case"j":output+='" textLength="'+i.toFixed(2)+'">';break;case"r":output+='" text-anchor="end">';break;default:output+='">'}out_str(n),output+="</text>\n"}function xy_str_b(e,t,n){var r=strwh(n);output+='<rect class="stroke" x="',out_sxsy(e-2,'" y="',t+r[1]+1),output+='" width="'+(r[0]+4).toFixed(2)+'" height="'+(r[1]+3).toFixed(2)+'"/>\n',xy_str(e,t,n)}function trim_title(e,t){var n;if(cfmt.titletrim){n=e.lastIndexOf(", ");if(n<0||e[n+2]<"A"||e[n+2]>"Z")n=0;else if(cfmt.titletrim==1){if(n<e.length-7||e.indexOf(" ",n+3)>=0)n=0}else n<e.length-cfmt.titletrim-2&&(n=0)}return!t&&cfmt.writefields.indexOf("X")>=0&&(e=info.X+". "+e),n&&(e=e.slice(n+2).trim()+" "+e.slice(0,n)),cfmt.titlecaps?e.toUpperCase():e}function get_lwidth(){return(img.width-img.lm-img.rm-2)/cfmt.scale}function write_title(e,t){var n,r;if(!e)return;set_page(),e=trim_title(e,t),t?(set_font("subtitle"),r=cfmt.subtitlespace):(set_font("title"),r=cfmt.titlespace),vskip(strwh(e)[1]+r),cfmt.titleleft?xy_str(0,0,e):xy_str(get_lwidth()/2,0,e,"c")}function put_inf2r(e,t,n,r,i){if(!n){if(!r)return;n=r,r=null}r?xy_str(e,t,n+" ("+r+")",i):xy_str(e,t,n,i)}function str_skip(e){vskip(strwh(e)[1]*cfmt.lineskipfac)}function write_text(e,t){if(t=="s")return;set_font("text"),set_page();var n=get_lwidth(),r=gene.curfont.size,i=r*cfmt.lineskipfac,s=r*cfmt.parskipfac,o=block.started?function(){}:blk_out,u=block.started?svg_flush:blk_flush,a,f,l,c,h,p,d,v;o();switch(t){default:switch(t){case"c":l=n/2;break;case"r":l=n;break;default:l=0}f=0;for(;;){a=e.indexOf("\n",f);if(a<0){v=e.slice(f),str_skip(v),xy_str(l,0,v,t);break}if(a==f){vskip(s),u(),use_font(gene.curfont);while(e[a+1]=="\n")vskip(i),a++;if(a==e.length)break;o()}else v=e.slice(f,a),str_skip(v),xy_str(l,0,v,t);f=a+1}vskip(s),u();break;case"f":case"j":f=0;for(;;){a=e.indexOf("\n\n",f),a<0?c=e.slice(f):c=e.slice(f,a),c=c.split(/\s+/),h=p=0;for(f=0;f<c.length;f++)d=strwh(c[f]+" ")[0],h+=d,h>=n&&(v=c.slice(p,f).join(" "),str_skip(v),xy_str(0,0,v,t,n),p=f,h=d);h!=0&&(v=c.slice(p).join(" "),str_skip(v),xy_str(0,0,v)),vskip(s),u();if(a<0)break;while(e[a+2]=="\n")vskip(i),a++;if(a==e.length)break;o(),use_font(gene.curfont),f=a+2}}}function put_words(e){function f(e,t,n){var r=0,i,s;e[r]=="$"&&e[r+1]>="0"&&e[r+1]<="9"&&(r+=2),s=0,i=r;if(e[r]>="0"&&e[r]<="9"||e[r+1]=="."){while(r<e.length){r++;if(e[r]==" "||e[r-1]==":"||e[r-1]==".")break}s=r;while(e[r]==" ")r++}return s!=0&&xy_str(t,0,e.slice(i,s),"r"),r<e.length&&xy_str(t+5,0,e.slice(r),"l"),r>=e.length&&s==0}var t,n,r,i,s,o,u,a;blk_out(),set_font("words");var l=get_lwidth()/2,c=(l-45)/(cwid("a")*gene.curfont.swfac);i=0,e=e.split("\n"),s=e.length;for(n=0;n<s;n++){t=e[n];if(t.length>c){i=0;break}t?a=!0:a&&(i++,a=!1)}if(i>0){n=i=(i+1)/2|0,a=!1;for(u=0;u<s;u++){t=e[u],r=0;while(t[r]==" ")r++;if(r==t.length){if(a&&--n<=0)break;a=!1}else a=!0}o=u+1}else o=u=s;vskip(cfmt.wordsspace);for(n=0;n<u||o<s;n++)n<u&&e[n].length==0&&(blk_out(),use_font(gene.curfont)),vskip(cfmt.lineskipfac*gene.curfont.size),n<u&&f(e[n],45,0),o<s&&(f(e[o],20+l,1)&&--i==0&&(n<u?i++:o<e.length-1&&(l*=.6)),o++)}function put_history(){var e,t,n,r,i,s,o,u,a=cfmt.infoname.split("\n"),f=a.length;for(e=0;e<f;e++){n=a[e][0];if(cfmt.writefields.indexOf(n)<0)continue;r=info[n];if(!r)continue;i||(i=!0,set_font("history"),vskip(cfmt.textspace),s=gene.curfont.size*cfmt.lineskipfac),u=a[e].slice(2),u[0]=='"'&&(u=u.slice(1,-1)),vskip(s),xy_str(0,0,u),o=strwh(u)[0],r=r.split("\n"),xy_str(o,0,r[0]);for(t=1;t<r.length;t++)vskip(s),xy_str(o,0,r[t]);vskip(s*.3),blk_out(),use_font(gene.curfont)}}function write_headform(e){var t,n,r,i,s,o,u,a={},f=clone(info_font_init),l={A:cfmt.infospace,C:cfmt.composerspace,O:cfmt.composerspace,R:cfmt.infospace},c={},h="",p=cfmt.titleformat,d=0,v=0;for(;;){while(p[v]==" ")v++;if(v>=p.length)break;t=p[v++];if(t<"A"||t>"Z"){if(t=="+"){if(h.length==0||h.slice(-1)=="+")continue;h=h.slice(0,-1)+"+"}else t==","&&(h.slice(-1)=="+"&&(h=h.slice(0,-1)+"l"),h+="\n");continue}if(!a[t]){if(!info[t])continue;a[t]=info[t].split("\n"),c[t]=1}else c[t]++;h+=t;switch(p[v]){case"-":h+="l",v++;break;case"0":h+="c",v++;break;case"1":h+="r",v++;break;default:h+="c"}}h.slice(-1)=="+"&&(h=h.slice(0,-1)+"l"),h+="\n";var m={l:cfmt.titlespace,c:cfmt.titlespace,r:cfmt.titlespace},g={l:0,c:e*.5,r:e},y={},b;p=h,v=0;for(;;){y.l=y.c=y.r=o=0,d=v;for(;;){t=p[d++];if(t=="\n")break;i=p[d++];if(i=="+")i=p[d+1];else if(y[i]!=0)continue;b=a[t];if(!b)continue;r=f[t],r||(r="history"),n=get_font(r),u=n.size*1.1,l[t]&&(u+=l[t]),o<u&&(o=u),y[i]=u}m.l+=o-y.l,m.c+=o-y.c,m.r+=o-y.r;for(;;){t=p[v++];if(t=="\n")break;i=p[v++];if(a[t].length==0)continue;b=a[t].shift(),i=="+"&&(c[t]--,t=p[v++],i=p[v++],a[t].length>0&&(b?b+=" "+a[t].shift():b=" "+a[t].shift())),r=f[t],r||(r="history"),n=get_font(r),u=n.size*1.1,l[t]&&(u+=l[t]),set_font(n),s=g[i],o=m[i]+u;if(t=="Q"){if(!glovar.tempo.del){if(i!="l"){var w=tempo_width(glovar.tempo);i=="c"&&(w*=.5),s-=w}write_tempo(glovar.tempo,s,-o)}}else b&&xy_str(s,-o,b,i);t=="T"&&(r=f.T="subtitle",l.T=cfmt.subtitlespace);if(c[t]<=1){t=="T"&&(n=get_font(r),u=n.size*1.1,l[t]&&(u+=l[t]),set_font(n));while(a[t].length>0)o+=u,b=a[t].shift(),xy_str(s,-o,b,i)}c[t]--,m[i]=o}m.c>m.l&&(m.l=m.c),m.r>m.l&&(m.l=m.r);if(v>=h.length)break;m.c=m.r=m.l}vskip(m.l)}function write_heading(){var e,t,n,r,i,s,o,u,a=get_lwidth();blk_out(),vskip(cfmt.topspace);if(cfmt.titleformat){write_headform(a),vskip(cfmt.musicspace);return}if(info.T&&cfmt.writefields.indexOf("T")>=0){e=0;for(;;){t=info.T.indexOf("\n",e);if(t<0){write_title(info.T.substring(e),e!=0);break}write_title(info.T.slice(e,t),e!=0),e=t+1}}set_font("composer"),o=u=0,parse.ckey.k_bagpipe&&!cfmt.infoline&&cfmt.writefields.indexOf("R")>=0&&(s=info.R),s&&(xy_str(0,-cfmt.composerspace,s),o=cfmt.composerspace),n=info.A,cfmt.writefields.indexOf("C")>=0&&(r=info.C),cfmt.writefields.indexOf("O")>=0&&(i=info.O);if(r||i||cfmt.infoline){var f,l;vskip(cfmt.composerspace),cfmt.aligncomposer<0?(f=0,l=" "):cfmt.aligncomposer==0?(f=a*.5,l="c"):(f=a,l="r"),u=o;if(r||i){cfmt.aligncomposer>=0&&o!=u&&vskip(o-u),e=0;for(;;){vskip(gene.curfont.size),r?t=r.indexOf("\n",e):t=-1;if(t<0){put_inf2r(f,0,r?r.substring(e):null,i,l);break}xy_str(f,0,r.slice(e,t),l),o+=gene.curfont.size,e=t+1}u>o&&vskip(u-o)}s=s?null:info.R,(s||n)&&cfmt.infoline&&(set_font("info"),vskip(gene.curfont.size+cfmt.infospace),put_inf2r(a,0,s,n,"r"),o+=gene.curfont.size+cfmt.infospace)}else u=cfmt.composerspace;info.P&&cfmt.writefields.indexOf("P")>=0&&(set_font("parts"),o=cfmt.partsspace+gene.curfont.size-o,o>0&&(u+=o),u>.01&&vskip(u),xy_str(0,0,info.P),u=0),vskip(u+cfmt.musicspace)}function m_gl(e){return e.replace(/[Cco]\||[co]\.|./g,function(e){return mgls[e]})}function def_use(e){var t,n,r;if(defined_glyph[e])return;defined_glyph[e]=!0,r=glyphs[e];if(!r){error(1,null,"Unknown glyph: '$1'",e);return}n=0;for(;;){t=r.indexOf('xlink:href="#',n);if(t<0)break;t+=13,n=r.indexOf('"',t),def_use(r.slice(t,n))}defs+="\n"+r}function defs_add(e){var t,n,r,i,s,o=0;e=e.replace(/<!--.*?-->/g,"");for(;;){s=e.indexOf("<",o);if(s<0)break;t=e.indexOf('id="',s);if(t<0)break;t+=4,n=e.indexOf('"',t);if(n<0)break;r=e.slice(t,n),o=e.indexOf(">",n);if(o<0)break;if(e[o-1]=="/")o++;else{t=e.indexOf(" ",s);if(t<0)break;i=e.slice(s+1,t),o=e.indexOf("</"+i+">",o);if(o<0)break;o+=3+i.length}e.substr(s,7)=="<filter"?fulldefs+="\n"+e.slice(s,o):glyphs[r]=e.slice(s,o)}}function set_g(){stv_g.started&&(stv_g.started=!1,output+="</g>\n");if(stv_g.scale==1&&!stv_g.color)return;output+="<g ",stv_g.scale!=1&&(stv_g.st>=0?output+=staff_tb[stv_g.st].scale_str:output+=voice_tb[stv_g.v].scale_str),stv_g.color&&(stv_g.scale!=1&&(output+=" "),output+='style="color:'+stv_g.color+'"'),output+=">\n",stv_g.started=!0}function set_color(e){if(e==stv_g.color)return undefined;var t=stv_g.color;return stv_g.color=e,set_g(),t}function set_sscale(e){var t,n;e!=stv_g.st&&stv_g.scale!=1&&(stv_g.scale=0),t=e>=0?staff_tb[e].staffscale:1,e>=0&&t!=1?n=staff_tb[e].y:n=posy;if(t==stv_g.scale&&n==stv_g.dy)return;stv_g.scale=t,stv_g.dy=n,stv_g.st=e,set_g()}function set_scale(e){var t=e.p_v.scale;if(t==1){set_sscale(e.st);return}if(t==stv_g.scale&&stv_g.dy==posy)return;stv_g.scale=t,stv_g.dy=posy,stv_g.st=-1,stv_g.v=e.v,set_g()}function set_dscale(e,t){output&&(stv_g.st<0?staff_tb[0].output+=output:stv_g.scale==1?staff_tb[stv_g.st].output+=output:staff_tb[stv_g.st].sc_out+=output,output=""),e<0?stv_g.scale=1:stv_g.scale=t?1:staff_tb[e].staffscale,stv_g.st=e,stv_g.dy=0}function delayed_update(){var e,t,n;for(e=0;e<=nstaff;e++){staff_tb[e].sc_out&&(output+='<g transform="translate(0,'+(posy-staff_tb[e].y).toFixed(2)+") scale("+staff_tb[e].staffscale.toFixed(2)+')">\n'+staff_tb[e].sc_out+"</g>\n",staff_tb[e].sc_out="");if(!staff_tb[e].output)continue;output+='<g transform="translate(0,'+(-staff_tb[e].y).toFixed(2)+')">\n'+staff_tb[e].output+"</g>\n",staff_tb[e].output=""}}function anno_out(e,t,n){if(e.istart==undefined)return;var r=e.type,i=e.ymx-e.ymn+4,s=e.wl||2,o=e.wr||2;e.grace&&(r=C.GRACE),n(t||anno_type[r],e.istart,e.iend,e.x-s-2,staff_tb[e.st].y+e.ymn+i-2,s+o+4,i,e)}function a_start(e,t){anno_out(e,t,user.anno_start)}function a_stop(e,t){anno_out(e,t,user.anno_stop)}function empty_function(){}function out_XYAB(e,t,n,r,i){t=sx(t),n=sy(n),output+=e.replace(/X|Y|A|B|F|G/g,function(e){switch(e){case"X":return t.toFixed(2);case"Y":return n.toFixed(2);case"A":return r;case"B":return i;case"F":return r.toFixed(2);default:return i.toFixed(2)}})}function g_open(e,t,n,r,i){out_XYAB('<g transform="translate(X,Y',e,t),n&&(output+=") rotate("+n.toFixed(2)),r&&(i?output+=") scale("+r.toFixed(2)+", "+i.toFixed(2):output+=") scale("+r.toFixed(2)),output+=')">\n',stv_g.g++}function g_close(){stv_g.g--,output+="</g>\n"}function sx(e){return stv_g.g?e:(e+posx)/stv_g.scale}function sy(e){return stv_g.g?-e:stv_g.scale==1?posy-e:stv_g.st<0?(posy-e)/stv_g.scale:stv_g.dy-e}function out_sxsy(e,t,n){e=sx(e),n=sy(n),output+=e.toFixed(2)+t+n.toFixed(2)}function xypath(e,t,n){out_XYAB('<path class="A" d="mX Y\n',e,t,n?"fill":"stroke")}function xygl(e,t,n){var r=tgls[n];if(r&&!glyphs[n]){e+=r.x*stv_g.scale,t-=r.y,r.sc?out_XYAB('<text transform="translate(X,Y) scale(F)">B</text>\n',e,t,r.sc,r.c):out_XYAB('<text x="X" y="Y">A</text>\n',e,t,r.c);return}if(!glyphs[n]){error(1,null,"no definition of $1",n);return}def_use(n),out_XYAB('<use x="X" y="Y" xlink:href="#A"/>\n',e,t,n)}function out_acciac(e,t,n,r,i){i?(e-=1,t+=4):(e-=5,t-=4),out_XYAB('<path class="stroke" d="mX YlF G"/>\n',e,t,n,-r)}function out_bar(e,t,n,r){if(r){var i=(5*r).toFixed(2);r='stroke-dasharray="'+i+","+i+'" '}else r="";output+='<path class="stroke" stroke-width="1" '+r+'d="m'+(e+posx).toFixed(2)+" "+(posy-t).toFixed(2)+"v"+(-n).toFixed(2)+'"/>\n'}function out_bnum(e,t,n){out_XYAB('<text style="font:italic 12px serif"\n x="X" y="Y" text-anchor="middle">A</text>\n',e,t,n.toString())}function out_brace(e,t,n){e+=posx-6,t=posy-t,n/=24,output+='<text transform="translate('+e.toFixed(2)+","+t.toFixed(2)+") scale(2.5,"+n.toFixed(2)+')">'+tgls.brace.c+"</text>\n"}function out_bracket(e,t,n){e+=posx-5,t=posy-t-3,n+=2,output+='<path class="fill"\n d="m'+e.toFixed(2)+" "+t.toFixed(2)+"\n c10.5 1 12 -4.5 12 -3.5c0 1 -3.5 5.5 -8.5 5.5\n v"+n.toFixed(2)+'\n c5 0 8.5 4.5 8.5 5.5c0 1 -1.5 -4.5 -12 -3.5"/>\n'}function out_hyph(e,t,n){var r,i,s=25+(n/20|0)*3;n>15?r=(n-15)/s|0:r=0,e+=(n-s*r-5)/2,out_XYAB('<path class="stroke" stroke-width="1.2"\n stroke-dasharray="5,A"\n d="mX YhB"/>\n',e,t+6,Math.round((s-5)/stv_g.scale),s*r+5)}function out_stem(e,t,n,r,i,s){var o=r?GSTEM_XOFF:3.5,u=-n;n<0&&(o=-o),e+=o*stv_g.scale,stv_g.st<0&&(u/=stv_g.scale),out_XYAB('<path class="stroke" d="mX YvF"/>\n',e,t,u);if(!i)return;output+='<path class="fill"\n d="',t+=n;if(n>0)if(!s)if(!r)if(i==1)out_XYAB("MX Yc0.6 5.6 9.6 9 5.6 18.4\n 1.6 -6 -1.3 -11.6 -5.6 -12.8\n",e,t);else while(--i>=0)out_XYAB("MX Yc0.9 3.7 9.1 6.4 6 12.4\n 1 -5.4 -4.2 -8.4 -6 -8.4\n",e,t),t-=5.4;else if(i==1)out_XYAB("MX Yc0.6 3.4 5.6 3.8 3 10\n 1.2 -4.4 -1.4 -7 -3 -7\n",e,t);else while(--i>=0)out_XYAB("MX Yc1 3.2 5.6 2.8 3.2 8\n 1.4 -4.8 -2.4 -5.4 -3.2 -5.2\n",e,t),t-=3.5;else if(!r){t+=1;while(--i>=0)out_XYAB("MX Yl7 3.2 0 3.2 -7 -3.2z\n",e,t),t-=5.4}else while(--i>=0)out_XYAB("MX Yl3 1.5 0 2 -3 -1.5z\n",e,t),t-=3;else if(!s)if(!r)if(i==1)out_XYAB("MX Yc0.6 -5.6 9.6 -9 5.6 -18.4\n 1.6 6 -1.3 11.6 -5.6 12.8\n",e,t);else while(--i>=0)out_XYAB("MX Yc0.9 -3.7 9.1 -6.4 6 -12.4\n 1 5.4 -4.2 8.4 -6 8.4\n",e,t),t+=5.4;else if(i==1)out_XYAB("MX Yc0.6 -3.4 5.6 -3.8 3 -10\n 1.2 4.4 -1.4 7 -3 7\n",e,t);else while(--i>=0)out_XYAB("MX Yc1 -3.2 5.6 -2.8 3.2 -8\n 1.4 4.8 -2.4 5.4 -3.2 5.2\n",e,t),t+=3.5;else if(!r){t+=1;while(--i>=0)out_XYAB("MX Yl7 -3.2 0 -3.2 -7 3.2z\n",e,t),t+=5.4}output+='"/>\n'}function out_thbar(e,t,n){e+=posx+1.5,t=posy-t,output+='<path class="stroke" stroke-width="3" d="m'+e.toFixed(2)+" "+t.toFixed(2)+"v"+(-n).toFixed(2)+'"/>\n'}function out_trem(e,t,n){out_XYAB('<path class="fill" d="mX Y\n ',e-4.5,t);for(;;){output+="l9 -3v3l-9 3z";if(--n<=0)break;output+="m0 5.4"}output+='"/>\n'}function out_tubr(e,t,n,r,i){var s=i?-3:3;t+=s,n/=stv_g.scale,output+='<path class="stroke" d="m',out_sxsy(e," ",t),output+="v"+s.toFixed(2)+"l"+n.toFixed(2)+" "+(-r).toFixed(2)+"v"+(-s).toFixed(2)+'"/>\n'}function out_tubrn(e,t,n,r,i,s){var o=s.length*10,u=i?-3:3;out_XYAB('<text style="font:italic 12px serif"\n x="X" y="Y" text-anchor="middle">A</text>\n',e+n/2,t+r/2,s),n/=stv_g.scale,i||(t+=6),output+='<path class="stroke" d="m',out_sxsy(e," ",t),output+="v"+u.toFixed(2)+"m"+n.toFixed(2)+" "+(-r).toFixed(2)+"v"+(-u).toFixed(2)+'"/>\n'+'<path class="stroke" stroke-dasharray="'+((n-o)/2).toFixed(2)+" "+o.toFixed(2)+'" d="m',out_sxsy(e," ",t-u),output+="l"+n.toFixed(2)+" "+(-r).toFixed(2)+'"/>\n'}function out_wln(e,t,n){out_XYAB('<path class="stroke" stroke-width="0.8" d="mX YhF"/>\n',e,t+3,n)}function out_deco_str(e,t,n,r){var i,s,o=deco_str_style[n];if(!o){xygl(e,t,n);return}e+=o.dx,t+=o.dy,o.def||(style+="\n."+n+" {"+o.style+"}",o.def=!0),out_XYAB('<text x="X" y="Y" class="A"B>',e,t,n,o.anchor||""),set_font("annotation"),out_str(r),output+="</text>\n"}function out_arp(e,t,n){g_open(e,t,270),e=0,n=Math.ceil(n/6);while(--n>=0)xygl(e,6,"ltr"),e+=6;g_close()}function out_cresc(e,t,n,r){e+=n,n=-n,out_XYAB('<path class="stroke"\n d="mX YlA ',e,t+5,n),r.nost?output+="-2.2m0 -3.6l"+(-n).toFixed(2)+' -2.2"/>\n':output+="-4l"+(-n).toFixed(2)+' -4"/>\n'}function out_dim(e,t,n,r){out_XYAB('<path class="stroke"\n d="mX YlA ',e,t+5,n),r.noen?output+="-2.2m0 -3.6l"+(-n).toFixed(2)+' -2.2"/>\n':output+="-4l"+(-n).toFixed(2)+' -4"/>\n'}function out_ltr(e,t,n){t+=4,n=Math.ceil(n/6);while(--n>=0)xygl(e,t,"ltr"),e+=6}function out_8va(e,t,n,r){r.nost?n-=5:(out_XYAB('<text x="X" y="Y" style="font:italic bold 12px serif">8<tspan dy="-4" style="font-size:10px">va</tspan></text>\n',e-8,t),e+=12,n-=12),t+=6,out_XYAB('<path class="stroke" stroke-dasharray="6,6" d="mX YhA"/>\n',e,t,n),r.noen||out_XYAB('<path class="stroke" d="mX Yv6"/>\n',e+n,t)}function out_8vb(e,t,n,r){r.nost?n-=5:(out_XYAB('<text x="X" y="Y" style="font:italic bold 12px serif">8<tspan dy="-4" style="font-size:10px">vb</tspan></text>\n',e-8,t),e+=4,n-=4),out_XYAB('<path class="stroke" stroke-dasharray="6,6" d="mX YhA"/>\n',e,t,n),r.noen||out_XYAB('<path class="stroke" d="mX Yv-6"/>\n',e+n,t)}function out_15ma(e,t,n,r){r.nost?n-=5:(out_XYAB('<text x="X" y="Y" style="font:italic bold 12px serif">15<tspan dy="-4" style="font-size:10px">ma</tspan></text>\n',e-10,t),e+=20,n-=20),t+=6,out_XYAB('<path class="stroke" stroke-dasharray="6,6" d="mX YhA"/>\n',e,t,n),r.noen||out_XYAB('<path class="stroke" d="mX Yv6"/>\n',e+n,t)}function out_15mb(e,t,n,r){r.nost?n-=5:(out_XYAB('<text x="X" y="Y" style="font:italic bold 12px serif">15<tspan dy="-4" style="font-size:10px">mb</tspan></text>\n',e-10,t),e+=7,n-=7),out_XYAB('<path class="stroke" stroke-dasharray="6,6" d="mX YhA"/>\n',e,t,n),r.noen||out_XYAB('<path class="stroke" d="mX Yv-6"/>\n',e+n,t)}function out_deco_val(e,t,n,r,i){deco_val_tb[n]?deco_val_tb[n](e,t,r,i):error(1,null,"No function for decoration '$1'",n)}function out_glisq(e,t,n){var r=n.start,i=r.x,s=r.y+staff_tb[r.st].y,o=Math.atan2(s-t,e-i),u=o/Math.PI*180,a=(e-i)/Math.cos(o);g_open(i,s,u),i=r.s.dots?13+r.s.xmx:8,a=(a-i-6)/6|0,a<1&&(a=1);while(--a>=0)xygl(i,0,"ltr"),i+=6;g_close()}function out_gliss(e,t,n){var r=n.start,i=r.x,s=r.y+staff_tb[r.st].y,o=-Math.atan2(t-s,e-i),u=o/Math.PI*180,a=(e-i)/Math.cos(o);g_open(i,s,u),i=r.s.dots?13+r.s.xmx:8,a-=i+8,xypath(i,0),output+="l"+a.toFixed(2)+' 0" stroke-width="1"/>\n',g_close()}function out_deco_long(e,t,n){var r=n.dd.glyph;deco_l_tb[r]?deco_l_tb[r](e,t,n):error(1,null,"No function for decoration '$1'",r)}function vskip(e){posy+=e}function svg_flush(){if(multicol||!output||!user.img_out||posy==0)return;var e='<svg xmlns="http://www.w3.org/2000/svg" version="1.1"\n xmlns:xlink="http://www.w3.org/1999/xlink"\n color="black" class="music" stroke-width=".7"',t="";cfmt.bgcolor&&(e+=' style="background-color: '+cfmt.bgcolor+'"'),posy*=cfmt.scale,user.imagesize?e+="\n"+user.imagesize+' viewBox="0 0 '+img.width.toFixed(0)+" "+posy.toFixed(0)+'">\n':e+='\n width="'+img.width.toFixed(0)+'px" height="'+posy.toFixed(0)+'px">\n';if(style||font_style||musicfont)e+='<style type="text/css">'+style+font_style,musicfont&&(musicfont.indexOf("(")>0?e+='\n.music {font:24px music; fill:currentColor}\n@font-face {\n font-family:"music";\n src:'+musicfont+"}":e+="\n.music {font:24px "+musicfont+"; fill:currentColor}"),e+="\n</style>\n";defs+=fulldefs,defs&&(e+="<defs>"+defs+"\n</defs>\n"),cfmt.scale!=1&&(e+='<g class="g" transform="scale('+cfmt.scale.toFixed(2)+')">\n',t="</g>\n"),psvg&&psvg.ps_flush(!0),user.img_out(e+output+t+"</svg>"),output="",font_style="",cfmt.fullsvg?(defined_glyph={},defined_font={}):(musicfont="",style="",fulldefs=""),defs="",posy=0}function blk_out(){if(multicol||!user.img_out)return;blk_flush(),user.page_format&&!block.started&&(block.started=!0,block.newpage?(block.newpage=!1,user.img_out('<div class="nobrk newpage">')):user.img_out('<div class="nobrk">'))}function blk_flush(){svg_flush(),block.started&&(block.started=!1,user.img_out("</div>"))}function voice_filter(){var e,t,n;for(e in parse.voice_opts){if(!parse.voice_opts.hasOwnProperty(e))continue;t=new RegExp(e);if(t.test(curvoice.id)||t.test(curvoice.nm))for(n in parse.voice_opts[e])parse.voice_opts[e].hasOwnProperty(n)&&self.do_pscom(parse.voice_opts[e][n])}}function sym_link(e){e.fname||set_ref(e),curvoice.ignore||(parse.last_sym=e,e.prev=curvoice.last_sym,curvoice.last_sym?curvoice.last_sym.next=e:curvoice.sym=e,curvoice.last_sym=e),e.v=curvoice.v,e.p_v=curvoice,e.st=curvoice.cst,e.time=curvoice.time,e.dur&&!e.grace&&(curvoice.time+=e.dur),e.pos=curvoice.pos,curvoice.second&&(e.second=!0),curvoice.floating&&(e.floating=!0)}function sym_add(e,t){var n={type:t,dur:0},r,i=curvoice;return curvoice=e,sym_link(n),curvoice=i,r=n.prev,r||(r=n.next),r&&(n.fname=r.fname,n.istart=r.istart,n.iend=r.iend),n}function mrest_expand(e){var t,n,r,i=e.nmes,s=e.dur/i,o=e.a_dd;e.type=C.REST,e.dur=s,e.head=C.FULL,e.nflags=-2,r=e.next,t=e.p_v,t.last_sym=e,t.time=e.time+s,t.cst=e.st,n=e;while(--i>0)n=sym_add(t,C.BAR),n.bar_type="|",n=sym_add(t,C.REST),e.invis&&(n.invis=!0),n.dur=s,n.head=C.FULL,n.nflags=-2,t.time+=s;n.next=r,r&&(r.prev=n),n.a_dd=o}function sort_all(){var e,t,n,r,i,s,o,u,a,f,l,c,h,p,d=voice_tb.length,v=[],m=[],g=-1;for(r=0;r<d;r++)v.push(voice_tb[r].sym);var y=1,b=cur_sy;for(;;){if(b&&y){p=b,b=null,a=-1,m=[];for(r=0;r<d;r++){if(!p.voices[r]){p.voices[r]={range:-1};continue}u=p.voices[r].range;if(u<0)continue;m[u]=r,a++}}o=i=1e6;for(u=0;u<d;u++){r=m[u];if(r==undefined)break;e=v[r];if(!e||e.time>i)continue;s=w_tb[e.type],e.time<i?(i=e.time,o=s):s<o&&(o=s),e.type==C.MREST&&(e.nmes==1?mrest_expand(e):a>0&&(g=i))}if(o>127)break;if(i==g){l=0;for(u=0;u<d;u++){r=m[u];if(r==undefined)break;e=v[r];if(!e||e.time!=i||w_tb[e.type]!=o)continue;if(e.type!=C.MREST){g=-1;break}if(l==0)l=e.nmes;else if(l!=e.nmes){g=-1;break}}if(g<0)for(u=0;u<d;u++){r=m[u];if(r==undefined)break;e=v[r],e&&e.type==C.MREST&&mrest_expand(e)}}for(u=0;u<d;u++){r=m[u];if(r==undefined)break;e=v[r];if(!e||e.time!=i||w_tb[e.type]!=o)continue;if(e.type==C.STAVES){b=e.sy;for(c=0;c<d;c++)if(m[c]==undefined)break;for(h=0;h<d;h++){if(!b.voices[h])continue;u=b.voices[h].range;if(u<0||p.voices[h].range>=0)continue;m[c++]=h}}y&&(y=0,e.seqst=!0),e.ts_prev=f,f?f.ts_next=e:tsfirst=e,f=e,v[r]=e.next}y=o}}function voice_adj(){function i(e){var t,n,r,i,s,o,u,i=e.dur,a=1;for(t=e;t;t=t.next){if(t.beam_end||!t.next)break;a++}if(a<=1){delete e.feathered_beam;return}n=t,s=i/2,u=i/(a-1),r=e.time;if(e.feathered_beam>0)for(t=e,o=a-1;t!=n;t=t.next,o--)i=(u*o|0)+s,t.dur=i,t.time=r,r+=i;else for(t=e,o=0;t!=n;t=t.next,o++)i=(u*o|0)+s,t.dur=i,t.time=r,r+=i;t.dur=t.time+t.dur-r,t.time=r}var e,t,n,r;t=glovar.tempo,t&&staves_found<=0&&(r=par_sy.top_voice,e=voice_tb[r],e.sym&&e.sym.type!=C.TEMPO&&(t=clone(t),t.v=r,t.p_v=e,t.st=e.st,t.time=0,t.next=e.sym,t.next&&(t.next.prev=t),e.sym=t));for(r=0;r<voice_tb.length;r++){e=voice_tb[r],e.ignore&&(e.ignore=!1);for(t=e.sym;t;t=t.next)if(t.time>=staves_found)break;for(;t;t=t.next){switch(t.type){case C.GRACE:t.next&&t.next.type==C.BAR&&t.time--;if(!cfmt.graceword)continue;for(n=t.next;n;n=n.next){switch(n.type){case C.SPACE:continue;case C.NOTE:if(!n.a_ly)break;t.a_ly=n.a_ly,n.a_ly=null}break}continue}t.feathered_beam&&i(t)}}}function dupl_voice(){var e,t,n,r,i,s,o,u,a=voice_tb.length;for(o=0;o<a;o++){e=voice_tb[o],t=e.clone;if(!t)continue;e.clone=null;for(n=e.sym;n;n=n.next)if(n.time>=staves_found)break;t.clef=clone(e.clef),curvoice=t;for(;n;n=n.next){if(n.type==C.STAVES)continue;r=clone(n);if(n.notes){r.notes=[];for(u=0;u<=n.nhd;u++)r.notes.push(clone(n.notes[u]))}sym_link(r),t.second?r.second=!0:delete r.second,t.floating?r.floating=!0:delete r.floating,delete r.a_ly,i=r.extra;if(!i)continue;s=clone(i),r.extra=s,r=s,r.v=t.v,r.p_v=t,r.st=t.st;for(i=i.next;i;i=i.next){s=clone(i);if(i.notes){s.notes=[];for(u=0;u<=i.nhd;u++)s.notes.push(clone(i.notes[u]))}r.next=s,s.prev=r,r=s,r.v=t.v,r.p_v=t,r.st=t.st}}}}function new_syst(e){var t,n,r={voices:[],staves:[],top_voice:0};if(e){cur_sy=par_sy=r;return}for(n=0;n<voice_tb.length;n++){t=par_sy.voices[n].st;var i=par_sy.staves[t],s=voice_tb[n];s.staffnonote!=undefined&&(i.staffnonote=s.staffnonote),s.staffscale&&(i.staffscale=s.staffscale),r.voices[n]=clone(par_sy.voices[n]),r.voices[n].range=-1,delete r.voices[n].second}for(t=0;t<par_sy.staves.length;t++)r.staves[t]=clone(par_sy.staves[t]),r.staves[t].flags=0;par_sy.next=r,par_sy=r}function set_bar_num(){var e,t,n,r,i,s,o=cur_sy.top_voice,u=voice_tb[o].meter.wmeasure,a=gene.nbar;for(e=tsfirst;;e=e.ts_next){if(!e)return;switch(e.type){case C.METER:u=e.wmeasure;case C.CLEF:case C.KEY:case C.STBRK:continue;case C.BAR:if(e.bar_num){gene.nbar=e.bar_num;break}e.text&&!cfmt.contbarnb&&(e.text[0]=="1"?a=gene.nbar:(gene.nbar=a,e.bar_num=gene.nbar))}break}r=e.time+u;if(e.time==0)for(t=e.ts_next;t;t=t.ts_next)if(t.type==C.BAR&&t.time){t.time<r&&(e=t,r=e.time+u);break}i=gene.nbar;for(;e;e=e.ts_next)switch(e.type){case C.METER:u=e.wmeasure,e.time<r&&(r=e.time+u);break;case C.MREST:i+=e.nmes-1;while(e.ts_next&&e.ts_next.type!=C.BAR)e=e.ts_next;break;case C.BAR:e.bar_num&&(i=e.bar_num);if(e.time<r){e.text&&e.text[0]=="1"&&(a=i,s=r-e.time);break}n=e.time,t=e;do{if(t.dur)break;if(t.type==C.BAR&&t.text)break;t=t.next}while(t&&t.time==n);i++;if(t&&t.type==C.BAR&&t.text)if(t.text[0]=="1")s=0,a=i;else{cfmt.contbarnb||(i=a);if(s){cfmt.contbarnb&&i--,r=n+s;break}}e.bar_num=i,r=n+u;while(e.ts_next&&!e.ts_next.seqst)e=e.ts_next}cfmt.measurenb<0&&(gene.nbar=i)}function get_map(e){if(!e)return;var t,n,r,i,s,o,u=info_split(e,2);if(u.length<3){syntax(1,"Not enough parameters in %%map");return}o=u[1];if(o.indexOf("octave,")==0||o.indexOf("key,")==0)o=o.replace(/[,']+$/m,"").toLowerCase(),o[0]=="k"&&(o=o.replace(/[_=^]+/,""));else if(o[0]=="*"||o.indexOf("all")==0)o="all";else{s=new scanBuf,s.buffer=u[1],n=parse_acc_pit(s);if(!n){syntax(1,"Bad note in %%map");return}o=note2abc(n)}r=maps[u[0]],r||(maps[u[0]]=r={}),i=r[o],i||(r[o]=i=[]);if(!u[2])return;t=2;if(u[2].indexOf("=")<0){u[2][0]!="*"&&(s=new scanBuf,s.buffer=u[2],i[1]=parse_acc_pit(s));if(!u[3])return;t++,u[3].indexOf("=")<0&&(i[0]=u[3].split(","),t++)}for(;t<u.length;t++)switch(u[t]){case"heads=":i[0]=u[++t].split(",");break;case"print=":if(cfmt.sound=="play")break;s=new scanBuf,s.buffer=u[++t],i[1]=parse_acc_pit(s);break;case"color=":i[2]=u[++t]}}function set_transp(){var e,t,n;if(curvoice.ckey.k_bagpipe||curvoice.ckey.k_drum)return;cfmt.transp&&curvoice.transp&&syntax(0,"Mix of old and new transposition syntaxes"),t=(cfmt.transp||0)+(curvoice.transp||0)+(curvoice.shift||0),n=curvoice.vtransp||0;if(t==n)return;curvoice.vtransp=t,e=curvoice.last_sym;if(!e){curvoice.key=clone(curvoice.okey),key_transp(curvoice.key),curvoice.ckey=clone(curvoice.key),curvoice.key.k_none&&(curvoice.key.k_sf=0);return}for(;;){if(e.type==C.KEY)break;if(!e.prev){e=curvoice.key;break}e=e.prev}key_transp(e),curvoice.ckey=clone(e),curvoice.key.k_none&&(e.k_sf=0)}function set_ottava(e){if(cfmt.sound)return;switch(e){case"15ma(":curvoice.ottava=-14;break;case"8va(":curvoice.ottava=-7;break;case"8vb(":curvoice.ottava=7;break;case"15mb(":curvoice.ottava=14;break;case"15ma)":case"8va)":case"8vb)":case"15mb)":curvoice.ottava=0}}function do_pscom(e){var t,n,r,i,s,o,u,a,f=!1;e.slice(-5)==" lock"&&(f=!0,e=e.slice(0,-5).trim()),i=e.match(/(\w|-)+/);if(!i)return;i=i[0],s=e.replace(i,"").trim();switch(i){case"center":if(parse.state>=2){r=new_block("text"),r.text=cnv_escape(s),r.opt="c";return}write_text(cnv_escape(s),"c");return;case"clef":parse.state>=2&&(parse.state==2&&goto_tune(),r=new_clef(s),r&&get_clef(r));return;case"deco":deco_add(s);return;case"linebreak":set_linebreak(s);return;case"map":get_map(s);return;case"maxsysstaffsep":if(parse.state==3){par_sy.voices[curvoice.v].maxsep=get_unit(s);return}break;case"multicol":generate();switch(s){case"start":blk_out(),multicol={posy:posy,maxy:posy,lmarg:cfmt.leftmargin,rmarg:cfmt.rightmargin,state:parse.state};break;case"new":if(!multicol){syntax(1,"%%multicol new without start");break}posy>multicol.maxy&&(multicol.maxy=posy),cfmt.leftmargin=multicol.lmarg,cfmt.rightmargin=multicol.rmarg,img.chg=!0,set_page(),posy=multicol.posy;break;case"end":if(!multicol){syntax(1,"%%multicol end without start");break}posy<multicol.maxy&&(posy=multicol.maxy),cfmt.leftmargin=multicol.lmarg,cfmt.rightmargin=multicol.rmarg,multicol=undefined,blk_flush(),img.chg=!0,set_page();break;default:syntax(1,"Unknown keyword '$1' in %%multicol",s)}return;case"musicfont":musicfont=s;return;case"ottava":if(parse.state!=3){if(parse.state!=2)return;goto_tune()}o=parseInt(s);if(isNaN(o)||o<-2||o>2){syntax(1,errs.bad_val,"%%ottava");return}switch(curvoice.ottava){case 14:a="15mb)";break;case 7:a="8vb)";break;case-7:a="8va)";break;case-14:a="15ma)"}a&&(a_dcn||(a_dcn=[]),a_dcn.push(a),set_ottava(a));switch(o){case-2:a="15mb(";break;case-1:a="8vb(";break;case 0:return;case 1:a="8va(";break;case 2:a="15ma("}a_dcn||(a_dcn=[]),a_dcn.push(a),set_ottava(a);return;case"repbra":parse.state>=2&&(parse.state==2&&goto_tune(),curvoice.norepbra=!get_bool(s));return;case"repeat":if(parse.state!=3)return;if(!curvoice.last_sym){syntax(1,"%%repeat cannot start a tune");return}if(!s.length)o=1,u=1;else{a=s.split(/\s+/),o=parseInt(a[0]),u=parseInt(a[1]);if(isNaN(o)||o<1||curvoice.last_sym.type==C.BAR&&o>2){syntax(1,"Incorrect 1st value in %%repeat");return}if(isNaN(u))u=1;else if(u<1){syntax(1,"Incorrect 2nd value in %%repeat");return}}parse.repeat_n=curvoice.last_sym.type==C.BAR?o:-o,parse.repeat_k=u;return;case"sep":var l,c,h,p;set_page(),p=img.width-img.lm-img.rm,t=l=c=0,s&&(h=s.split(/\s+/),t=get_unit(h[0]),h[1]&&(l=get_unit(h[1]),h[2]&&(c=get_unit(h[2])))),t<1&&(t=14),l<1&&(l=t),c<1&&(c=90);if(parse.state>=2){r=new_block(i),r.x=(p-c)/2/cfmt.scale,r.l=c/cfmt.scale,r.sk1=t,r.sk2=l;return}blk_out(),vskip(t),output+='<path class="stroke"\n d="M',out_sxsy((p-c)/2/cfmt.scale," ",0),output+="h"+(c/cfmt.scale).toFixed(2)+'"/>\n',vskip(l),blk_flush();return;case"setbarnb":n=parseInt(s),isNaN(n)?syntax(1,"Bad %%setbarnb value"):parse.state>=2?glovar.new_nbar=n:cfmt.measurefirst=n;return;case"staff":if(parse.state!=3){if(parse.state!=2)return;goto_tune()}n=parseInt(s);if(isNaN(n)){syntax(1,"Bad %%staff value '$1'",s);return}var d;s[0]=="+"||s[0]=="-"?d=curvoice.cst+n:d=n-1;if(d<0||d>nstaff){syntax(1,"Bad %%staff number $1 (cur $2, max $3)",d,curvoice.cst,nstaff);return}delete curvoice.floating,curvoice.cst=d;return;case"staffbreak":if(parse.state!=3){if(parse.state!=2)return;goto_tune()}r={type:C.STBRK,dur:0},s[0]>="0"&&s[0]<="9"?(r.xmx=get_unit(s),s.slice(-1)=="f"&&(r.stbrk_forced=!0)):(r.xmx=14,s[0]=="f"&&(r.stbrk_forced=!0)),sym_link(r);return;case"stafflines":case"staffscale":case"staffnonote":self.set_v_param(i,s);return;case"staves":case"score":if(parse.state==0)return;get_staves(i,s);return;case"sysstaffsep":if(parse.state==3){par_sy.voices[curvoice.v].sep=get_unit(s);return}break;case"text":if(parse.state>=2){r=new_block(i),r.text=cnv_escape(s),r.opt=cfmt.textoption;return}write_text(cnv_escape(s),cfmt.textoption);return;case"transpose":if(cfmt.sound)return;switch(parse.state){case 0:cfmt.transp=0;case 1:case 2:cfmt.transp=(cfmt.transp||0)+get_transp(s);return}for(r=curvoice.last_sym;r;r=r.prev){switch(r.type){case C.NOTE:r=clone(curvoice.okey),r.k_old_sf=curvoice.ckey.k_sf,sym_link(r);break;case C.KEY:break;default:continue}break}do_info("V",curvoice.id+" shift="+s);return;case"tune":return;case"user":set_user(s);return;case"voicecolor":if(parse.state!=3){if(parse.state!=2)return;goto_tune()}curvoice.color=s;return;case"vskip":n=get_unit(s);if(n<0){syntax(1,"%%vskip cannot be negative");return}if(parse.state>=2){r=new_block(i),r.sk=n;return}vskip(n);return;case"newpage":case"leftmargin":case"rightmargin":case"pagescale":case"pagewidth":case"printmargin":case"scale":case"staffwidth":if(parse.state==3){r=new_block(i),r.param=s;return}if(i=="newpage"){blk_flush(),block.newpage=!0;return}}self.set_format(i,s,f)}function do_begin_end(e,t,n){var r,i,s,o;switch(e){case"js":js_inject(n);break;case"ml":parse.state>=2?(o=new_block(e),o.text=n):(svg_flush(),user.img_out(n));break;case"svg":i=0;for(;;){r=n.indexOf('<style type="text/css">\n',i);if(r<0)break;i=n.indexOf("</style>",r);if(i<0){syntax(1,"No </style> in %%beginsvg sequence");break}style+=n.slice(r+23,i).replace(/\s+$/,"")}i=0;for(;;){r=n.indexOf("<defs>\n",i);if(r<0)break;i=n.indexOf("</defs>",r);if(i<0){syntax(1,"No </defs> in %%beginsvg sequence");break}defs_add(n.slice(r+6,i))}break;case"text":s=get_textopt(t),s||(s=cfmt.textoption);if(parse.state>=2){o=new_block(e),o.text=cnv_escape(n),o.opt=s;break}write_text(cnv_escape(n),s)}}function generate(){var e,t;vover&&(syntax(1,"No end of voice overlay"),get_vover(vover.bar?"|":")"));if(voice_tb.length==0)return;voice_adj(),dupl_voice(),sort_all();if(!tsfirst)return;self.set_bar_num();if(!tsfirst)return;user.get_abcmodel&&user.get_abcmodel(tsfirst,voice_tb,anno_type,info),user.img_out&&self.output_music();for(e=0;e<voice_tb.length;e++)t=voice_tb[e],t.time=0,t.sym=t.last_sym=null,t.st=cur_sy.voices[e].st,t.second=cur_sy.voices[e].second,delete t.have_ly,t.hy_st=0,delete t.bar_start,delete t.slur_st,delete t.s_tie,delete t.s_rtie;staves_found=0}function key_transp(e){var t=curvoice.vtransp/3|0,n=(t&-2)+(t&1)*7+e.k_sf;switch((curvoice.vtransp+210)%3){case 1:n=(n+4+48)%12-4;break;case 2:n=(n+7+48)%12-7;break;default:n=(n+5+48)%12-5}e.k_sf=n,e.k_delta=cgd2cde[(n+7)%7]}function set_k_acc(e){var t,n,r,i,s,o=[],u=[],a=[],f=[];if(e.k_sf>0)for(i=0;i<e.k_sf;i++)o[i]=1,u[i]=[26,23,27,24,21,25,22][i];else for(i=0;i<-e.k_sf;i++)o[i]=-1,u[i]=[22,25,21,24,20,23,26][i];r=e.k_a_acc.length;for(t=0;t<r;t++){s=e.k_a_acc[t];for(n=0;n<i;n++)if(u[n]==s.pit){o[n]=s.acc,s.micro_n&&(a[n]=s.micro_n,f[n]=s.micro_d);break}n==i&&(o[n]=s.acc,u[n]=s.pit,s.micro_n&&(a[n]=s.micro_n,f[n]=s.micro_d),i++)}for(t=0;t<i;t++)s=e.k_a_acc[t],s||(s=e.k_a_acc[t]={}),s.acc=o[t],s.pit=u[t],a[t]?(s.micro_n=a[t],s.micro_d=f[t]):(delete s.micro_n,delete s.micro_d)}function acc_same_pitch(e){var t,n,r=curvoice.last_sym.prev;if(!r)return;n=r.time;for(;r;r=r.prev)switch(r.type){case C.BAR:if(r.time<n)return;for(;;){r=r.prev;if(!r)return;if(r.type==C.NOTE){if(r.time+r.dur==n)break;return}if(r.time<n)return}for(t=0;t<=r.nhd;t++)if(r.notes[t].pit==e&&r.notes[t].ti1)return r.notes[t].acc;return;case C.NOTE:for(t=0;t<=r.nhd;t++)if(r.notes[t].pit==e)return r.notes[t].acc}return}function get_staves(e,t){var n,r,i,s,o,u,a,f,l,c=parse_staves(t);if(!c)return;voice_tb.length!=0&&(voice_adj(),dupl_voice());var h=0,p=!0;for(u=0;u<voice_tb.length;u++)r=voice_tb[u],r.time>h&&(h=r.time),r.sym&&(p=!1);if(p||h==0&&staves_found<0)for(u=0;u<par_sy.voices.length;u++)par_sy.voices[u].range=-1;else{for(u=0;u<par_sy.voices.length;u++)if(par_sy.voices[u].range>=0){curvoice=voice_tb[u];break}curvoice.time=h,n={type:C.STAVES,dur:0},sym_link(n),par_sy.nstaff=nstaff,new_syst(),n.sy=par_sy}staves_found=h;for(u=0;u<voice_tb.length;u++)r=voice_tb[u],delete r.second,delete r.ignore,delete r.floating;l=0;for(s=0;s<c.length;s++){a=c[s][0],r=new_voice(a),r.time=h,u=r.v,s==0&&(par_sy.top_voice=r.v);if(par_sy.voices[u].range>=0){i=clone(r),par_sy.voices[voice_tb.length]=clone(par_sy.voices[u]),u=voice_tb.length,i.v=u,i.sym=i.last_sym=null,i.time=h,voice_tb.push(i),delete i.clone;while(r.clone)r=r.clone;r.clone=i,r=i}c[s][0]=r,par_sy.voices[u].range=l++}if(e[1]=="t")for(s=0;s<c.length;s++){o=c[s][1];if(!(o&(OPEN_BRACE|OPEN_BRACE2)))continue;if((o&(OPEN_BRACE|CLOSE_BRACE))==(OPEN_BRACE|CLOSE_BRACE)||(o&(OPEN_BRACE2|CLOSE_BRACE2))==(OPEN_BRACE2|CLOSE_BRACE2))continue;if(c[s+1][1]!=0)continue;if(o&OPEN_PARENTH||c[s+2][1]&OPEN_PARENTH)continue;c[s+2][1]&(CLOSE_BRACE|CLOSE_BRACE2)?c[s+1][1]|=FL_VOICE:c[s+2][1]==0&&c[s+3][1]&(CLOSE_BRACE|CLOSE_BRACE2)&&(c[s][1]|=OPEN_PARENTH,c[s+1][1]|=CLOSE_PARENTH,c[s+2][1]|=OPEN_PARENTH,c[s+3][1]|=CLOSE_PARENTH)}f=-1;for(s=0;s<c.length;s++){o=c[s][1],(o&(OPEN_PARENTH|CLOSE_PARENTH))==(OPEN_PARENTH|CLOSE_PARENTH)&&(o&=~(OPEN_PARENTH|CLOSE_PARENTH),c[s][1]=o),r=c[s][0],o&FL_VOICE?(r.floating=!0,r.second=!0):(f++,par_sy.staves[f]||(par_sy.staves[f]={stafflines:"|||||",staffscale:1}),par_sy.staves[f].flags=0),u=r.v,r.st=r.cst=par_sy.voices[u].st=f,par_sy.staves[f].flags|=o;if(o&OPEN_PARENTH){i=r;while(s<c.length-1){r=c[++s][0],u=r.v,c[s][1]&MASTER_VOICE?(i.second=!0,i=r):r.second=!0,r.st=r.cst=par_sy.voices[u].st=f;if(c[s][1]&CLOSE_PARENTH)break}par_sy.staves[f].flags|=c[s][1]}}f<0&&(f=0),par_sy.nstaff=nstaff=f;if(e[1]=="c")for(f=0;f<nstaff;f++)par_sy.staves[f].flags^=STOP_BAR;for(u=0;u<voice_tb.length;u++){r=voice_tb[u];if(par_sy.voices[u].range<0){r.ignore=!0;continue}par_sy.voices[u].second=r.second,f=r.st,f>0&&!r.norepbra&&!(par_sy.staves[f-1].flags&STOP_BAR)&&(r.norepbra=!0)}curvoice=parse.state>=2?voice_tb[par_sy.top_voice]:null}function get_vover(e){function l(e){var t,n;for(t=0;t<voice_tb.length;t++){n=voice_tb[t];if(n.id==e)return n}return n=clone(curvoice),n.v=voice_tb.length,n.id=e,n.sym=n.last_sym=null,delete n.nm,delete n.snm,delete n.new_name,delete n.lyric_restart,delete n.lyric_cont,delete n.ly_a_h,delete n.sym_restart,delete n.sym_cont,delete n.have_ly,voice_tb.push(n),n}var t,n,r,i,s,o,u,a,f=parse.line;if(curvoice.ignore)return;if(e=="|"||e==")"){if(!curvoice.last_note){syntax(1,errs.nonote_vo);return}curvoice.last_note.beam_end=!0;if(!vover){syntax(1,"Erroneous end of voice overlay");return}curvoice.time!=vover.p_voice.time&&(syntax(1,"Wrong duration in voice overlay"),curvoice.time>vover.p_voice.time&&(vover.p_voice.time=curvoice.time)),curvoice=vover.p_voice,vover=null;return}if(e=="("){if(vover){syntax(1,"Voice overlay already started");return}vover={p_voice:curvoice,time:curvoice.time};return}if(!curvoice.last_note){syntax(1,errs.nonote_vo);return}curvoice.last_note.beam_end=!0,t=curvoice.voice_down;if(!t){t=l(curvoice.id+"o"),curvoice.voice_down=t,t.time=0,t.second=!0,u=t.v,par_sy.voices[u]={st:curvoice.st,second:!0};var c=curvoice.clone!=undefined?1:0;r=par_sy.voices[curvoice.v].range;for(o=0;o<par_sy.voices.length;o++)par_sy.voices[o].range>r&&(par_sy.voices[o].range+=c+1);par_sy.voices[u].range=r+1,c&&(n=l(t.id+"c"),n.second=!0,a=n.v,par_sy.voices[a]={second:!0,range:r+2},t.clone=n)}t.ulen=curvoice.ulen,t.dur_fact=curvoice.dur_fact,curvoice.uscale&&(t.uscale=curvoice.uscale);if(!vover){vover={bar:!0,p_voice:curvoice},s=t.time;for(i=curvoice.last_sym;;i=i.prev)if(i.type==C.BAR||i.time<=s)break;vover.time=i.time}else curvoice!=vover.p_voice&&curvoice.time!=vover.p_voice.time&&(syntax(1,"Wrong duration in voice overlay"),curvoice.time>vover.p_voice.time&&(vover.p_voice.time=curvoice.time));t.time=vover.time,curvoice=t}function is_voice_sig(){var e;if(!curvoice.sym)return!0;if(curvoice.time!=0)return!1;for(e=curvoice.last_sym;e;e=e.prev)if(w_tb[e.type]!=0)return!1;return!0}function get_clef(e){var t,n;if(is_voice_sig()){curvoice.clef=e;return}for(t=curvoice.last_sym;t&&t.prev&&t.time==curvoice.time;t=t.prev)if(w_tb[t.type]!=0)break;if(t&&t.prev&&t.time==curvoice.time&&(t.type==C.KEY&&!t.k_none||t.type==C.BAR)){for(n=t;n.prev;n=n.prev){switch(n.prev.type){case C.KEY:case C.BAR:continue}break}t=curvoice.last_sym,curvoice.last_sym=n.prev,sym_link(e),e.next=n,n.prev=e,curvoice.last_sym=t}else sym_link(e);e.clef_small=!0}function get_key(e){var t,n,r,i,s=new_key(e),o=s[0];s=s[1],o.k_sf&&!o.k_exp&&o.k_a_acc&&set_k_acc(o);switch(parse.state){case 1:o.k_sf==undefined&&!o.k_a_acc&&(o.k_sf=0,o.k_none=!0);for(t=0;t<voice_tb.length;t++)n=voice_tb[t],n.key=clone(o),n.okey=clone(o),n.ckey=clone(o);parse.ckey=o,s.length!=0&&memo_kv_parm("*",s),glovar.ulen||(glovar.ulen=C.BLEN/8),parse.state=2,set_page(),write_heading(),reset_gen(),gene.nbar=cfmt.measurefirst;return;case 2:goto_tune(!0)}s.length!=0&&set_kv_parm(s),!curvoice.ckey.k_bagpipe&&!curvoice.ckey.k_drum&&(i=(cfmt.transp||0)+(curvoice.transp||0)+(curvoice.shift||0));if(o.k_sf==undefined){if(!o.k_a_acc&&!i)return;o.k_sf=curvoice.okey.k_sf}curvoice.okey=clone(o),i&&(curvoice.vtransp=i,key_transp(o)),o.k_old_sf=curvoice.ckey.k_sf,curvoice.ckey=o;if(is_voice_sig()){curvoice.key=clone(o),o.k_none&&(curvoice.key.k_sf=0);return}r=curvoice.last_sym,r&&r.type==C.METER?(curvoice.last_sym=r.prev,curvoice.last_sym||(curvoice.sym=null),sym_link(o),o.next=r,r.prev=o,curvoice.last_sym=r):sym_link(o)}function new_voice(e){var t,n,r,i=voice_tb.length;if(i==1&&voice_tb[0].default){delete voice_tb[0].default;if(voice_tb[0].time==0)return t=voice_tb[0],t.id=e,cfmt.transp&&parse.state>=2&&(r=curvoice,curvoice=t,set_transp(),curvoice=r),t}for(n=0;n<i;n++){t=voice_tb[n];if(t.id==e)return t}return t={v:n,id:e,time:0,"new":!0,pos:{dyn:0,gch:0,gst:0,orn:0,stm:0,voc:0,vol:0},scale:1,ulen:glovar.ulen,dur_fact:1,key:clone(parse.ckey),ckey:clone(parse.ckey),okey:clone(parse.ckey),meter:clone(glovar.meter),wmeasure:glovar.meter.wmeasure,clef:{type:C.CLEF,clef_auto:!0,clef_type:"a",time:0},hy_st:0},voice_tb.push(t),par_sy.voices[n]={range:-1},t}function init_tune(){nstaff=-1,voice_tb=[],curvoice=null,new_syst(!0),staves_found=-1,gene={},a_de=[],od={}}function do_cloning(e){var t,n,r=parse.file,i=parse.eol+1,s=i;for(;;){n=r.indexOf("\n",s);if(n<0){n=0;break}if(/%.*|\n.*|.:.|\[.:/.test(r.slice(n+1,n+4)))break;s=n+1}include++,tosvg(parse.fname,r,i,n);for(t=0;t<e.length;t++)get_voice(e[t]),tosvg(parse.fname,r,i,n);include--}function get_voice(e){var t,n,r,i,s=info_split(e,1),o=s.shift();if(!o)return;o.indexOf(",")>0&&(i=o.split(","),o=i.shift());if(parse.state<2){s.length!=0&&memo_kv_parm(o,s),o!="*"&&parse.state==1&&new_voice(o);return}if(o=="*"){syntax(1,"Cannot have V:* in tune body");return}curvoice=new_voice(o),set_kv_parm(s),parse.state==2&&goto_tune(),set_transp(),t=curvoice.v,curvoice.new&&(delete curvoice.new,staves_found<0&&(curvoice.st=curvoice.cst=++nstaff,par_sy.nstaff=nstaff,par_sy.voices[t].st=nstaff,par_sy.voices[t].range=t,par_sy.staves[nstaff]={stafflines:curvoice.stafflines||"|||||",staffscale:1}),par_sy.voices[t].range<0&&staves_found>=0&&(curvoice.ignore=!0)),!curvoice.filtered&&!curvoice.ignore&&parse.voice_opts&&(curvoice.filtered=!0,voice_filter()),i&&do_cloning(i)}function goto_tune(e){var t,n,r={type:C.STAVES,dur:0,sy:par_sy};parse.state=3,voice_tb.length==0?(get_voice("1"),curvoice.clef.istart=curvoice.key.istart,curvoice.clef.iend=curvoice.key.iend,curvoice.default=!0):curvoice||(curvoice=voice_tb[staves_found<0?0:par_sy.top_voice]),!curvoice.init&&!e&&(set_kv_parm([]),set_transp());for(t=0;t<voice_tb.length;t++)n=voice_tb[t],n.ulen=glovar.ulen,n.ckey.k_bagpipe&&!n.pos.stm&&(n.pos=clone(n.pos),n.pos.stm=C.SL_BELOW);if(staves_found<0){nstaff=voice_tb.length-1;for(t=0;t<=nstaff;t++)n=voice_tb[t],delete n.new,n.st=n.cst=par_sy.voices[t].st=par_sy.voices[t].range=t,par_sy.staves[t]={stafflines:n.stafflines||"|||||",staffscale:1};par_sy.nstaff=nstaff}n=curvoice,curvoice=voice_tb[par_sy.top_voice],sym_link(r),curvoice=n}function get_sym(e,t){var n,r,i,s,o;if(curvoice.ignore)return;if(t){n=curvoice.sym_cont;if(!n){syntax(1,"+: symbol line without music");return}}else{curvoice.sym_restart?(curvoice.sym_start=n=curvoice.sym_restart,curvoice.sym_restart=null):n=curvoice.sym_start,n||(n=curvoice.sym);if(!n){syntax(1,"s: without music");return}}i=0;for(;;){while(e[i]==" "||e[i]==" ")i++;r=e[i];if(!r)break;switch(r){case"|":while(n&&n.type!=C.BAR)n=n.next;if(!n){syntax(1,"Not enough measure bars for symbol line");return}n=n.next,i++;continue;case"!":case'"':s=++i,i=e.indexOf(r,s);if(i<0){syntax(1,r=="!"?"No end of decoration":"No end of guitar chord"),i=e.length;continue}o=e.slice(s-1,i+1);break;case"*":break;default:o=r.charCodeAt(0);if(o<128){o=char_tb[o];if(o.length>1&&(o[0]=="!"||o[0]=='"')){r=o[0];break}}syntax(1,errs.bad_char,r)}while(n&&(n.type!=C.NOTE||n.grace))n=n.next;if(!n){syntax(1,"Too many elements in symbol line");return}switch(r){default:break;case"!":deco_cnv([o.slice(1,-1)],n,n.prev);break;case'"':a_gch=n.a_gch,parse_gchord(o),a_gch&&self.gch_build(n)}n=n.next,i++}curvoice.lyric_cont=n}function get_lyrics(e,t){var n,r,i,s,o,u;if(curvoice.ignore)return;curvoice.pos.voc!=C.SL_HIDDEN&&(curvoice.have_ly=!0);if(t){n=curvoice.lyric_cont;if(!n){syntax(1,"+: lyric without music");return}}else{set_font("vocal"),curvoice.lyric_restart?(curvoice.lyric_start=n=curvoice.lyric_restart,curvoice.lyric_restart=null,curvoice.lyric_line=0):(curvoice.lyric_line++,n=curvoice.lyric_start),n||(n=curvoice.sym);if(!n){syntax(1,"w: without music");return}}i=e,s=0;for(;;){while(i[s]==" "||i[s]==" ")s++;if(!i[s])break;o=parse.istart+s+2;switch(i[s]){case"|":while(n&&n.type!=C.BAR)n=n.next;if(!n){syntax(1,"Not enough measure bars for lyric line");return}n=n.next,s++;continue;case"-":r="-\n";break;case"_":r="_\n";break;case"*":r="";break;default:if(i[s]=="\\"&&s==i.length-1){curvoice.lyric_cont=n;return}r="";for(;;){if(!i[s])break;switch(i[s]){case"_":case"*":case"|":s--;case" ":case" ":break;case"~":r+=" ",s++;continue;case"-":r+="\n";break;case"\\":r+=i[++s],s++;continue;default:r+=i[s++];continue}break}}while(n&&(n.type!=C.NOTE||n.grace))n=n.next;if(!n){syntax(1,"Too many words in lyric line");return}r&&n.pos.voc!=C.SL_HIDDEN&&(r.match(/^\$\d/)&&(r[1]=="0"?set_font("vocal"):set_font("u"+r[1]),r=r.slice(2)),u={t:r,font:gene.curfont,w:strwh(r)[0],istart:o,iend:o+r.length},n.a_ly||(n.a_ly=[]),n.a_ly[curvoice.lyric_line]=u),n=n.next,s++}curvoice.lyric_cont=n}function ly_width(e,t){var n,r,i,s,o,u,a,f,l,c,h,p=e.a_ly;s=0;for(a=0;a<p.length;a++){n=p[a];if(!n)continue;h=n.t;if(h=="-\n"||h=="_\n"){n.shift=0;continue}u=n.w,i=n.font.swfac,o=u+2*cwid(" ")*i,e.type==C.GRACE?c=e.wl:h[0]>="0"&&h[0]<="9"&&h.length>2||h[1]==":"||h[0]=="("||h[0]==")"?(h[0]=="("?r=cwid("(")*i:(f=h.indexOf(" "),set_font(n.font),f>0?r=strwh(h.slice(0,f))[0]:r=u),c=(u-r+2*cwid(" ")*i)*.4,c>20&&(c=20),c+=r,n.t[0]>="0"&&n.t[0]<="9"&&c>s&&(s=c)):(c=o*.4,c>20&&(c=20)),n.shift=c,t<c&&(t=c),o-=c,c=2*cwid(" ")*i;for(l=e.next;l;l=l.next){switch(l.type){case C.NOTE:case C.REST:if(!l.a_ly||!l.a_ly[a]||l.a_ly[a].w==0)o-=9;else{if(l.a_ly[a].t!="-\n"&&l.a_ly[a].t!="_\n")break;o-=c}if(o<=0)break;continue;case C.CLEF:case C.METER:case C.KEY:o-=10;continue;default:o-=5}break}o>e.wr&&(e.wr=o)}if(s>0)for(a=0;a<p.length;a++)n=p[a],n&&n.t[0]>="0"&&n.t[0]<="9"&&(n.shift=s);return t}function draw_lyric_line(e,t,n){var r,i,s,o,u,a,f,l,c,h,p,d;e.hy_st&1<<t&&(l=!0,e.hy_st&=~(1<<t));for(o=e.sym;;o=o.next)if(o.type!=C.CLEF&&o.type!=C.KEY&&o.type!=C.METER)break;i=o.prev?o.prev.x:tsfirst.x,h=0;for(;o;o=o.next){o.a_ly?a=o.a_ly[t]:a=null;if(!a){switch(o.type){case C.REST:case C.MREST:c&&(out_wln(i+3,n,h-i),c=!1,i=o.x+o.wr)}continue}a.font!=gene.curfont&&(gene.curfont=p=a.font),r=a.t,s=a.w,d=a.shift,l&&(r=="_\n"?r="-\n":r!="-\n"&&(out_hyph(i,n,o.x-d-i),l=!1,i=o.x+o.wr)),c&&r!="_\n"&&(out_wln(i+3,n,h-i+3),c=!1,i=o.x+o.wr);if(r=="-\n"||r=="_\n"){h==0&&i>o.x-18&&(i=o.x-18),r[0]=="-"?l=!0:c=!0,h=o.x-d;continue}h=o.x-d,r.slice(-1)=="\n"&&(r=r.slice(0,-1),l=!0);if(user.anno_start||user.anno_stop)u={st:o.st,istart:a.istart,iend:a.iend,x:h,y:n,ymn:n,ymx:n+gene.curfont.size,wl:0,wr:s},anno_start(u,"lyrics");xy_str(h,n,r),anno_stop(u,"lyrics"),i=h+s}l&&(l=!1,h=realwidth-10,h<i+10&&(h=i+10),out_hyph(i,n,h-i),cfmt.hyphencont&&(e.hy_st|=1<<t));for(e.s_next;o;o=o.next)if(o.type==C.NOTE){if(!o.a_ly)break;a=o.a_ly[t],a&&a.t=="_\n"&&(c=!0,h=realwidth-15,h<i+12&&(h=i+12));break}c&&(out_wln(i+3,n,h-i+3),c=!1)}function draw_lyrics(e,t,n,r,i){var s,o,u=staff_tb[e.st].staffscale;set_font("vocal");if(i>0){r>-cfmt.vocalspace&&(r=-cfmt.vocalspace),r*=u;for(s=0;s<t;s++)r-=n[s]*1.1,draw_lyric_line(e,s,r);return(r-n[s-1]/6)/u}o=staff_tb[e.st].topbar+cfmt.vocalspace,r<o&&(r=o),r*=u;for(s=t;--s>=0;)draw_lyric_line(e,s,r),r+=n[s]*1.1;return r/u}function draw_all_lyrics(){var e,t,n,r,i,s,o,u,a,f,l=new Array(nstaff),c=voice_tb.length,h=new Array(c),p=new Array(c),d=new Array(c),v=new Array(c),m=0,g=0,y=-1;for(n=0;n<c;n++){e=voice_tb[n];if(!e.sym)continue;e.st!=y&&(m=0,g=0,y=e.st),r=0;if(e.have_ly){h[n]||(h[n]=[]);for(t=e.sym;t;t=t.next){a=t.a_ly;if(!a)continue;s=t.x,u=10;for(i=0;i<a.length;i++){f=a[i];if(f&&f.w!=0){s-=f.shift,u=f.w;break}}o=y_get(e.st,1,s,u),m<o&&(m=o),o=y_get(e.st,0,s,u),g>o&&(g=o);while(r<a.length)h[n][r++]=0;for(i=0;i<a.length;i++){f=a[i];if(!f)continue;if(!h[n][i]||f.font.size>h[n][i])h[n][i]=f.font.size}}}else o=y_get(e.st,1,0,realwidth),m<o&&(m=o),o=y_get(e.st,0,0,realwidth),g>o&&(g=o);l[y]||(l[y]={}),l[y].top=m,l[y].bot=g,p[n]=r;if(r==0)continue;e.pos.voc?d[n]=e.pos.voc==C.SL_ABOVE:voice_tb[n+1]&&voice_tb[n+1].st==y&&voice_tb[n+1].have_ly?d[n]=!0:d[n]=!1,d[n]?l[y].a=!0:l[y].b=!0}i=0;for(n=0;n<c;n++){e=voice_tb[n];if(!e.sym)continue;if(!e.have_ly)continue;if(d[n]){v[i++]=n;continue}y=e.st,set_dscale(y,!0),p[n]>0&&(l[y].bot=draw_lyrics(e,p[n],h[n],l[y].bot,1))}while(--i>=0)n=v[i],e=voice_tb[n],y=e.st,set_dscale(y,!0),l[y].top=draw_lyrics(e,p[n],h[n],l[y].top,-1);for(n=0;n<c;n++){e=voice_tb[n];if(!e.sym)continue;y=e.st;if(l[y].a){m=l[y].top+2;for(t=e.sym.next;t;t=t.next)t.a_ly&&y_set(y,1,t.x-2,10,m)}if(l[y].b){g=l[y].bot-2;if(p[e.v]>0)for(t=e.sym.next;t;t=t.next)t.a_ly&&y_set(y,0,t.x-2,10,g);else y_set(y,0,0,realwidth,g)}}}function parse_gchord(e){function h(){var e="";for(;;){t=n[o++];if("1234567890.-".indexOf(t)<0)return parseFloat(e);e+=t}}var t,n,r,i,s,e,o,u,a,f=get_font("annotation"),l=f.size,c=parse.line;u=parse.bol+c.index;if(e.length>1)n=e.slice(1,-1),a=u+1;else{n="";for(;;){t=c.next_char();if(!t){syntax(1,"No end of guitar chord");return}if(t=='"')break;t=="\\"&&(n+=t,t=c.next_char()),n+=t}a=parse.bol+c.index+1}if(curvoice.pos.gch==C.SL_HIDDEN)return;o=0,e="g";for(;;){t=n[o];if(!t)break;r={text:"",istart:u,iend:a,font:f};switch(t){case"@":e=t,o++,i=h(),t!=","?(syntax(1,"',' lacking in annotation '@x,y'"),s=0):(s=h(),t!=" "&&o--),r.x=i,r.y=s-l/2;break;case"^":case"_":case"<":case">":o++,e=t;break;default:switch(e){case"g":r.font=get_font("gchord");break;case"@":r.x=i,s-=l,r.y=s-l/2}}r.type=e;for(;;){t=n[o];if(!t)break;switch(t){case"\\":t=n[++o];if(!t||t=="n")break;r.text+="\\";default:r.text+=t,o++;continue;case"&":for(;;){r.text+=t,t=n[++o];switch(t){default:continue;case";":case undefined:case"\\":}break}if(t==";"){o++,r.text+=t;continue}break;case";":}o++;break}a_gch||(a_gch=[]),a_gch.push(r)}}function gch_tr1(e,t){var n,r,i,s,o,u,a,f,l,c,h=0;switch(e[0]){case"A":i=5;break;case"B":i=6;break;case"C":i=0;break;case"D":if(e[1]=="o"){h++,i=0;break}i=1;break;case"E":i=2;break;case"F":e[1]=="a"&&h++,i=3;break;case"G":i=4;break;case"L":h++,i=5;break;case"M":h++,i=2;break;case"R":h++,i=1;break;case"S":h++,e[1]=="o"?(h++,i=4):i=6;break;case"/":h--;break;default:return e}f=0,l=h+1;if(h>=0){while(e[l]=="#")f++,l++;while(e[l]=="b")f--,l++;o=cde2fcg[i]+t+f*7,u=cgd2cde[(o+112)%7],s=(((o+22)/7|0)+159)%5,n=(h?latin_names[u]:note_names[u])+acc_name[s]}else n="";return c=e.indexOf("/",l),c<0?n+e.slice(l):(i=note_names.indexOf(e[++c]),i<0?n+e.slice(l):(n+=e.slice(l,c),f=0,e[++c]=="#"?(f++,e[++c]=="#"&&(f++,c++)):e[c]=="b"&&(f--,e[++c]=="b"&&(f--,c++)),o=cde2fcg[i]+t+f*7,u=cgd2cde[(o+112)%7],s=(((o+22)/7|0)+159)%5,n+note_names[u]+acc_name[s]+e.slice(c)))}function gch_transp(e){var t,n,r,i=0,s=curvoice.ckey.k_sf-curvoice.okey.k_sf;for(;;){t=e.a_gch[i++];if(!t)return;if(t.type!="g")continue;n=t.text,r=n.indexOf(" "),r>=0&&(r++,n=n.slice(0,r)+gch_tr1(n.slice(r),s)),t.text=gch_tr1(n,s)}}function gch_build(e){var t,n,r,i,s=curvoice.pos.gch==C.SL_BELOW?-1:1,o=0,u=0,a=0,f=0,l=cfmt.gchordbox,c=.4;e.a_gch=a_gch,a_gch=null,curvoice.vtransp&&gch_transp(e);for(i=0;i<e.a_gch.length;i++){t=e.a_gch[i];if(t.type=="g")cfmt.chordnames&&(t.otext=t.text,t.text=t.text.replace(/A|B|C|D|E|F|G/g,function(e){return cfmt.chordnames[e]}),cfmt.chordnames.B=="H"&&(t.text=t.text.replace(/Hb/g,"Bb"))),t.text=t.text.replace(/##|#|=|bb|b/g,function(e){switch(e){case"##":return"x";case"#":return"♯";case"=":return"♮";case"b":return"♭"}return"bb"});else{t.text=cnv_escape(t.text);if(t.type=="@"&&!user.anno_start&&!user.anno_stop)continue}gene.curfont=t.font,n=strwh(t.text),t.w=n[0];switch(t.type){case"@":break;case"^":r=n[0]*c,r>8&&(r=8),t.x=-r,o-=n[1],t.y=o;break;case"_":r=n[0]*c,r>8&&(r=8),t.x=-r,u-=n[1],t.y=u;break;case"<":t.x=-(n[0]+6),a-=n[1],t.y=a+n[1]/2;break;case">":t.x=6,f-=n[1],t.y=f+n[1]/2;break;default:t.box=l,r=n[0]*c,r>8&&(r=8),t.x=-r,s<0?(u-=n[1],t.y=u,l&&(u-=2,t.y-=1)):(o-=n[1],t.y=o,l&&(o-=2,t.y-=1))}}a/=2,f/=2;for(i=0;i<e.a_gch.length;i++){t=e.a_gch[i];switch(t.type){case"^":t.y-=o;break;case"<":t.y-=a;break;case">":t.y-=f;break;case"g":s>0&&(t.y-=o)}}}function draw_gchord(e,t,n){var r,i,s,o,u,a,f,l,c,h,p,d=e.a_gch[0].w,v=y_get(e.st,1,e.x-2,d),m=y_get(e.st,0,e.x-2,d),g=e.dur?((e.notes[e.nhd].pit+e.notes[0].pit>>1)-18)*3:12;for(o=0;o<e.a_gch.length;o++){r=e.a_gch[o];if(r.type!="g")continue;i=r;if(r.y<0)break}i&&(i.y>=0?v<n&&(v=n):m>t&&(m=t)),set_dscale(e.st);for(o=0;o<e.a_gch.length;o++){r=e.a_gch[o],use_font(r.font),set_font(r.font),p=r.font.size,d=r.w,u=e.x+r.x,s=r.text;switch(r.type){case"_":a=r.y+m,y_set(e.st,0,u,d,a-p*.2-2);break;case"^":a=r.y+v,y_set(e.st,1,u,d,a+p*.8+2);break;case"<":e.notes[0].acc&&(u-=e.notes[0].shac),a=r.y+g-p/2;break;case">":e.xmx&&(u+=e.xmx),e.dots&&(u+=1.5+3.5*e.dots),a=r.y+g-p/2;break;default:h=r.box?3:2,r.y>=0?(a=r.y+v,y_set(e.st,!0,u,d,a+p+h)):(a=r.y+m,y_set(e.st,!1,u,d,a-h)),l=s.indexOf(" ");if(l>=0){u=realwidth;for(var y=e.next;y;y=y.next){switch(y.type){default:continue;case C.NOTE:case C.REST:case C.BAR:u=y.x}break}c=2;for(;;){l=s.indexOf(" ",l+1);if(l<0)break;c++}var b=(u-e.x)/c;u=e.x,a*=staff_tb[e.st].staffscale,user.anno_start&&user.anno_start("gchord",r.istart,r.iend,u-2,a+p+2,d+4,p+4,e),l=0,c=l;for(;;){l=s.indexOf(" ",c);if(l<0)break;xy_str(u,a,s.slice(c,l),"c"),u+=b,c=l+1}xy_str(u,a,s.slice(c),"c"),user.anno_stop&&user.anno_stop("gchord",r.istart,r.iend,e.x-2,a+p+2,d+4,p+4,e);continue}break;case"@":a=r.y+g,a>0?(f=a+p,f>staff_tb[e.st].ann_top&&(staff_tb[e.st].ann_top=f)):a<staff_tb[e.st].ann_bot&&(staff_tb[e.st].ann_bot=a)}user.anno_start&&user.anno_start("annot",r.istart,r.iend,u-2,a+p+2,d+4,p+4,e),r.box?xy_str_b(u,a,s):xy_str(u,a,s),user.anno_stop&&user.anno_stop("annot",r.istart,r.iend,u-2,a+p+2,d+4,p+4,e)}}function psdeco(){return!1}function psxygl(){return!1}function set_hooks(){function n(e){for(var t=0;t<e.length;t++)e[t](self)}var e=abc2svg.modules.hooks,t=abc2svg.modules.g_hooks;hook_init?e.length&&(n(e),t.push.apply(t,e),abc2svg.modules.hooks=[]):(e.length&&(t.push.apply(t,e),abc2svg.modules.hooks=[]),n(t),hook_init=!0)}var C=abc2svg.C,require=empty_function,system=empty_function,write=empty_function,XMLHttpRequest=empty_function,OPEN_BRACE=1,CLOSE_BRACE=2,OPEN_BRACKET=4,CLOSE_BRACKET=8,OPEN_PARENTH=16,CLOSE_PARENTH=32,STOP_BAR=64,FL_VOICE=128,OPEN_BRACE2=256,CLOSE_BRACE2=512,OPEN_BRACKET2=1024,CLOSE_BRACKET2=2048,MASTER_VOICE=4096,IN=96,CM=37.8,YSTEP=256,errs={bad_char:"Bad character '$1'",bad_val:"Bad value in $1",bar_grace:"Cannot have a bar in grace notes",ignored:"$1: inside tune - ignored",misplaced:"Misplaced '$1' in %%staves",must_note:"!$1! must be on a note",must_note_rest:"!$1! must be on a note or a rest",nonote_vo:"No note in voice overlay",not_enough_n:"Not enough notes/rests for %%repeat",not_enough_m:"Not enough measures for %%repeat",not_ascii:"Not an ASCII character"},self=this,glovar={meter:{type:C.METER,wmeasure:1,a_meter:[]}},info={},mac={},maci=new Int8Array(128),parse={ctx:{},prefix:"%",state:0,line:new scanBuf},psvg,dd_tb={},a_de,od,decos={dot:"0 stc 5 1 1",tenuto:"0 emb 5 3 3",slide:"1 sld 3 7 0",arpeggio:"2 arp 12 10 0",roll:"3 roll 7 6 6",fermata:"3 hld 12 7 7",emphasis:"3 accent 7 4 4",lowermordent:"3 lmrd 10 5 5",coda:"3 coda 24 10 10",uppermordent:"3 umrd 10 5 5",segno:"3 sgno 22 8 8",trill:"3 trl 14 5 5",upbow:"3 upb 10 5 5",downbow:"3 dnb 9 5 5",gmark:"3 grm 6 5 5",wedge:"3 wedge 8 3 3",turnx:"3 turnx 10 0 5",breath:"3 brth 0 1 20",longphrase:"3 lphr 0 1 1",mediumphrase:"3 mphr 0 1 1",shortphrase:"3 sphr 0 1 1",invertedfermata:"3 hld 12 7 7",invertedturn:"3 turn 10 0 5",invertedturnx:"3 turnx 10 0 5",0:"3 fng 8 3 3 0",1:"3 fng 8 3 3 1",2:"3 fng 8 3 3 2",3:"3 fng 8 3 3 3",4:"3 fng 8 3 3 4",5:"3 fng 8 3 3 5",plus:"3 dplus 7 3 3","+":"3 dplus 7 3 3",accent:"3 accent 7 4 4",">":"3 accent 7 4 4",marcato:"3 marcato 9 3 3","^":"3 marcato 9 3 3",mordent:"3 lmrd 10 5 5",open:"3 opend 10 3 3",snap:"3 snap 14 3 3",thumb:"3 thumb 14 3 3",dacapo:"3 dacs 16 20 20 Da Capo",dacoda:"3 dacs 16 20 20 Da Coda","D.C.":"3 dcap 16 10 10","D.S.":"3 dsgn 16 10 10","D.C.alcoda":"3 dacs 16 38 38 D.C. al Coda","D.S.alcoda":"3 dacs 16 38 38 D.S. al Coda","D.C.alfine":"3 dacs 16 38 38 D.C. al Fine","D.S.alfine":"3 dacs 16 38 38 D.S. al Fine",fine:"3 dacs 16 10 10 Fine",turn:"3 turn 10 0 5","trill(":"3 ltr 8 0 0","trill)":"3 ltr 8 0 0",f:"6 f 18 1 7",ff:"6 ff 18 2 10",fff:"6 fff 18 4 13",ffff:"6 ffff 18 6 16",mf:"6 mf 18 6 13",mp:"6 mp 18 6 16",p:"6 p 18 2 8",pp:"6 pp 18 5 14",ppp:"6 ppp 18 8 20",pppp:"6 pppp 18 10 25",pralltriller:"3 umrd 10 5 5",sfz:"6 sfz 18 4 10",ped:"4 ped 20 0 0","ped-up":"4 pedoff 20 0 0","crescendo(":"7 cresc 18 0 0","crescendo)":"7 cresc 18 0 0","<(":"7 cresc 18 0 0","<)":"7 cresc 18 0 0","diminuendo(":"7 dim 18 0 0","diminuendo)":"7 dim 18 0 0",">(":"7 dim 18 0 0",">)":"7 dim 18 0 0","-(":"8 gliss 0 0 0","-)":"8 gliss 0 0 0","~(":"8 glisq 0 0 0","~)":"8 glisq 0 0 0","8va(":"3 8va 10 0 0","8va)":"3 8va 10 0 0","8vb(":"4 8vb 10 0 0","8vb)":"4 8vb 10 0 0","15ma(":"3 15ma 10 0 0","15ma)":"3 15ma 10 0 0","15mb(":"4 15mb 10 0 0","15mb)":"4 15mb 10 0 0",invisible:"32 0 0 0 0",beamon:"33 0 0 0 0",trem1:"34 0 0 0 0",trem2:"34 0 0 0 0",trem3:"34 0 0 0 0",trem4:"34 0 0 0 0",xstem:"35 0 0 0 0",beambr1:"36 0 0 0 0",beambr2:"36 0 0 0 0",rbstop:"37 0 0 0 0","/":"38 0 0 6 6","//":"38 0 0 6 6","///":"38 0 0 6 6","beam-accel":"39 0 0 0 0","beam-rall":"39 0 0 0 0",stemless:"40 0 0 0 0",rbend:"41 0 0 0 0"},f_near=[!0,!0,!0],f_note=[!1,!1,!1,!0,!0,!0,!1,!1,!0],f_staff=[!1,!1,!1,!1,!1,!1,!0,!0],func_tb=[d_near,d_slide,d_arp,d_upstaff,d_upstaff,d_trill,d_pf,d_cresc],ottava={"8va(":1,"8va)":1,"15ma(":1,"15ma)":1,"8vb(":1,"8vb)":1,"15mb(":1,"15mb)":1},STEM_MIN=16,STEM_MIN2=14,STEM_MIN3=12,STEM_MIN4=10,STEM_CH_MIN=14,STEM_CH_MIN2=10,STEM_CH_MIN3=9,STEM_CH_MIN4=9,BEAM_DEPTH=3.2,BEAM_OFFSET=.25,BEAM_SHIFT=5,BEAM_SLOPE=.4,BEAM_STUB=8,SLUR_SLOPE=.5,GSTEM=15,GSTEM_XOFF=2.3,cache,min_tb=[[STEM_MIN,STEM_MIN,STEM_MIN2,STEM_MIN3,STEM_MIN4,STEM_MIN4],[STEM_CH_MIN,STEM_CH_MIN,STEM_CH_MIN2,STEM_CH_MIN3,STEM_CH_MIN4,STEM_CH_MIN4]],sharp_cl=new Int8Array([24,9,15,21,6,12,18]),flat_cl=new Int8Array([12,18,24,9,15,21,6]),sharp1=new Int8Array([-9,12,-9,-9,12,-9]),sharp2=new Int8Array([12,-9,12,-9,12,-9]),flat1=new Int8Array([9,-12,9,-12,9,-12]),flat2=new Int8Array([-12,9,-12,9,-12,9]),rest_tb=["r128","r64","r32","r16","r8","r4","r2","r1","r0","r00"],musicfont='url("data:application/x-font-ttf;base64,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MDgyB3VuaUUwODMHdW5pRTA4NAd1bmlFMDg1B3VuaUUwODYHdW5pRTA4Nwd1bmlFMDg4B3VuaUUwODkHdW5pRTA4QQd1bmlFMDhCB3VuaUUwOEMHdW5pRTA5NAd1bmlFMDk1B3VuaUUwQTAHdW5pRTBBMQd1bmlFMEEyB3VuaUUwQTMHdW5pRTBBNAd1bmlFMEE5B3VuaUUwQjMHdW5pRTEwMQd1bmlFMUI5B3VuaUUxQkIHdW5pRTFFNwd1bmlFMjYwB3VuaUUyNjEHdW5pRTI2Mgd1bmlFMjYzB3VuaUUyNjQHdW5pRTI4MAd1bmlFMjgxB3VuaUUyODIHdW5pRTI4Mwd1bmlFNEEwB3VuaUU0QTIHdW5pRTRBNAd1bmlFNEE4B3VuaUU0QUMHdW5pRTRDMAd1bmlFNENFB3VuaUU0RTEHdW5pRTRFMgd1bmlFNEUzB3VuaUU0RTQHdW5pRTRFNQd1bmlFNEU2B3VuaUU0RTcHdW5pRTRFOAd1bmlFNEU5B3VuaUU0RUEHdW5pRTRFRQd1bmlFNTAwB3VuaUU1MDEHdW5pRTUyMAd1bmlFNTIxB3VuaUU1MjIHdW5pRTUyNAd1bmlFNTI1B3VuaUU1MjkHdW5pRTUyQQd1bmlFNTJCB3VuaUU1MkMHdW5pRTUyRAd1bmlFNTJGB3VuaUU1MzAHdW5pRTUzMQd1bmlFNTM5B3VuaUU1NjYHdW5pRTU2Nwd1bmlFNTY5B3VuaUU1NkMHdW5pRTU2RAd1bmlFNTgyB3VuaUU1RDAHdW5pRTVFMgd1bmlFNjEwB3VuaUU2MTIHdW5pRTYxNAd1bmlFNjE4B3VuaUU2MjQHdW5pRTYzMAd1bmlFNjUwB3VuaUU2NTUHdW5pRTkxMAd1bmlFOTExB3VuaUU5MTIHdW5pRTkxNAd1bmlFOTE1B3VuaUU5MTgHdW5pRTkyMAd1bmlFOTI1B3VuaUU5NUQHdW5pRUEwMgd1bmlFQUE0AAAAAAH//wACAAEAAAAAAAAADAAUAAQAAAACAAAAAQAAAAEAAAAAAAEAAAAA1+feHQAAAADRlyIXAAAAANgWv3Y=")',defined_font={},font_tb={},fid=1,font_scale_tb={serif:1.05,serifBold:1.05,"sans-serif":1.1,"sans-serifBold":1.1,Palatino:1.1,Mono:1.35},fmt_lock={},cfmt={aligncomposer:1,breaklimit:.7,breakoneoln:!0,cancelkey:!0,composerspace:6,dblrepbar:":][:",decoerr:!0,dynalign:!0,fullsvg:"",gracespace:new Float32Array([4,8,11]),graceslurs:!0,hyphencont:!0,indent:0,infoname:'R "Rhythm: "\nB "Book: "\nS "Source: "\nD "Discography: "\nN "Notes: "\nZ "Transcription: "\nH "History: "',infospace:0,keywarn:!0,leftmargin:1.4*CM,lineskipfac:1.1,linewarn:!0,maxshrink:.65,maxstaffsep:2e3,maxsysstaffsep:2e3,measurefirst:1,measurenb:-1,musicspace:6,parskipfac:.4,partsspace:8,pagewidth:21*CM,printmargin:0,rightmargin:1.4*CM,rbdbstop:!0,rbmax:4,rbmin:2,scale:1,slurheight:1,staffsep:46,stemheight:21,stretchlast:.25,stretchstaff:!0,subtitlespace:3,sysstaffsep:34,textspace:14,titlespace:6,titletrim:!0,topspace:22,tuplets:[0,0,0,0],vocalspace:10,writefields:"CMOPQsTWw",wordsspace:5},textopt={align:"j",center:"c",fill:"f",justify:"j",ragged:"f",right:"r",skip:"s"},posval={above:C.SL_ABOVE,auto:0,below:C.SL_BELOW,down:C.SL_BELOW,hidden:C.SL_HIDDEN,opposite:C.SL_HIDDEN,under:C.SL_BELOW,up:C.SL_ABOVE};Abc.prototype.style_font=style_font;var abc_utf={"=D":"Đ","=H":"Ħ","=T":"Ŧ","=d":"đ","=h":"ħ","=t":"ŧ","/O":"Ø","/o":"ø","/L":"Ł","/l":"ł",vL:"Ľ",vl:"ľ",vd:"ď",".i":"ı",AA:"Å",aa:"å",AE:"Æ",ae:"æ",DH:"Ð",dh:"ð",OE:"Œ",oe:"œ",ss:"ß",TH:"Þ",th:"þ"},oct_acc={1:"♯",2:"♭",3:"♮",4:"x",5:"bb"},include=0;Abc.prototype.tosvg=tosvg;var gene,staff_tb,nstaff,tsnext,realwidth,insert_meter,spf_last,space_tb=new Float32Array([7,10,14.15,20,28.3,40,56.6,80,100,120]),smallest_duration,dx_tb=new Float32Array([10,10,11,13,13]),hw_tb=new Float32Array([4.5,5,6,7,8]),w_note=new Float32Array([3.5,3.7,5,6,7]),delta_tb={t:-4,c:0,b:4,p:-6},rest_sp=[[18,18],[12,18],[12,12],[0,12],[6,8],[10,10],[6,4],[10,0],[10,4],[10,10]],delpit=[0,-7,-14,0],MAXPIT=96,blocks=[],a_gch,a_dcn,multicol,maps={},qplet_tb=new Int8Array([0,1,3,2,3,0,2,0,3,0]),ntb="CDEFGABcdefgab",note_pit=new Int8Array([0,2,4,5,7,9,11]),reg_dur=/(\d*)(\/*)(\d*)/g,cde2fcg=new Int8Array([0,2,4,-1,1,3,5]),cgd2cde=new Int8Array([0,4,1,5,2,6,3]),acc2=new Int8Array([-2,-1,3,1,2]),nil=["0"],char_tb=[nil,nil,nil,nil,nil,nil,nil,nil,nil," ","\n",nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil," ","!",'"',"i","\n",nil,"&",nil,"(",")","i",nil,nil,"-","!dot!",nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,"|","i","<","n","<","i","i","n","n","n","n","n","n","n","!fermata!","d","d","d","!emphasis!","!lowermordent!","d","!coda!","!uppermordent!","d","d","!segno!","!trill!","d","d","d","n","d","n","[","\\","|","n","n","i","n","n","n","n","n","n","n","d","d","d","d","d","d","d","d","d","d","d","d","d","!upbow!","!downbow!","d","n","n","n","{","|","}","!gmark!",nil],cw_tb=new Float32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,.25,.333,.408,.5,.5,.833,.778,.333,.333,.333,.5,.564,.25,.564,.25,.278,.5,.5,.5,.5,.5,.5,.5,.5,.5,.5,.278,.278,.564,.564,.564,.444,.921,.722,.667,.667,.722,.611,.556,.722,.722,.333,.389,.722,.611,.889,.722,.722,.556,.722,.667,.556,.611,.722,.722,.944,.722,.722,.611,.333,.278,.333,.469,.5,.333,.444,.5,.444,.5,.444,.333,.5,.5,.278,.278,.5,.278,.778,.5,.5,.5,.5,.333,.389,.278,.5,.5,.722,.5,.5,.444,.48,.2,.48,.541,.5]),info_font_init={A:"info",C:"composer",O:"composer",P:"parts",Q:"tempo",R:"info",T:"title",X:"title"},output="",style="\n.fill {fill: currentColor}\n.stroke {stroke: currentColor; fill: none}\n.music text, .music tspan {fill:currentColor}",font_style="",posx=cfmt.leftmargin/cfmt.scale,posy=0,img={width:cfmt.pagewidth,lm:cfmt.leftmargin,rm:cfmt.rightmargin},defined_glyph={},defs="",fulldefs="",stv_g={scale:1,dy:0,st:-1,v:0,g:0},block={},tgls={brace:{x:0,y:0,c:""},hl:{x:-4,y:0,c:""},hl1:{x:-6,y:0,c:""},hl2:{x:-6,y:0,c:""},ghl:{x:-4,y:0,c:""},lphr:{x:0,y:24,c:""},mphr:{x:0,y:24,c:""},sphr:{x:0,y:27,c:""},rdots:{x:-1,y:0,c:""},dsgn:{x:-4,y:-4,c:""},dcap:{x:-4,y:-4,c:""},sgno:{x:-6,y:0,c:""},coda:{x:-12,y:-6,c:""},tclef:{x:-8,y:0,c:""},cclef:{x:-8,y:0,c:""},bclef:{x:-8,y:0,c:""},pclef:{x:-6,y:0,c:""},spclef:{x:-6,y:0,c:""},stclef:{x:-8,y:0,c:""},scclef:{x:-8,y:0,c:""},sbclef:{x:-7,y:0,c:""},oct:{x:0,y:2,c:""},HDD:{x:-7,y:0,c:""},breve:{x:-6,y:0,c:""},HD:{x:-5.2,y:0,c:""},Hd:{x:-3.8,y:0,c:""},hd:{x:-3.7,y:0,c:""},ghd:{x:2,y:0,c:"",sc:.66},pshhd:{x:-3.7,y:0,c:""},pfthd:{x:-3.7,y:0,c:""},x:{x:-3.7,y:0,c:""},"circle-x":{x:-3.7,y:0,c:""},srep:{x:-5,y:0,c:""},diamond:{x:-4,y:0,c:""},triangle:{x:-4,y:0,c:""},dot:{x:-2,y:0,c:""},"acc-1":{x:-3,y:0,c:""},acc3:{x:-2,y:0,c:""},acc1:{x:-3,y:0,c:""},acc2:{x:-3,y:0,c:""},"acc-2":{x:-3,y:0,c:""},"acc-1_1_4":{x:-3,y:0,c:""},"acc-1_3_4":{x:-4,y:0,c:""},acc1_1_4:{x:-2,y:0,c:""},acc1_3_4:{x:-4,y:0,c:""},accent:{x:-3,y:0,c:""},stc:{x:-1,y:-2,c:""},emb:{x:-4,y:-2,c:""},wedge:{x:-1,y:0,c:""},marcato:{x:-3,y:0,c:""},hld:{x:-7,y:0,c:""},brth:{x:0,y:0,c:""},r00:{x:-1.5,y:0,c:""},r0:{x:-1.5,y:0,c:""},r1:{x:-3.5,y:-6,c:""},r2:{x:-3.2,y:0,c:""},r4:{x:-3,y:0,c:""},r8:{x:-3,y:0,c:""},r16:{x:-4,y:0,c:""},r32:{x:-4,y:0,c:""},r64:{x:-4,y:0,c:""},r128:{x:-4,y:0,c:""},mrest:{x:-10,y:0,c:""},mrep:{x:-6,y:0,c:""},mrep2:{x:-9,y:0,c:""},p:{x:-4,y:-6,c:""},f:{x:-4,y:-6,c:""},pppp:{x:-4,y:-6,c:""},ppp:{x:-4,y:-6,c:""},pp:{x:-4,y:-6,c:""},mp:{x:-4,y:-6,c:""},mf:{x:-4,y:-6,c:""},ff:{x:-4,y:-6,c:""},fff:{x:-4,y:-6,c:""},ffff:{x:-4,y:-6,c:""},sfz:{x:-4,y:-6,c:""},trl:{x:-4,y:-4,c:""},turn:{x:-5,y:-4,c:""},turnx:{x:-5,y:-4,c:""},umrd:{x:-7,y:-2,c:""},lmrd:{x:-7,y:-2,c:""},dplus:{x:-4,y:10,c:""},sld:{x:-8,y:12,c:""},grm:{x:-2,y:0,c:""},dnb:{x:-4,y:0,c:""},upb:{x:-3,y:0,c:""},opend:{x:-2,y:0,c:""},roll:{x:0,y:0,c:""},thumb:{x:0,y:0,c:""},snap:{x:-2,y:0,c:""},ped:{x:-10,y:0,c:""},pedoff:{x:-5,y:0,c:""},longa:{x:-6,y:0,c:""},custos:{x:-4,y:3,c:""},ltr:{x:2,y:6,c:""}},glyphs={},mgls={" ":" ",0:"",1:"",2:"",3:"",4:"",5:"",6:"",7:"",8:"",9:"",C:"","+":"","(":"",")":"",o:"",c:"",".":"","|":""},anno_type=["bar","clef","custos","","grace","key","meter","Zrest","note","part","rest","yspace","staves","Break","tempo","","block","remark"],anno_start=user.anno_start?a_start:empty_function,anno_stop=user.anno_stop?a_stop:empty_function;Abc.prototype.out_svg=function(e){output+=e},Abc.prototype.sx=sx,Abc.prototype.sy=sy,Abc.prototype.sh=function(e){return stv_g.st<0?e/stv_g.scale:e},Abc.prototype.ax=function(e){return e+posx},Abc.prototype.ay=function(e){return stv_g.st<0?posy-e:posy+(stv_g.dy-e)*stv_g.scale-stv_g.dy},Abc.prototype.ah=function(e){return stv_g.st<0?e:e*stv_g.scale},Abc.prototype.out_sxsy=out_sxsy,Abc.prototype.xypath=xypath;var deco_str_style={crdc:{dx:0,dy:5,style:"font:italic 14px serif"},dacs:{dx:0,dy:3,style:"font:16px serif",anchor:' text-anchor="middle"'},fng:{dx:0,dy:1,style:"font-family:Bookman; font-size:8px",anchor:' text-anchor="middle"'},pf:{dx:0,dy:5,style:"font:italic bold 16px serif"},"@":{dx:0,dy:5,style:"font: 12px sans-serif"}},deco_val_tb={arp:out_arp,cresc:out_cresc,dim:out_dim,ltr:out_ltr,"8va":out_8va,"8vb":out_8vb,"15ma":out_15ma,"15mb":out_15mb},deco_l_tb={glisq:out_glisq,gliss:out_gliss};Abc.prototype.blk_out=blk_out,Abc.prototype.blk_flush=blk_flush;var par_sy,cur_sy,voice_tb,curvoice,staves_found,vover,tsfirst,w_tb=new Uint8Array([2,1,8,0,3,5,6,9,9,0,9,3,0,7,0,0,0,0]),note_names="CDEFGAB",latin_names=["Do","Re","Mi","Fa","Sol","La","Si"],acc_name=["bb","b","","#","##"];font_init(),init_tune(),Abc.prototype.add_style=function(e){style+=e},Abc.prototype.calculate_beam=calculate_beam,Abc.prototype.cfmt=function(){return cfmt},Abc.prototype.clone=clone,Abc.prototype.deco_cnv=deco_cnv,Abc.prototype.do_pscom=do_pscom,Abc.prototype.do_begin_end=do_begin_end,Abc.prototype.draw_gchord=draw_gchord,Abc.prototype.draw_note=draw_note,Abc.prototype.draw_symbols=draw_symbols,Abc.prototype.errs=errs,Abc.prototype.font_class=font_class,Abc.prototype.gch_build=gch_build,Abc.prototype.gch_tr1=gch_tr1,Abc.prototype.get_a_gch=function(){return a_gch},Abc.prototype.get_bool=get_bool,Abc.prototype.get_cur_sy=function(){return cur_sy},Abc.prototype.get_curvoice=function(){return curvoice},Abc.prototype.get_delta_tb=function(){return delta_tb},Abc.prototype.get_decos=function(){return decos},Abc.prototype.get_fname=function(){return parse.fname},Abc.prototype.get_font=get_font,Abc.prototype.get_font_style=function(){return font_style},Abc.prototype.get_glyphs=function(){return glyphs},Abc.prototype.get_img=function(){return img},Abc.prototype.get_maps=function(){return maps},Abc.prototype.get_multi=function(){return multicol},Abc.prototype.get_newpage=function(){if(block.newpage)return block.newpage=!1,!0},Abc.prototype.get_posy=function(){var e=posy;return posy=0,e},Abc.prototype.get_staff_tb=function(){return staff_tb},Abc.prototype.get_top_v=function(){return par_sy.top_voice},Abc.prototype.get_tsfirst=function(){return tsfirst},Abc.prototype.get_voice_tb=function(){return voice_tb},Abc.prototype.goto_tune=goto_tune,Abc.prototype.info=function(){return info},Abc.prototype.new_note=new_note,Abc.prototype.out_arp=out_arp,Abc.prototype.out_deco_str=out_deco_str,Abc.prototype.out_deco_val=out_deco_val,Abc.prototype.out_ltr=out_ltr,Abc.prototype.output_music=output_music,Abc.prototype.param_set_font=param_set_font,Abc.prototype.parse=parse,Abc.prototype.psdeco=psdeco,Abc.prototype.psxygl=psxygl,Abc.prototype.set_bar_num=set_bar_num,Abc.prototype.set_cur_sy=function(e){cur_sy=e},Abc.prototype.set_dscale=set_dscale,Abc.prototype.set_font=set_font,Abc.prototype.set_format=set_format,Abc.prototype.set_pitch=set_pitch,Abc.prototype.set_scale=set_scale,Abc.prototype.set_stem_dir=set_stem_dir,Abc.prototype.set_stems=set_stems,Abc.prototype.set_sym_glue=set_sym_glue,Abc.prototype.set_tsfirst=function(e){tsfirst=e},Abc.prototype.set_vp=set_vp,Abc.prototype.set_v_param=set_v_param,Abc.prototype.set_width=set_width,Abc.prototype.set_xhtml=function(e){var t=write_text;return write_text=e,t},Abc.prototype.sort_pitch=sort_pitch,Abc.prototype.strwh=strwh,Abc.prototype.stv_g=function(){return stv_g},Abc.prototype.svg_flush=svg_flush,Abc.prototype.syntax=syntax,Abc.prototype.unlksym=unlksym,Abc.prototype.use_font=use_font,Abc.prototype.xy_str=xy_str,Abc.prototype.xygl=xygl;var hook_init}};var Abc=abc2svg.Abc;typeof module=="object"&&typeof exports=="object"&&(exports.abc2svg=abc2svg,exports.Abc=Abc),abc2svg.loadjs=function(e,t,n){n&&n()},abc2svg.modules={ambitus:{fn:"ambitus-1.js"},beginps:{fn:"psvg-1.js"},"break":{fn:"break-1.js"},capo:{fn:"capo-1.js"},clip:{fn:"clip-1.js"},voicecombine:{fn:"combine-1.js"},diagram:{fn:"diag-1.js"},equalbars:{fn:"equalbars-1.js"},grid:{fn:"grid-1.js"},grid2:{fn:"grid2-1.js"},MIDI:{fn:"MIDI-1.js"},percmap:{fn:"perc-1.js"},soloffs:{fn:"soloffs-1.js"},sth:{fn:"sth-1.js"},temperament:{fn:"temper-1.js"},nreq:0,hooks:[],g_hooks:[],load:function(e,t,n){function r(){return typeof user=="object"&&user.errmsg?user.errmsg:typeof printErr=="function"?printErr:typeof alert=="function"?function(e){alert(e)}:typeof console=="object"?console.log:function(){}}var i,s,o=this.nreq,u=e.match(/(^|\n)(%%|I:).+?\b/g);if(!u)return!0;this.cbf=t||function(){},this.errmsg=n||r();for(var a=0;a<u.length;a++){i=abc2svg.modules[u[a].replace(/\n?(%%|I:)/,"")];if(!i||i.loaded)continue;i.loaded=!0,this.nreq++,abc2svg.loadjs(i.fn,function(){--abc2svg.modules.nreq==0&&abc2svg.modules.cbf()},function(){abc2svg.modules.errmsg("error loading "+i.fn),--abc2svg.modules.nreq==0&&abc2svg.modules.cbf()})}return this.nreq==o}},abc2svg.version="1.18.2",abc2svg.vdate="2018-11-18",abc2svg.MIDI={do_midi:function(e){function r(e){var r=Number(e);if(isNaN(r))return;return e=(r/12|0)*7-19,r%=12,e+=t[r],note={pit:e},n[r]&&(note.acc=n[r]),note}function i(e){var t=e.match(/^([_^=]*)([A-Ga-g])([,']*)$/);if(!t)return;return e.match(/[A-Z]/)&&(e=e.toLowerCase(),e.indexOf("'")>0?e=e.replace("'",""):e+=","),e}var t=new Int8Array([0,0,1,2,2,3,3,4,5,5,6,6]),n=new Int8Array([0,1,0,-1,0,0,1,0,-1,0,-1,0]),s,o,u=this.get_maps(),a=e.split(/\s+/);switch(a[1]){case"channel":if(a[2]!="10")break;this.set_v_param("midictl","0 1");break;case"drummap":if(this.cfmt().sound!="play")break;s=i(a[2]),o=r(a[3]);if(!s||!o){this.syntax(1,this.errs.bad_val,"%%MIDI drummap");break}u.MIDIdrum||(u.MIDIdrum={}),u.MIDIdrum[s]=[null,o],this.set_v_param("mididrum","MIDIdrum");break;case"program":a[3]!=undefined?o=a[3]:o=a[2],o=parseInt(o);if(isNaN(o)||o<0||o>128){this.syntax(1,"Bad program in %%MIDI");return}this.set_v_param("instr",o);break;case"control":s=parseInt(a[2]);if(isNaN(s)||s<0||s>127){this.syntax(1,"Bad controller number in %%MIDI");return}o=parseInt(a[3]);if(isNaN(o)||o<0||o>127){this.syntax(1,"Bad controller value in %%MIDI");return}this.set_v_param("midictl",a[2]+" "+a[3])}},set_midi:function(e){var t,n,r=this.get_curvoice();for(t=0;t<e.length;t++)switch(e[t]){case"instr=":r.instr=e[t+1];break;case"midictl=":r.midictl||(r.midictl={}),n=e[t+1].split(" "),r.midictl[n[0]]=Number(n[1]);break;case"mididrum=":r.map||(r.map={}),r.map=e[t+1]}},do_pscom:function(e,t){t.slice(0,5)=="MIDI "?abc2svg.MIDI.do_midi.call(this,t):e(t)},set_vp:function(e,t){abc2svg.MIDI.set_midi.call(this,t),e(t)},set_hooks:function(e){e.do_pscom=abc2svg.MIDI.do_pscom.bind(e,e.do_pscom),e.set_vp=abc2svg.MIDI.set_vp.bind(e,e.set_vp)}},abc2svg.modules.hooks.push(abc2svg.MIDI.set_hooks),abc2svg.modules.MIDI.loaded=!0,abc2svg.combine={comb_v:function(){function t(t){var n,r=t.ts_next;return!r||r.type!=e.NOTE&&r.type!=e.REST?!1:r.v==t.v||r.st!=t.st||r.time!=t.time||r.dur!=t.dur?!1:t.combine<=0&&r.type!=t.type?!1:t.a_gch&&r.a_gch?!1:t.type==e.REST?t.type==r.type&&t.invis&&!r.invis?!1:!0:r.a_ly||r.sl1||r.sl2||r.slur_start||r.slur_end?!1:r.beam_st!=t.beam_st||r.beam_end!=t.beam_end?!1:(n=r.nhd,t.combine<=1&&t.notes[0].pit<=r.notes[n].pit+1?!1:!0)}function n(t,n){var r,i,s;t.notes=t.notes.concat(n.notes),t.nhd=r=t.notes.length-1,this.sort_pitch(t);if(t.combine>=3){for(s=r;s>0;s--)t.notes[s].pit==t.notes[s-1].pit&&t.notes[s].acc==t.notes[s-1].acc&&t.notes.splice(s,1);t.nhd=r=t.notes.length-1}t.ymx=3*(t.notes[r].pit-18)+4,t.ymn=3*(t.notes[0].pit-18)-4,i=t.notes[0].ti1,(i&15)==e.SL_AUTO&&(t.notes[0].ti1=e.SL_BELOW|i&~e.SL_DOTTED),i=t.notes[r].ti1,(i&15)==e.SL_AUTO&&(t.notes[r].ti1=e.SL_ABOVE|i&~e.SL_DOTTED)}function r(r){var i,s,o,u;for(;;){s=r.nhd,i=r.ts_next,o=i.nhd,r.type!=i.type?i.type!=e.REST&&(i=r,r=i.ts_next):r.type==e.REST?r.invis&&!i.invis&&delete r.invis:n.call(this,r,i),i.a_gch&&(r.a_gch=i.a_gch),i.a_dd&&(r.a_dd?r.a_dd=r.a_dd.concat(i.a_dd):r.a_dd=i.a_dd),this.unlksym(i);if(r.in_tuplet||!t.call(this,r))break}}var e=abc2svg.C,i,s,o,u,a;for(i=this.get_tsfirst();i;i=i.ts_next){switch(i.type){case e.REST:if(i.combine==undefined||i.combine<0)continue;t.call(this,i)&&r.call(this,i);continue;default:continue;case e.NOTE:if(i.combine==undefined||i.combine<=0)continue}if(!i.beam_st)continue;if(i.beam_end){t.call(this,i)&&r.call(this,i);continue}s=i;for(;;){if(!t.call(this,s)){s=null;break}if(s.beam_end)break;do s=s.next;while(s.type!=e.NOTE&&s.type!=e.REST)}if(!s)continue;s=i;for(;;){r.call(this,s);if(s.beam_end)break;do s=s.next;while(s.type!=e.NOTE&&s.type!=e.REST)}}},do_pscom:function(e,t){t.slice(0,13)=="voicecombine "?this.set_v_param("combine",t.split(/[ \t]/)[1]):e(t)},new_note:function(e,t,n){var r=this.get_curvoice(),i=e(t,n);return i&&i.notes&&r.combine!=undefined&&(i.combine=r.combine),i},set_stem_dir:function(e){e(),abc2svg.combine.comb_v.call(this)},set_vp:function(e,t){var n,r=this.get_curvoice();for(n=0;n<t.length;n++)if(t[n]=="combine="){r.combine=t[n+1];break}e(t)},set_hooks:function(e){e.do_pscom=abc2svg.combine.do_pscom.bind(e,e.do_pscom),e.new_note=abc2svg.combine.new_note.bind(e,e.new_note),e.set_stem_dir=abc2svg.combine.set_stem_dir.bind(e,e.set_stem_dir),e.set_vp=abc2svg.combine.set_vp.bind(e,e.set_vp)}},abc2svg.modules.hooks.push(abc2svg.combine.set_hooks),abc2svg.modules.voicecombine.loaded=!0,abc2svg.diag={do_diag:function(){var e=this.get_glyphs(),t=this.get_voice_tb();if(!e.fb){var n,r,i,s=this.get_decos();ns="CDEFGAB",ms=["","m","7","m7","maj7","sus4"],this.add_style("\n.diag {font:6px sans-serif}\n.frn {font:italic 7px sans-serif}");for(n=0;n<ns.length;n++)for(r=0;r<ms.length;r++)i=ns[n]+ms[r],s[i]="3 "+i+" 40 0 0";for(r=0;r<ms.length;r++)i="F♯"+ms[r],s[i]="3 F#"+ms[r]+" 40 0 0";e.fb='<g id="fb">\n<path class="stroke" stroke-width="0.4" d="M-10 -34h20m0 6h-20m0 6h20m0 6h-20m0 6h20"/>\n<path class="stroke" stroke-width="0.5" d="M-10 -34v24m4 0v-24m4 0v24m4 0v-24m4 0v24m4 0v-24"/>\n</g>',e.nut='<path id="nut" class="stroke" stroke-width="1.6" d="M-10.2 -34.5h20.4"/>',e.barre='<path id="barre" class="stroke" stroke-width=".9" d="M-10.2 -31h20.4"/>',e.fr1='<text id="fr1" x="-20" y="-29" class="frn">fr1</text>',e.fr2='<text id="fr2" x="-20" y="-29" class="frn">fr2</text>',e.fr3='<text id="fr3" x="-20" y="-29" class="frn">fr3</text>',e.ddot='<circle id="ddot" class="fill" r="1.5"/>',e.C='<g id="C">\n<use xlink:href="#nut"/>\n<use xlink:href="#fb"/>\n<text x="-8,-3,4" y="-36" class="diag">321</text>\n<use x="-6" y="-19" xlink:href="#ddot"/>\n<use x="-2" y="-25" xlink:href="#ddot"/>\n<use x="6" y="-31" xlink:href="#ddot"/>\n</g>',e.Cm='<g id="Cm">\n<use xlink:href="#barre"/>\n<use xlink:href="#fr3"/>\n<use xlink:href="#fb"/>\n<text x="-4,0,4" y="-36" class="diag">342</text>\n<use x="2" y="-19" xlink:href="#ddot"/>\n<use x="-2" y="-19" xlink:href="#ddot"/>\n<use x="6" y="-25" xlink:href="#ddot"/>\n</g>',e.C7='<g id="C7">\n<use xlink:href="#nut"/>\n<use xlink:href="#fb"/>\n<text x="-8,-4,0,4" y="-36" class="diag">3241</text>\n<use x="2" y="-19" xlink:href="#ddot"/>\n<use x="-6" y="-19" xlink:href="#ddot"/>\n<use x="-2" y="-25" xlink:href="#ddot"/>\n<use x="6" y="-31" xlink:href="#ddot"/>\n</g>',e.Cm7='<g id="Cm7">\n<use xlink:href="#barre"/>\n<use xlink:href="#fr3"/>\n<use xlink:href="#fb"/>\n<text x="-12,-4,4" y="-36" class="diag">x32</text>\n<use x="-2" y="-19" xlink:href="#ddot"/>\n<use x="6" y="-25" xlink:href="#ddot"/>\n</g>',e.Cmaj7='<g id="Cmaj7">\n<use xlink:href="#nut"/>\n<use xlink:href="#fb"/>\n<text x="-12,-8,-4" y="-36" class="diag">x21</text>\n<use x="-2" y="-25" xlink:href="#ddot"/>\n<use x="-6" y="-19" xlink:href="#ddot"/>\n</g>',e.Csus4='<g id="Csus4">\n<use xlink:href="#barre"/>\n<use xlink:href="#fr3"/>\n<use xlink:href="#fb"/>\n<text x="-12,0,4" y="-36" class="diag">x34</text>\n<use x="6" y="-13" xlink:href="#ddot"/>\n<use x="2" y="-19" xlink:href="#ddot"/>\n</g>',e.D='<g id="D">\n<use xlink:href="#nut"/>\n<use xlink:href="#fb"/>\n<text x="-12,0,4,8" y="-36" class="diag">x132</text>\n<use x="6" y="-19" xlink:href="#ddot"/>\n<use x="10" y="-25" xlink:href="#ddot"/>\n<use x="2" y="-25" xlink:href="#ddot"/>\n</g>',e.Dm='<g id="Dm">\n<use xlink:href="#nut"/>\n<use xlink:href="#fb"/>\n<text x="-12,0,4,8" y="-36" class="diag">x231</text>\n<use x="6" y="-19" xlink:href="#ddot"/>\n<use x="2" y="-25" xlink:href="#ddot"/>\n<use x="10" y="-31" xlink:href="#ddot"/>\n</g>',e.D7='<g id="D7">\n<use xlink:href="#nut"/>\n<use xlink:href="#fb"/>\n<text x="-12,0,4,8" y="-36" class="diag">x312</text>\n<use x="10" y="-25" xlink:href="#ddot"/>\n<use x="2" y="-25" xlink:href="#ddot"/>\n<use x="6" y="-31" xlink:href="#ddot"/>\n</g>',e.Dm7='<g id="Dm7">\n<use xlink:href="#nut"/>\n<use xlink:href="#fb"/>\n<text x="-12,-8,0,4,8" y="-36" class="diag">xx211</text>\n<use x="2" y="-25" xlink:href="#ddot"/>\n<use x="10" y="-31" xlink:href="#ddot"/>\n<use x="6" y="-31" xlink:href="#ddot"/>\n</g>',e.Dmaj7='<g id="Dmaj7">\n<use xlink:href="#nut"/>\n<use xlink:href="#fb"/>\n<text x="-12,-8,0,4,8" y="-36" class="diag">xx123</text>\n<use x="10" y="-25" xlink:href="#ddot"/>\n<use x="6" y="-25" xlink:href="#ddot"/>\n<use x="2" y="-25" xlink:href="#ddot"/>\n</g>',e.Dsus4='<g id="Dsus4">\n<use xlink:href="#nut"/>\n<use xlink:href="#fb"/>\n<text x="-12,-8,0,4,8" y="-36" class="diag">xx123</text>\n<use x="10" y="-19" xlink:href="#ddot"/>\n<use x="6" y="-19" xlink:href="#ddot"/>\n<use x="2" y="-25" xlink:href="#ddot"/>\n</g>',e.E='<g id="E">\n<use xlink:href="#nut"/>\n<use xlink:href="#fb"/>\n<text x="-8,-4,0" y="-36" class="diag">231</text>\n<use x="-2" y="-25" xlink:href="#ddot"/>\n<use x="-6" y="-25" xlink:href="#ddot"/>\n<use x="2" y="-31" xlink:href="#ddot"/>\n</g>',e.Em='<g id="Em">\n<use xlink:href="#nut"/>\n<use xlink:href="#fb"/>\n<text x="-8,-4" y="-36" class="diag">23</text>\n<use x="-2" y="-25" xlink:href="#ddot"/>\n<use x="-6" y="-25" xlink:href="#ddot"/>\n</g>',e.E7='<g id="E7">\n<use xlink:href="#nut"/>\n<use xlink:href="#fb"/>\n<text x="-8,0" y="-36" class="diag">21</text>\n<use x="2" y="-31" xlink:href="#ddot"/>\n<use x="-6" y="-25" xlink:href="#ddot"/>\n</g>',e.Em7='<g id="Em7">\n<use xlink:href="#nut"/>\n<use xlink:href="#fb"/>\n<text x="-8" y="-36" class="diag">1</text>\n<use x="-6" y="-25" xlink:href="#ddot"/>\n</g>',e.Emaj7='<g id="Emaj7">\n<use xlink:href="#nut"/>\n<use xlink:href="#fb"/>\n<text x="-8,-4,0" y="-36" class="diag">312</text>\n<use x="2" y="-31" xlink:href="#ddot"/>\n<use x="-2" y="-31" xlink:href="#ddot"/>\n<use x="-6" y="-25" xlink:href="#ddot"/>\n</g>',e.Esus4='<g id="Esus4">\n<use xlink:href="#nut"/>\n<use xlink:href="#fb"/>\n<text x="-4,0" y="-36" class="diag">12</text>\n<use x="2" y="-25" xlink:href="#ddot"/>\n<use x="-2" y="-25" xlink:href="#ddot"/>\n</g>',e.F='<g id="F">\n<use xlink:href="#barre"/>\n<use xlink:href="#fr1"/>\n<use xlink:href="#fb"/>\n<text x="-8,-4,0" y="-36" class="diag">342</text>\n<use x="-2" y="-19" xlink:href="#ddot"/>\n<use x="-6" y="-19" xlink:href="#ddot"/>\n<use x="2" y="-25" xlink:href="#ddot"/>\n</g>',e.Fm='<g id="Fm">\n<use xlink:href="#barre"/>\n<use xlink:href="#fr1"/>\n<use xlink:href="#fb"/>\n<text x="-8,-4" y="-36" class="diag">34</text>\n<use x="-2" y="-19" xlink:href="#ddot"/>\n<use x="-6" y="-19" xlink:href="#ddot"/>\n</g>',e.F7='<g id="F7">\n<use xlink:href="#barre"/>\n<use xlink:href="#fr1"/>\n<use xlink:href="#fb"/>\n<text x="-8,0" y="-36" class="diag">32</text>\n<use x="2" y="-25" xlink:href="#ddot"/>\n<use x="-6" y="-19" xlink:href="#ddot"/>\n</g>',e.Fm7='<g id="Fm7">\n<use xlink:href="#barre"/>\n<use xlink:href="#fr1"/>\n<use xlink:href="#fb"/>\n<text x="-8" y="-36" class="diag">3</text>\n<use x="-6" y="-19" xlink:href="#ddot"/>\n</g>',e.Fmaj7='<g id="Fmaj7">\n<use xlink:href="#barre"/>\n<use xlink:href="#fr1"/>\n<use xlink:href="#fb"/>\n<text x="-8,-4,0" y="-36" class="diag">423</text>\n<use x="2" y="-25" xlink:href="#ddot"/>\n<use x="-2" y="-25" xlink:href="#ddot"/>\n<use x="-6" y="-19" xlink:href="#ddot"/>\n</g>',e.Fsus4='<g id="Fsus4">\n<use xlink:href="#barre"/>\n<use xlink:href="#fr1"/>\n<use xlink:href="#fb"/>\n<text x="-4,0" y="-36" class="diag">34</text>\n<use x="2" y="-19" xlink:href="#ddot"/>\n<use x="-2" y="-19" xlink:href="#ddot"/>\n</g>',e["F#"]='<g id="F#">\n<use xlink:href="#barre"/>\n<use xlink:href="#fr2"/>\n<use xlink:href="#fb"/>\n<text x="-8,-4,0" y="-36" class="diag">342</text>\n<use x="-2" y="-19" xlink:href="#ddot"/>\n<use x="-6" y="-19" xlink:href="#ddot"/>\n<use x="2" y="-25" xlink:href="#ddot"/>\n</g>',e["F#m"]='<g id="F#m">\n<use xlink:href="#barre"/>\n<use xlink:href="#fr2"/>\n<use xlink:href="#fb"/>\n<text x="-8,-4" y="-36" class="diag">34</text>\n<use x="-2" y="-19" xlink:href="#ddot"/>\n<use x="-6" y="-19" xlink:href="#ddot"/>\n</g>',e["F#7"]='<g id="F#7">\n<use xlink:href="#barre"/>\n<use xlink:href="#fr2"/>\n<use xlink:href="#fb"/>\n<text x="-8,0" y="-36" class="diag">32</text>\n<use x="2" y="-25" xlink:href="#ddot"/>\n<use x="-6" y="-19" xlink:href="#ddot"/>\n</g>',e["F#m7"]='<g id="F#m7">\n<use xlink:href="#barre"/>\n<use xlink:href="#fr2"/>\n<use xlink:href="#fb"/>\n<text x="-8" y="-36" class="diag">3</text>\n<use x="-6" y="-19" xlink:href="#ddot"/>\n</g>',e["F#maj7"]='<g id="F#maj7">\n<use xlink:href="#barre"/>\n<use xlink:href="#fr2"/>\n<use xlink:href="#fb"/>\n<text x="-8,-4,0" y="-36" class="diag">423</text>\n<use x="2" y="-25" xlink:href="#ddot"/>\n<use x="-2" y="-25" xlink:href="#ddot"/>\n<use x="-6" y="-19" xlink:href="#ddot"/>\n</g>',e["F#sus4"]='<g id="F#sus4">\n<use xlink:href="#barre"/>\n<use xlink:href="#fr2"/>\n<use xlink:href="#fb"/>\n<text x="-4,0" y="-36" class="diag">34</text>\n<use x="2" y="-19" xlink:href="#ddot"/>\n<use x="-2" y="-19" xlink:href="#ddot"/>\n</g>',e.G='<g id="G">\n<use xlink:href="#nut"/>\n<use xlink:href="#fb"/>\n<text x="-12,-8,8" y="-36" class="diag">234</text>\n<use x="10" y="-19" xlink:href="#ddot"/>\n<use x="-10" y="-19" xlink:href="#ddot"/>\n<use x="-6" y="-25" xlink:href="#ddot"/>\n</g>',e.Gm='<g id="Gm">\n<use xlink:href="#barre"/>\n<use xlink:href="#fr3"/>\n<use xlink:href="#fb"/>\n<text x="-8,-4" y="-36" class="diag">34</text>\n<use x="-2" y="-19" xlink:href="#ddot"/>\n<use x="-6" y="-19" xlink:href="#ddot"/>\n</g>',e.G7='<g id="G7">\n<use xlink:href="#nut"/>\n<use xlink:href="#fb"/>\n<text x="-12,-8,8" y="-36" class="diag">321</text>\n<use x="-10" y="-19" xlink:href="#ddot"/>\n<use x="-6" y="-25" xlink:href="#ddot"/>\n<use x="10" y="-31" xlink:href="#ddot"/>\n</g>',e.Gm7='<g id="Gm7">\n<use xlink:href="#barre"/>\n<use xlink:href="#fr3"/>\n<use xlink:href="#fb"/>\n<text x="-8" y="-36" class="diag">3</text>\n<use x="-6" y="-19" xlink:href="#ddot"/>\n</g>',e.Gmaj7='<g id="Gmaj7">\n<use xlink:href="#nut"/>\n<use xlink:href="#fb"/>\n<text x="-12,-8,8" y="-36" class="diag">312</text>\n<use x="10" y="-25" xlink:href="#ddot"/>\n<use x="-6" y="-25" xlink:href="#ddot"/>\n<use x="-10" y="-19" xlink:href="#ddot"/>\n</g>',e.Gsus4='<g id="Gsus4">\n<use xlink:href="#barre"/>\n<use xlink:href="#fr3"/>\n<use xlink:href="#fb"/>\n<text x="-4,0" y="-36" class="diag">34</text>\n<use x="2" y="-19" xlink:href="#ddot"/>\n<use x="-2" y="-19" xlink:href="#ddot"/>\n</g>',e.A='<g id="A">\n<use xlink:href="#nut"/>\n<use xlink:href="#fb"/>\n<text x="-4,0,4" y="-36" class="diag">234</text>\n<use x="6" y="-25" xlink:href="#ddot"/>\n<use x="2" y="-25" xlink:href="#ddot"/>\n<use x="-2" y="-25" xlink:href="#ddot"/>\n</g>',e.Am='<g id="Am">\n<use xlink:href="#nut"/>\n<use xlink:href="#fb"/>\n<text x="-4,0,4" y="-36" class="diag">231</text>\n<use x="2" y="-25" xlink:href="#ddot"/>\n<use x="-2" y="-25" xlink:href="#ddot"/>\n<use x="6" y="-31" xlink:href="#ddot"/>\n</g>',e.A7='<g id="A7">\n<use xlink:href="#nut"/>\n<use xlink:href="#fb"/>\n<text x="-4,4" y="-36" class="diag">23</text>\n<use x="6" y="-25" xlink:href="#ddot"/>\n<use x="-2" y="-25" xlink:href="#ddot"/>\n</g>',e.Am7='<g id="Am7">\n<use xlink:href="#nut"/>\n<use xlink:href="#fb"/>\n<text x="-4,4" y="-36" class="diag">21</text>\n<use x="6" y="-31" xlink:href="#ddot"/>\n<use x="-2" y="-25" xlink:href="#ddot"/>\n</g>',e.Amaj7='<g id="Amaj7">\n<use xlink:href="#nut"/>\n<use xlink:href="#fb"/>\n<text x="-12,-4,0,4" y="-36" class="diag">x213</text>\n<use x="6" y="-25" xlink:href="#ddot"/>\n<use x="2" y="-31" xlink:href="#ddot"/>\n<use x="-2" y="-25" xlink:href="#ddot"/>\n</g>',e.Asus4='<g id="Asus4">\n<use xlink:href="#nut"/>\n<use xlink:href="#fb"/>\n<text x="-12,0,4" y="-36" class="diag">x12</text>\n<use x="6" y="-19" xlink:href="#ddot"/>\n<use x="2" y="-25" xlink:href="#ddot"/>\n</g>',e.B='<g id="B">\n<use xlink:href="#barre"/>\n<use xlink:href="#fr2"/>\n<use xlink:href="#fb"/>\n<text x="-4,0,4" y="-36" class="diag">234</text>\n<use x="6" y="-19" xlink:href="#ddot"/>\n<use x="2" y="-19" xlink:href="#ddot"/>\n<use x="-2" y="-19" xlink:href="#ddot"/>\n</g>',e.Bm='<g id="Bm">\n<use xlink:href="#barre"/>\n<use xlink:href="#fr2"/>\n<use xlink:href="#fb"/>\n<text x="-4,0,4" y="-36" class="diag">341</text>\n<use x="6" y="-25" xlink:href="#ddot"/>\n<use x="2" y="-19" xlink:href="#ddot"/>\n<use x="-2" y="-19" xlink:href="#ddot"/>\n</g>',e.B7='<g id="B7">\n<use xlink:href="#nut"/>\n<use xlink:href="#fb"/>\n<text x="-12,-8,-4,0,8" y="-36" class="diag">x2134</text>\n<use x="10" y="-25" xlink:href="#ddot"/>\n<use x="2" y="-25" xlink:href="#ddot"/>\n<use x="-6" y="-25" xlink:href="#ddot"/>\n<use x="-2" y="-31" xlink:href="#ddot"/>\n</g>',e.Bm7='<g id="Bm7">\n<use xlink:href="#barre"/>\n<use xlink:href="#fr2"/>\n<use xlink:href="#fb"/>\n<text x="-12,0,8" y="-36" class="diag">x32</text>\n<use x="-2" y="-19" xlink:href="#ddot"/>\n<use x="6" y="-25" xlink:href="#ddot"/>\n</g>',e.Bmaj7='<g id="Bmaj7">\n<use xlink:href="#barre"/>\n<use xlink:href="#fr2"/>\n<use xlink:href="#fb"/>\n<text x="-12,-4,0,4" y="-36" class="diag">x324</text>\n<use x="6" y="-19" xlink:href="#ddot"/>\n<use x="2" y="-25" xlink:href="#ddot"/>\n<use x="-2" y="-19" xlink:href="#ddot"/>\n</g>',e.Bsus4='<g id="Bsus4">\n<use xlink:href="#barre"/>\n<use xlink:href="#fr2"/>\n<use xlink:href="#fb"/>\n<text x="-12,0,4" y="-36" class="diag">x34</text>\n<use x="6" y="-19" xlink:href="#ddot"/>\n<use x="2" y="-25" xlink:href="#ddot"/>\n</g>'}var o,n,u,a;for(o=t[0].sym;o;o=o.next){if(!o.a_gch)continue;for(n=0;n<o.a_gch.length;n++){u=o.a_gch[n];if(!u||u.type!="g"||u.capo)continue;a=u.otext||u.text,this.deco_cnv(a.split(/[ \t/]/,1),o,null)}}},output_music:function(e){this.cfmt().diag&&abc2svg.diag.do_diag.call(this),e()},set_fmt:function(e,t,n,r){if(t=="diagram"){this.cfmt().diag=n;return}e(t,n,r)},set_hooks:function(e){e.output_music=abc2svg.diag.output_music.bind(e,e.output_music),e.set_format=abc2svg.diag.set_fmt.bind(e,e.set_format)}},abc2svg.modules.hooks.push(abc2svg.diag.set_hooks),abc2svg.modules.diagram.loaded=!0,abc2svg.grid={do_grid:function(){function a(t){var n=e.BLEN/4;return!t.a_meter[0]||t.a_meter[0].top[0]=="C"||!t.a_meter[0].bot?n:(n=e.BLEN/t.a_meter[0].bot[0]|0,t.a_meter[0].bot[0]==8&&t.a_meter[0].top[0]%3==0&&(n=e.BLEN/8*3),n)}function f(e,t,n,a){function C(){var t,n,r="-";for(t=0;t<e.length;t++){n=e[t],n[0]||(n[0]=r);if(n.length==0)continue;if(n.length==1){r=n[0];continue}if(n.length==2){n[2]=n[1],r=n[2];continue}if(n.length==3){r=n[2];continue}n[2]||(n[2]=n[1]||n[0]),r=n[3]}}var f,l,c,h,p,d,v,m,g,y,b,w,E,S="",x="",T=[],N=u.n;C();if(!u.ls)T=e;else{v=t,t=[];for(f=0;f<u.ls.length;f++){h=u.ls[f],h.indexOf("-")<0?h=[h,h]:h=h.split("-");for(c=h[0]-1;c<h[1];c++){if(!e[c])break;T.push(e[c]),t.push(v[c])}}}N<0&&(N=-N),N<3&&(N=T.length%6==0?6:8),N>T.length&&(N=T.length),p=(T.length+N-1)/N|0,g=n.size*2,a<g*1.4&&(a=g*1.4),m=a*N,m>r.width&&(N/=2,p*=2,m/=2),d='<svg xmlns="http://www.w3.org/2000/svg" version="1.1"\n xmlns:xlink="http://www.w3.org/1999/xlink"\n color="black" width="'+r.width.toFixed(0)+'px" height="'+(g*p+6).toFixed(0)+'px"',f=o.bgcolor,f&&(d+=' style="background-color: '+f+'"'),d+='>\n<style type="text/css">\n.mid {text-anchor:middle}\n',o.fullsvg&&(d+=".stroke {stroke: currentColor; fill: none}\n."+i+" {"+this.style_font(n.name+"."+n.size)+"}\n"),d+="</style>\n",d+='<path class="stroke" d="\n',y=(r.width-m)/2,w=1;for(l=0;l<=p;l++)d+="M"+y.toFixed(2)+" "+w.toFixed(2)+"h"+m.toFixed(2)+"\n",w+=g;b=y;for(f=0;f<=N;f++)d+="M"+b.toFixed(2)+" 1v"+(g*p).toFixed(2)+"\n",b+=a;d+='"/>\n',w=1-g/2+n.size*.3,E=1;for(f=0;f<T.length;f++)S=T[f],f%N==0&&(w+=g,E+=g,b=y+a/2),S.length>1?(d+='<path class="stroke" stroke-width="1" d="M'+(b-a/2).toFixed(2)+" "+E.toFixed(2)+"l"+a.toFixed(2)+" -"+g.toFixed(2)+'"/>\n',S[1]?(d+='<path class="stroke" stroke-width="1" d="M'+(b-a/2).toFixed(2)+" "+(E-g).toFixed(2)+"l"+(a/2).toFixed(2)+" "+(g/2).toFixed(2)+'"/>\n',d+='<text class="'+s+'" style="font-size:'+(n.size*.72).toFixed(2)+'" x="'+(b-a/3).toFixed(2)+'" y="'+w.toFixed(2)+'">'+S[0]+"</text>\n",d+='<text class="'+s+'" style="font-size:'+(n.size*.72).toFixed(2)+'" x="'+b.toFixed(2)+'" y="'+(w-g/3).toFixed(2)+'">'+S[1]+"</text>\n"):d+='<text class="'+s+'" style="font-size:'+(n.size*.72).toFixed(2)+'" x="'+(b-a*.2).toFixed(2)+'" y="'+(w-g/4).toFixed(2)+'">'+S[0]+"</text>\n",S.length>=3&&(S[3]?(d+='<path class="stroke" stroke-width="1" d="M'+b.toFixed(2)+" "+(E-g/2).toFixed(2)+"l"+(a/2).toFixed(2)+" "+(g/2).toFixed(2)+'"/>\n',d+='<text class="'+s+'" style="font-size:'+(n.size*.72).toFixed(2)+'" x="'+b.toFixed(2)+'" y="'+(w+g/3).toFixed(2)+'">'+S[2]+"</text>\n",d+='<text class="'+s+'" style="font-size:'+(n.size*.72).toFixed(2)+'" x="'+(b+a/3).toFixed(2)+'" y="'+w.toFixed(2)+'">'+S[3]+"</text>\n"):d+='<text class="'+s+'" style="font-size:'+(n.size*.72).toFixed(2)+'" x="'+(b+a*.2).toFixed(2)+'" y="'+(w+g/4).toFixed(2)+'">'+S[2]+"</text>\n")):d+='<text class="'+s+'" x="'+b.toFixed(2)+'" y="'+w.toFixed(2)+'">'+S[0]+"</text>\n",b+=a;w=1-g/2+n.size*.3,b=y;for(f=0;f<t.length;f++)v=t[f],v[0]==":"&&(d+='<text class="'+s+'" x="'+(b-5).toFixed(2)+'" y="'+w.toFixed(2)+'" style="font-weight:bold;font-size:'+(n.size+2).toFixed(2)+'">:</text>\n'),f%N==0&&(w+=g,b=y),v[v.length-1]==":"&&(d+='<text class="'+s+'" x="'+(b+5).toFixed(2)+'" y="'+w.toFixed(2)+'" style="font-weight:bold;font-size:'+(n.size+2).toFixed(2)+'">:</text>\n'),b+=a;return d+"</svg>"}var e=abc2svg.C,t=this.get_tsfirst(),n=this.get_voice_tb(),r,i,s,o=this.cfmt(),u=o.grid,l,c,h,p,d,v,m,g,y,b,w,E,S,x=[],T=[],N=[];r=this.get_img(),c=a(n[0].meter),y=n[0].meter.wmeasure,o.gridfont||this.param_set_font("gridfont","serif 16"),g=this.get_font("grid"),i=this.font_class(g),s=i+" mid",this.set_font("grid"),h=d=m=E=0,x.push("|");for(l=n[0].sym;l;l=l.next){while(l.time>h)d<3&&d++,h+=c;switch(l.type){case e.NOTE:case e.REST:if(l.a_gch)for(p=0;p<l.a_gch.length;p++)if(l.a_gch[p].type=="g"){N[d]||(N[d]=l.a_gch[p].text,w=this.strwh(N[d])[0],w>E&&(E=w),m++);break}break;case e.BAR:b=u.norep?"|":l.bar_type;if(l.time<y)N.length?(T.push(N),x.push(b)):x[0]=b;else{if(!l.bar_num)break;T.push(N),x.push(b)}N=[],h=l.time,d=0,b.indexOf(":")&&(S=!0);break;case e.METER:c=a(l),y=l.wmeasure}}if(m==0)return;N.length!=0&&(x.push(""),T.push(N)),E+=this.strwh(S?" ":" ")[0],v=n[this.get_top_v()],l={type:e.BLOCK,subtype:"ml",dur:0,time:0,p_v:v,v:v.v,text:f.call(this,T,x,g,E)};if(o.grid.n<0){for(var C=t;C.ts_next;C=C.ts_next);l.time=C.time,l.prev=v.last_sym,l.ts_prev=C,v.last_sym.next=l,C.ts_next=l}else l.time=0,l.next=v.sym,l.ts_next=t,t.ts_prev=l,t=l,this.set_tsfirst(l),v.sym.prev=l,v.sym=l},output_music:function(e){this.cfmt().grid&&abc2svg.grid.do_grid.call(this),e()},set_fmt:function(e,t,n,r){if(t=="grid"){n||(n="1"),n=n.split(/\s+/);var i=this.cfmt().grid={n:Number(n.shift())};isNaN(i.n)&&(i.n=1);while(n.length){var s=n.shift();s=="norepeat"?i.norep=!0:s.slice(0,8)=="include="&&(i.ls=s.slice(8).split(","))}return}e(t,n,r)},set_hooks:function(e){e.output_music=abc2svg.grid.output_music.bind(e,e.output_music),e.set_format=abc2svg.grid.set_fmt.bind(e,e.set_format)}},abc2svg.modules.hooks.push(abc2svg.grid.set_hooks),abc2svg.modules.grid.loaded=!0,abc2svg.equalbars={output_music:function(e){this.equalbars_d=0,e()},set_fmt:function(e,t,n,r){t=="equalbars"?this.cfmt().equalbars=this.get_bool(n):e(t,n,r)},set_sym_glue:function(e,t){var n=abc2svg.C,r,i,s,o,u,a,l,c,h,p=[],v=this.get_tsfirst();e(t);if(!this.cfmt().equalbars)return;for(i=v;i;i=i.ts_next){if(!i.seqst)continue;switch(i.type){default:continue;case n.BAR:case n.GRACE:case n.MREST:case n.NOTE:case n.REST:case n.SPACE:}break}if(!i)return;r=i.ts_next,h=c=r.time;for(;;){if(!r.ts_next){p.push([r,r.time-c]),c=r.time,r.dur&&(c+=r.dur);break}r.type==n.BAR&&r.seqst&&(p.push([r,r.time-c]),c=r.time),r=r.ts_next}u=p.length;if(u==0)return;a=i.type==n.GRACE?i.extra.x:i.x,d=this.equalbars_d,d||(d=this.equalbars_d=a),s=(t-d)/(c-h);for(o=0;o<u;o++){r=p[o][0],f=s*p[o][1]/(r.x-a);for(;i!=r;i=i.ts_next)if(i.type==n.GRACE)for(l=i.extra;l;l=l.next)l.x=d+(l.x-a)*f;else i.x&&(i.x=d+(i.x-a)*f);d+=s*p[o][1],a=i.x;for(;;){i.x=d,i=i.ts_next;if(!i||i.seqst)break}if(!i)break}},set_hooks:function(e){e.output_music=abc2svg.equalbars.output_music.bind(e,e.output_music),e.set_format=abc2svg.equalbars.set_fmt.bind(e,e.set_format),e.set_sym_glue=abc2svg.equalbars.set_sym_glue.bind(e,e.set_sym_glue)}},abc2svg.modules.hooks.push(abc2svg.equalbars.set_hooks),abc2svg.modules.equalbars.loaded=!0,abc2svg.perc={do_perc:function(e){function i(e){var i,s,o,u=Number(e);if(isNaN(u)){o=e.match(/^([_^=]*)([A-Ga-g])([,']*)$/);if(o){i="CDEFGABcdefgab".indexOf(o[2])+16;switch(o[3]){case"'":i+=7*o[3].length;break;case",":i-=7*o[3].length}note={pit:i};switch(o[1]){case"^":note.acc=1;break;case"_":note.acc=-1}return note}e=e.toLowerCase(e),o=e[0],i=0;for(;;){s=e.indexOf("-",i);if(s<0)break;i=s+1,o+="-"+e[i]}u=r[o];if(!u)switch(e[0]){case"c":switch(e[1]){case"a":u=r.ca;break;case"l":u=r.cl;break;case"o":u=r.co}break;case"h":case"l":i=e.indexOf("-");if(e[i+1]!="t")break;switch(e[1]){case"i":case"o":u=r[o+e[1]]}}}if(!u)return;return e=(u/12|0)*7-19,u%=12,e+=t[u],note={pit:e},n[u]&&(note.acc=n[u]),note}function s(e){var t=e.match(/^([_^]*)([A-Ga-g])([,']*)$/);if(!t)return;return e.match(/[A-Z]/)&&(e=e.toLowerCase(),e.indexOf("'")>0?e=e.replace("'",""):e+=","),e}var t=new Int8Array([0,0,1,2,2,3,3,4,5,5,6,6]),n=new Int8Array([0,1,0,-1,0,0,1,0,-1,0,-1,0]),r={"a-b-d":35,"a-s":38,"b-d-1":36,ca:69,cl:75,co:56,"c-c":52,"c-c-1":49,"c-c-2":57,"c-h-h":42,"e-s":40,"h-a":67,"h-b":60,"h-c":39,"h-f-t":43,"h-m-t":48,"h-ti":65,"h-to":50,"h-w-b":76,"l-a":68,"l-b":61,"l-c":64,"l-f-t":41,"l-g":74,"l-m-t":47,"l-ti":66,"l-to":45,"l-w":72,"l-w-b":77,m:70,"m-c":78,"m-h-c":62,"m-t":80,"o-c":79,"o-h-c":63,"o-h-h":46,"o-t":81,"p-h-h":44,"r-b":53,"r-c-1":51,"r-c-2":59,"s-c":55,"s-g":73,"s-s":37,"s-w":71,t:54,v:58},o,u,a=this.get_maps(),f=e.split(/\s+/);o=s(f[1]);if(!o){this.syntax(1,this.errs.bad_val,"%%percmap");return}if(this.cfmt().sound!="play"){if(!f[3])return;a.MIDIdrum||(a.MIDIdrum={}),u=i(o);if(!u){this.syntax(1,this.errs.bad_val,"%%percmap");return}delete u.acc,a.MIDIdrum[o]=[[f[3]],u]}else{u=i(f[2]);if(!u){this.syntax(1,this.errs.bad_val,"%%percmap");return}a.MIDIdrum||(a.MIDIdrum={}),a.MIDIdrum[o]=[null,u]}this.set_v_param("perc","MIDIdrum")},set_perc:function(e){var t,n,r=this.get_curvoice();for(t=0;t<e.length;t++)switch(e[t]){case"perc=":r.map||(r.map={}),r.map=e[t+1],r.midictl||(r.midictl={}),r.midictl[0]=1}},do_pscom:function(e,t){t.slice(0,8)=="percmap "?abc2svg.perc.do_perc.call(this,t):e(t)},set_vp:function(e,t){abc2svg.perc.set_perc.call(this,t),e(t)},set_hooks:function(e){e.do_pscom=abc2svg.perc.do_pscom.bind(e,e.do_pscom),e.set_vp=abc2svg.perc.set_vp.bind(e,e.set_vp)}},abc2svg.modules.hooks.push(abc2svg.perc.set_hooks),abc2svg.modules.percmap.loaded=!0,abc2svg.ambitus={do_ambitus:function(){var e=abc2svg.C,t,n,r,i,s,o=this.get_voice_tb();for(n=0;n<o.length;n++){r=o[n];if(r.second)continue;i=100,s=-100;for(t=r.sym;t;t=t.next){if(t.type!=e.NOTE)continue;t.notes[t.nhd].pit>s&&(s=t.notes[t.nhd].pit),t.notes[0].pit<i&&(i=t.notes[0].pit)}if(i==100)continue;t=r.clef,t.stem=1,t.head=e.FULL,t.stemless=!0,t.nhd=1,t.notes=[{dur:e.BLEN/4,pit:i,shhd:0},{dur:e.BLEN/4,pit:s,shhd:0}]}},draw_symbols:function(e,t){var n=this.get_staff_tb(),r=t.sym;r.clef_type!=undefined&&r.nhd>0&&(r.x-=26,this.set_scale(r),this.draw_note(r),r.notes[1].pit-r.notes[0].pit>4&&(this.xypath(r.x,3*(r.notes[1].pit-18)+n[r.st].y),this.out_svg("v"+((r.notes[1].pit-r.notes[0].pit)*3).toFixed(2)+'" stroke-width=".6"/>\n')),r.x+=26,t.clef.nhd=0),e(t)},set_pitch:function(e,t){e(t),!t&&this.cfmt().ambitus&&abc2svg.ambitus.do_ambitus.call(this)},set_fmt:function(e,t,n,r){if(t=="ambitus"){this.cfmt().ambitus=n;return}e(t,n,r)},set_width:function(e,t){t.clef_type!=undefined&&t.nhd>0?(t.wl=40,t.wr=12):e(t)},set_hooks:function(e){e.draw_symbols=abc2svg.ambitus.draw_symbols.bind(e,e.draw_symbols),e.set_pitch=abc2svg.ambitus.set_pitch.bind(e,e.set_pitch),e.set_format=abc2svg.ambitus.set_fmt.bind(e,e.set_format),e.set_width=abc2svg.ambitus.set_width.bind(e,e.set_width)}},abc2svg.modules.hooks.push(abc2svg.ambitus.set_hooks),abc2svg.modules.ambitus.loaded=!0,abc2svg.break={get_break:function(e){var t=abc2svg.C,r,i,s,o,u=e.split(/[ ,]/),a=this.cfmt();a.break||(a.break=[]);for(n=1;n<u.length;n++){r=u[n],i=r.match(/(\d+)([a-z]?)(:\d+\/\d+)?/);if(!i){this.syntax(1,this.errs.bad_val,"%%break");continue}i[2]&&(o=i[2].charCodeAt(0)-97);if(!i[3]){a.break.push({m:i[1],t:0,sq:o});continue}s=i[3].match(/:(\d+)\/(\d+)/);if(!s||s[2]<1){this.syntax(1,"Bad denominator in %%break");continue}a.break.push({m:i[1],t:s[1]*t.BLEN/s[2],sq:o})}},do_break:function(){var e,t,n,r,i,o=this.get_voice_tb();v=this.get_cur_sy().top_voice,s1=o[v].sym,cfmt=this.cfmt();for(e=0;e<cfmt.break.length;e++){r=cfmt.break[e],t=r.m;for(s=s1;s;s=s.next)if(s.bar_num==t)break;if(!s)continue;if(r.sq){i=r.sq;for(s=s.ts_next;s;s=s.ts_next)if(s.bar_num==t&&--i==0)break;if(!s)continue}n=r.t;if(n){n=s.time+n;for(;s;s=s.next)if(s.time>=n)break;if(!s)continue;s=s.prev}s.eoln=!0}},do_pscom:function(e,t){t.slice(0,6)=="break "?abc2svg.break.get_break.call(this,t):e(t)},set_bar_num:function(e){e(),this.cfmt().break&&abc2svg.break.do_break.call(this)},set_hooks:function(e){e.do_pscom=abc2svg.break.do_pscom.bind(e,e.do_pscom),e.set_bar_num=abc2svg.break.set_bar_num.bind(e,e.set_bar_num)}},abc2svg.modules.hooks.push(abc2svg.break.set_hooks),abc2svg.modules.break.loaded=!0,abc2svg.capo={gch_capo:function(e){var t,n,r,i=this.cfmt(),s=i.capo,o=0;for(;;){t=e[o++];if(!t)return;if(t.type=="g")break}n=Object.create(t),n.capo=!1,n.text=this.gch_tr1(n.text,[0,5,-2,3,-4,1,-6,-1,4,-3,2,-5][s%12]),this.capo_first||(this.capo_first=!0,n.text+=" (capo: "+s.toString()+")"),n.font=this.get_font(i.capofont?"capo":"annotation"),e.splice(o,0,n),t.capo=!0},gch_build:function(e,t){var n=this.get_a_gch();this.cfmt().capo&&n&&abc2svg.capo.gch_capo.call(this,n),e(t)},output_music:function(e){this.capo_first=!1,e()},set_fmt:function(e,t,n,r){if(t=="capo"){this.cfmt().capo=n;return}e(t,n,r)},set_hooks:function(e){e.gch_build=abc2svg.capo.gch_build.bind(e,e.gch_build),e.output_music=abc2svg.capo.output_music.bind(e,e.output_music),e.set_format=abc2svg.capo.set_fmt.bind(e,e.set_format)}},abc2svg.modules.hooks.push(abc2svg.capo.set_hooks),abc2svg.modules.capo.loaded=!0,abc2svg.clip={get_clip:function(e){function n(e){var n,r,i,s=e.match(/(\d+)([a-z]?)(:\d+\/\d+)?/);if(!s)return;s[2]&&(i=s[2].charCodeAt(0)-97);if(!s[3])return{m:s[1],t:0,sq:i};e=s[3].match(/:(\d+)\/(\d+)/);if(!e||e[2]<1)return;return{m:s[1],t:e[1]*t.BLEN/e[2],sq:i}}var t=abc2svg.C,r,i,s=e.split(/[ -]/);if(s.length!=3){this.syntax(1,this.errs.bad_val,"%%clip");return}s[1]?r=n(s[1]):r={m:0,t:0},i=n(s[2]);if(!r||!i){this.syntax(1,this.errs.bad_val,"%%clip");return}this.cfmt().clip=[r,i]},do_clip:function(){function t(t,n){var r,i,s;if(n.m<=1){if(n.m==1){for(r=t;r;r=r.ts_next)if(r.type==e.BAR&&r.time!=0)break;r.time<voice_tb[this.get_cur_sy().top_voice].meter.wmeasure&&(t=r)}}else{for(;t;t=t.ts_next)if(t.type==e.BAR&&t.bar_num>=n.m)break;if(!t)return;if(n.sq){s=n.sq;for(t=t.ts_next;t;t=t.ts_next)if(t.type==e.BAR&&t.bar_num==n.m&&--s==0)break;if(!t)return}}if(n.t==0)return t;i=t.time+n.t;while(t.time<i){t=t.ts_next;if(!t)return t}do t=t.ts_prev;while(!t.seqst);return t}var e=abc2svg.C;voice_tb=this.get_voice_tb(),cfmt=this.cfmt();var n,r,i,s,o;n=this.get_tsfirst();if(cfmt.clip[0].m>0||cfmt.clip[0].t>0){n=t(n,cfmt.clip[0]);if(!n){this.set_tsfirst(null);return}i=this.get_cur_sy();for(r=this.get_tsfirst();r!=n;r=r.ts_next)switch(r.type){case e.CLEF:r.p_v.clef=r;break;case e.KEY:r.p_v.key=this.clone(r.as.u.key);break;case e.METER:r.p_v.meter=this.clone(r.as.u.meter);break;case e.STAVES:i=r.sy,this.set_cur_sy(i)}for(o=0;o<voice_tb.length;o++){s=voice_tb[o];for(r=n;r;r=r.ts_next)if(r.v==o){delete r.prev;break}s.sym=r}this.set_tsfirst(n),delete n.ts_prev}n=t(n,cfmt.clip[1]);if(!n)return;do{n=n.ts_next;if(!n)return}while(!n.seqst);for(o=0;o<voice_tb.length;o++){s=voice_tb[o];for(r=n.ts_prev;r;r=r.ts_prev)if(r.v==o){delete r.next;break}r||(s.sym=null)}delete n.ts_prev.ts_next},do_pscom:function(e,t){t.slice(0,5)=="clip "?abc2svg.clip.get_clip.call(this,t):e(t)},set_bar_num:function(e){e(),this.cfmt().clip&&abc2svg.clip.do_clip.call(this)},set_hooks:function(e){e.do_pscom=abc2svg.clip.do_pscom.bind(e,e.do_pscom),e.set_bar_num=abc2svg.clip.set_bar_num.bind(e,e.set_bar_num)}},abc2svg.modules.hooks.push(abc2svg.clip.set_hooks),abc2svg.modules.clip.loaded=!0,abc2svg.grid2={do_grid:function(){var e,t,n,r=this.get_voice_tb();for(t=0;t<r.length;t++){n=r[t];if(!n.grid2)continue;n.clef.invis=!0,n.key.k_sf=n.key.k_a_acc=0,n.staffnonote=2;for(e=n.sym;e;e=e.next)e.dur&&(e.invis=!0,delete e.sl1,e.ti1=0)}},draw_chosym:function(e){var t,n;this.set_dscale(e.st);for(t=0;t<e.a_gch.length;t++){n=e.a_gch[t];if(n.type!="g")continue;this.use_font(n.font),this.set_font(n.font),this.xy_str(e.x+n.x,n.y+6,n.text)}},draw_gchord:function(e,t,n,r){t.p_v.grid2?abc2svg.grid2.draw_chosym.call(this,t):e(t,n,r)},output_music:function(e){abc2svg.grid2.do_grid.call(this),e()},set_fmt:function(e,t,n,r){if(t=="grid2"){var i=this.get_curvoice();i&&(this.set_v_param("stafflines","..."),i.grid2=n);return}e(t,n,r)},set_hooks:function(e){e.draw_gchord=abc2svg.grid2.draw_gchord.bind(e,e.draw_gchord),e.output_music=abc2svg.grid2.output_music.bind(e,e.output_music),e.set_format=abc2svg.grid2.set_fmt.bind(e,e.set_format)}},abc2svg.modules.hooks.push(abc2svg.grid2.set_hooks),abc2svg.modules.grid2.loaded=!0,abc2svg.psvg={do_begin_end:function(e,t,n,r){if(t!="ps"){e(t,n,r);return}if(n=="nosvg")return;this.psvg||(this.psvg=new Psvg(this)),this.psvg.ps_eval.call(this.psvg,r)},psdeco:function(e,t,n,r,i){return this.psvg?this.psvg.psdeco.call(this.psvg,t,n,r,i):!1},psxygl:function(e,t,n,r){return this.psvg?this.psvg.psxygl.call(this.psvg,t,n,r):!1},set_hooks:function(e){e.do_begin_end=abc2svg.psvg.do_begin_end.bind(e,e.do_begin_end),e.psdeco=abc2svg.psvg.psdeco.bind(e,e.psdeco),e.psxygl=abc2svg.psvg.psxygl.bind(e,e.psxygl)}},abc2svg.modules.hooks.push(abc2svg.psvg.set_hooks),abc2svg.modules.beginps.loaded=!0,abc2svg.soloffs={set_fmt:function(e,t,n,r){if(t=="soloffs"){var i,s,o=abc2svg.C,u=this.cfmt().soloffs={};n=n.split(/\s+/);while(n.length){i=n.shift().split("="),s=Number(i[1]);if(isNaN(s))continue;switch(i[0]){case"part":u[o.PART]=s+10;break;case"tempo":u[o.TEMPO]=s+16;break;case"space":u[o.SPACE]=s}}return}e(t,n,r)},set_sym_glue:function(e,t){var n,r=abc2svg.C,i=this.get_tsfirst(),s=this.cfmt().soloffs;e(t);if(!s)return;for(n=i;n;n=n.ts_next){if(n.dur)break;s[n.type]!=undefined&&(n.x=s[n.type])}},set_hooks:function(e){e.set_sym_glue=abc2svg.soloffs.set_sym_glue.bind(e,e.set_sym_glue),e.set_format=abc2svg.soloffs.set_fmt.bind(e,e.set_format)}},abc2svg.modules.hooks.push(abc2svg.soloffs.set_hooks),abc2svg.modules.soloffs.loaded=!0,abc2svg.temper={set_bar_num:function(e){e();if(this.cfmt().temper){var t=this.get_voice_tb()[0];t.temper=new Float32Array(12);for(var n=0;n<12;n++)t.temper[n]=this.cfmt().temper[n]/100}},set_fmt:function(e,t,n,r){if(t=="temperament"){var i=new Float32Array(n.split(/ +/)),s=i.length;if(s==12){while(--s>=0)if(isNaN(parseInt(i[s])))break;if(s<0){this.cfmt().temper=i;return}}this.syntax(1,this.errs.bad_val,"%%temperament");return}e(t,n,r)},set_hooks:function(e){e.set_bar_num=abc2svg.temper.set_bar_num.bind(e,e.set_bar_num),e.set_format=abc2svg.temper.set_fmt.bind(e,e.set_format)}},abc2svg.modules.hooks.push(abc2svg.temper.set_hooks),abc2svg.modules.temperament.loaded=!0,abc2svg.sth={recal_beam:function(e,t){var n=this.get_staff_tb(),r=n[t.st].y,i=e.s2,s=n[i.st].y;t.sth&&(t.ys=t.sth),i.sth&&(i.ys=i.sth),e.a=(t.ys+r-i.ys-s)/(t.xs-i.xs),e.b=t.ys-t.xs*e.a+r;for(;;){t.ys=e.a*t.xs+e.b-r,t.stem>0?t.ymx=t.ys+2.5:t.ymn=t.ys-2.5,t=t.next;if(t==i)break}},set_sth:function(){var e,t,n,r,i,s=this.get_voice_tb();for(n=0;n<s.length;n++){i=s[n];if(i.sth!=null)continue;r=[];for(e=i.sym;e;e=e.next){e.sth&&(r=e.sth,e.sth=null);if(r.length==0||e.nflags<=-2||e.stemless||!e.beam_st&&!e.beam_end)continue;t=r.shift();if(t=="*")continue;if(t=="|"){for(e=e.next;e;e=e.next)if(e.bar_type)break;continue}t=Number(t);if(isNaN(t)||!t)continue;e.stem>=0?(e.ys=e.y+t,e.ymx=e.ys+2.5|0):(e.ys=e.y-t,e.ymn=e.ys-2.5|0),e.sth=e.ys}}},calculate_beam:function(e,t,n){var r=e(t,n);return r&&t.s2&&(n.sth||t.s2.sth)&&abc2svg.sth.recal_beam.call(this,t,n),r},new_note:function(e,t,n){var r=abc2svg.C,i=e(t,n),s=this.get_curvoice();return s.sth&&i&&i.type==r.NOTE&&(i.sth=s.sth,s.sth=null),i},set_format:function(e,t,n,r){if(t=="sth"){var i=this.get_curvoice();this.parse.state==2&&this.goto_tune(),i&&(i.sth=n.split(/[ \t;-]+/));return}e(t,n,r)},set_stems:function(e){e(),abc2svg.sth.set_sth.call(this)},set_hooks:function(e){e.calculate_beam=abc2svg.sth.calculate_beam.bind(e,e.calculate_beam),e.new_note=abc2svg.sth.new_note.bind(e,e.new_note),e.set_format=abc2svg.sth.set_format.bind(e,e.set_format),e.set_stems=abc2svg.sth.set_stems.bind(e,e.set_stems)}},abc2svg.modules.hooks.push(abc2svg.sth.set_hooks),abc2svg.modules.sth.loaded=!0 function
/plugin/diagramsnet/lib/WEB-INF/lib/
H A Dhttpclient-4.5.5.jarMETA-INF/MANIFEST.MF META-INF/ org/ org/apache/ org/ ...
/plugin/amcharts/assets/amcharts/plugins/export/libs/pdfmake/
H A Dpdfmake.min.js.map1stack","followingNodeList","pageBreak","pageBreakCalculated","pageNumber","followingNodesOnPage","…
/plugin/sequencediagram/bower_components/snap.svg/doc/css/
H A Dtopcoat-desktop-light.css3524 .topcoat-icon--menu-stack {
/plugin/jdraw/lib/
H A Djgraphx.jarMETA-INF/MANIFEST.MF META-INF/HAMMURAP.SF META-INF/HAMMURAP ...

1...<<111213141516