diff --git a/backend/omr/dist/gauge-server.js b/backend/omr/dist/gauge-server.js index 22b6314db4dd5fc0ff3d01c27745bb29ff486a9d..7c6d2b6b4396af9ea26e7d68f18f80e2a6a6b04e 100644 --- a/backend/omr/dist/gauge-server.js +++ b/backend/omr/dist/gauge-server.js @@ -1,2 +1,2 @@ -"use strict";var e=require("yargs"),t=require("msgpackr"),i=require("zeromq"),r=require("skia-canvas");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=n(require("gl"));globalThis.ImageData=r.ImageData;const o=e=>{const t=[];for(const i of e)for(const e of i)t.push(e);return t};class GLCanvas{constructor(e){this._width=256,this._height=192,this.ctx=e}get width(){return this._width}set width(e){this._width=e;this.ctx.getExtension("STACKGL_resize_drawingbuffer").resize(e,this.height)}get height(){return this._height}set height(e){this._height=e;this.ctx.getExtension("STACKGL_resize_drawingbuffer").resize(this.width,e)}addEventListener(e){}async toBuffer(){const e=new Uint8Array(this.width*this.height*4);this.ctx.readPixels(0,0,this.width,this.height,this.ctx.RGBA,this.ctx.UNSIGNED_BYTE,e);const t=new r.Canvas(this.width,this.height);return t.getContext("2d").putImageData(new r.ImageData(new Uint8ClampedArray(e),this.width,this.height),0,0),t.toBuffer("png")}}const s=a.default(512,192,{antialias:!0});const h=new class GaugeRenderer{constructor(e){this.width=256,this.height=192,this.source=e.source,this.gauge=e.gauge,this.canvas=new GLCanvas(s),s.getShaderPrecisionFormat(s.VERTEX_SHADER,s.HIGH_FLOAT),s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.HIGH_FLOAT),s.getExtension("OES_element_index_uint"),this.program=s.createProgram();const t=s.createShader(s.VERTEX_SHADER);s.shaderSource(t,"//#version 300 es\n//#define attribute in\n//#define varying out\n//#define texture2D texture\n\nprecision highp float;\nprecision highp int;\n\n#define HIGH_PRECISION\n#define SHADER_NAME MeshBasicMaterial\n#define VERTEX_TEXTURES\n#define USE_MAP\n#define USE_UV\n#define BONE_TEXTURE\n#define DOUBLE_SIDED\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform vec3 cameraPosition;\n\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\n\n#ifdef USE_UV\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif\n\nvoid main() {\n#ifdef USE_UV\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n#endif\n\n\tvec3 transformed = vec3( position );\n\n\tvec4 mvPosition = vec4( transformed, 1.0 );\n\tmvPosition = modelViewMatrix * mvPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n}\n"),s.compileShader(t);const i=s.getShaderInfoLog(t);i&&console.warn("vs log:",i);const r=s.createShader(s.FRAGMENT_SHADER);s.shaderSource(r,"//#version 300 es\n//#define varying in\n//out highp vec4 pc_fragColor;\n//#define gl_FragColor pc_fragColor\n//#define texture2D texture\n\nprecision highp float;\nprecision highp int;\n\n#define HIGH_PRECISION\n#define SHADER_NAME MeshBasicMaterial\n#define USE_MAP\n#define USE_UV\n#define DOUBLE_SIDED\nuniform vec3 cameraPosition;\n\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 mapTexelToLinear( vec4 value ) { return LinearToLinear( value ); }\n\nuniform vec3 diffuse;\nuniform float opacity;\n\n#if defined( USE_UV )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n\n\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n#endif\n\n\tgl_FragColor = diffuseColor;\n}\n"),s.compileShader(r);const n=s.getShaderInfoLog(r);n&&console.warn("fs log:",n),s.attachShader(this.program,t),s.attachShader(this.program,r),s.linkProgram(this.program);const a=s.getProgramInfoLog(this.program);a&&console.warn("program log:",a),s.deleteShader(t),s.deleteShader(r);const{name:o}=s.getActiveUniform(this.program,0),h=s.getUniformLocation(this.program,o),{name:c}=s.getActiveUniform(this.program,1),g=s.getUniformLocation(this.program,c),{name:f}=s.getActiveUniform(this.program,2),d=s.getUniformLocation(this.program,f),{name:u}=s.getActiveUniform(this.program,3),l=s.getUniformLocation(this.program,u),{name:m}=s.getActiveUniform(this.program,4),E=s.getUniformLocation(this.program,m),{name:p}=s.getActiveUniform(this.program,5),v=s.getUniformLocation(this.program,p);s.useProgram(this.program),s.uniformMatrix4fv(g,!1,new Float32Array([.002739726100116968,0,0,0,0,.010416666977107525,0,0,0,0,-.20202019810676575,0,0,0,-1.0202020406723022,1])),s.uniformMatrix4fv(h,!1,new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,-1,1])),s.uniformMatrix3fv(d,!1,new Float32Array([1,0,0,0,1,0,0,0,1])),s.uniform3f(l,1,1,1),s.uniform1f(E,1),s.uniform1i(v,0),this.texture=s.createTexture(),s.activeTexture(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,this.texture),s.pixelStorei(37440,!0),s.pixelStorei(37441,!1),s.pixelStorei(s.UNPACK_ALIGNMENT,4),s.pixelStorei(37443,0),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.LINEAR_MIPMAP_LINEAR),s.disable(s.CULL_FACE),s.depthMask(!0),s.colorMask(!0,!0,!0,!0),s.disable(s.STENCIL_TEST),s.disable(s.POLYGON_OFFSET_FILL),s.disable(s.SAMPLE_ALPHA_TO_COVERAGE),this.pos=s.createBuffer(),this.uv=s.createBuffer(),this.ib=s.createBuffer();const A=s.getAttribLocation(this.program,"position"),_=s.getAttribLocation(this.program,"uv");s.enableVertexAttribArray(A),s.bindBuffer(s.ARRAY_BUFFER,this.pos),s.vertexAttribPointer(A,3,s.FLOAT,!1,0,0),s.enableVertexAttribArray(_),s.bindBuffer(s.ARRAY_BUFFER,this.uv),s.vertexAttribPointer(_,2,s.FLOAT,!1,0,0)}updateMaterial({width:e=null,sw:t=this.width,sh:i=this.height}={}){if(t!==this.width||i!==this.height){Number.isFinite(e)?this.width=e:this.width=Math.round(this.height*t/i),this.canvas.width=this.width,this.canvas.height=this.height,s.viewport(0,0,this.width,this.height);const r=s.getUniformLocation(this.program,"projectionMatrix");s.uniformMatrix4fv(r,!1,new Float32Array([2/this.width,0,0,0,0,2/this.height,0,0,0,0,-.20202019810676575,0,0,0,-1.0202020406723022,1]))}const n=new r.Canvas(this.source.width,this.source.height);n.getContext("2d").drawImage(this.source,0,0),s.bindTexture(s.TEXTURE_2D,this.texture),s.texImage2D(s.TEXTURE_2D,0,s.RGBA,s.RGBA,s.UNSIGNED_BYTE,n),s.generateMipmap(s.TEXTURE_2D)}updateGeometry(e=null){const{width:t,height:i}=this.gauge,n=new r.Canvas(t,i).getContext("2d");n.drawImage(this.gauge,0,0);const{data:a}=n.getImageData(0,0,t,i),h=this.width/t;e=Math.round(Number.isFinite(e)?e:i/2),e=Math.max(0,Math.min(i-1,e));const c=Array(i).fill(null).map((e,r)=>Array(t).fill(null).map((e,n)=>({uv:[(n+.5)/t,1-(r+.5)/i],position:[(n-t/2)*h,(a[4*(r*t+n)]+a[4*(r*t+n)+2]/256-128)/h,0]})));for(let i=e;i>0;--i)for(let e=0;ee.uv)),f=o(o(c).map(e=>e.position)),d=Array(i-1).fill(null).map((e,i)=>Array(t-1).fill(null).map((e,r)=>[i*t+r,i*t+r+1,(i+1)*t+r,(i+1)*t+r,(i+1)*t+r+1,i*t+r+1])),u=o(o(d));s.bindBuffer(s.ARRAY_BUFFER,this.pos),s.bufferData(s.ARRAY_BUFFER,new Float32Array(f),s.STATIC_DRAW),s.bindBuffer(s.ARRAY_BUFFER,this.uv),s.bufferData(s.ARRAY_BUFFER,new Float32Array(g),s.STATIC_DRAW),s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,this.ib),s.bufferData(s.ELEMENT_ARRAY_BUFFER,new Uint32Array(u),s.STATIC_DRAW),this.primitiveCount=u.length}render(){return s.clearColor(1,1,1,1),s.clear(s.COLOR_BUFFER_BIT),s.drawElements(s.TRIANGLES,this.primitiveCount,s.UNSIGNED_INT,0),this.canvas.toBuffer()}dispose(){s.deleteBuffer(this.pos),s.deleteBuffer(this.uv),s.deleteBuffer(this.ib),s.deleteProgram(this.program),s.deleteTexture(this.texture)}}({source:new r.Image,gauge:new r.Image});console.info("%cstarry-omr%c v1.0.0 2026-07-24T04:03:48.953Z","color:#fff; background-color: #555;padding: 5px;border-radius: 3px 0 0 3px;","color: #fff; background-color: #007dc6;padding: 5px;border-radius: 0 3px 3px 0;");const c=["bind","constructor","toString","toJSON"];class GaugeServer{async bind(e){this.socket=new i.Reply,await this.socket.bind(e),console.log(`gauge server listening at ${e}`);try{for await(const[e]of this.socket){const{method:i,args:r,kwargs:n}=t.unpack(e)??{};if(console.log(`request: ${i}`),!c.includes(i)&&this[i])try{const e=await(this[i]?.(r,n));console.log(`success: ${i}`),await this.socket.send(t.pack({code:0,msg:"success",data:e}))}catch(e){console.error(`fail: ${i}, error: ${e}`),await this.socket.send(t.pack({code:-1,msg:`Error: ${JSON.stringify(e)}`,data:null}))}else console.error(`fail: ${i}, error: no method`),await this.socket.send(t.pack({code:-1,msg:`no method: ${i}`,data:null}))}}catch(t){console.log("restarting gauge server..",t.stack),await this.socket.close(),await this.bind(e)}}async predict(e,t){let i,n,a;return e&&([i,n,a]=e),t&&({source:i,gauge:n,baseY:a}=t),(async(e,t,i)=>{const n=await r.loadImage(e),a=await r.loadImage(t);return h.source=n,h.gauge=a,h.updateMaterial({width:a.width,sw:n.width,sh:n.height}),h.updateGeometry(i),console.log(process.memoryUsage().heapUsed),{buffer:await h.render(),size:{width:h.width,height:h.height}}})(i,n,a)}}!async function(){const t=new GaugeServer;await t.bind(`tcp://*:${e.argv.port}`)}(); +"use strict";var e=require("yargs"),t=require("msgpackr"),i=require("zeromq"),r=require("skia-canvas");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=n(require("gl"));globalThis.ImageData=r.ImageData;const o=e=>{const t=[];for(const i of e)for(const e of i)t.push(e);return t};class GLCanvas{constructor(e){this._width=256,this._height=192,this.ctx=e}get width(){return this._width}set width(e){this._width=e;this.ctx.getExtension("STACKGL_resize_drawingbuffer").resize(e,this.height)}get height(){return this._height}set height(e){this._height=e;this.ctx.getExtension("STACKGL_resize_drawingbuffer").resize(this.width,e)}addEventListener(e){}async toBuffer(){const e=new Uint8Array(this.width*this.height*4);this.ctx.readPixels(0,0,this.width,this.height,this.ctx.RGBA,this.ctx.UNSIGNED_BYTE,e);const t=new r.Canvas(this.width,this.height);return t.getContext("2d").putImageData(new r.ImageData(new Uint8ClampedArray(e),this.width,this.height),0,0),t.toBuffer("png")}}const s=a.default(512,192,{antialias:!0});const h=new class GaugeRenderer{constructor(e){this.width=256,this.height=192,this.source=e.source,this.gauge=e.gauge,this.canvas=new GLCanvas(s),s.getShaderPrecisionFormat(s.VERTEX_SHADER,s.HIGH_FLOAT),s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.HIGH_FLOAT),s.getExtension("OES_element_index_uint"),this.program=s.createProgram();const t=s.createShader(s.VERTEX_SHADER);s.shaderSource(t,"//#version 300 es\n//#define attribute in\n//#define varying out\n//#define texture2D texture\n\nprecision highp float;\nprecision highp int;\n\n#define HIGH_PRECISION\n#define SHADER_NAME MeshBasicMaterial\n#define VERTEX_TEXTURES\n#define USE_MAP\n#define USE_UV\n#define BONE_TEXTURE\n#define DOUBLE_SIDED\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform vec3 cameraPosition;\n\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\n\n#ifdef USE_UV\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif\n\nvoid main() {\n#ifdef USE_UV\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n#endif\n\n\tvec3 transformed = vec3( position );\n\n\tvec4 mvPosition = vec4( transformed, 1.0 );\n\tmvPosition = modelViewMatrix * mvPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n}\n"),s.compileShader(t);const i=s.getShaderInfoLog(t);i&&console.warn("vs log:",i);const r=s.createShader(s.FRAGMENT_SHADER);s.shaderSource(r,"//#version 300 es\n//#define varying in\n//out highp vec4 pc_fragColor;\n//#define gl_FragColor pc_fragColor\n//#define texture2D texture\n\nprecision highp float;\nprecision highp int;\n\n#define HIGH_PRECISION\n#define SHADER_NAME MeshBasicMaterial\n#define USE_MAP\n#define USE_UV\n#define DOUBLE_SIDED\nuniform vec3 cameraPosition;\n\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 mapTexelToLinear( vec4 value ) { return LinearToLinear( value ); }\n\nuniform vec3 diffuse;\nuniform float opacity;\n\n#if defined( USE_UV )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n\n\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n#endif\n\n\tgl_FragColor = diffuseColor;\n}\n"),s.compileShader(r);const n=s.getShaderInfoLog(r);n&&console.warn("fs log:",n),s.attachShader(this.program,t),s.attachShader(this.program,r),s.linkProgram(this.program);const a=s.getProgramInfoLog(this.program);a&&console.warn("program log:",a),s.deleteShader(t),s.deleteShader(r);const{name:o}=s.getActiveUniform(this.program,0),h=s.getUniformLocation(this.program,o),{name:c}=s.getActiveUniform(this.program,1),g=s.getUniformLocation(this.program,c),{name:f}=s.getActiveUniform(this.program,2),d=s.getUniformLocation(this.program,f),{name:u}=s.getActiveUniform(this.program,3),l=s.getUniformLocation(this.program,u),{name:m}=s.getActiveUniform(this.program,4),E=s.getUniformLocation(this.program,m),{name:p}=s.getActiveUniform(this.program,5),v=s.getUniformLocation(this.program,p);s.useProgram(this.program),s.uniformMatrix4fv(g,!1,new Float32Array([.002739726100116968,0,0,0,0,.010416666977107525,0,0,0,0,-.20202019810676575,0,0,0,-1.0202020406723022,1])),s.uniformMatrix4fv(h,!1,new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,-1,1])),s.uniformMatrix3fv(d,!1,new Float32Array([1,0,0,0,1,0,0,0,1])),s.uniform3f(l,1,1,1),s.uniform1f(E,1),s.uniform1i(v,0),this.texture=s.createTexture(),s.activeTexture(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,this.texture),s.pixelStorei(37440,!0),s.pixelStorei(37441,!1),s.pixelStorei(s.UNPACK_ALIGNMENT,4),s.pixelStorei(37443,0),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.LINEAR_MIPMAP_LINEAR),s.disable(s.CULL_FACE),s.depthMask(!0),s.colorMask(!0,!0,!0,!0),s.disable(s.STENCIL_TEST),s.disable(s.POLYGON_OFFSET_FILL),s.disable(s.SAMPLE_ALPHA_TO_COVERAGE),this.pos=s.createBuffer(),this.uv=s.createBuffer(),this.ib=s.createBuffer();const A=s.getAttribLocation(this.program,"position"),_=s.getAttribLocation(this.program,"uv");s.enableVertexAttribArray(A),s.bindBuffer(s.ARRAY_BUFFER,this.pos),s.vertexAttribPointer(A,3,s.FLOAT,!1,0,0),s.enableVertexAttribArray(_),s.bindBuffer(s.ARRAY_BUFFER,this.uv),s.vertexAttribPointer(_,2,s.FLOAT,!1,0,0)}updateMaterial({width:e=null,sw:t=this.width,sh:i=this.height}={}){if(t!==this.width||i!==this.height){Number.isFinite(e)?this.width=e:this.width=Math.round(this.height*t/i),this.canvas.width=this.width,this.canvas.height=this.height,s.viewport(0,0,this.width,this.height);const r=s.getUniformLocation(this.program,"projectionMatrix");s.uniformMatrix4fv(r,!1,new Float32Array([2/this.width,0,0,0,0,2/this.height,0,0,0,0,-.20202019810676575,0,0,0,-1.0202020406723022,1]))}const n=new r.Canvas(this.source.width,this.source.height);n.getContext("2d").drawImage(this.source,0,0),s.bindTexture(s.TEXTURE_2D,this.texture),s.texImage2D(s.TEXTURE_2D,0,s.RGBA,s.RGBA,s.UNSIGNED_BYTE,n),s.generateMipmap(s.TEXTURE_2D)}updateGeometry(e=null){const{width:t,height:i}=this.gauge,n=new r.Canvas(t,i).getContext("2d");n.drawImage(this.gauge,0,0);const{data:a}=n.getImageData(0,0,t,i),h=this.width/t;e=Math.round(Number.isFinite(e)?e:i/2),e=Math.max(0,Math.min(i-1,e));const c=Array(i).fill(null).map((e,r)=>Array(t).fill(null).map((e,n)=>({uv:[(n+.5)/t,1-(r+.5)/i],position:[(n-t/2)*h,(a[4*(r*t+n)]+a[4*(r*t+n)+2]/256-128)/h,0]})));for(let i=e;i>0;--i)for(let e=0;ee.uv)),f=o(o(c).map(e=>e.position)),d=Array(i-1).fill(null).map((e,i)=>Array(t-1).fill(null).map((e,r)=>[i*t+r,i*t+r+1,(i+1)*t+r,(i+1)*t+r,(i+1)*t+r+1,i*t+r+1])),u=o(o(d));s.bindBuffer(s.ARRAY_BUFFER,this.pos),s.bufferData(s.ARRAY_BUFFER,new Float32Array(f),s.STATIC_DRAW),s.bindBuffer(s.ARRAY_BUFFER,this.uv),s.bufferData(s.ARRAY_BUFFER,new Float32Array(g),s.STATIC_DRAW),s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,this.ib),s.bufferData(s.ELEMENT_ARRAY_BUFFER,new Uint32Array(u),s.STATIC_DRAW),this.primitiveCount=u.length}render(){return s.clearColor(1,1,1,1),s.clear(s.COLOR_BUFFER_BIT),s.drawElements(s.TRIANGLES,this.primitiveCount,s.UNSIGNED_INT,0),this.canvas.toBuffer()}dispose(){s.deleteBuffer(this.pos),s.deleteBuffer(this.uv),s.deleteBuffer(this.ib),s.deleteProgram(this.program),s.deleteTexture(this.texture)}}({source:new r.Image,gauge:new r.Image});console.info("%cstarry-omr%c v1.0.0 2026-07-24T11:52:09.267Z","color:#fff; background-color: #555;padding: 5px;border-radius: 3px 0 0 3px;","color: #fff; background-color: #007dc6;padding: 5px;border-radius: 0 3px 3px 0;");const c=["bind","constructor","toString","toJSON"];class GaugeServer{async bind(e){this.socket=new i.Reply,await this.socket.bind(e),console.log(`gauge server listening at ${e}`);try{for await(const[e]of this.socket){const{method:i,args:r,kwargs:n}=t.unpack(e)??{};if(console.log(`request: ${i}`),!c.includes(i)&&this[i])try{const e=await(this[i]?.(r,n));console.log(`success: ${i}`),await this.socket.send(t.pack({code:0,msg:"success",data:e}))}catch(e){console.error(`fail: ${i}, error: ${e}`),await this.socket.send(t.pack({code:-1,msg:`Error: ${JSON.stringify(e)}`,data:null}))}else console.error(`fail: ${i}, error: no method`),await this.socket.send(t.pack({code:-1,msg:`no method: ${i}`,data:null}))}}catch(t){console.log("restarting gauge server..",t.stack),await this.socket.close(),await this.bind(e)}}async predict(e,t){let i,n,a;return e&&([i,n,a]=e),t&&({source:i,gauge:n,baseY:a}=t),(async(e,t,i)=>{const n=await r.loadImage(e),a=await r.loadImage(t);return h.source=n,h.gauge=a,h.updateMaterial({width:a.width,sw:n.width,sh:n.height}),h.updateGeometry(i),console.log(process.memoryUsage().heapUsed),{buffer:await h.render(),size:{width:h.width,height:h.height}}})(i,n,a)}}!async function(){const t=new GaugeServer;await t.bind(`tcp://*:${e.argv.port}`)}(); //# sourceMappingURL=gauge-server.js.map diff --git a/backend/omr/dist/index.d.ts b/backend/omr/dist/index.d.ts index b072465ded770e5594ba63fd0695ddfa5649c3dc..e68cca407bce013647955be6257539da876fbe0c 100644 --- a/backend/omr/dist/index.d.ts +++ b/backend/omr/dist/index.d.ts @@ -978,6 +978,7 @@ declare namespace EquationSolver { unitSize: number; measureLayout?: MeasureLayout; staffLayout: StaffLayout; + staffLayoutCode: string; paperOptions?: Partial; headers: Partial; voiceStaves: VoicesStaff[]; @@ -2319,6 +2320,7 @@ declare namespace starry { unitSize: number; measureLayout?: MeasureLayout; staffLayout: StaffLayout; + staffLayoutCode: string; paperOptions?: Partial; headers: Partial; voiceStaves: VoicesStaff[]; diff --git a/backend/omr/dist/index.js b/backend/omr/dist/index.js index 1b693a6b7c2559bb59f7915a2ae67bbd1448631a..332381fca3f28efd605c7fa72e738a20d93c29ee 100644 --- a/backend/omr/dist/index.js +++ b/backend/omr/dist/index.js @@ -1,2 +1,2 @@ -"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("lodash/pick"),t=require("js-sha1"),s=require("math-erf"),i=require("msgpackr"),n=require("zeromq"),r=require("portfinder"),a=require("python-shell"),o=require("lodash"),c=require("skia-canvas"),l=require("weak-lru-cache"),u=require("spark-md5"),h=require("sharp"),m=require("got");function d(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var f=d(e),p=d(t),g=d(s),y=d(u),v=d(h),x=d(m);globalThis.window=globalThis.window||globalThis,globalThis.btoa=e=>Buffer.from(e,"binary").toString("base64"),globalThis.atob=e=>Buffer.from(e,"base64").toString("binary");const S=(e,t)=>("object"==typeof e&&(e=JSON.stringify(e)),JSON.parse(e,(e,s)=>{if(s&&"object"==typeof s&&s.__prototype){const e=t[s.__prototype];if(e){const{__prototype:t,...i}=s;return new e(i)}}return s})),k=(e,t=null)=>{if((t=t||new Map).get(e))return t.get(e);if(Array.isArray(e)){const s=[];return t.set(e,s),e.forEach(e=>s.push(k(e,t))),s}if(e&&"object"==typeof e){const s={};return t.set(e,s),Object.entries(e).forEach(([e,i])=>s[e]=k(i,t)),Object.setPrototypeOf(s,e.__proto__),s}return e};class SimpleClass{assign(e){e&&Object.assign(this,e)}toJSON(){const e=this.constructor,t=e.serializedKeys||e.blackKeys&&Object.keys(this).filter(t=>!e.blackKeys.includes(t)),s=t?f.default(this,t):this;return{__prototype:e.className,...s}}deepCopy(){return k(this)}}var b={Matrix:function(){}};b.Matrix.create=function(e){return(new b.Matrix).setElements(e)},b.Matrix.I=function(e){for(var t,s=[],i=e;i--;)for(t=e,s[i]=[];t--;)s[i][t]=i===t?1:0;return b.Matrix.create(s)},b.Matrix.prototype={dup:function(){return b.Matrix.create(this.elements)},isSquare:function(){var e=0===this.elements.length?0:this.elements[0].length;return this.elements.length===e},toRightTriangular:function(){if(0===this.elements.length)return b.Matrix.create([]);var e,t,s,i,n=this.dup(),r=this.elements.length,a=this.elements[0].length;for(t=0;t=r&&l[a].push(n);for(o.elements[a]=s,e=a;e--;){for(s=[],t=0;t{const i=Math.round(10*s.x),n=Math.round(10*s.y),r=`${e}|${t}|${s.semantic}|${i}|${n}`,a=p.default.array(r).slice(12),o=globalThis.btoa(String.fromCharCode(...a)).substring(0,11);return s.id=o,o},O=(e,t)=>{const s=Math.round(t.x),i=Math.round(t.y),n=`p-${e}|${t.semantic}|${s}|${i}`,r=p.default.array(n).slice(12),a=globalThis.btoa(String.fromCharCode(...r)).substring(0,11);return t.id=a,a},B=(e,t,s=-1/0)=>Math.max(Math.round(e/t)*t,s),_=(e,t)=>{const s=e.x-t.x,i=e.y-t.y;return Math.sqrt(s*s+i*i)},R=(e,t)=>Number.isInteger(e)&&Number.isInteger(t)?0===t?e:R(t,e%t):(console.error("non-integer gcd:",e,t),1),F=(e,t)=>({numerator:e,denominator:t}),D=(e,t)=>{e=Math.round(e),t=Math.round(t);const s=0!==e?R(e,t):t;return F(e/s,t/s)},q=e=>`${e.numerator}/${e.denominator}`,L=(e,t)=>t?e*t.numerator/t.denominator:e,$=(e,t)=>{const s=[...e].sort((e,s)=>e[t]-s[t]);let i=null,n=null;return s.reduce((e,r,a)=>(n?r[t]-n[t]<.4?i.push(r):(i.length>1&&e.push(i),n=r,i=[r]):(n=r,i=[r]),i.length>1&&a===s.length-1&&e.push(i),e),[])},j=e=>{if(e.length<=1)return[];let t=e.slice(1);const s=N.find(t=>t.includes(e[0].semantic));if(!s)return j(t);const i=t.filter(e=>s.includes(e.semantic));return t=t.filter(e=>!s.includes(e.semantic)),[...i,...j(t)]},H=e=>{const t=new Set(e),s=$(e,"x"),i=[].concat(...s.map(e=>$(e,"y")));return i.forEach(e=>e.sort((e,t)=>t.confidence-e.confidence)),i.forEach(e=>{j(e).forEach(e=>t.delete(e))}),Array.from(t)},W=[0,2,4,5,7,9,11],V=({note:e,alter:t})=>{const s=Math.floor(e/7),i=(e=>{let t=e%7;for(;t<0;)t+=7;return t})(e);return 60+12*s+W[i]+t},G=e=>{const t=Math.max(...e);return e.indexOf(t)};class DummyLogger{debug(...e){}group(...e){}groupCollapsed(...e){}groupEnd(){}info(...e){}warn(...e){}assert(...e){}}const U=1921920,z=e=>1===e?null:(e=>{const t=Math.round(1920*e);return D(t,1920)})(e);var K,Y,Z;!function(e){e[e.PLACE=0]="PLACE",e[e.VERTICAL=1]="VERTICAL",e[e.HORIZONTAL=2]="HORIZONTAL"}(K||(K={}));class Action{constructor(e){Object.assign(this,e)}static P(e){return new Action({type:K.PLACE,e1:e})}static V(e,t,s=1){return new Action({type:K.VERTICAL,e1:s>0?e:t,e2:s>0?t:e})}static H(e,t){return new Action({type:K.HORIZONTAL,e1:e,e2:t})}get id(){switch(this.type){case K.PLACE:return this.e1.toString();case K.VERTICAL:return`${this.e1}|${this.e2}`;case K.HORIZONTAL:return`${this.e1}-${this.e2>=0?this.e2:"."}`}}get events(){return[this.e1,this.e2].filter(Number.isFinite)}}class StageMatrix{static fromNode(e,t){const s=Array(e.stages.length).fill(null).map(()=>Array(e.stages.length).fill(null).map(()=>new Set));e.actions.filter(e=>e.type===K.HORIZONTAL).forEach(t=>{const i=e.stages.findIndex(e=>e.events.includes(t.e1)),n=e.stages.findIndex(e=>e.events.includes(t.e2));console.assert(i>=0&&n>=0,"invalid stages for H action:",e.id,e.stages,t),s[i][n].add(t.e1)}),s[0][e.stages.length-1].add(0);const i=e.stagedEvents,n=t.matrixH[t.matrixH.length-1].filter((e,t)=>!i.has(t)),r=Math.max(0,Math.max(...n)-.01),a=e.actions.filter(e=>e.type===K.HORIZONTAL),o=Object.keys(t.eventMap).map(Number).filter(e=>!a.find(t=>t.e2===e));return e.stages.forEach(i=>{i.events.forEach(n=>{if(n>0){!a.find(e=>e.e1===n)&&t.matrixH[t.matrixH.length-1][n]>=r&&(o.some(e=>t.matrixH[e][n]>0)||s[i.index][e.stages.length-1].add(n))}})}),new StageMatrix({matrix:s})}constructor(e){Object.assign(this,e)}pathOf(e,t,s,i=0){if(this.matrix[e][t].size){const n=[...this.matrix[e][t]][i];if(t===s)return[n];for(let e=t+1;e<=s;++e){const i=this.pathOf(t,e,s);if(i)return[n,...i]}}return null}findDoublePath(e,t){const s=[];for(let i=t;i>=e+1;--i)for(let n=0;nt.forEach(t=>e.forEach(e=>t.delete(e))))}toEquations(e){const t=[];for(let s=1;sr[e]=1),n.forEach(e=>r[e]=-1),t.push(r),this.reducePath(i.length>n.length?i:n)}}}return t}}class PathNode{constructor(e){Object.assign(this,e),console.assert(this.logger,"logger is null:",e)}get actions(){const e=this.parent?this.parent.actions:[];return this.action?[...e,this.action]:e}get id(){return this.actions.map(e=>e.id).sort().join(" ")}get stagedEvents(){const e=new Set;return this.stages&&this.stages.forEach(t=>t.events.forEach(t=>t>=0&&e.add(t))),e}like(e){return e.split(" ").sort().join(" ")===this.id}constructStages(e){this.stages=[{events:[-1]}];for(const t of this.actions)switch(t.type){case K.PLACE:this.stages.unshift({events:[t.e1]});break;case K.VERTICAL:{const e=this.stages.find(e=>e.events.includes(t.e1)),s=this.stages.find(e=>e.events.includes(t.e2));console.assert(e||s,"invalid V action:",this.stages,t),e&&s?(e.events.push(...s.events),s.events=null,this.stages=this.stages.filter(e=>e.events)):e?s||e.events.push(t.e2):s.events.unshift(t.e1)}break;case K.HORIZONTAL:{const s=this.stages.find(e=>e.events.includes(t.e1)),i=this.stages.find(e=>e.events.includes(t.e2));console.assert(s||i,"invalid H action:",this.stages,t);const n=s=>{console.assert(e.eventMap[s],"invalid event id:",t.id,s,e.eventMap);const i=e.eventMap[s].x,n=this.stages.find(t=>t.events.some(t=>t>0&&e.eventMap[t].x<=i)&&t.events.some(t=>t>0&&e.eventMap[t].x>=i));if(n)n.events.push(s);else{const t={events:[s]},n=this.stages.findIndex(t=>-1===t.events[0]||e.eventMap[t.events[0]].x>=i);this.stages.splice(n,0,t)}};s||n(t.e1),i||n(t.e2)}}this.stages.forEach((e,t)=>e.index=t)}constructConstraints(e){const t=Object.keys(e.eventMap).length,s=StageMatrix.fromNode(this,e).toEquations(t),i=Array(t).fill(null).map((t,s)=>e.eventMap[s].duration);this.constraints=s.map(e=>e.map((e,t)=>e*i[t]))}inbalancesConstraints(e){console.assert(this.constraints,"constraints not constructed.");const t=Object.keys(e.eventMap).length,s=Array(t).fill(!0),i=Array(t).fill(!1),n=[];for(const e of this.constraints){const t=e.reduce((e,t)=>e+t,0);if(0!==t){const r=t<0?e.map(e=>-e):e;if(r[0]>0)continue;n.push(r),r.forEach((e,t)=>{i[t]=i[t]||e<0,e&&(s[t]=e<0||i[t])})}}return this.constraints.forEach(e=>{const t=e.reduce((e,t)=>e+t,0);0!==t||e[0]||e.some((e,t)=>e&&!s[t])&&(e.forEach((e,t)=>e&&(s[t]=!1)),n.push(e))}),{ones:s,inbalances:n}}solveEquations({ones:e,inbalances:t}){if(!t.length)return e.map(()=>1);const s=e.map((e,t)=>({fixed:e,i:t})).filter(({fixed:e})=>!e).map(({i:e})=>e).filter(e=>t.some(t=>0!==t[e]));if(!s.length)return e.map(()=>1);const i=s.map(e=>Math.abs(t.find(t=>0!==t[e])[e])),n=new Map;let r=!1;const a=t.map(e=>{const t=e.filter((e,t)=>s.includes(t)),i=-e.reduce((e,t,i)=>e+(s.includes(i)?0:t),0);return{line:t,bias:i}}).filter(({line:e,bias:t})=>{if(e.every(e=>0===e))return!1;const s=e.join(",");return n.has(s)?(r=n.get(s)!==t,!1):(n.set(s,t),!0)});if(r)return null;const o=a.slice(0,s.length),c=a.slice(s.length);if(o.lengths===t?1:s===n?-1:0),bias:0,prior:(i[t]+i[n])/U};o.some(e=>e.line[t]&&e.line[n])&&(r.prior-=10),o.some(e=>1===e.line.filter(Number).length&&(e.line[t]||e.line[n]))&&(r.prior+=1),e.push(r)}e.sort((e,t)=>e.prior-t.prior),o.push(...e.slice(0,s.length-o.length))}const l=o.map(({line:e})=>e),u=o.map(({bias:e})=>e),h=function(e){const t=b.Matrix.create(e).inverse();return null!==t?t.elements:null}(l);if(!h)return this.logger.warn("null invert:",l),null;const m=h.map(e=>e.reduce((e,t,s)=>e+t*u[s],0));if(c.length&&c.some(e=>Math.abs(e.line.reduce((e,t,s)=>e+t*m[s],0))>.001))return null;const d=e.map(()=>1);return s.forEach((e,t)=>d[e]=m[t]),d}optimallySolve(e){const{ones:t,inbalances:s}=this.inbalancesConstraints(e),i=t.map((t,s)=>t?-1:B(e.eventMap[s].shrinkness,.01)).reduce((e,t,s)=>(t>=0&&(e[t]=e[t]||[],e[t].push(s)),e),{}),n=Object.entries(i).sort((e,t)=>Number(t[0])-Number(e[0])).map(e=>e[1]);for(let i=1;i!r.includes(t)),o=this.solveEquations({ones:a,inbalances:s});if(o&&o.every((t,s)=>t<=1&&t>e.eventMap[s].lowWarp))return o}return this.solveEquations({ones:t,inbalances:s})}isConflicted(e){const{ones:t,inbalances:s}=this.inbalancesConstraints(e);for(const i of s){const s=i.reduce((s,i,n)=>s+i*(t[n]||i<=0?1:e.eventMap[n].lowWarp),0);if(s>=0)return i.forEach((t,s)=>{t&&(e.eventTendencies[s]+=t>0?1:-1)}),!0}if(!s.length)return!1;const i=this.solveEquations({ones:t,inbalances:s});return!i||!i.every((t,s)=>t>e.eventMap[s].lowWarp&&t<=1)}getSolution(e){const t=t=>e.eventMap[t.e2]?e.eventMap[t.e2].x+.06*Math.abs(e.eventMap[t.e2].x-e.eventMap[t.e1].x):e.eventMap[t.e1].x+1e4,s=this.actions.filter(e=>e.type===K.HORIZONTAL).sort((e,s)=>t(e)-t(s)),i=s.reduce((e,t)=>({...e,[t.e1]:t.e2}),{}),n=new Set([...Object.keys(i)].map(Number));s.forEach(e=>n.delete(e.e2)),this.stages[0].events.forEach(e=>e>0&&n.add(e));let r=[...n].map(e=>{const t=[e];let s=e;for(;i[s]&&(s=i[s],!(s<0||t.includes(s)));)t.push(s);return t});const a=Object.values(e.eventMap).filter(e=>e.id>0).map(e=>({id:e.id,tick:null,endTick:null,tickGroup:null,timeWarp:null})),o=a.filter(e=>r.some(t=>t.includes(e.id))||s.some(t=>[t.e1,t.e2].includes(e.id))).reduce((e,t)=>({...e,[t.id]:t}),{});this.stages.forEach((e,t)=>e.events.forEach(e=>o[e]&&(o[e].tickGroup=t))),this.stages[0].tick=0,this.stages[0].events.forEach(e=>o[e]&&(o[e].tick=0));const c=this.optimallySolve(e);a.forEach(e=>e.timeWarp=z(c[e.id]));const l=this.stages.slice(0,this.stages.length-1),u=()=>{if(l.every(e=>Number.isFinite(e.tick)))return!1;let t=!1;return s.forEach(s=>{const i=this.stages.find(e=>e.events.includes(s.e1)),n=this.stages.find(e=>e.events.includes(s.e2));Number.isFinite(i.tick)&&!Number.isFinite(n.tick)&&(n.tick=i.tick+L(e.eventMap[s.e1].duration,o[s.e1].timeWarp),n.events.forEach(e=>o[e]&&(o[e].tick=n.tick)),t=!0)}),[...s].reverse().forEach(s=>{const i=this.stages.find(e=>e.events.includes(s.e1)),n=this.stages.find(e=>e.events.includes(s.e2));!Number.isFinite(i.tick)&&Number.isFinite(n.tick)&&(i.tick=n.tick-L(e.eventMap[s.e1].duration,o[s.e1].timeWarp),i.events.forEach(e=>o[e]&&(o[e].tick=i.tick)),t=!0)}),t};for(;u(););console.assert(l.every(e=>Number.isFinite(e.tick)),"stage ticks not all solved:",this.stages,this.id),a.filter(e=>Number.isFinite(e.tick)).forEach(t=>t.endTick=t.tick+L(e.eventMap[t.id].duration,t.timeWarp));const h=e.eventMap[0].duration;r.forEach(e=>{const t=e.findIndex(e=>o[e].endTick>h);if(t>=0){e.splice(t,e.length-t).forEach(e=>{o[e].tick=null,o[e].endTick=null})}}),r=r.filter(e=>e.length);const m=Math.max(0,...a.map(e=>e.endTick).filter(Number.isFinite));return this.logger.debug(String.fromCodePoint(127822),this.id,c),{voices:r,events:a,duration:m,actions:this.actions.map(e=>e.id).join(" ")}}deduce(e,t){this.stages||this.constructStages(e);const s=e.actionAccessing.get(this.id)||{times:0};if(++s.times,e.actionAccessing.set(this.id,s),this.constructConstraints(e),this.isConflicted(e))return s.closed=!0,this.logger.info(this.action.id,"❌"),null;if(this.logger.group(this.action&&this.action.id),t.credits>0){if(--t.credits,this.children||this.expand(e),this.children=this.children.filter(t=>!e.actionAccessing.get(t.id)||!e.actionAccessing.get(t.id).closed),this.children.length){const s=t=>t.possibility/((e.actionAccessing.get(t.id)||{times:0}).times+1);this.children.sort((e,t)=>s(t)-s(e));for(const s of this.children){const i=s.deduce(e,t);if(i)return this.logger.groupEnd(),i;if(t.credits<=0)break}}}else this.logger.debug("quota exhausted.");return this.logger.groupEnd(),s.closed=!0,this.getSolution(e)}expand(e){this.constructStages(e);const{eventMap:t,matrixV:s,matrixH:i}=e,n=this.stagedEvents,r=[],a=e=>{if(!this.actions.some(t=>t.id===e.action.id)&&!r.some(t=>t.action.id===e.action.id)){const t=this.stages.find(t=>t.events.includes(e.action.e1)),i=this.stages.find(t=>t.events.includes(e.action.e2));if(t===i||t&&i&&t.index>=i.index)return;if(t&&i)if(e.action.type===K.VERTICAL){if(i.index-t.index>1)return;if(this.actions.some(e=>t.events.includes(e.e1)&&i.events.includes(e.e2)))return}else if(e.action.type===K.HORIZONTAL&&t.index>i.index)return;if(e.action.type===K.HORIZONTAL&&this.actions.some(t=>t.type===K.HORIZONTAL&&(t.e1===e.action.e1||t.e2===e.action.e2||t.e1===e.action.e2&&t.e2===e.action.e1)))return;if(e.action.type===K.VERTICAL){if(t&&(e.possibility=Math.min(e.possibility,...t.events.map(t=>s[e.action.e2][t])),e.possibility<=0))return;if(i&&(e.possibility=Math.min(e.possibility,...i.events.map(t=>s[t][e.action.e1])),e.possibility<=0))return}r.push(e)}};for(const e of n)e<0||(s[e].forEach((t,s)=>{t>0&&e!==s&&a({action:Action.V(s,e),possibility:t})}),s.forEach((t,s)=>{const i=t[e];i>0&&a({action:Action.V(e,s),possibility:i})}),i[e].forEach((t,s)=>{t>0&&a({action:Action.H(s,e),possibility:t})}),i.forEach((s,i)=>{i=i>=Object.keys(t).length?-1:i;const n=s[e];n>0&&a({action:Action.H(e,i),possibility:n})}));r.some(e=>[K.HORIZONTAL,K.PLACE].includes(e.action.type)||!n.has(e.action.e1)||!n.has(e.action.e2))?this.children=r.map(e=>new PathNode({logger:this.logger,parent:this,...e})):this.children=[]}}class Solver{constructor(e,{quota:t=1e3,logger:s=new DummyLogger}={}){this.quota=t,this.logger=s;const i={id:0,x:0,confidence:1,shrinkness:e.measureShrinkness,duration:e.expectedDuration,lowWarp:0};this.events=[i,...e.events.map(e=>({id:e.id,x:e.x,confidence:e.confidence,shrinkness:e.shrinkness,staff:e.staff,duration:e.duration,lowWarp:.5}))],this.eventMap=this.events.reduce((e,t)=>({...e,[t.id]:t}),{}),this.matrixH=e.matrixH,this.matrixV=e.matrixV,this.xSpan=e.endX-Math.min(e.endX-1,...e.events.map(e=>e.x)),this.actionAccessing=new Map}solve(){this.pathRoot=new PathNode({logger:this.logger,action:null}),this.pathRoot.children=this.events.slice(1).map(e=>new PathNode({logger:this.logger,parent:this.pathRoot,action:Action.P(e.id),possibility:this.matrixV[e.id].reduce((e,t)=>e+t,0)}));let e=null;this.logger.groupCollapsed("solve");const t=Array(this.events.length).fill(0),s={credits:this.quota,times:0};for(;s.credits>0;){++s.times;const i={eventMap:this.eventMap,matrixH:this.matrixH,matrixV:this.matrixV,actionAccessing:this.actionAccessing,eventTendencies:t},n=this.pathRoot.deduce(i,s);if(n.credits=this.quota-s.credits,n.times=s.times,this.evaluateSolution(n),this.logger.debug("loss:",n.loss),e=!e||n.losse/s.times)),e}evaluateSolution(e){e.loss=0;const t=e.events.reduce((e,t)=>({...e,[t.id]:{...t,...this.eventMap[t.id]}}),{}),s=e.events.filter(e=>Number.isFinite(e.tick)).map(e=>t[e.id]),i=s.reduce((e,t)=>(e[t.staff]=e[t.staff]||[],e[t.staff].push(t),e),{});Object.values(i).forEach(t=>{t.sort((e,t)=>e.x-t.x).slice(0,t.length-1).forEach((s,i)=>{t[i+1].tick{if(Number.isFinite(s.tick)&&!e.voices.every(e=>!e.includes(s.id))||(e.loss+=100*t[s.id].confidence),s.timeWarp){const{numerator:e,denominator:i}=s.timeWarp,r=t[s.id].shrinkness;n.set(e,Math.max(n.get(e)||0,1-r)),n.set(i,Math.max(n.get(i)||0,1-r))}});const r=D(e.duration,this.eventMap[0].duration);n.set(r.numerator,Math.max(n.get(r.numerator)||0,1-this.eventMap[0].shrinkness)),n.set(r.denominator,Math.max(n.get(r.denominator)||0,1-this.eventMap[0].shrinkness));for(const[t,s]of n.entries())t>1&&(e.loss+=Math.log(t)*s);let a=0,o=0;e.voices.forEach(s=>{console.assert(t[s[0]],"invalid voice:",s,Object.keys(t));const i=Math.abs(t[s[0]].tick),n=t[s[s.length-1]].endTick;a+=Math.max(0,i+e.duration-n);let r=null;s.forEach(e=>{const s=t[e];s.staff!==r&&(null!==r&&++o,r=s.staff)})}),e.loss+=10*a/U,e.loss+=5**o-1;const c=[...s].sort((e,t)=>e.x-t.x),l=c.slice(1).map((t,s)=>{const i=c[s],n=t.x-i.x,r=t.tick-i.tick;if(!r)return n/this.xSpan;return(4*Math.atan2(r/e.duration,n/this.xSpan)/Math.PI-1)**2}),u=Math.max(...l,0);e.loss+=u**2,console.assert(e.loss>=0,"Invalid solution loss!!!",e.loss,n,a,o),e.loss<0&&(e.loss=1/0)}}!function(e){e[e.PAD=0]="PAD",e[e.BOS=1]="BOS",e[e.EOS=2]="EOS",e[e.CHORD=3]="CHORD",e[e.REST=4]="REST"}(Y||(Y={}));class EventCluster extends SimpleClass{constructor(e){super(),super.assign(e)}get regular(){return this.elements.some(e=>[Y.CHORD,Y.REST].includes(e.type)&&!e.fake)&&this.elements.every(e=>[e.x,e.y1,e.y2,e.tick].every(Number.isFinite))&&this.elements.slice(1).every((e,t)=>e.fake||this.elements[t].fake||e.grace||this.elements[t].grace||e.fullMeasure||this.elements[t].fullMeasure||e.tick<=this.elements[t].tick||e.x>this.elements[t].x)}get grant(){return this.annotation&&this.annotation.grant}get feature(){return{index:this.index,elements:this.elements}}get estimatedDuration(){const e=this.elements.find(e=>e.type===Y.EOS),t=e?.predisposition?e.predisposition?.tick:e?.tick;return Number.isFinite(t)?t:this.duration}assignPrediction(e){console.assert(e.index===this.index,"index mismatch:",e.index,this.index),this.matrixH=e.matrixH,e.elements.forEach(e=>{const{index:t,...s}=e,i=this.elements.find(e=>e.index===t);console.assert(i,"element not found:",t),i&&(i.predisposition=s)})}}EventCluster.className="EventCluster",EventCluster.blackKeys=["id"];class EventClusterSet extends SimpleClass{constructor(e){super(),super.assign(e)}trimIrregular(){let e=0;return this.clusters=this.clusters.filter(t=>{const s=t.regular;return s||(console.debug("irregular cluster:",t),++e),s}),e?console.debug("Irregular clusters trimmed:",`${e}/${this.clusters.length+e}`):console.debug(`The EventClusterSet (${this.clusters.length}) is fine.`),e}}EventClusterSet.className="EventClusterSet";class PatchMeasure extends SimpleClass{constructor(e){super(),Object.assign(this,e)}get staffN(){return Math.floor(Math.log2(this.staffMask))+1}get basics(){return Array(this.staffN).fill(this.basic)}get duration(){return Math.max(0,...(this.voices||[]).map(e=>e.map(e=>this.events.find(t=>t.id===e)).reduce((e,t)=>e+t.duration,0)))}}PatchMeasure.className="PatchMeasure",function(e){e.ClefG="clefs-G",e.ClefF="clefs-F",e.ClefC="clefs-C",e.TimesigC44="timesig-C44",e.TimesigC22="timesig-C22",e.TimesigZero="zero|timesig0",e.TimesigOne="one|timesig1",e.TimesigTwo="two|timesig2",e.TimesigThree="three|timesig3",e.TimesigFour="four|timesig4",e.TimesigFive="five|timesig5",e.TimesigSix="six|timesig6",e.TimesigSeven="seven|timesig7",e.TimesigEight="eight|timesig8",e.TimesigNine="nine|timesig9",e.OctaveShift8va="octave-a",e.OctaveShift8vb="octave-b",e.OctaveShift0="octave-0",e.Zero="zero|n0",e.One="one|n1",e.Two="two|n2",e.Three="three|n3",e.Four="four|n4",e.Five="five|n5",e.Six="six|n6",e.Seven="seven|n7",e.Eight="eight|n8",e.Nine="nine|n9",e.AccNatural="accidentals-natural",e.AccSharp="accidentals-sharp",e.AccDoublesharp="accidentals-doublesharp",e.AccFlat="accidentals-flat",e.AccFlatflat="accidentals-flatflat",e.KeyNatural="accidentals-natural|key-natural",e.KeySharp="accidentals-sharp|key-sharp",e.KeyFlat="accidentals-flat|key-flat",e.NoteheadS0="noteheads-s0",e.NoteheadS1="noteheads-s1",e.NoteheadS2="noteheads-s2",e.NoteheadS1stemU="noteheads-s1|noteheads-s1-u",e.NoteheadS1stemD="noteheads-s1|noteheads-s1-d",e.NoteheadS2stemU="noteheads-s2|noteheads-s2-u",e.NoteheadS2stemD="noteheads-s2|noteheads-s2-d",e.Rest0="rests-0o",e.Rest1="rests-1o",e.Rest2="rests-2",e.Rest3="rests-3",e.Rest4="rests-4",e.Rest5="rests-5",e.Rest6="rests-6",e.Rest0W="rests-0",e.RestM1="rests-M1",e.Flag3="flags-u3",e.Flag4="flags-u4",e.Flag5="flags-u5",e.Flag6="flags-u6",e.Flag7="flags-u7",e.Flag8="flags-u8",e.BeamLeft="|beam-left",e.BeamRight="|beam-right",e.BeamContinue="|beam-continue",e.TremoloLeft="|tremolo-left",e.TremoloRight="|tremolo-right",e.TremoloMiddle="|tremolo-middle",e.SlurBegin="|slur-begin",e.SlurEnd="|slur-end",e.TieBegin="|tie-begin",e.TieEnd="|tie-end",e.VoltaLeft="|volta-left",e.VoltaRight="|volta-right",e.VoltaAlternativeBegin="|volta-alter-begin",e.BarTerminal="|bar-terminal",e.BarSegment="|bar-segment",e.Dot="|dot",e.DotDot="|dotdot",e.f="f",e.p="p",e.m="m",e.r="r",e.s="s",e.z="z",e.WedgeCrescendo="|wedge-crescendo",e.WedgeDiminuendo="|wedge-diminuendo",e.WedgeClose="|wedge-close",e.CrescendoBegin="|wedge-crescendo",e.DecrescendoBegin="|wedge-diminuendo",e.CrescendoEnd="|wedge-close",e.DecrescendoEnd="|wedge-close",e.ScriptFermata="scripts-ufermata",e.ScriptShortFermata="scripts-ushortfermata",e.ScriptSforzato="scripts-sforzato",e.ScriptStaccato="scripts-staccato",e.ScriptStaccatissimo="scripts-ustaccatissimo",e.ScriptTurn="scripts-turn",e.ScriptTrill="scripts-trill",e.ScriptSegno="scripts-segno",e.ScriptCoda="scripts-coda",e.ScriptArpeggio="scripts-arpeggio",e.ScriptPrall="scripts-prall",e.ScriptMordent="scripts-mordent",e.ScriptMarcato="scripts-umarcato",e.ScriptTenuto="scripts-tenuto",e.ScriptPortato="scripts-uportato",e.PedalStar="pedal-star",e.PedalPed="pedal-Ped",e.Text="|text",e.GraceNotehead="|grace-notehead"}(Z||(Z={}));const J=Z,X=Object.values(Z),Q=X.filter(e=>/clefs-/.test(e)),ee=X.filter(e=>/timesig/.test(e)),te=X.filter(e=>/timesig-/.test(e)),se=X.filter(e=>/timesig\d/.test(e)),ie=X.filter(e=>/octave-/.test(e)),ne=X.filter(e=>/n\d/.test(e)),re=X.filter(e=>/accidentals-/.test(e)),ae=X.filter(e=>/noteheads-/.test(e)),oe=[J.NoteheadS0,J.NoteheadS1,J.NoteheadS2],ce=X.filter(e=>/noteheads-.+-[ud]/.test(e)),le=X.filter(e=>/rests-/.test(e)),ue=X.filter(e=>/flags-/.test(e)),he=X.filter(e=>/volta-/.test(e)),me=X.filter(e=>/^[a-z]$/.test(e)),de=X.filter(e=>/scripts-/.test(e)),fe=X.filter(e=>/pedal-/.test(e)),pe=[J.Dot,J.DotDot],ge=[J.SlurBegin,J.SlurEnd,J.TieBegin,J.TieEnd],ye=X.filter(e=>/beam-/.test(e)),ve=X.filter(e=>/wedge-/.test(e)),xe=[...ne,...me,...ve,...fe,...ge,J.ScriptFermata,J.ScriptShortFermata,J.ScriptSforzato,J.ScriptStaccato,J.ScriptStaccatissimo,J.ScriptTurn,J.ScriptTrill,J.ScriptPrall,J.ScriptMordent,J.ScriptMarcato,J.ScriptTenuto,J.ScriptPortato],Se=[...fe],ke=[...Q,...ee,...ne,...re,J.NoteheadS0,J.NoteheadS1,J.NoteheadS2,...le,...me,...de,...fe,...pe],be={};Q.forEach(e=>be[e]=1),se.forEach(e=>be[e]=1),re.forEach(e=>be[e]=.5),ae.forEach(e=>be[e]=.5),le.forEach(e=>be[e]=.5),pe.forEach(e=>be[e]=.5);const Te={};te.forEach(e=>Te[e]=0),he.forEach(e=>Te[e]=0);class Token{constructor(e){Object.assign(this,e)}get typeId(){return this.type.split("|").reverse()[0]}get isPredicted(){return Number.isFinite(this.confidence)}get isNotehead(){return ce.includes(this.type)||this.type===Z.NoteheadS0}get isContexted(){return Q.includes(this.type)||ee.includes(this.type)||ie.includes(this.type)||re.includes(this.type)}get isAccessory(){return ne.includes(this.type)||me.includes(this.type)||de.includes(this.type)||fe.includes(this.type)}get division(){switch(this.type){case J.NoteheadS0:return 0;case J.NoteheadS1stemU:case J.NoteheadS1stemD:return 1;case J.NoteheadS2stemU:case J.NoteheadS2stemD:return 2;case J.Flag3:return 3;case J.Flag4:return 4;case J.Flag5:return 5;case J.Flag6:return 6;case J.Flag7:return 7;case J.Flag8:return 8;case J.RestM1:return-1;case J.Rest0:return 0;case J.Rest1:return 1;case J.Rest2:return 2;case J.Rest3:return 3;case J.Rest4:return 4;case J.Rest5:return 5;case J.Rest6:return 6}return null}get dots(){switch(this.type){case J.Dot:return 1;case J.DotDot:return 2}return null}get direction(){switch(this.type){case J.NoteheadS1stemU:case J.NoteheadS2stemU:return"u";case J.NoteheadS1stemD:case J.NoteheadS2stemD:return"d"}return null}get width(){switch(this.type){case J.NoteheadS0:return w.NoteheadS0;case J.NoteheadS1stemU:case J.NoteheadS1stemD:return w.NoteheadS1;case J.NoteheadS2stemU:case J.NoteheadS2stemD:return w.NoteheadS2}}get left(){switch(this.type){case J.NoteheadS0:return this.x-this.width/2;case J.NoteheadS1stemU:case J.NoteheadS2stemU:return this.x-this.width;case J.NoteheadS1stemD:case J.NoteheadS2stemD:return this.x}return this.x}get right(){switch(this.type){case J.NoteheadS0:return this.x+this.width/2;case J.NoteheadS1stemU:case J.NoteheadS2stemU:return this.x;case J.NoteheadS1stemD:case J.NoteheadS2stemD:return this.x+this.width}return this.x}get voiceIndices(){return!this.voice||this.voice<0?[]:Array(Math.floor(Math.log2(this.voice))+1).fill(null).reduce((e,t,s)=>this.voice&1<"CDEFGAB"[(e.note+700)%7]).join("")}get zeroHolder(){return!!this.grace||this.tremoloCatcher}}var Oe;EventTerm.className="EventTerm",function(e){e[e.Clef=0]="Clef",e[e.KeyAcc=1]="KeyAcc",e[e.Acc=2]="Acc",e[e.OctaveShift=3]="OctaveShift",e[e.TimeSignatureC=4]="TimeSignatureC",e[e.TimeSignatureN=5]="TimeSignatureN"}(Oe||(Oe={}));class ContextedTerm extends Term{constructor(e){super(),Object.assign(this,e)}get type(){return Q.includes(this.tokenType)?Oe.Clef:/\|key-/.test(this.tokenType)?Oe.KeyAcc:/accidentals-/.test(this.tokenType)?Oe.Acc:ie.includes(this.tokenType)?Oe.OctaveShift:te.includes(this.tokenType)?Oe.TimeSignatureC:se.includes(this.tokenType)?Oe.TimeSignatureN:null}get staffLevel(){return[Oe.OctaveShift,Oe.Clef,Oe.KeyAcc].includes(this.type)}get prior(){return this.tick-.1}get clef(){switch(this.tokenType){case Z.ClefG:return-this.y-2;case Z.ClefF:return 2-this.y;case Z.ClefC:return-this.y}return null}get alter(){switch(this.tokenType){case Z.AccNatural:case Z.KeyNatural:return 0;case Z.AccSharp:case Z.KeySharp:return 1;case Z.AccFlat:case Z.KeyFlat:return-1;case Z.AccDoublesharp:return 2;case Z.AccFlatflat:return-2}return null}get octaveShift(){switch(this.tokenType){case Z.OctaveShift8va:return-1;case Z.OctaveShift0:return 0;case Z.OctaveShift8vb:return 1}return null}get number(){switch(this.tokenType){case Z.TimesigZero:return 0;case Z.TimesigOne:return 1;case Z.TimesigTwo:return 2;case Z.TimesigThree:return 3;case Z.TimesigFour:return 4;case Z.TimesigFive:return 5;case Z.TimesigSix:return 6;case Z.TimesigSeven:return 7;case Z.TimesigEight:return 8;case Z.TimesigNine:return 9}return null}}ContextedTerm.className="ContextedTerm";class MarkTerm extends Term{get prior(){return this.tick+.01}}MarkTerm.className="MarkTerm";const Be=Array(7).fill(0).map((e,t)=>String.fromCodePoint(119133+t));class TempoTerm extends MarkTerm{static fromNumeralText(e){if(/.+=.*\d+/.test(e)){const[t,s]=e.split("=");let i=Be.findIndex(e=>t.includes(e));i=i>=0?i:2;let n=(2**i).toString();return t.includes(".")&&(n+="."),new TempoTerm({tick:0,duration:n,beats:s})}return null}constructor(e){super(),Object.assign(this,e)}get prior(){return this.tick-.01}get durationMagnitude(){const[e,t,s]=this.duration.match(/^(\d+)(\.)?$/);return we/Number(t)*(s?1.5:1)}get bpm(){const[e]=this.beats.match(/\d+/)||[90];return Number(e)*this.durationMagnitude*4/we}isValid(e=[10,400]){const t=this.bpm;return Number.isFinite(this.bpm)&&t>=e[0]&&t{const t=(e=>{const t=new Map;return e.rows.forEach(e=>{if(1===e.events.length){const t=e.events[0];t.rest&&0===t.division&&(t.rest="R")}}),e.events.forEach(e=>{const s=Math.round(10*e.pivotX)/10;let i=0;i=e.fullMeasureRest?Math.min(s,...t.keys()):[...t.keys()].find(s=>{const i=t.get(s),n=Math.min(...i.map(e=>e.left)),r=Math.max(...i.map(e=>e.right));return Math.min(r,e.right)-Math.max(n,e.left)>.62*w.NoteheadS1})||s,e.roundX=i;const n=t.get(i)||[];t.set(i,n),n.push(e)}),t})(e);let s=0;const i=new Set([s]),n=[...t.entries()].sort(([e],[t])=>e-t);for(const[e,t]of n)t.forEach(e=>{e.predisposition&&(e.rest=e.rest&&e.predisposition.fullMeasure>.5?"R":e.rest,e.grace=e.predisposition.grace?Ee.Grace:null,e.division=G(e.predisposition.divisionVector),e.dots=G(e.predisposition.dotsVector),e.predisposition.timeWarped>.5&&(e.timeWarp=F(2,3))),e.fullMeasureRest?e.tick=0:(e.zeroHolder&&(s-=e.duration),!e.zeroHolder&&e.predisposition&&Number.isInteger(e.predisposition.tick)?e.tick=e.predisposition.tick:e.tick=s,i.add(e.tick+e.duration))}),i.delete(s),i.size&&(s=Math.min(...i));Number.isInteger(e.estimatedDuration)?e.duration=e.estimatedDuration:e.duration=Math.max(...i,0)},e.computeMeasureVoices=e=>{e.voices=[];for(const t of e.rows){const s=t.events.filter(e=>!(e.grace||e.tremoloCatcher||e.fullMeasureRest||e.predisposition&&e.predisposition.fake>.5)),i=new Set(s);for(;i.size;){let t=0;const n=[],r=e=>{n.push(e.id),e.zeroHolder||(t+=e.duration),i.delete(e)},a=s.find(e=>i.has(e));for(a.alignedTick>0&&(t=a.alignedTick),r(a);;){const e=s.find(e=>i.has(e)&&e.alignedTick===t);if(!e)break;r(e)}e.voices.push(n)}}}}(_e||(_e={}));var Re,Fe,Pe;!function(e){const t=1921920,s=.7071067811865475,i=[[null,null],[null,Ae.Open],[Ae.Open,Ae.Continue],[Ae.Open,Ae.Close],[Ae.Continue,Ae.Continue],[Ae.Continue,Ae.Close],[Ae.Close,null],[Ae.Close,Ae.Open]].map(e=>e.join("-")),n=(e,t)=>{if(!e.events.length)return{events:[],voices:[],duration:0};return new Solver(e,t).solve()};e.estiamteMeasure=e=>{const n=e.events.filter(e=>!e.zeroHolder).map(s=>({id:s.id,staff:s.staff,x:s.x,tickEstimated:s.predisposition&&Number.isFinite(s.predisposition.tick)?s.predisposition.tick:s.x,tipX:s.tipX,y:s.tipY+100*s.staff,duration:s.mainDuration*t/we,division:s.division,dots:s.dots,stemDirection:s.stemDirection,beam:s.beam,rest:s.rest,pR:"R"===s.rest?1:"r"===s.rest&&0===s.division?Math.tanh(s.x-e.eventStartX):0,fakeP:s.predisposition&&s.predisposition.fakeP||0,shrinkness:s.predisposition?s.predisposition.timeWarped:null}));let r=t*e.timeSignature.numerator/e.timeSignature.denominator;Number.isFinite(e.estimatedDuration)&&(r=Math.max(r,B(e.estimatedDuration,480480)));const a=e.staffGroups.reduce((e,t,s)=>(t.forEach(t=>e[t]=s),e),{}),o=[0,...n.map(e=>e.id)],c=n.map(t=>({...t,id:o.indexOf(t.id),x:t.x-e.startX,confidence:(1-t.pR)*(1-t.fakeP),shrinkness:Number.isFinite(t.shrinkness)?t.shrinkness:Math.tanh((t.division-.1*t.dots)/4),staffGroup:a[t.staff]})),l=Array(o.length+1).fill(null).map(()=>Array(o.length).fill(0)),u=Array(o.length).fill(null).map(()=>Array(o.length).fill(0)),h=e=>g.default(e/1.6)*g.default(1.6/e);for(const t of c){for(const e of c){if(u[t.id][e.id]=t!==e&&t.tickEstimated>=e.tickEstimated?1-g.default((t.tickEstimated-e.tickEstimated)*s/.6):0,t.staffGroup!==e.staffGroup)l[t.id][e.id]=0;else if(t.x<=e.x)l[t.id][e.id]=0;else{const s=Math.exp(2*-Math.abs(t.staff-e.staff)),i=t.staff===e.staff?Math.exp(-Math.abs(t.y-e.y)/16):1,n=t.x-e.x,r=t.tipX-e.tipX;l[t.id][e.id]=(s*i*Math.min(h(n),h(r)))**(1/3)}const n=(1-t.pR)*(1-e.pR);u[t.id][e.id]*=n,l[t.id][e.id]*=n,u[t.id][e.id]<.01&&(u[t.id][e.id]=0),t.stemDirection&&e.stemDirection&&t.stemDirection!==e.stemDirection&&(l[t.id][e.id]*=.9),t.rest||e.rest||i.includes([e.beam,t.beam].join("-"))||(l[t.id][e.id]*=.2)}l[o.length][t.id]=h(e.width-t.x)**(1/3)}return{ids:o,events:c,expectedDuration:r,measureShrinkness:0,endX:e.position.right,matrixH:l,matrixV:u}},e.regulateMeasure=async(s,{solver:i=null,...r})=>{const a=e.estiamteMeasure(s),{ids:o,matrixH:c,matrixV:l}=a;if(s.matrixH){console.assert(s.matrixH.length>o[o.length-1]&&s.matrixH[0].length>o[o.length-1],"matrix shape mismatch:",o.length,`${s.matrixH.length}x${s.matrixH[0].length}`,`${c.length}x${c[0].length}`);for(let e=0;ee.forEach((e,i)=>{const n=s.matrixV[o[t]][o[i]];Number.isFinite(n)&&(l[t][i]=n)})),Number.isFinite(s.estimatedDuration)&&(a.measureShrinkness=Math.tanh(-3*Math.log(Math.min(1,s.estimatedDuration/s.duration)))),r.logger&&r.logger.info("--- MEASURE",s.measureIndex,"---",a);const u=i?await i(a,r):n(a,r),h=u.events.map(e=>({...e,id:a.ids[e.id]}));h.forEach(e=>{const i=s.events.find(t=>t.id===e.id);i.tick=Number.isFinite(e.tick)?Math.round(e.tick*we/t):null,i.tickGroup=e.tickGroup,i.timeWarp=e.timeWarp}),s.duration=Math.round(u.duration*we/t),s.voices=u.voices.map(e=>e.map(e=>a.ids[e])),s.solutionStat={loss:u.loss,solverCredits:u.credits,solverTimes:u.times},s.events.forEach(e=>{const t=h.find(t=>t.id===e.id);t&&(Number.isFinite(t.tick)||"r"!==e.rest||0!==e.division?"R"===e.rest&&(e.tick=0,e.tickGroup=0,e.duration=s.duration,s.voices.push([e.id])):(e.tick=0,e.tickGroup=0,e.rest="R",e.duration=s.duration,s.voices.push([e.id])))})},e.regulateMeasureWithRectification=async(e,i,{solver:r=null,...a})=>{const o=e.events.filter(e=>!e.zeroHolder).map(s=>{const n=i.events.find(e=>e&&e.id===s.id),r=Number.isFinite(n?.division)?n.division:s.division,a=Number.isFinite(n?.dots)?n.dots:s.dots,o=t*2**-r*(2-2**-a);return{id:s.id,staff:s.staff,x:s.x,tickEstimated:s.predisposition?.tick,y:s.tipY+100*s.staff,duration:o,pR:"R"===s.rest?1:"r"===s.rest&&0===s.division?Math.tanh(s.x-e.eventStartX):0,fakeP:s.predisposition&&s.predisposition.fakeP||0,shrinkness:s.predisposition?.timeWarped||0}});let c=t*e.timeSignature.numerator/e.timeSignature.denominator;Number.isFinite(e.estimatedDuration)&&(c=Math.max(c,B(e.estimatedDuration,480480)));const l=e.staffGroups.reduce((e,t,s)=>(t.forEach(t=>e[t]=s),e),{}),u=[0,...o.map(e=>e.id)],h=o.map(t=>({...t,id:u.indexOf(t.id),x:t.x-e.startX,confidence:(1-t.pR)*(1-t.fakeP),shrinkness:t.shrinkness,staffGroup:l[t.staff]})),m=Array(u.length+1).fill(null).map(()=>Array(u.length).fill(0)),d=Array(u.length).fill(null).map(()=>Array(u.length).fill(0));for(const e of h)for(const t of h){d[e.id][t.id]=e!==t&&e.tickEstimated>=t.tickEstimated?1-g.default((e.tickEstimated-t.tickEstimated)*s/.6):0;const i=(1-e.pR)*(1-t.pR);d[e.id][t.id]*=i,d[e.id][t.id]<.01&&(d[e.id][t.id]=0)}console.assert(e.matrixH&&e.matrixH.length>u[u.length-1]&&e.matrixH[0].length>u[u.length-1],"matrix shape mismatch:",u.length,`${e.matrixH.length}x${e.matrixH[0].length}`,`${m.length}x${m[0].length}`);for(let t=0;t{const a=i.events.find(t=>t&&t.id===e),o=Number.isFinite(s)?Math.round(s*we/t):s;return{id:e,tick:o,tickGroup:n,timeWarp:r,division:a?.division,dots:a?.dots}}),S=Math.round(y.duration*we/t);return{events:x,voices:y.voices,duration:S,priority:v}}}(Re||(Re={}));class SpartitoMeasure extends SimpleClass{static reorderEvents(e,t){const s=[],i=e.map(e=>({id:e.id,staff:e.staff,x:e.x/.7,rx:0,ry:t[e.staff]+e.tipY,tipY:e.tipY,prior:0}));i.sort((e,t)=>e.x-t.x),i.slice(1).forEach((e,t)=>{const s=Math.min(Math.round(e.x-i[t].x),2);e.rx=i[t].rx+s}),i.forEach(e=>{e.prior=1e4*e.staff+e.rx+.01*e.tipY,s.includes(e.ry)||s.push(e.ry)}),i.sort((e,t)=>e.prior-t.prior),s.sort((e,t)=>e-t);let n=0;const r=s.map((e,t)=>(!t||s[t]-s[t-1]<.5||++n,n)),a=i.map(t=>new EventTerm({...e.find(e=>e.id===t.id),intX:t.rx,intY:r[s.indexOf(t.ry)]}));return a.forEach((e,t)=>e.id=t+1),a}constructor(e){super(),super.assign(e),this.originalRegulationHash||this.regulated||(this.originalRegulationHash=this.regulationHash),this.barTypes=this.barTypes||{},this.regulated&&this.position&&this.postRegulate()}get timeSignature(){return this.basics&&this.basics[0].timeSignature}get keySignature(){return this.basics&&this.basics[0].keySignature}get timeSignatureChanged(){return this.contexts.filter(Boolean)[0].some(e=>[Oe.TimeSignatureC,Oe.TimeSignatureN].includes(e.type))}get doubtfulTimesig(){return this.basics&&this.basics[0].doubtfulTimesig}get regulated(){return!!this.voices}get validRegulated(){return!!this.voices&&this.voices.flat(1).every(e=>Number.isFinite(this.events.find(t=>t.id===e)?.tick))}get rows(){return this.contexts.map((e,t)=>({events:this.events.filter(e=>e.staff===t),contexts:e}))}get eventStartX(){return this.events.length?Math.min(...this.events.map(e=>e.x)):this.startX}get startX(){return this.position.left}get width(){return this.position.right-this.position.left}get tickMap(){return this.events.concat([this.endEvent]).filter(Boolean).reduce((e,t)=>(Number.isFinite(t.tick)&&(e.has(t.tick)||e.set(t.tick,[]),e.get(t.tick).push(t)),e),new Map)}get tickToX(){return[...this.tickMap.entries()].reduce((e,[t,s])=>{if((s=s.filter(e=>!e.fullMeasureRest&&!e.grace)).length){const i=Math.min(...s.map(e=>e.x));e[t]=i}return e},{})}get tickRates(){const e=this.events.filter(e=>Number.isFinite(e.tick)&&!e.fullMeasureRest);return e.sort((e,t)=>e.x-t.x),e.slice(0,e.length-1).map((t,s)=>{const i=e[s+1];return(i.tick-t.tick)/Math.max(i.x-t.x,.001)})}get tickRatesInStaves(){const e=this.events.filter(e=>Number.isFinite(e.tick)&&!e.fullMeasureRest&&!e.grace).reduce((e,t)=>(e[t.staff]=e[t.staff]||[],e[t.staff].push(t),e),{}),t=Object.values(e).map(e=>e.sort((e,t)=>e.x-t.x).slice(0,e.length-1).map((t,s)=>{const i=e[s+1];return(i.tick-t.tick)/Math.max(i.x-t.x,.001)}));return[].concat(...t)}get tickRatesInGroups(){const e=this.events.filter(e=>Number.isFinite(e.tick)&&!e.fullMeasureRest).reduce((e,t)=>{const s=this.staffGroups.findIndex(e=>e.includes(t.staff));return e[s]=e[s]||[],e[s].push(t),e},{}),t=Object.values(e).map(e=>e.sort((e,t)=>e.x-t.x).slice(0,e.length-1).map((t,s)=>{const i=e[s+1];return(i.tick-t.tick)/Math.max(i.x-t.x,.001)}));return[].concat(...t)}get tickTwist(){if(!this.duration||!this.staffGroups)return;const e=this.events.filter(e=>Number.isFinite(e.tick)&&!e.fullMeasureRest&&!e.grace&&!e.tremoloCatcher&&!(e.rest&&0===e.division)).reduce((e,t)=>{const s=this.staffGroups.findIndex(e=>e.includes(t.staff));return e[s]=e[s]||[],e[s].push(t),e},{}),t=Object.values(e).map(e=>{const t=[...e].sort((e,t)=>e.pivotX-t.pivotX),s=this.position.right-t[0].x,i=t.slice(1).map((e,i)=>{const n=t[i],r=e.pivotX-n.pivotX,a=e.tick-n.tick;if(!a)return r/s;return(4*Math.atan2(a/this.duration,r/s)/Math.PI-1)**2});return Math.max(0,...i)});return Math.max(0,...t)}get eventMap(){return this.events.reduce((e,t)=>(e[t.id]=t,e),{})}get empty(){return!this.events?.length||!this.voices?.length}get hasIllEvent(){const e=this.voices.flat(1),t=this.eventMap;return this.regulated&&e.some(e=>{const s=t[e];return!s.zeroHolder&&!Number.isFinite(s.tick)&&!s.fullMeasureRest})}get brief(){return[`${this.timeSignature.numerator}/${this.timeSignature.denominator}`,...this.events.map(e=>[e.staff,e.intX,Math.round(e.tip?e.tip.y:e.ys?.[0]??0),e.fullMeasureRest?0:e.division,e.fullMeasureRest?0:e.dots,e.rest?"r":"",e.grace||"",e.stemDirection,e.beam||""].join("|"))].join("\n")}get regulationHash(){return p.default(this.brief)}get regulationHash0(){return this.originalRegulationHash||this.regulationHash}get regulationHashes(){return Array.from(new Set([this.originalRegulationHash,this.regulationHash].filter(Boolean)))}get featureWords(){if(!this.regulated||!this.voices||!this.voices.length)return null;const e=this.tickRatesInStaves.some(e=>e<0),t=this.events.filter(e=>!e.zeroHolder&&!e.rest).map(e=>e.ys).flat(1).map(e=>"Y"+2*-e),s=Array.from(new Set(t));this.keySignature&&s.push(`K${this.keySignature}`);const i=this.voices.map(e=>e.map(e=>this.events.find(t=>t.id===e)).filter(e=>!e.zeroHolder&&!e.rest)).filter(e=>e.length),n=e?[]:i.map(e=>e.map(e=>e.scaleChord).join("-")),r=e?[]:i.map(e=>e.map(e=>e.division).join(""));return this.timeSignature&&r.push(`T${this.timeSignature.numerator}/${this.timeSignature.denominator}`),[s,n,r]}get barType(){if(this.voltaEnd)return"VoltaRight";const e=Object.entries(this.barTypes).sort((e,t)=>t[1]-e[1]);return e[0]&&e[0][1]>=1?e[0][0]:null}get partialDuration(){if(!Number.isFinite(this.duration))return!1;const e=L(we,this.timeSignature);return this.duration{const t=e.events.filter(e=>e.grace);if(!t.length)return;const s=[...e.tickMap.entries()].reduce((e,[t,s])=>(s.forEach(s=>{if(!s.grace){e[s.staff]=e[s.staff]||{};const i=e[s.staff][t];e[s.staff][t]=!i||i.x>s.x?s:i}}),e),{}),i=Object.entries(s).reduce((t,[s,i])=>{t[s]=Object.entries(i).map(([e,t])=>({event:t,tick:Number(e),preTick:-240,graces:[]})).sort((e,t)=>e.event.x-t.event.x),t[s].push({tick:e.duration,event:e.endEvent,preTick:0,graces:[]});let n=0;return t[s].forEach(e=>{e.tick>n&&(e.preTick=n,n=e.tick)}),t},{});t.forEach(e=>{const t=i[e.staff];if(t){const s=t.find(t=>t.event.x>e.x);s&&s.graces.push(e),e.roundX=e.x}}),Object.values(i).forEach(e=>e.forEach(e=>{if(e.graces.length){e.event.graceIds=e.graces.map(e=>e.id);const t=e.graces.reduce((e,t)=>e+t.duration,0),s=Math.min(t,e.tick-e.preTick)/t;let i=e.tick;[...e.graces].reverse().forEach(e=>{e.tick=Math.round(i-e.duration*s),i=e.tick})}}))})(this),(e=>{const t=e.events.filter(e=>e.tremoloCatcher&&!e.grace),s=e.events.filter(e=>e.tremoloLink===Ne.Pitcher&&!e.grace);t.forEach(t=>{let i=s.filter(e=>e.division===t.division&&e.xNumber.isFinite(e.tick)&&!e.grace&&!e.rest&&e.division===t.division&&e.dots===t.dots&&e.xt.x-e.x),i.length){const e=i[0];e.catcherId=t.id;const n=Math.max(e.tremolo||3,t.tremolo||3);e.tremolo=n,t.tremolo=n,t.tick||(t.tick=e.tick+e.duration/2);const r=s.indexOf(e);r>=0&&s.splice(r,1)}})})(this),this.updateContextTick()}updateRoundX(){const e=this.tickToX;e&&this.events.forEach(t=>{const s=e[t.tick];Number.isFinite(s)&&(t.roundX=s)})}updateContextTick(){if(!this.staffGroups)return;const e=this.contexts.flat(1);this.staffGroups.flat(1).forEach(t=>{const s=[...this.events.filter(e=>e.staff===t),...e.filter(e=>e.staff===t)];s.sort((e,t)=>t.x-e.x);let i=this.duration;s.forEach(e=>{e instanceof EventTerm?e.fullMeasureRest||e.zeroHolder||(i=e.tick):e instanceof ContextedTerm&&(e.tick=i)})})}asSolution(e=void 0){return this.regulated?{events:this.events.map(t=>{const s={id:t.id,tick:t.tick,tickGroup:t.tickGroup,timeWarp:t.timeWarp};if(e){const i=e.events.find(e=>e.id===t.id);i&&(t.division!==i.division&&(s.division=t.division),t.dots!==i.dots&&(s.dots=t.dots),t.grace!==i.grace&&(s.grace=!!t.grace),t.beam!==i.beam&&(s.beam=t.beam),t.fullMeasureRest!==i.fullMeasureRest&&(s.fullMeasure=t.fullMeasureRest))}return s}),voices:this.voices,duration:this.duration,priority:-this.solutionStat?.loss}:null}applySolution(e){e.timeSignature&&this.basics.forEach(t=>{t.timeSignature=e.timeSignature,t.doubtfulTimesig=!1}),this.voices=e.voices,this.duration=e.duration,this.events.forEach(t=>{t.timeWarp=null,t.tick=null,t.tickGroup=null;const s=e.events?.find(e=>e.id===t.id);s&&(t.tick=s.tick,t.timeWarp=s.timeWarp,t.tickGroup=s.tickGroup,Number.isFinite(s.division)&&(t.division=s.division),Number.isFinite(s.dots)&&(t.dots=s.dots),void 0!==s.beam&&(t.beam=s.beam),void 0!==s.grace&&(t.grace=s.grace?Ee.Grace:void 0),s.fullMeasure&&(t.rest="R"))}),Number.isFinite(e.priority)&&(this.solutionStat={loss:-e.priority}),this.postRegulate()}cleanupRegulation(){this.voices=null,this.duration=null,this.events.forEach(e=>{e.tick=null,e.tickGroup=null,e.timeWarp=null})}regulateTest(){this.duration=0,this.voices=this.rows.map(e=>e.events.map(e=>e.id)),this.voices.forEach(e=>{let t=0;e.map(e=>this.events.find(t=>t.id===e)).forEach((e,s)=>{e.tickGroup=s,e.tick=t,t+=e.duration}),this.duration=Math.max(this.duration,t)})}regulateSimple(){_e.computeMeasureTicks(this),_e.computeMeasureVoices(this)}async regulateEquations(e){await Re.regulateMeasure(this,e)}async regulate({policy:e="advanced",...t}={}){switch(e){case"test":this.regulateTest();break;case"equations":case"advanced":await this.regulateEquations(t);break;default:this.regulateSimple()}this.postRegulate()}createPatch(){return new PatchMeasure({measureIndex:this.measureIndex,staffMask:this.staffMask,basic:this.basics[0],events:this.events,contexts:this.contexts,marks:this.marks,voices:this.voices})}createClusters(){const e=this.voices&&new Set(this.voices.flat(1));return this.staffGroups.filter(e=>e.length).map(t=>{const s=this.position.staffYs[0],i=e=>this.position.staffYs[t.indexOf(e)]-s,n=this.events.filter(e=>t.includes(e.staff));if(!n.length)return null;const r=n.map(s=>({index:s.id,voice:(this.voices||[]).findIndex(e=>e.includes(s.id)),type:s.rest?Y.REST:Y.CHORD,staff:t.indexOf(s.staff),x:s.tipX,pivotX:s.pivotX,y1:i(s.staff)+("u"===s.stemDirection?s.tipY:s.ys[s.ys.length-1]),y2:i(s.staff)+("u"===s.stemDirection?s.ys[0]:s.tipY),headY:"u"===s.stemDirection?s.ys[0]:s.ys[s.ys.length-1],feature:s.feature,division:s.division,dots:s.dots,beam:s.beam||null,stemDirection:s.stemDirection,grace:!!s.grace,tremoloCatcher:s.tremoloCatcher,timeWarped:!!s.timeWarp,fullMeasure:s.fullMeasureRest,tick:s.tick||0,fake:!s.fullMeasureRest&&!s.grace&&this.voices&&!e.has(s.id)}));if(!r.some(e=>!e.fake))return null;const a=L(we,this.timeSignature);r.unshift({index:0,type:Y.BOS,staff:null,division:null,beam:null,dots:null,stemDirection:null,grace:!1,tremoloCatcher:!1,fullMeasure:!1,x:this.position.left,pivotX:this.position.left,y1:0,y2:0,headY:0,feature:null,timeWarped:this.durationr.map(()=>0)),this.voices.forEach(e=>{let t=0;e.forEach(e=>{const s=r.findIndex(t=>t.index===e);s>0&&t>=0&&(o[s][t]=1),t=s}),t>=0&&(o[r.length-1][t]=1)}));const c={...this.solutionStat,patched:this.patched},l=this.backgroundImages&&this.backgroundImages.map(({url:e,position:t})=>({url:e,position:{...t,y:t.y-s}}));return new EventCluster({index:this.measureIndex,duration:this.duration,signatureDuration:a,staffY0:s,elements:r,matrixH:o,annotation:c,backgroundImages:l})}).filter(Boolean)}applyClusters(e){const t=this.events.reduce((e,t)=>Math.max(e,t.id),0)+1;this.matrixH=Array(t+1).fill(null).map(()=>Array(t).fill(0)),e.forEach(e=>{const s=e.elements.map(e=>e.index);console.assert(e.matrixH.length===s.length-1,"unexpected matrixH size:",e.matrixH.length,s.length);for(let i=1;i{const t=this.events.find(t=>t.id===e.index);t&&(t.predisposition=e.predisposition,void 0!==t.predisposition.grace&&(t.grace=t.predisposition.grace?Ee.Grace:null))})}),this.estimatedDuration=e.reduce((e,t)=>e+t.estimatedDuration,0)/e.length}}SpartitoMeasure.className="SpartitoMeasure",SpartitoMeasure.blackKeys=["staffGroups","solutionStat","measureNumber","deposit"];class EditableEvent extends EventTerm{constructor(e){super(e)}get agent(){return new Proxy(this,{get(e,t){const s=e;switch(t){case"id":case"tick":case"duration":case"rest":case"division":case"dots":case"stemDirection":case"beam":case"tremolo":case"tremoloLink":case"arpeggioStyle":{const e=s[t];return void 0===e?null:e}case"tying":case"tied":case"glissando":{const e=s[t];return void 0!==e&&e}case"grace":return!!s.grace;case"timeWarp":return s.timeWarp?`${s.timeWarp.numerator}/${s.timeWarp.denominator}`:null;case"multiplier":return s.multiplier?`${s.multiplier.numerator}/${s.multiplier.denominator}`:null;case"pitches":return s.pitches}},set:(e,t,s)=>{const i=e;switch(t){case"tick":case"duration":case"rest":case"division":case"dots":case"stemDirection":case"tying":case"tied":case"beam":case"tremolo":case"tremoloLink":case"glissando":case"arpeggioStyle":return i[t]=s,!0;case"grace":return i.grace=s?Ee.Grace:null,!0;case"timeWarp":if(i.timeWarp=null,s&&"string"==typeof s){const e=s.match(/^(\d+)\/(\d+)/);e&&(i.timeWarp={numerator:parseInt(e[1]),denominator:parseInt(e[2])})}return!0;case"multiplier":if(i.multiplier=null,s&&"string"==typeof s){const e=s.match(/^(\d+)\/(\d+)/);e&&(i.multiplier={numerator:parseInt(e[1]),denominator:parseInt(e[2])})}return!0;case"id":case"pitches":return!0}return!1},ownKeys:()=>["id","duration","rest","division","dots","stemDirection","tying","tied","beam","timeWarp","multiplier","tremolo","tremoloLink","glissando","arpeggioStyle","tick","grace","pitches"],getOwnPropertyDescriptor:()=>({enumerable:!0,configurable:!0})})}}class EditableMeasure extends SpartitoMeasure{constructor(e){super(e),this.events=null,this.events=e.events,this.events?.some(e=>!(e instanceof EditableEvent))&&(this.events=this.events.map(e=>new EditableEvent(e))),this.voices&&this.syncVoiceToEvents()}syncVoiceToEvents(){this.events.forEach(e=>e.voice=-1),this.voices.forEach((e,t)=>{e.forEach(e=>{const s=this.events.find(t=>t.id===e);s?s.voice=t:console.warn("no event with id:",e,this.events.length)})})}syncVoiceFromEvents(){const e=[];this.events.forEach(t=>{t?.voice>=0&&(e[t.voice]=e[t.voice]||[],e[t.voice].push(t))}),e.forEach(e=>e.sort((e,t)=>e.tick-t.tick)),this.voices=e.map(e=>e.map(e=>e.id))}get agent(){return new Proxy(this,{get:(e,t)=>{const s=e;switch(t){case"measureIndex":case"duration":return s[t];case"voices":return s.voices?.map(e=>e.join(","))||null;case"timeSignature":case"keySignature":case"doubtfulTimesig":return s.basics[0][t];case"toJSON":return()=>({measureIndex:s.measureIndex,voices:s.voices,duration:s.duration,timeSignature:s.basics[0].timeSignature,keySignature:s.basics[0].keySignature})}},set:(e,t,s)=>{const i=e;switch(t){case"timeSignature":case"keySignature":case"doubtfulTimesig":return i.basics[0][t]=s,i.basics=i.basics.map(()=>i.basics[0]),!0;case"duration":return i.duration=s,!0;case"measureIndex":case"voices":return!0}return!1},ownKeys:()=>["measureIndex","timeSignature","doubtfulTimesig","keySignature","duration","voices"],getOwnPropertyDescriptor:()=>({enumerable:!0,configurable:!0})})}makeMIDI(e=120){if(!this.regulated)return null;const t=6e7/e,s=this.voices.map((e,s)=>{const i=e.map(e=>{const t=this.events.find(t=>t.id===e);if(t){const e=t.graceIds?t.graceIds.map(e=>this.events.find(t=>t.id===e)):[];return[...e,t]}return[]}).flat(1),n=i.filter(e=>!e.rest&&Number.isFinite(e.tick)&&e.tick>=0&&Number.isFinite(e.duration)).map(e=>e.pitches.map(t=>[{id:e.id,time:e.tick,type:"channel",subtype:"noteOn",channel:e.staff,noteNumber:V(t),velocity:96},{id:e.id,time:e.tick+e.duration,type:"channel",subtype:"noteOff",channel:e.staff,noteNumber:V(t)}])).flat(2);return n.sort(function(e,t){return e.time-t.time}),0===s&&n.unshift({time:0,type:"meta",subtype:"timeSignature",numerator:this.timeSignature.numerator,denominator:this.timeSignature.denominator,thirtyseconds:8},{time:0,type:"meta",subtype:"setTempo",microsecondsPerBeat:t}),n.forEach(e=>{e.ticks=Math.round(e.time-0)}),n.forEach((e,t)=>{e.deltaTime=e.ticks-(t>0?n[t-1].ticks:0)}),n.push({deltaTime:0,type:"meta",subtype:"endOfTrack"}),n});return{header:{formatType:0,ticksPerBeat:480},tracks:s}}}EditableMeasure.className="EditableMeasure",EditableMeasure.blackKeys=[],function(e){e.ByLines="ByLines",e.ByBlocks="ByBlocks"}(Fe||(Fe={})),function(e){e.Title="Title",e.Author="Author",e.TempoText="TempoText",e.TempoNumeral="TempoNumeral",e.TextualMark="TextualMark",e.Lyric="Lyric",e.Instrument="Instrument",e.MeasureNumber="MeasureNumber",e.Times="Times",e.Alternation1="Alternation1",e.Alternation2="Alternation2",e.Chord="Chord",e.PageMargin="PageMargin",e.Other="Other"}(Pe||(Pe={}));const De={[Ae.Open]:1,[Ae.Continue]:0,[Ae.Close]:-1},qe=e=>{if(!e.regulated)return;const t=e.eventMap,s=e.events.length,i=e.voices.flat(1).length,n=e.events.filter(e=>e.timeWarp).length,r=new Set(e.events.filter(e=>e.timeWarp&&!(e.rest&&0===e.division)).map(e=>`${e.timeWarp.numerator}/${e.timeWarp.denominator}`)),a=new Set(r);a.delete("2/3");const o=e.voices.some(e=>{const s=e.map(e=>t[e]);if(!s.some(e=>e.timeWarp))return!1;let i=0,n=0,r=0;return s.some((e,t)=>{const a=e.timeWarp?e.timeWarp.denominator:0;if(a!==i){if(i>0&&(n%i||r<2))return!0;n=0,r=0}return i=a,n+=e.duration,++r,!!(t===s.length-1&&i>0&&(n%i||r<2))})}),c=e.voices.some(e=>{const s=e.map(e=>t[e]);let i=0;return s.some(e=>!e.grace&&(e.ticke.timeWarp&&e.timeWarp.denominator>3).map(e=>e.duration)).size>1,u=L(we,e.timeSignature),h=e.doubtfulTimesig?e.duration:u,m=e.voices.flat(1).map(e=>t[e]),d=m.some(e=>!e||!Number.isFinite(e.tick)||!Number.isFinite(e.division)||e.division<0||!Number.isFinite(e.duration)||e.duration<=0),f=m.reduce((e,t)=>e||t.tick<0||t.tick+t.duration>h,!1),p=e.duration>u,g=m.some(e=>e.grace),y=e.events.filter(e=>e.grace).length,v=y>=m.length,x=m.some(e=>{let t=e.tick*2**(e.division+2);if(e.timeWarp&&(t*=e.timeWarp.denominator),!Number.isFinite(t))return!0;return R(Math.round(t),we)e.reduce(({status:e,broken:s},i,n)=>{const r=t[i];return r.beam?(0===n&&[Ae.Continue,Ae.Close].includes(r.beam)&&(e=1),e+=De[r.beam],s=s||!(e>=0&&e<=1)):r.rest||(s=s||0!==e),{status:e,broken:s}},{status:0,broken:!1})).some(({broken:e})=>e);let k=0,b=0;e.voices.forEach(s=>{const i=s.reduce((e,s)=>e+t[s].duration,0);k+=Math.max(0,e.duration-i),b+=Math.max(0,i-e.duration)}),k/=we;const T=e.events.filter(e=>!(e.grace||e.fullMeasureRest||e.tremoloCatcher||e.predisposition&&!(e.predisposition.fakeP<.1)||Number.isFinite(e.tick))).length,w=e.events.filter(e=>!(e.fullMeasureRest||e.grace||e.tremoloCatcher||m.includes(e))).length,{voiceRugged:M}=e.voices.flat(1).reduce((e,t)=>!e.voiceRugged&&e.es.has(t)?{voiceRugged:!0,es:e.es}:(e.es.add(t),e),{voiceRugged:!1,es:new Set}),E=e.tickTwist||0,A=d||E>=1||c||M||e.tickRatesInStaves.some(e=>e<0)||T>2||!e.timeSignature||f||e.duration>h||e.events.some(e=>e.timeWarp&&e.timeWarp.numerator/e.timeWarp.denominator<=.5),N=!A&&!p&&E<.2&&!o&&!a.size&&!x&&!k&&!b&&!!e.voices.length&&!S&&!g&&!v&&(e.duration===h||Number.isFinite(e.estimatedDuration)&&e.estimatedDuration<=.75*h),I=!(A||p||!(E<.3)||o||x||b||S||g);let C=Math.min(h,3840);Number.isFinite(e.estimatedDuration)&&(C=Math.max(0,Math.min(C,e.estimatedDuration)));const O=e.duration/C;let B=0;if(e.patched&&!d)B=1;else if(!A){const t=Math.tanh(1*Math.abs(k/Math.max(1,e.voices.length)));let s=Math.min(h,3840);Number.isFinite(e.estimatedDuration)&&(s=Math.max(0,Math.min(s,e.estimatedDuration)));B=(1-t)*(1-(s?Math.max(0,1-O)**2:0))*(1-Math.tanh(a.size))*(1-E**2)}return{events:s,validEvents:i,voiceRugged:M,nullEvents:T,fakeEvents:w,warpedEvents:n,complicatedTimewarp:l,spaceTime:k,surplusTime:b,durationRate:O,beamBroken:S,fractionalWarp:o,irregularWarpsN:a.size,irregularTick:x,tickTwist:E,tickOverlapped:c,graceInVoice:g,graceN:y,graceDominant:v,perfect:N,fine:I,error:A,qualityScore:B}};var Le;!function(e){e.Ordinary="ordinary",e.Full="full",e.Conservative="conservative",e.Once="once"}(Le||(Le={}));const $e=(e,t=Le.Ordinary)=>[].concat(...e.map(e=>e.serialize(t))),je=(e,{withBrackets:t=!1}={})=>{let s="",i=!1;for(let t=0;t0&&!i&&(s+=", "),i=!1,s+=e[t].code)}return t?`[${s}]`:s};class SingleMLayout extends SimpleClass{static from(e){const t=new SingleMLayout;return t.measure=e,t}constructor(e=void 0){super(),this.assign(e)}serialize(){return[this.measure]}get seq(){return[this]}get code(){return this.measure.toString()}}SingleMLayout.className="SingleMLayout";class BlockMLayout extends SimpleClass{static trimSeq(e){const t=[];for(const s of e)if(s instanceof BlockMLayout)for(const e of s.seq)t.push(e);else t.push(s);const s=[];let i=null;for(const e of t)e instanceof SingleMLayout?e.measure>i&&(s.push(e),i=e.measure):s.push(e);return s}static fromSeq(e){const t=new BlockMLayout;return t.seq=BlockMLayout.trimSeq(e),t}constructor(e=void 0){super(),this.assign(e)}serialize(e){return $e(this.seq,e)}get code(){return je(this.seq,{withBrackets:!0})}}BlockMLayout.className="BlockMLayout";class VoltaMLayout extends SimpleClass{constructor(e=void 0){super(),this.assign(e)}serialize(e){const t=$e(this.body);if(this.alternates){const s=this.alternates.map(e=>$e(e)),i=s[s.length-1];switch(e){case Le.Ordinary:return t.concat(...s);case Le.Conservative:case Le.Full:return[...[].concat(...Array(this.times-1).fill(null).map((e,i)=>[...t,...s[i%(this.times-1)]])),...t,...i];case Le.Once:return[...t,...i]}}else switch(e){case Le.Ordinary:case Le.Conservative:case Le.Once:return t;case Le.Full:return[].concat(...Array(this.times).fill(null).map(()=>t))}console.warn("the current case not handled:",e,this)}get seq(){const e=this.alternates?this.alternates[this.alternates.length-1]:[];return[...this.body,...e]}get code(){const e=je(this.body,{withBrackets:!0});let t=`${this.times}*${e}`;return this.alternates&&(t+="{"+this.alternates.map(e=>je(e,{withBrackets:e.length>1})).join(", ")+"}"),t}}VoltaMLayout.className="VoltaMLayout";class ABAMLayout extends SimpleClass{constructor(e=void 0){super(),this.assign(e)}serialize(e){const t=this.main.serialize(e),s=$e(this.main.seq,Le.Once),i=$e(this.rest,e);switch(e){case Le.Ordinary:return[...t,...i];case Le.Once:return[...i,...s];case Le.Conservative:case Le.Full:return[...t,...i,...s];default:console.warn("the current case not handled:",e,this)}}get seq(){return[this.main,...this.rest]}get code(){return"<"+this.main.code+", "+je(this.rest)+">"}}ABAMLayout.className="ABAMLayout";var He=Object.freeze({__proto__:null,get LayoutType(){return Le},SingleMLayout:SingleMLayout,BlockMLayout:BlockMLayout,VoltaMLayout:VoltaMLayout,ABAMLayout:ABAMLayout}),We=function(){var e=function(e,t,s,i){for(s=s||{},i=e.length;i--;s[e[i]]=t);return s},t=[1,13],s=[1,16],i=[1,15],n=[1,26],r=[1,29],a=[1,28],o=[1,30],c=[5,13,22,27,29],l=[2,15],u=[1,32],h=[5,14,21,22,27,28,29],m={trace:function(){},yy:{},symbols_:{error:2,start_symbol:3,measure_layout:4,EOF:5,index_wise_measure_layout:6,"i:":7,"s:":8,segment_wise_measure_layout:9,iw_sequence:10,iw_item:11,range:12,",":13,UNSIGNED:14,"..":15,single:16,iw_block_item:17,iw_volta:18,iw_aba:19,iw_block:20,"[":21,"]":22,"*":23,iw_optional_alternates:24,iw_alternates:25,"{":26,"}":27,"<":28,">":29,sw_sequence:30,sw_item:31,segment:32,sw_block_item:33,sw_volta:34,sw_aba:35,sw_block:36,sw_optional_alternates:37,sw_alternates:38,$accept:0,$end:1},terminals_:{2:"error",5:"EOF",7:"i:",8:"s:",13:",",14:"UNSIGNED",15:"..",21:"[",22:"]",23:"*",26:"{",27:"}",28:"<",29:">"},productions_:[0,[3,2],[4,1],[4,2],[4,2],[6,1],[10,1],[10,1],[10,3],[10,3],[12,3],[11,1],[11,1],[11,1],[11,1],[16,1],[17,1],[20,3],[18,4],[24,0],[24,1],[25,3],[19,5],[9,1],[30,1],[30,2],[31,1],[31,1],[31,1],[31,1],[32,1],[33,1],[36,3],[34,4],[37,0],[37,1],[38,3],[35,4]],performAction:function(e,t,s,i,n,r,a){var o=r.length-1;switch(n){case 1:return r[o-1];case 2:this.$=d(null,r[o]);break;case 3:this.$=d("index-wise",r[o]);break;case 4:this.$=d("segment-wise",k(r[o]));break;case 5:case 23:1===r[o].length&&"BlockMLayout"===r[o][0].__prototype?this.$=r[o][0]:this.$=p(r[o]);break;case 6:case 24:this.$=[r[o]];break;case 7:case 11:case 12:case 13:case 14:case 20:case 27:case 28:case 29:case 35:this.$=r[o];break;case 8:this.$=[...r[o-2],r[o]];break;case 9:this.$=[...r[o-2],...r[o]];break;case 10:this.$=S(r[o-2],r[o]);break;case 15:this.$=f(r[o]);break;case 16:case 31:this.$=p(r[o]);break;case 17:case 32:this.$=r[o-1];break;case 18:case 33:this.$=g(r[o-3],r[o-1],r[o]);break;case 19:case 34:this.$=null;break;case 21:case 36:this.$=x(r[o-1]);break;case 22:this.$=y(r[o-3],r[o-1]);break;case 25:this.$=[...r[o-1],r[o]];break;case 26:this.$=p([r[o]]);break;case 30:this.$=v(r[o]);break;case 37:this.$=y(r[o-2],r[o-1])}},table:[{3:1,4:2,6:3,7:[1,4],8:[1,5],10:6,11:7,12:8,14:t,16:9,17:10,18:11,19:12,20:14,21:s,28:i},{1:[3]},{5:[1,17]},{5:[2,2]},{6:18,10:6,11:7,12:8,14:t,16:9,17:10,18:11,19:12,20:14,21:s,28:i},{9:19,14:n,21:r,28:a,30:20,31:21,32:22,33:23,34:24,35:25,36:27},{5:[2,5],13:o},e(c,[2,6]),e(c,[2,7]),e(c,[2,11]),e(c,[2,12]),e(c,[2,13]),e(c,[2,14]),e(c,l,{15:[1,31],23:u}),e(c,[2,16]),{11:33,14:[1,34],16:9,17:10,18:11,19:12,20:14,21:s,28:i},{10:35,11:7,12:8,14:t,16:9,17:10,18:11,19:12,20:14,21:s,28:i},{1:[2,1]},{5:[2,3]},{5:[2,4]},{5:[2,23],14:n,21:r,28:a,31:36,32:22,33:23,34:24,35:25,36:27},e(h,[2,24]),e(h,[2,26]),e(h,[2,27]),e(h,[2,28]),e(h,[2,29]),e(h,[2,30],{23:[1,37]}),e(h,[2,31]),{14:n,21:r,28:a,31:38,32:22,33:23,34:24,35:25,36:27},{14:n,21:r,28:a,30:39,31:21,32:22,33:23,34:24,35:25,36:27},{11:40,12:41,14:t,16:9,17:10,18:11,19:12,20:14,21:s,28:i},{14:[1,42]},{20:43,21:s},{13:[1,44]},{13:l,23:u},{13:o,22:[1,45]},e(h,[2,25]),{21:r,36:46},{14:n,21:r,28:a,30:47,31:21,32:22,33:23,34:24,35:25,36:27},{14:n,21:r,22:[1,48],28:a,31:36,32:22,33:23,34:24,35:25,36:27},e(c,[2,8]),e(c,[2,9]),e(c,[2,10]),e(c,[2,19],{24:49,25:50,26:[1,51]}),{10:52,11:7,12:8,14:t,16:9,17:10,18:11,19:12,20:14,21:s,28:i},e([5,13,22,26,27,29],[2,17]),e(h,[2,34],{37:53,38:54,26:[1,55]}),{14:n,21:r,28:a,29:[1,56],31:36,32:22,33:23,34:24,35:25,36:27},e([5,14,21,22,26,27,28,29],[2,32]),e(c,[2,18]),e(c,[2,20]),{10:57,11:7,12:8,14:t,16:9,17:10,18:11,19:12,20:14,21:s,28:i},{13:o,29:[1,58]},e(h,[2,33]),e(h,[2,35]),{14:n,21:r,28:a,30:59,31:21,32:22,33:23,34:24,35:25,36:27},e(h,[2,37]),{13:o,27:[1,60]},e(c,[2,22]),{14:n,21:r,27:[1,61],28:a,31:36,32:22,33:23,34:24,35:25,36:27},e(c,[2,21]),e(h,[2,36])],defaultActions:{3:[2,2],17:[2,1],18:[2,3],19:[2,4]},parseError:function(e,t){if(!t.recoverable){var s=new Error(e);throw s.hash=t,s}this.trace(e)},parse:function(e){var t=this,s=[0],i=[null],n=[],r=this.table,a="",o=0,c=0,l=n.slice.call(arguments,1),u=Object.create(this.lexer),h={yy:{}};for(var m in this.yy)Object.prototype.hasOwnProperty.call(this.yy,m)&&(h.yy[m]=this.yy[m]);u.setInput(e,h.yy),h.yy.lexer=u,h.yy.parser=this,void 0===u.yylloc&&(u.yylloc={});var d=u.yylloc;n.push(d);var f=u.options&&u.options.ranges;"function"==typeof h.yy.parseError?this.parseError=h.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;for(var p,g,y,v,x,S,k,b,T=function(){var e;return"number"!=typeof(e=u.lex()||1)&&(e=t.symbols_[e]||e),e},w={};;){if(g=s[s.length-1],this.defaultActions[g]?y=this.defaultActions[g]:(null==p&&(p=T()),y=r[g]&&r[g][p]),void 0===y||!y.length||!y[0]){var M="";for(x in b=[],r[g])this.terminals_[x]&&x>2&&b.push("'"+this.terminals_[x]+"'");M=u.showPosition?"Parse error on line "+(o+1)+":\n"+u.showPosition()+"\nExpecting "+b.join(", ")+", got '"+(this.terminals_[p]||p)+"'":"Parse error on line "+(o+1)+": Unexpected "+(1==p?"end of input":"'"+(this.terminals_[p]||p)+"'"),this.parseError(M,{text:u.match,token:this.terminals_[p]||p,line:u.yylineno,loc:d,expected:b})}if(y[0]instanceof Array&&y.length>1)throw new Error("Parse Error: multiple actions possible at state: "+g+", token: "+p);switch(y[0]){case 1:s.push(p),i.push(u.yytext),n.push(u.yylloc),s.push(y[1]),p=null,c=u.yyleng,a=u.yytext,o=u.yylineno,d=u.yylloc;break;case 2:if(S=this.productions_[y[1]][1],w.$=i[i.length-S],w._$={first_line:n[n.length-(S||1)].first_line,last_line:n[n.length-1].last_line,first_column:n[n.length-(S||1)].first_column,last_column:n[n.length-1].last_column},f&&(w._$.range=[n[n.length-(S||1)].range[0],n[n.length-1].range[1]]),void 0!==(v=this.performAction.apply(w,[a,c,o,h.yy,y[1],i,n].concat(l))))return v;S&&(s=s.slice(0,-1*S*2),i=i.slice(0,-1*S),n=n.slice(0,-1*S)),s.push(this.productions_[y[1]][0]),i.push(w.$),n.push(w._$),k=r[s[s.length-2]][s[s.length-1]],s.push(k);break;case 3:return!0}}return!0}};const d=(e,t)=>({__prototype:"MesaureLayout",type:e,data:t}),f=e=>({__prototype:"SingleMLayout",measure:Number(e)}),p=e=>({__prototype:"BlockMLayout",seq:e}),g=(e,t,s)=>({__prototype:"VoltaMLayout",times:Number(e),body:t,alternates:s}),y=(e,t)=>({__prototype:"ABAMLayout",main:e,rest:t}),v=e=>({segment:!0,length:Number(e)}),x=e=>e.map(e=>"BlockMLayout"===e.__prototype?e.seq:[e]),S=(e,t)=>{if(e=Number(e),!((t=Number(t))>=e))throw new Error(`invalid measure range: ${e}..${t}`);return Array(t+1-e).fill(0).map((t,s)=>f(e+s))},k=(e,t={index:1})=>{const s=e=>[].concat(...e.map(e=>((e,t)=>{if(e.segment){const s=t.index;return t.index+=e.length,Array(e.length).fill(0).map((e,t)=>f(s+t))}return[k(e,t)]})(e,t)));switch(e.__prototype){case"BlockMLayout":e.seq=s(e.seq);break;case"VoltaMLayout":e.body=s(e.body),e.alternates=e.alternates&&e.alternates.map(s);break;case"ABAMLayout":e.main=k(e.main,t),e.rest=s(e.rest)}return e};var b={EOF:1,parseError:function(e,t){if(!this.yy.parser)throw new Error(e);this.yy.parser.parseError(e,t)},setInput:function(e,t){return this.yy=t||this.yy||{},this._input=e,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var e=this._input[0];return this.yytext+=e,this.yyleng++,this.offset++,this.match+=e,this.matched+=e,e.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),e},unput:function(e){var t=e.length,s=e.split(/(?:\r\n?|\n)/g);this._input=e+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-t),this.offset-=t;var i=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),s.length-1&&(this.yylineno-=s.length-1);var n=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:s?(s.length===i.length?this.yylloc.first_column:0)+i[i.length-s.length].length-s[0].length:this.yylloc.first_column-t},this.options.ranges&&(this.yylloc.range=[n[0],n[0]+this.yyleng-t]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},less:function(e){this.unput(this.match.slice(e))},pastInput:function(){var e=this.matched.substr(0,this.matched.length-this.match.length);return(e.length>20?"...":"")+e.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var e=this.match;return e.length<20&&(e+=this._input.substr(0,20-e.length)),(e.substr(0,20)+(e.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var e=this.pastInput(),t=new Array(e.length+1).join("-");return e+this.upcomingInput()+"\n"+t+"^"},test_match:function(e,t){var s,i,n;if(this.options.backtrack_lexer&&(n={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(n.yylloc.range=this.yylloc.range.slice(0))),(i=e[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=i.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:i?i[i.length-1].length-i[i.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+e[0].length},this.yytext+=e[0],this.match+=e[0],this.matches=e,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(e[0].length),this.matched+=e[0],s=this.performAction.call(this,this.yy,this,t,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),s)return s;if(this._backtrack){for(var r in n)this[r]=n[r];return!1}return!1},next:function(){if(this.done)return this.EOF;var e,t,s,i;this._input||(this.done=!0),this._more||(this.yytext="",this.match="");for(var n=this._currentRules(),r=0;rt[0].length)){if(t=s,i=r,this.options.backtrack_lexer){if(!1!==(e=this.test_match(s,n[r])))return e;if(this._backtrack){t=!1;continue}return!1}if(!this.options.flex)break}return t?!1!==(e=this.test_match(t,n[i]))&&e:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){var e=this.next();return e||this.lex()},begin:function(e){this.conditionStack.push(e)},popState:function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(e){return(e=this.conditionStack.length-1-Math.abs(e||0))>=0?this.conditionStack[e]:"INITIAL"},pushState:function(e){this.begin(e)},stateStackSize:function(){return this.conditionStack.length},options:{},performAction:function(e,t,s,i){switch(s){case 0:break;case 1:case 3:case 4:return t.yytext;case 2:return 14;case 5:return 5}},rules:[/^(?:\s+)/,/^(?:([*,\[\]<>{}]))/,/^(?:(([1-9])([0-9])*))/,/^(?:(([a-z])+):)/,/^(?:\.\.)/,/^(?:$)/],conditions:{INITIAL:{rules:[0,1,2,3,4,5],inclusive:!0}}};function T(){this.yy={}}return m.lexer=b,T.prototype=m,m.Parser=T,new T}();We.Parser;We.Parser;var Ve=function(){return We.parse.apply(We,arguments)};var Ge,Ue;!function(e){e[e.Default=0]="Default",e[e.Brace=1]="Brace",e[e.Bracket=2]="Bracket",e[e.Square=3]="Square"}(Ge||(Ge={})),function(e){e[e.Blank=0]="Blank",e[e.Dashed=1]="Dashed",e[e.Solid=2]="Solid"}(Ue||(Ue={}));const ze=e=>({type:Ge.Default,staff:e}),Ke={"{":Ge.Brace,"}":Ge.Brace,"<":Ge.Bracket,">":Ge.Bracket,"[":Ge.Square,"]":Ge.Square},Ye={",":Ue.Blank,"-":Ue.Solid,".":Ue.Dashed},Ze=()=>btoa(Math.random().toString().substr(2)).replace(/=/g,"").split("").reverse().slice(0,6).join(""),Je=(e,t)=>{let s=t;for(;s.length;){const t=s.shift(),i=Ke[t];if(i){if("}>]".includes(t)&&i===e.type)break;if("{<[".includes(t)){const t={type:i,level:Number.isFinite(e.level)?e.level+1:0};s=Je(t,s),e.subs=e.subs||[],e.subs.push(t)}}else e.subs=e.subs||[],e.subs.push(ze(t))}for(;e.type===Ge.Default&&e.subs&&1===e.subs.length;){const t=e.subs[0];e.type=t.type,e.subs=t.subs,e.staff=t.staff,e.level=t.level}for(;e.subs&&1===e.subs.length&&e.subs[0].type===Ge.Default;){const t=e.subs[0];e.subs=t.subs,e.staff=t.staff}return e.grand=e.type===Ge.Brace&&e.subs&&e.subs.every(e=>e.staff),s},Xe=e=>e.staff?e.staff:e.subs?Xe(e.subs[0]):void 0,Qe=e=>e.staff?e.staff:e.subs?Qe(e.subs[e.subs.length-1]):void 0,et=(e,t)=>{t[(e=>e.staff?e.staff:e.subs?`${Xe(e)}-${Qe(e)}`:void 0)(e)]=e,e.subs&&e.subs.forEach(e=>et(e,t))};class StaffLayout{constructor(e){const t=new Set;e.forEach((e,s)=>{e.id=((e,t,s)=>{let i=s;for(i?e.has(i)&&(i+="_"+t.toString()):i=t.toString();e.has(i);)i+="_"+Ze();return i})(t,s+1,e.id),t.add(e.id)}),this.staffIds=e.map(e=>e.id),this.conjunctions=e.slice(0,e.length-1).map(e=>e.conjunction?Ye[e.conjunction]:Ue.Blank);const s=[].concat(...e.map(e=>[...e.leftBounds,e.id,...e.rightBounds]));this.group={type:Ge.Default},Je(this.group,s);const i={};et(this.group,i),this.groups=Object.entries(i).map(([e,t])=>{let s=e.split("-");1===s.length&&(s=[s[0],s[0]]);return{group:t,range:s.map(e=>this.staffIds.indexOf(e)),key:e}}),this.maskCache=new Map}get stavesCount(){return this.staffIds?this.staffIds.length:null}get partGroups(){const e=this.groups.filter(e=>e.group.grand);return this.groups.filter(t=>{if(t.group.grand)return!0;if(t.range[0]===t.range[1]){const s=t.range[0];return!e.some(e=>e.range[0]<=s&&e.range[1]>=s)}return!1})}get standaloneGroups(){const e=[],t=s=>{s.grand?e.push(s.subs.map(e=>e.staff)):s.staff?e.push([s.staff]):s.subs&&s.subs.forEach(e=>t(e))};return t(this.group),e}conjunctionBetween(e,t){if(t<=e)return null;let s=Ue.Solid;for(let i=e;it&1<({ids:e.staffIds.slice(t.range[0],t.range[1]+1).filter(e=>s.includes(e)),...t})).filter(({ids:e})=>e.length).map(({ids:e,...t})=>({key:t.key,group:t.group,range:[s.indexOf(e[0]),s.indexOf(e[e.length-1])]})),n=s.slice(0,s.length-1).map((t,i)=>{const n=s[i+1];return e.conjunctionBetween(e.staffIds.indexOf(t),e.staffIds.indexOf(n))});return{staffIds:s,conjunctions:n,groups:i}}mask(e){return this.maskCache.get(e)||this.maskCache.set(e,StaffLayout.makeMaskLayout(this,e)),this.maskCache.get(e)}partialMaskCode(e,t=!1){const s=this.staffIds.map((t,s)=>s(e[this.staffIds[s]]=t,e),{}),i=e=>{if(e.staff)return[s[e.staff]?e.staff:null,null===s[e.staff]];const t=e.subs.map(e=>i(e)),n=t.map(e=>e[0]).filter(Boolean).join(","),r=t.some(([e,t])=>t),a=n?((e,t=!1)=>{if(e===Ge.Default)return e=>e;if(t)switch(e){case Ge.Brace:return e=>`{${e}`;case Ge.Bracket:return e=>`<${e}`;case Ge.Square:return e=>`[${e}`;default:return e=>e}switch(e){case Ge.Brace:return e=>`{${e}}`;case Ge.Bracket:return e=>`<${e}>`;case Ge.Square:return e=>`[${e}]`;default:return e=>e}})(e.type,r)(n):null;return[a,r]};let[n]=i(this.group);return n=n||"",t||(n=n.replace(/[_\w]+/g,"")),n}}var tt=function(){var e=function(e,t,s,i){for(s=s||{},i=e.length;i--;s[e[i]]=t);return s},t=[1,15],s=[1,16],i=[1,17],n=[1,11],r=[1,12],a=[1,13],o=[1,24],c=[1,25],l=[1,26],u=[5,11,12,13,15,16,17,21,22,23,24],h=[15,16,17,21,22,23,24],m=[11,12,13,15,16,17,21,22,23,24],d=[5,11,12,13,21,22,23,24],f={trace:function(){},yy:{},symbols_:{error:2,start_symbol:3,staff_layout:4,EOF:5,seq:6,seq_id:7,seq_br:8,seq_con:9,bound_left:10,"<":11,"[":12,"{":13,bound_right:14,">":15,"]":16,"}":17,bound_lefts:18,bound_rights:19,conjunction:20,"-":21,",":22,".":23,ID:24,seq_bl:25,$accept:0,$end:1},terminals_:{2:"error",5:"EOF",11:"<",12:"[",13:"{",15:">",16:"]",17:"}",21:"-",22:",",23:".",24:"ID"},productions_:[0,[3,2],[4,1],[6,0],[6,1],[6,1],[6,1],[10,1],[10,1],[10,1],[14,1],[14,1],[14,1],[18,1],[18,2],[19,1],[19,2],[20,1],[20,1],[20,1],[7,1],[7,2],[7,2],[7,2],[7,2],[25,1],[25,2],[25,2],[25,2],[8,2],[8,2],[8,2],[9,1],[9,2],[9,2],[9,2],[9,2]],performAction:function(e,t,s,i,n,r,a){var o=r.length-1;switch(n){case 1:return r[o-1];case 2:r[o].next(),this.$=r[o].toJSON();break;case 3:this.$=new Seq;break;case 13:case 15:this.$=[r[o]];break;case 14:case 16:this.$=[...r[o-1],r[o]];break;case 20:this.$=new Seq,this.$.tip.i(r[o]);break;case 21:case 23:r[o-1].next(),r[o-1].tip.i(r[o]),this.$=r[o-1];break;case 22:case 24:r[o-1].tip.i(r[o]),this.$=r[o-1];break;case 25:this.$=new Seq,this.$.tip.bl(r[o]);break;case 26:case 27:r[o-1].next(),r[o-1].tip.bl(r[o]),this.$=r[o-1];break;case 28:r[o-1].tip.bl(r[o]),this.$=r[o-1];break;case 29:case 30:case 31:r[o-1].tip.br(r[o]),this.$=r[o-1];break;case 32:this.$=new Seq,this.$.tip.con(r[o]),this.$.next();break;case 33:case 34:case 35:case 36:r[o-1].tip.con(r[o]),r[o-1].next(),this.$=r[o-1]}},table:[{3:1,4:2,5:[2,3],6:3,7:4,8:5,9:6,10:14,11:t,12:s,13:i,18:10,20:9,21:n,22:r,23:a,24:[1,7],25:8},{1:[3]},{5:[1,18]},{5:[2,2]},{5:[2,4],10:14,11:t,12:s,13:i,14:23,15:o,16:c,17:l,18:22,19:20,20:21,21:n,22:r,23:a,24:[1,19]},{5:[2,5],10:14,11:t,12:s,13:i,18:29,20:28,21:n,22:r,23:a,24:[1,27]},{5:[2,6],10:14,11:t,12:s,13:i,14:23,15:o,16:c,17:l,18:33,19:31,20:32,21:n,22:r,23:a,24:[1,30]},e(u,[2,20]),{14:23,15:o,16:c,17:l,19:35,20:36,21:n,22:r,23:a,24:[1,34]},e(u,[2,32]),e(h,[2,25],{10:37,11:t,12:s,13:i}),e(u,[2,17]),e(u,[2,18]),e(u,[2,19]),e(m,[2,13]),e(m,[2,7]),e(m,[2,8]),e(m,[2,9]),{1:[2,1]},e(u,[2,21]),e(d,[2,29],{14:38,15:o,16:c,17:l}),e(u,[2,33]),e(h,[2,26],{10:37,11:t,12:s,13:i}),e(u,[2,15]),e(u,[2,10]),e(u,[2,11]),e(u,[2,12]),e(u,[2,23]),e(u,[2,35]),e(h,[2,27],{10:37,11:t,12:s,13:i}),e(u,[2,24]),e(d,[2,31],{14:38,15:o,16:c,17:l}),e(u,[2,36]),e(h,[2,28],{10:37,11:t,12:s,13:i}),e(u,[2,22]),e(d,[2,30],{14:38,15:o,16:c,17:l}),e(u,[2,34]),e(m,[2,14]),e(u,[2,16])],defaultActions:{3:[2,2],18:[2,1]},parseError:function(e,t){if(!t.recoverable){var s=new Error(e);throw s.hash=t,s}this.trace(e)},parse:function(e){var t=this,s=[0],i=[null],n=[],r=this.table,a="",o=0,c=0,l=n.slice.call(arguments,1),u=Object.create(this.lexer),h={yy:{}};for(var m in this.yy)Object.prototype.hasOwnProperty.call(this.yy,m)&&(h.yy[m]=this.yy[m]);u.setInput(e,h.yy),h.yy.lexer=u,h.yy.parser=this,void 0===u.yylloc&&(u.yylloc={});var d=u.yylloc;n.push(d);var f=u.options&&u.options.ranges;"function"==typeof h.yy.parseError?this.parseError=h.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;for(var p,g,y,v,x,S,k,b,T=function(){var e;return"number"!=typeof(e=u.lex()||1)&&(e=t.symbols_[e]||e),e},w={};;){if(g=s[s.length-1],this.defaultActions[g]?y=this.defaultActions[g]:(null==p&&(p=T()),y=r[g]&&r[g][p]),void 0===y||!y.length||!y[0]){var M="";for(x in b=[],r[g])this.terminals_[x]&&x>2&&b.push("'"+this.terminals_[x]+"'");M=u.showPosition?"Parse error on line "+(o+1)+":\n"+u.showPosition()+"\nExpecting "+b.join(", ")+", got '"+(this.terminals_[p]||p)+"'":"Parse error on line "+(o+1)+": Unexpected "+(1==p?"end of input":"'"+(this.terminals_[p]||p)+"'"),this.parseError(M,{text:u.match,token:this.terminals_[p]||p,line:u.yylineno,loc:d,expected:b})}if(y[0]instanceof Array&&y.length>1)throw new Error("Parse Error: multiple actions possible at state: "+g+", token: "+p);switch(y[0]){case 1:s.push(p),i.push(u.yytext),n.push(u.yylloc),s.push(y[1]),p=null,c=u.yyleng,a=u.yytext,o=u.yylineno,d=u.yylloc;break;case 2:if(S=this.productions_[y[1]][1],w.$=i[i.length-S],w._$={first_line:n[n.length-(S||1)].first_line,last_line:n[n.length-1].last_line,first_column:n[n.length-(S||1)].first_column,last_column:n[n.length-1].last_column},f&&(w._$.range=[n[n.length-(S||1)].range[0],n[n.length-1].range[1]]),void 0!==(v=this.performAction.apply(w,[a,c,o,h.yy,y[1],i,n].concat(l))))return v;S&&(s=s.slice(0,-1*S*2),i=i.slice(0,-1*S),n=n.slice(0,-1*S)),s.push(this.productions_[y[1]][0]),i.push(w.$),n.push(w._$),k=r[s[s.length-2]][s[s.length-1]],s.push(k);break;case 3:return!0}}return!0}};class Item{constructor(){this.id=null,this.leftBounds=[],this.rightBounds=[],this.conjunction=null}i(e){return this.id=e,this}bl(e){return this.leftBounds=e,this}br(e){return this.rightBounds=e,this}con(e){return this.conjunction=e,this}}class Seq{constructor(){this.body=[],this.tip=new Item}next(){return this.body.push(this.tip),this.tip=new Item,this}toJSON(){return this.body}}var p={EOF:1,parseError:function(e,t){if(!this.yy.parser)throw new Error(e);this.yy.parser.parseError(e,t)},setInput:function(e,t){return this.yy=t||this.yy||{},this._input=e,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var e=this._input[0];return this.yytext+=e,this.yyleng++,this.offset++,this.match+=e,this.matched+=e,e.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),e},unput:function(e){var t=e.length,s=e.split(/(?:\r\n?|\n)/g);this._input=e+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-t),this.offset-=t;var i=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),s.length-1&&(this.yylineno-=s.length-1);var n=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:s?(s.length===i.length?this.yylloc.first_column:0)+i[i.length-s.length].length-s[0].length:this.yylloc.first_column-t},this.options.ranges&&(this.yylloc.range=[n[0],n[0]+this.yyleng-t]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},less:function(e){this.unput(this.match.slice(e))},pastInput:function(){var e=this.matched.substr(0,this.matched.length-this.match.length);return(e.length>20?"...":"")+e.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var e=this.match;return e.length<20&&(e+=this._input.substr(0,20-e.length)),(e.substr(0,20)+(e.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var e=this.pastInput(),t=new Array(e.length+1).join("-");return e+this.upcomingInput()+"\n"+t+"^"},test_match:function(e,t){var s,i,n;if(this.options.backtrack_lexer&&(n={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(n.yylloc.range=this.yylloc.range.slice(0))),(i=e[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=i.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:i?i[i.length-1].length-i[i.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+e[0].length},this.yytext+=e[0],this.match+=e[0],this.matches=e,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(e[0].length),this.matched+=e[0],s=this.performAction.call(this,this.yy,this,t,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),s)return s;if(this._backtrack){for(var r in n)this[r]=n[r];return!1}return!1},next:function(){if(this.done)return this.EOF;var e,t,s,i;this._input||(this.done=!0),this._more||(this.yytext="",this.match="");for(var n=this._currentRules(),r=0;rt[0].length)){if(t=s,i=r,this.options.backtrack_lexer){if(!1!==(e=this.test_match(s,n[r])))return e;if(this._backtrack){t=!1;continue}return!1}if(!this.options.flex)break}return t?!1!==(e=this.test_match(t,n[i]))&&e:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){var e=this.next();return e||this.lex()},begin:function(e){this.conditionStack.push(e)},popState:function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(e){return(e=this.conditionStack.length-1-Math.abs(e||0))>=0?this.conditionStack[e]:"INITIAL"},pushState:function(e){this.begin(e)},stateStackSize:function(){return this.conditionStack.length},options:{},performAction:function(e,t,s,i){switch(s){case 0:break;case 1:return t.yytext;case 2:return 24;case 3:return 5}},rules:[/^(?:\s+)/,/^(?:([-,.\[\]<>{}]))/,/^(?:([a-zA-Z_0-9]+))/,/^(?:$)/],conditions:{INITIAL:{rules:[0,1,2,3],inclusive:!0}}};function g(){this.yy={}}return f.lexer=p,g.prototype=f,f.Parser=g,new g}();tt.Parser;tt.Parser;var st=function(){return tt.parse.apply(tt,arguments)};const it=e=>{const t=st(e);return new StaffLayout(t)};class SemanticGraph extends SimpleClass{constructor(e){super(),super.assign(e)}static fromPoints(e=[]){const t=new SemanticGraph;return t.points=e,t}getLayer(e){return this.points.filter(t=>t.semantic===e)}getConfidentLayer(e,t){return this.points.filter(s=>s.semantic===e&&(!Number.isFinite(s.confidence)||s.confidence>=t))}getSystemPoints(){return this.points.filter(e=>E.includes(e.semantic))}getStaffPoints(){return this.points.filter(e=>!E.includes(e.semantic))}offset(e,t){this.points.forEach(s=>{s.x+=e,s.y+=t})}scale(e){this.points.forEach(t=>{t.x*=e,t.y*=e})}transform(e){this.points.forEach(t=>{let s=t.x*e[0][0]+t.y*e[1][0]+e[2][0];const i=t.x*e[0][1]+t.y*e[1][1]+e[2][1];if(t.extension){if(Number.isFinite(t.extension.y1)){const i=t.x*e[0][1]+t.extension.y1*e[1][1]+e[2][1],n=t.x*e[0][1]+t.extension.y2*e[1][1]+e[2][1];s=t.x*e[0][0]+.5*(t.extension.y1+t.extension.y2)*e[1][0]+e[2][0],t.extension.y1=i,t.extension.y2=n}if(Number.isFinite(t.extension.width)){const s=Math.sqrt(e[0][0]*e[1][1]-e[0][1]*e[1][0]);t.extension.width*=s,t.extension.height*=s}}t.x=s,t.y=i})}}SemanticGraph.className="SemanticGraph";const nt=[T.ClefG,T.ClefF,T.ClefC,T.TimesigC44,T.TimesigC22,T.TimesigZero,T.TimesigOne,T.TimesigTwo,T.TimesigThree,T.TimesigFour,T.TimesigFive,T.TimesigSix,T.TimesigSeven,T.TimesigEight,T.TimesigNine,T.OctaveShift8va,T.OctaveShift8vb,T.OctaveShift0,T.Zero,T.One,T.Two,T.Three,T.Four,T.Five,T.Six,T.Seven,T.Eight,T.Nine,T.AccNatural,T.AccSharp,T.AccDoublesharp,T.AccFlat,T.AccFlatflat,T.NoteheadS0,T.NoteheadS1,T.NoteheadS2,T.NoteheadS1stemU,T.NoteheadS1stemD,T.NoteheadS2stemU,T.NoteheadS2stemD,T.Rest0,T.Rest1,T.Rest2,T.Rest3,T.Rest4,T.Rest5,T.Rest6,T.Rest0W,T.RestM1,T.SlurBegin,T.SlurEnd,T.Dot,T.f,T.p,T.m,T.n,T.r,T.s,T.z,T.ScriptFermata,T.ScriptShortFermata,T.ScriptSforzato,T.ScriptStaccato,T.ScriptStaccatissimo,T.ScriptTurn,T.ScriptTrill,T.ScriptSegno,T.ScriptCoda,T.ScriptArpeggio,T.ScriptPrall,T.ScriptMordent,T.ScriptMarcato,T.ScriptTenuto,T.ScriptPortato,T.PedalStar,T.PedalPed,T.GraceNotehead,T.BeamLeft,T.BeamRight,T.BeamContinue,T.CrescendoBegin,T.CrescendoEnd,T.DecrescendoBegin,T.DecrescendoEnd,T.TremoloLeft,T.TremoloRight,T.TremoloMiddle],rt=[T.AccNatural,T.AccSharp,T.AccDoublesharp,T.AccFlat,T.AccFlatflat,T.NoteheadS0,T.NoteheadS1,T.NoteheadS2,T.NoteheadS1stemU,T.NoteheadS1stemD,T.NoteheadS2stemU,T.NoteheadS2stemD],at=[T.SignLined,T.SignInterval],ot=[T.NoteheadS1,T.NoteheadS2],ct={AccSharp:Z.KeySharp,AccNatural:Z.KeyNatural,AccFlat:Z.KeyFlat},lt={[T.NoteheadS1]:{up:T.NoteheadS1stemU,down:T.NoteheadS1stemD},[T.NoteheadS2]:{up:T.NoteheadS2stemU,down:T.NoteheadS2stemD}},ut=[T.Rest0,T.Rest1,T.Rest2,T.Rest3,T.Rest4,T.Rest5,T.Rest6],ht={[Z.BeamLeft]:"Open",[Z.BeamRight]:"Close",[Z.BeamContinue]:"Continue"},mt={Alter1:Pe.Alternation1,Alter2:Pe.Alternation2},dt=(e,t)=>{switch(e.length){case 0:return;case 1:return e[0];case 2:return"u"===t?Math.min(...e):Math.max(...e);default:{const s=e.reduce((e,t)=>e+t,0)/e.length;return e.sort((e,t)=>Math.abs(e-s)-Math.abs(t-s)),dt(e.slice(0,e.length-1),t)}}};class Measure extends SimpleClass{constructor(e){super(),super.assign(e),this.tokens=this.tokens||[],this.antiTokens=this.antiTokens||[],this.barTypes=this.barTypes||{}}get right(){return this.left+this.width}get noteheads(){return this.tokens.filter(e=>e.isNotehead).sort((e,t)=>e.x-t.x)}get chordRects(){const e=this.noteheads.filter(e=>[Z.NoteheadS0,Z.NoteheadS1stemU,Z.NoteheadS2stemU,Z.NoteheadS1stemD,Z.NoteheadS2stemD].includes(e.type));let t=0;const s=e.reduce((e,s)=>{const i=s.tip?`${s.tip.x}|${s.tip.y}`:`nul${t}`;let n=`${s.type}|${i}`;return!s.tip&&e[n]&&(e[n].some(e=>Math.abs(e.x-s.x){const t=Math.min(...e.map(e=>e.x)),s=Math.max(...e.map(e=>e.x)),i=Math.min(...e.map(e=>e.y)),n=Math.max(...e.map(e=>e.y)),r=e[0],a=r&&r.tip?r.tip.x:t;let o=t,c=s-t,l=null;switch(r.type){case Z.NoteheadS0:o-=w.NoteheadS0/2,c+=w.NoteheadS0;break;case Z.NoteheadS1stemU:case Z.NoteheadS2stemU:l="u",o-=w.NoteheadS1,c+=w.NoteheadS1;break;case Z.NoteheadS1stemD:case Z.NoteheadS2stemD:l="d",c+=w.NoteheadS1}return{x:o,width:c,stemX:a,stemDirection:l,top:i,bottom:n,tip:r.tip}})}get timeWarped(){return this.tokens&&this.tokens.some(e=>e.timeWarped)}get additionalLines(){const e=this.getChords();return[...e.filter(e=>e.ys.some(e=>e<=-3)).map(e=>({left:e.left,right:e.right,n:Math.ceil(Math.min(...e.ys))+2})),...e.filter(e=>e.ys.some(e=>e>=3)).map(e=>({left:e.left,right:e.right,n:Math.floor(Math.max(...e.ys))-2}))].map(e=>({left:e.left-.28,right:e.right+.28,n:e.n}))}getChords(){const e=this.tokens.filter(e=>ue.includes(e.type)),t=this.tokens.filter(e=>pe.includes(e.type)),s=this.tokens.filter(e=>ye.includes(e.type)),i=this.chordRects.map(e=>{const t=this.noteheads.filter(t=>t.direction===e.stemDirection&&t.left>=e.x&&t.right<=e.x+e.width+.2&&t.y>=e.top&&t.y<=e.bottom);t.sort((e,t)=>t.y-e.y);const s=t.map(e=>e.y),i=t.map(e=>e.id),n=t.reduce((e,t)=>Math.max(e,t.division),0);return{rect:e,left:e.x,right:e.x+e.width,pivotX:(r=t,dt(r.map(e=>Number.isFinite(e.pivotX)?e.pivotX:e.x),r[0].direction)),ys:s,tip:e.tip,noteIds:i,division:n,dots:null,rest:!1,stemDirection:e.stemDirection,beam:null};var r}).sort((e,t)=>t.left-e.left),n=new Set,r=i.map(({rect:i,...r})=>{if(r.division>=1){const t=[i.bottom,i.top];switch(i.stemDirection){case"u":t[0]=i.tip?i.tip.y-.2:i.top-6-.5;break;case"d":t[1]=i.tip?i.tip.y+.2:i.bottom+6+.5}const a=e.filter(e=>!n.has(e.id)&&e.x>i.stemX-.2&&e.xt[0]&&e.yMath.max(e,t.division),r.division),a.forEach(e=>n.add(e.id)),r.division>=3){const e=i.tip&&s.find(e=>Math.abs(i.tip.x-e.x)<.3&&Math.abs(i.tip.y-e.y)<.7);e&&(r.beam=ht[e.type])}}const a=t.filter(e=>!n.has(e.id)&&e.x>i.x+i.width-.2&&e.xi.top-1&&e.y<=i.bottom+.5);return r.dots=a.reduce((e,t)=>Math.max(e,t.dots),0),a.forEach(e=>n.add(e.id)),r});return r.reverse(),r}getRests(){const e=this.tokens.filter(e=>le.includes(e.type)),t=this.tokens.filter(e=>pe.includes(e.type));return e.map(e=>{const s=t.filter(t=>t.x>e.x+.5&&t.xe.y-1&&t.yMath.max(e,t.dots),0);return{left:e.x-.75,right:e.x+.75,pivotX:e.x,rest:!0,ys:[e.y],noteIds:[e.id],dots:s,division:e.division,stemDirection:null}})}getEvents(){return[...this.getChords(),...this.getRests()].sort((e,t)=>e.left-t.left)}getContexts(e={}){return this.tokens.filter(e=>e.isContexted).sort((e,t)=>e.x-t.x).map(t=>new ContextedTerm({x:t.x,y:t.y,tokenType:t.type,...e}))}assignAccessoriesOnEvents(e){e.forEach(e=>e.accessories=e.accessories||[]);this.tokens.filter(e=>xe.includes(e.type)).forEach(t=>{const s=e.filter(e=>t.x>e.left-1&&t.x0){let e=s[0];s.length>1&&(e=s.map(e=>({event:e,d:Math.min(...e.ys.map(e=>Math.abs(e-t.y)))})).sort(({d:e},{d:t})=>e-t).map(({event:e})=>e)[0]);let i=t.y>Math.max(...e.ys)?Me.Down:Me.Up;Se.includes(t.type)&&(i=null),e.accessories.push({type:t.type,id:t.id,direction:i,x:t.x-e.left})}});const t=[...e];t.sort((e,t)=>e.left-t.left);this.tokens.filter(e=>e.type===Z.ScriptArpeggio).forEach(e=>{const s=t.find(t=>e.xtt>e.y));s&&s.accessories.push({type:Z.ScriptArpeggio,id:e.id,x:e.x-s.left})});this.tokens.filter(e=>e.type===Z.GraceNotehead).forEach(t=>{const s=e.find(e=>t.x>e.left&&t.xMath.abs(t.y-e)<.4));s&&(s.grace=Ee.Grace)});const s=this.tokens.filter(e=>e.type===Z.TremoloLeft),i=this.tokens.filter(e=>e.type===Z.TremoloRight),n=this.tokens.filter(e=>e.type===Z.TremoloMiddle),r=e.filter(e=>!e.rest).map(e=>{const t=[...e.ys];e.tip?t.push(e.tip.y):(t.push(e.ys[0]+2),t.push(e.ys[e.ys.length-1]-2));const s=e.tip?e.tip.x:e.left,i=e.tip?e.tip.x:e.right;return{event:e,top:Math.min(...t),bottom:Math.max(...t),stemL:s,stemR:i}});n.forEach(e=>{const t=r.find(t=>!!t.event.tip&&(e.y>t.top&&e.y{const t=r.find(t=>e.y>t.top&&e.yt.stemR&&e.x{const t=r.find(t=>e.y>t.top&&e.yt.stemL-1.6);t&&(t.event.tremolo=t.event.tremolo||2,++t.event.tremolo,t.event.tremoloLink=Ne.Catcher)})}assignFeaturesOnEvents(e,t){const s=t.filter(e=>e.x>this.left&&e.xut.includes(e.semantic)),n=s.filter(e=>e.semantic===T.Flag3),r=s.filter(e=>e.semantic===T.Dot),a=s.filter(e=>e.semantic===T.BeamLeft),o=s.filter(e=>e.semantic===T.BeamContinue),c=s.filter(e=>e.semantic===T.BeamRight),l=s.filter(e=>e.semantic===T.GraceNotehead),u=s.filter(e=>e.semantic===T.TremoloRight),h=s.filter(e=>e.semantic===T.vline_Stem),m=s.filter(e=>e.semantic===T.NoteheadS0),d=s.filter(e=>e.semantic===T.NoteheadS1),f=s.filter(e=>e.semantic===T.NoteheadS2);e.forEach(e=>{const t=e.tip?e.tip.x:(e.left+e.right)/2,s=e.tip?Math.min(e.tip.y,e.ys[e.ys.length-1]):e.ys[e.ys.length-1],p=e.tip?Math.max(e.tip.y,e.ys[0]):e.ys[0],g=e.tip?e.tip.x:e.left,y=[0,0,0,0,0,0,0];if(e.rest){i.filter(s=>_(s,{x:t,y:e.ys[0]})<.5).forEach(e=>{const t=ut.indexOf(e.semantic);y[t]=Math.max(y[t],e.confidence)})}else{const i=[m,d,f].map(t=>t.filter(t=>t.x>e.left&&t.xs-.25&&t.yMath.max(0,...e.map(e=>e.confidence))),r=n.filter(e=>e.y>s-.2&&e.yt.confidence-e.confidence),y[0]=i[0],y[1]=i[1],y[2]=i[2],Array(y.length-3).fill(0).forEach((e,t)=>y[3+t]=r[t]?r[t].confidence:0)}const v=r.filter(s=>s.x>t&&s.xv.some(t=>e.x>t.x&&Math.abs(e.y-t.y)<.2)),S=[Math.max(0,...v.map(e=>e.confidence)),Math.max(0,...x.map(e=>e.confidence))],k=[a,o,c].map(e=>e.filter(e=>Math.abs(e.x-t)<.2&&e.y>s-.2&&e.yMath.max(0,...e.map(e=>e.confidence))),b=h.filter(s=>_({x:t,y:e.ys[0]},{x:s.x,y:s.extension.y2})<.5),T=h.filter(s=>_({x:t,y:e.ys[e.ys.length-1]},{x:s.x,y:s.extension.y1})<.5),w=[Math.max(0,...b.map(e=>e.confidence)),Math.max(0,...T.map(e=>e.confidence))],M=l.filter(s=>Math.abs(s.x-t)<.6&&e.ys.some(e=>Math.abs(s.y-e)<.4)),E=Math.max(0,...M.map(e=>e.confidence)),A=0===e.division?u.filter(t=>t.x>e.left-2&&t.xe.y>s-.04&&e.yg-2&&e.xe.confidence));e.feature={divisions:y,dots:S,beams:k,stemDirections:w,grace:E,tremoloCatcher:N}})}}Measure.className="Measure",Measure.blackKeys=["tokens","antiTokens"];class Staff extends SimpleClass{constructor({measureCount:e=null,measureBars:t=null,...s}={}){if(super(),super.assign(s),this.height=this.height||10,this.staffY=this.staffY||5,t){let e=0;this.measures=t.map(t=>{const s=new Measure({left:e,width:t-e,height:this.height});return e=t,s})}else this.measures=e?Array(e).fill(null).map(()=>new Measure):[]}get noteRange(){const e=[].concat(...this.measures.map(e=>e.noteheads)).map(e=>e.y);return{top:Math.min(-2,...e),bottom:Math.max(2,...e)}}get additionalLines(){return[].concat(...this.measures.map(e=>e.additionalLines))}rearrangeMeasures(e){if(!e.length)return void console.warn("rearrangeMeasures error, measureBars are empty.");const t=this.measures?.map(e=>e.tokens).flat(1)||[];let s=0;this.measures=e.map(e=>{const t=new Measure({left:s,width:e-s,height:this.height});return s=e,t}),this.reassignTokens(t)}reassignTokens(e=null){e||(e=[].concat(...this.measures.map(e=>e.tokens))),this.measures.forEach(e=>e.tokens=[]),e.forEach(e=>{for(const t of this.measures)if(e.xe.semantic===T.TempoNotehead).forEach(e=>{const t=i.findIndex(t=>/^Notehead/.test(t.semantic)&&_(e,t)<.3);t>=0&&i.splice(t,1)});const n=e=>t.displacementSemantics?.[e]?this.semantics.find(t=>t.id===e):null;i.filter(e=>nt.includes(e.semantic)).forEach(e=>this.appendPoint(e,{points:i}));const r=i.filter(e=>e.semantic===T.vline_Stem).filter(e=>e.extension.y2-e.extension.y1>1.5).map(e=>({x:e.x,y1:e.extension.y1,y2:e.extension.y2,direction:null})),a=i.filter(e=>ot.includes(e.semantic)&&e.y>this.semanticTop&&e.y{if((s?1:0)^(e.x{const t=a.filter(t=>Math.abs(t.x-e.x)-w[t.semantic]/2<.32&&Math.abs(t.x-e.x)-w[t.semantic]/2>-.44&&t.y>e.y1-.5&&t.ye.x&&t.y>e.y2)&&!(t.xe.y-t.y);const s=Math.min(...t.map(t=>t.y-e.y1)),r=Math.min(...t.map(t=>e.y2-t.y));if(Math.min(s,r)>.5)return;const a=s!o.has(e.id)).forEach(e=>{const a=r.filter(t=>Math.abs(t.x-e.x)<2&&e.y>t.y1&&e.yMath.abs(t.x-e.x)-Math.abs(s.x-e.x)),o=a[0];if(o){const t="d"===o.direction,s=t?lt[e.semantic].down:lt[e.semantic].up;this.appendPoint({id:e.id,semantic:s,x:o.x+c(e,o,t),y:e.y,pivotX:e.x,confidence:e.confidence},{tip:{x:o.x,y:t?o.y2:o.y1},antiPoint:n(e.id),points:i})}else s.debug("isolated notehead:",t.index,this.index,e)});const l=i.filter(e=>e.semantic===T.Flag3);l.sort((e,t)=>e.x-t.x),this.appendFlags(l,r);const u=i.filter(e=>e.semantic===T.Dot).map(e=>{const t=B(e.y,.5);return{x:e.x,y:t}}).reduce((e,t)=>(e[t.y]=e[t.y]||[],e[t.y].push(t),e),{});Object.entries(u).forEach(([e,t])=>{const s=Number(e);if(t.length>1){t.sort((e,t)=>e.x-t.x);for(let e=0;ee.x>r.x&&e.x-r.x<1.2)&&this.appendPoint({id:r.id,x:r.x,y:s,confidence:r.confidence},{type:Z.DotDot,antiPoint:n(r.id),points:i})}}});const h=i.filter(e=>e.semantic===T.KeyAcc);i.filter(e=>ct[e.semantic]).forEach(e=>{h.some(t=>Math.abs(e.x-t.x)<.5&&Math.abs(e.y-t.y)<1)&&this.appendPoint({id:e.id,semantic:e.semantic,x:e.x,y:e.y,confidence:e.confidence},{type:ct[e.semantic],points:i})});i.filter(e=>e.semantic===T.OctaveShift8).forEach(e=>{const t=e.y<0?Z.OctaveShift8va:Z.OctaveShift8vb;this.appendPoint({id:e.id,x:e.x,y:e.y,confidence:e.confidence},{type:t,points:i})});const m=this.semantics.filter(e=>[T.VoltaLeft,T.VoltaRight].includes(e.semantic));m.sort((e,t)=>e.x-t.x);const d=m.reduce((e,t)=>{const s=e[t.semantic],i=Array.from(Object.keys(s)).map(Number).find(e=>t.x{if(s.length>1){const i=s.reduce((e,t)=>e+t.confidence,0);s[0].y*s[1].y<0&&i>=2*e&&this.appendPoint(s[0],{type:Z[t]})}})}appendPoint(e,{type:t,points:s=null,antiPoint:i,...n}={}){const r=e.x,a=this.measures.find(e=>rat.includes(t.semantic)&&Math.abs(t.y-e.y)<.2&&Math.abs(t.x-e.x)<1.2);t.some(e=>e.semantic===T.SignLined)?o=!0:t.some(e=>e.semantic===T.SignInterval)&&(c=!0)}t=t||Z[e.semantic];const l=Te[t];let u=be[t];(o||c)&&(u=Math.max(u,1));let h=e.y;Number.isFinite(l)?h=l:u&&(h=c?B(h+.5,u)-.5:B(h,u));const m=a.tokens.find(e=>e.type===t&&Math.abs(e.x-r)<.1&&Math.abs(e.y-h)<.1);m?Number.isFinite(m.confidence)&&m.confidence3||(a.tokens.push(new Token({id:e.id,type:t,x:r,y:h,pivotX:e.pivotX,confidence:e.confidence,...n})),i&&a.antiTokens.push(new Token({id:i.id,type:t,x:r,y:i.y,confidence:i.confidence})))}appendFlags(e,t){t.map(t=>({...t,flags:e.filter(e=>Math.abs(e.x-t.x)<.3&&e.y>t.y1-.5&&e.ye.flags.length).forEach(e=>{const t=e.flags.reduce((e,t)=>e&&e.confidence>t.confidence?e:t,null),s="d"===e.direction,i=s?Math.min(e.y2,e.y1+6):Math.max(e.y1,e.y2-6),n=e.flags.map(e=>({tip:(i-e.y)*(s?1:-1),confidence:e.confidence})).filter(e=>e.tip<2||e.confidence>.7*t.confidence).length,r=ue[n-1];r&&this.appendPoint({id:e.flags[0].id,x:e.x,y:i,confidence:Math.min(...e.flags.map(e=>e.confidence))},{type:r})})}clearTokens(){this.measures.forEach(e=>e.tokens=[]),this.semantics=[]}clearPredictedTokens(){this.measures.forEach(e=>e.tokens=e.tokens.filter(e=>!e.isPredicted))}}Staff.className="Staff",Staff.blackKeys=["index","semanticTop","semanticBttom"];class System extends SimpleClass{constructor({stavesCount:e,...t}){if(super(),super.assign(t),!this.measureBars){const e=5,t=(this.width-e)/this.measureCount;this.measureBars=Array(this.measureCount).fill(0).map((s,i)=>e+t*(i+1))}!t.staves&&e&&(this.staves=Array(e).fill(null).map(()=>new Staff({measureBars:this.measureBars}))),this.arrangePosition(),this.measureCount=this.measureCount||this.measureBars.length,this.sidBlackList=this.sidBlackList||[],this.sidWhiteList=this.sidWhiteList||[]}get noteRange(){if(!this.staves.length)return null;const e=this.staves[0],t=this.staves[this.staves.length-1];return{top:e.top+e.staffY+e.noteRange.top,bottom:t.top+t.staffY+t.noteRange.bottom}}get staffPositions(){return this.staves.map(e=>({y:e.top+e.staffY,radius:2}))}get staffMask(){return this.staffMaskChanged?this.staffMaskChanged:this.prev&&this.staves.length===this.prev.staves.length?this.prev.staffMask:2**this.staves.length-1}get staffTop(){const e=this.staffPositions;return e.length?e[0].y-e[0].radius:0}get staffBottom(){const e=this.staffPositions;return e.length?e[e.length-1].y+e[e.length-1].radius:0}arrangePosition(){let e=0;for(const t of this.staves){if(Number.isFinite(t.top))break;t.top=e,e+=t.height}}tidyMeasureBars(){this.measureBars=this.measureBars.filter(e=>e>1),this.measureBars.sort((e,t)=>e-t);const e=this.width-this.measureBars[this.measureBars.length-1];e>12?this.measureBars.push(this.width):e<2&&(this.measureBars[this.measureBars.length-1]=this.width),this.measureBars=this.measureBars.filter((e,t)=>t<1||e-this.measureBars[t-1]>4)}rearrangeMeasures(){this.measureCount=this.measureBars.length,this.staves.forEach(e=>e.rearrangeMeasures(this.measureBars))}get height(){return this.staves.reduce((e,t)=>e+t.height,0)}get connectionLine(){const e=this.staves[0],t=this.staves[this.staves.length-1];return e&&{top:e.top+e.staffY-2,bottom:t.top+t.staffY+2}}get middleY(){if(!this.staves.length)return 0;return this.staves.reduce((e,t)=>e+t.top+t.staffY,0)/this.staves.length}get timeSignatureOnHead(){return this.staves.some(e=>e.measures[0]?.tokens.some(e=>ee.includes(e.type)))}getStaffArray(e){let t=0;return Array(e).fill(null).map((e,s)=>{const i=this.staffMask&1<0?this.measureBars[e-1]:0,s=this.measureBars[e];return[...(this.tokens??[]).filter(e=>e.x>=t&&e.xTempoTerm.fromNumeralText(e.text)).filter(Boolean)]}getEvents(e){if(console.assert(Number.isInteger(this.headMeasureIndex),"invalid headMeasureIndex:",this.headMeasureIndex),!this.measureBars?.length&&this.staves.every(e=>!e.measures?.length))return{staffMask:this.staffMask,columns:[]};const t=this.getStaffArray(e).map(e=>e?e.measures.map(t=>{const s=t.getEvents();return t.assignAccessoriesOnEvents(s),t.assignFeaturesOnEvents(s,e.semantics),{events:s.map(t=>new EventTerm({staff:e.index,system:this.index,...t,rest:t.rest?"r":null})),contexts:t.getContexts({staff:e.index}),voltaBegin:t.tokens.some(e=>e.type===Z.VoltaLeft),voltaEnd:t.tokens.some(e=>e.type===Z.VoltaRight),alternative:t.alternative,barTypes:t.barTypes}}):Array(this.measureCount).fill(null).map(()=>({events:[],contexts:[],voltaBegin:!1,voltaEnd:!1,alternative:!1,barTypes:{}})));for(let e=0;et[e]?.contexts?.filter(e=>[Oe.TimeSignatureC,Oe.TimeSignatureN].includes(e.type))).find(e=>e?.length);s&&t.forEach(t=>{!t[e]||t[e].contexts.length||t[e].events.length||t[e].contexts.push(...s)})}const s=Array(this.measureCount).fill(null).map((e,s)=>({measureIndex:this.headMeasureIndex+s,rows:t.map(e=>e[s]),marks:this.getMarksInMeasure(s),duration:0,voltaBegin:t.some(e=>e[s]?.voltaBegin),voltaEnd:t.some(e=>e[s]?.voltaEnd),alternative:t.some(e=>e[s]?.alternative),barTypes:t.reduce((e,t)=>({...e,...t[s]?.barTypes}),{})}));s.forEach(e=>{[].concat(...e.rows.filter(Boolean).map(e=>e.events)).forEach((e,t)=>e.id=t+1)});const i=s[s.length-1];return i&&(i.break=!0),{staffMask:this.staffMask,columns:s}}getEventsFunctional(e,t,s=[],{useXMap:i=!1}={}){const n=this.getStaffArray(e).map((e,s)=>e?e.measures.map((e,i)=>{const n=t(s,i);return n&&{events:n.map(e=>new EventTerm({system:this.index,...e,rest:e.rest?"r":null})),contexts:e.getContexts({staff:s}),voltaBegin:e.tokens.some(e=>e.type===Z.VoltaLeft),voltaEnd:e.tokens.some(e=>e.type===Z.VoltaRight),alternative:e.alternative,barTypes:e.barTypes}}):Array(this.measureCount).fill(null).map(()=>({events:[],contexts:[],voltaBegin:!1,voltaEnd:!1,alternative:!1,barTypes:{}}))),r=Array(this.measureCount).fill(null).map((e,t)=>{const s=n.map(e=>e[t]);if(s.some(e=>!e))return null;let r=null;if(i){const e=[].concat(...s.map(e=>e.events)).reduce((e,t)=>(Number.isFinite(t.tickGroup)&&(e[t.tickGroup]=e[t.tickGroup]||[]),e[t.tickGroup].push(t),e),{});r=Object.values(e).reduce((e,t)=>{const s=Math.min(...t.map(e=>(e.left+e.right)/2));return e.set(s,t),e},new Map)}return{measureIndex:this.headMeasureIndex+t,rows:s,marks:this.getMarksInMeasure(t),duration:0,xMap:r,voltaBegin:s.some(e=>e.voltaBegin),voltaEnd:s.some(e=>e.voltaEnd),alternative:s.some(e=>e.alternative),barTypes:s.reduce((e,t)=>({...e,...t.barTypes}),{})}});return s.forEach(e=>r.forEach(e)),{staffMask:this.staffMask,columns:r}}getContexts(e){const t=this.getStaffArray(e).map(e=>e?e.measures.map(e=>({events:null,contexts:e.getContexts(),voltaBegin:e.tokens.some(e=>e.type===Z.VoltaLeft),voltaEnd:e.tokens.some(e=>e.type===Z.VoltaRight),alternative:t.some(e=>e.alternative),barTypes:e.barTypes})):Array(this.measureCount).fill(null).map(()=>({events:null,contexts:[],voltaBegin:!1,voltaEnd:!1,alternative:!1,barTypes:{}})));for(let e=0;et[e]?.contexts.filter(e=>[Oe.TimeSignatureC,Oe.TimeSignatureN].includes(e.type))).find(e=>e?.length);s&&t.forEach(t=>{t[e].contexts.length||t[e].contexts.push(...s)})}const s=Array(this.measureCount).fill(null).map((e,s)=>({measureIndex:this.headMeasureIndex+s,rows:t.map(e=>e[s]),marks:[],duration:0,voltaBegin:t.some(e=>e[s].voltaBegin),voltaEnd:t.some(e=>e[s].voltaEnd),alternative:t.some(e=>e.alternative),barTypes:t.reduce((e,t)=>({...e,...t[s].barTypes}),{})}));return{staffMask:this.staffMask,columns:s}}assignSemantics(e,t){const s=this.staves[e];console.assert(s,"staff is null:",e,this.staves);const i=s.top+s.staffY;t.getSystemPoints().forEach(e=>{const t={...e};t.y+=i,t.extension&&(t.extension={...t.extension},Number.isFinite(t.extension.y1)&&(t.extension.y1+=i,t.extension.y2+=i)),this.semantics.push(t)})}assemble(e,t=new DummyLogger){if(this.measureBars=[],!this.semantics)return;const s=SemanticGraph.fromPoints(this.semantics).getConfidentLayer(T.vline_BarMeasure,e);s.sort((e,t)=>e.x-t.x);const i=this.staffTop,n=this.staffBottom;let r=0;const a=s.reduce((e,t)=>{const s=Number.isFinite(t.confidence)?Math.tanh(t.confidence):1,a=t.x-r>.4?t.x:r;r=t.x;let o=e[a]||0;return o+=(Math.min(t.extension.y2,n)-Math.max(t.extension.y1,i))*s,t.x!==a&&delete e[a],e[t.x]=o,e},{}),o=Object.entries(a).filter(([e,t])=>t>3*this.staves.length).map(([e])=>Number(e));if(this.sidWhiteList.length)for(const e of s)this.sidWhiteList.includes(e.id)&&!o.some(t=>Math.abs(t-e.x)<=2)&&o.push(e.x);o.sort((e,t)=>e-t),o.forEach((e,t)=>{(t<=0||e-o[t-1]>2)&&this.measureBars.push(e)}),this.measureBars.length||this.measureBars.push(this.width),this.tidyMeasureBars(),this.rearrangeMeasures();this.semantics.filter(e=>[T.vline_BarTerminal,T.vline_BarSegment].includes(e.semantic)).forEach(e=>{const t=this.staves[0].measures.find(t=>e.x>t.right-2&&e.x{for(;!(l&1<C(this.index,i,e)),s.clearPredictedTokens(),s.assemble(e,this,t))})}qualifiedSemantics(e,t=1){return e.filter(e=>this.sidWhiteList.includes(e.id)||!this.sidBlackList.includes(e.id)&&(e.confidence>=t||!Number.isFinite(e.confidence))).map(e=>this.displacementSemantics&&this.displacementSemantics[e.id]?{...e,...this.displacementSemantics[e.id]}:e)}clearTokens(){this.staves.forEach(e=>e.clearTokens()),this.semantics=[]}newPoint(e,t,s=1){const i=this.staves[e];console.assert(i,"staff index out of bound:",e,this.staves.length);const{semantic:n,x:r,y:a,confidence:o=0,extension:c=null}=t,l={semantic:n,x:r,y:a,confidence:o,extension:c};return l.extension||delete l.extension,C(this.index,e,l),i.semantics.push(l),i.clearPredictedTokens(),i.assemble(s,this),l}appendToken(e){switch(this.tokens.push(e),e.textType){case Pe.TempoNumeral:{const t=this.staves[0];if(t){const s=t.top+t.staffY;t.measures.forEach(t=>{t.tokens=t.tokens.filter(t=>!ae.includes(t.type)||Math.abs(t.x-e.x)>e.width/2||Math.abs(s+t.y-e.y)>e.fontSize/2)})}}break;case Pe.Alternation1:case Pe.Alternation2:this.staves[0].measures.forEach(t=>{const s=Math.min(t.left+t.width,e.x+e.width/2)-Math.max(t.left,e.x-e.width/2);t.alternative=t.alternative||s/t.width>.5})}}}System.className="System",System.blackKeys=["index","pageIndex","prev","next","headMeasureIndex","tokens","indent"];class Page extends SimpleClass{constructor(e){super(),super.assign(e),this.systems=this.systems||[],this.source&&(this.source.matrix=this.source.matrix||[1,0,0,1,0,0])}get sidBlackList(){const e=[].concat(...this.systems.map(e=>e.sidBlackList));return new Set(e)}get sidWhiteList(){const e=[].concat(...this.systems.map(e=>e.sidWhiteList));return new Set(e)}clearTokens(){this.semantics=null,this.tokens=null,this.lyricTokens=null,this.systems.forEach(e=>e.tokens=null)}assignTexts(e,[t,s]){const i=this.source&&this.source.interval?this.source.interval*(t/this.source.dimensions.height):t/this.height;this.semantics=e.map(e=>{const n={x:(e.cx-s/2)/i,y:(e.cy-t/2)/i},r=this.source&&this.source.matrix?(a=n,{x:(o=this.source.matrix)[0]*a.x+o[2]*a.y+o[4],y:o[1]*a.x+o[3]*a.y+o[5]}):n;var a,o;return this.createTextSemantic(e,r.x+this.width/2,r.y+this.height/2,i)})}assignPageTexts(e,[t,s]){const i=s/this.width,n=t/this.height;this.semantics=e.map(e=>this.createTextSemantic(e,e.cx/i,e.cy/n,i,n))}createTextSemantic(e,t,s,i,n=i){return{confidence:e.score,x:t,y:s,semantic:T.rect_Text,extension:{text:e.text,type:e.type,width:e.width/i,height:e.height/n,theta:e.theta,textFeature:e.feature_dict}}}assemble({textAnnotations:e=null}={},t=new DummyLogger){if(this.tokens=[],this.lyricTokens=[],this.systems.forEach(e=>e.tokens=[]),this.systems.length){const e=this.systems.map(e=>e.left),t=e[Math.floor((e.length-1)/2)];this.systems.forEach(e=>e.indent=e.left>t+2)}if(this.semantics){const t=this.source?this.source.name:this.index.toString();this.semantics.forEach(s=>{O(t,s);const i={id:s.id,type:Z.Text,confidence:s.confidence,textType:mt[s.extension.type]||s.extension.type,text:e&&e[s.id]||s.extension.text,textFeasure:s.extension.textFeature,width:s.extension.width,fontSize:s.extension.height};if(s.semantic===T.rect_Text)switch(i.textType){case Pe.Title:case Pe.Author:case Pe.PageMargin:case Pe.Other:this.tokens.push(new TextToken({x:s.x,y:s.y,...i}));break;case Pe.TempoNumeral:case Pe.Chord:case Pe.MeasureNumber:case Pe.Instrument:case Pe.Alternation1:case Pe.Alternation2:{const e=this.systems.find(e=>e.top+e.staffTop>s.y);e&&e.appendToken(new TextToken({x:s.x-e.left,y:s.y-e.top,...i}))}break;case Pe.Lyric:(this.lyricTokens||(this.lyricTokens=[])).push(new TextToken({x:s.x,y:s.y,...i}));break;case Pe.TextualMark:case Pe.Times:{const e=[...this.systems].reverse().find(e=>e.topt>=e.top&&tn>=e.left&&n[e,ft[`TimeD${e}`]])),gt=Object.fromEntries(Array(12).fill(null).map((e,t)=>t+1).map(e=>[e,ft[`TimeN${e}`]])),yt=ft,vt={[yt.BOS]:"BOS",[yt.NoteheadS0]:"noteheads-s0",[yt.NoteheadS1]:"noteheads-s1",[yt.NoteheadS2]:"noteheads-s2",[yt.NoteheadGrace]:"GraceNotehead",[yt.Flag3]:"flags-u3",[yt.BeamLeft]:"BeamLeft",[yt.BeamContinue]:"BeamContinue",[yt.BeamRight]:"BeamRight",[yt.Dot]:"dot",[yt.Rest0]:"rests-0o",[yt.Rest1]:"rests-1o",[yt.Rest2]:"rests-2",[yt.Rest3]:"rests-3",[yt.Rest4]:"rests-4",[yt.Rest5]:"rests-5",[yt.Rest6]:"rests-6"},xt={[yt.NoteheadS0]:0,[yt.NoteheadS1]:1,[yt.NoteheadS2]:2,[yt.NoteheadGrace]:2},St=[yt.NoteheadS0,yt.NoteheadS1,yt.NoteheadS2,yt.NoteheadGrace],kt=[yt.Rest0,yt.Rest1,yt.Rest2,yt.Rest3,yt.Rest4,yt.Rest5,yt.Rest6],bt=[yt.BeamLeft,yt.BeamContinue,yt.BeamRight],Tt=[...St,...kt],wt=[...St,...kt,yt.vline_Stem],Mt=[yt.BOS,yt.NoteheadS0,yt.vline_Stem,...kt],Et=[...Tt,yt.vline_Stem],At={[yt.BeamLeft]:"Open",[yt.BeamRight]:"Close"},Nt=e=>({type:e,staff:-1,x:0,y1:0,y2:0}),It=Nt(ft.BOS),Ct=e=>[Nt(gt[e.numerator]),Nt(pt[e.denominator])],Ot=(e,t)=>{const s=e.filter((e,s)=>t[s]),i=Math.max(...s);return e.findIndex(e=>e===i)};class SemanticCluster extends SimpleClass{static elementToJSON(e){const t={type:e.type,staff:e.staff,x:e.x,y1:e.y1,y2:e.y2};return e.id&&(t.id=e.id),t}constructor(e){super(),super.assign(e)}get sourceMask(){return this.elements.map(e=>wt.includes(e.type))}get targetMask(){return this.elements.map(e=>Mt.includes(e.type))}get vMask(){return this.elements.map(e=>Et.includes(e.type))}get compactMatrixH(){if(!this.matrixH)return null;const e=this.sourceMask,t=this.targetMask;return this.matrixH.filter((t,s)=>e[s]).map(e=>e.filter((e,s)=>t[s]))}set compactMatrixH(e){this.matrixH=Bt([].concat(...e),[this.sourceMask,this.targetMask])}get compactMatrixV(){if(!this._matrixV)return null;const e=this.vMask,t=this._matrixV.filter((t,s)=>e[s]).map(t=>t.filter((t,s)=>e[s]));return[].concat(...t.map((e,t)=>e.slice(0,t)))}set compactMatrixV(e){this.matrixV=e&&_t(e,this.vMask)}get matrixV(){return this.groupsV&&Rt(this.elements.length,this.groupsV)}set matrixV(e){if(!e)return this.groupsV=null,void(this._matrixV=e);const t=[],s=e.map((t,s)=>t.some(Number.isFinite)||e.some(e=>Number.isFinite(e[s])));e.forEach((e,i)=>{if(s[i]){let s=!1;for(let n=0;n=.5){const e=t.findIndex(e=>e.includes(n));t[e].push(i),s=!0;break}}s||t.push([i])}}),this.groupsV=t,this._matrixV=e}toJSON(){return{__prototype:"SemanticCluster",index:this.index,elements:this.elements.map(SemanticCluster.elementToJSON),compactMatrixH:this.compactMatrixH,compactMatrixV:this.compactMatrixV}}static mapMatrix(e,t,s){return t.reduce((t,s,i)=>(t[s]?t[s]=t[s].map((t,s)=>t+e[i][s]?1:0):t[s]=e[i],t),[]).map(e=>s.map(t=>e[t]))}mergeOverlapping(){const e=this.overlappedNoteheads();if(e.length){const t=this.elements.map((t,s)=>{const i=e.find(e=>s===e[1]),n=i?i[0]:s;return n-e.filter(e=>e[1]t.findIndex(e=>e===s));this.elements=s.map(e=>this.elements[e]),console.assert(this.elements.every(Boolean),"null element found:",this,t,s),this.matrixH=SemanticCluster.mapMatrix(this.matrixH,t,s),this.groupsV=this.groupsV.map(e=>Array.from(new Set(e.map(e=>t[e]))))}}overlappedNoteheads(){const e=[],t=this.elements.filter(e=>St.includes(e.type));for(let s=0;st),t=this.masks?this.masks[1]:e.map(e=>Mt.includes(this.elements[e].type)),s=e.map(e=>this.elements[e].type===yt.vline_Stem&&this.elements[e].y2-this.elements[e].y1>2),i=e.filter(e=>[yt.NoteheadS1,yt.NoteheadS2,yt.NoteheadGrace].includes(this.elements[e].type)),n=e.filter(e=>this.elements[e].type===yt.NoteheadS0),r=e.map(()=>!1),a={};i.forEach(t=>{const i=this.elements[t];e.filter(e=>s[e]).filter(e=>this.elements[e].y1-.5i.y1).sort((e,s)=>this.matrixH[t][s]-this.matrixH[t][e]).slice(0,2).filter((e,s)=>0===s||this.matrixH[t][e]>=.5).forEach(e=>{a[e]=a[e]||[],a[e].push(t)})}),n.forEach(e=>{const s=this.elements[e],i=Ot(this.matrixH[e],t),n=this.elements[i];n.type===yt.NoteheadS0&&Math.abs(s.x-n.x)<2.6?(r[e]=!0,a[i]=a[i]||[i],a[i].push(e)):a[e]=a[e]||[e]});const o={},c=e.filter(e=>a[e]||kt.includes(this.elements[e].type));c.sort((e,t)=>this.elements[e].x-this.elements[t].x);const l=e.map(e=>e===yt.BOS);c.forEach(e=>{const t=Ot(this.matrixH[e],l);o[e]=t,t&&!kt.includes(this.elements[t].type)&&(l[t]=!1),l[e]=!0});const u=this.elements.filter(e=>e.type===yt.Dot),h=this.elements.filter(e=>e.type===yt.Flag3),m=this.elements.filter(e=>bt.includes(e.type)),d=this.groupsV;return c.map(e=>{const t=this.elements[e],s=d?d.findIndex(t=>t.includes(e)):null;if(kt.includes(t.type)){const i=u.filter(e=>e.x>t.x+.5&&e.xt.y1-1&&e.y1this.elements[e]),n=Math.min(...i.map(e=>e.x-.7)),r=Math.max(...i.map(e=>e.x+.7));i.sort((e,t)=>t.y1-e.y1);const c=i.map(e=>e.y1),l=i.map(e=>e.id),d=c[0],f=c[c.length-1],p=u.filter(e=>e.x>r&&e.xd-1&&e.y1{const s=B(t.y1,.5);return e[s]=e[s]||[],e[s].push(t),e},{}),g=Math.max(...Object.values(p).map(e=>e.length),0);let y=xt[i[0].type],v=null,x=null,S=null;if(t.type===yt.vline_Stem){if(v=d-t.y1>t.y2-f?"u":"d",S={x:t.x,y:"u"===v?t.y1:t.y2},2===y){const e="u"===v?[t.y1-.4,t.y2-1]:[t.y1+1,t.y2+.4];y+=h.filter(s=>Math.abs(s.x-t.x)<.2&&s.y1>e[0]&&s.y1Math.abs(s.x-t.x)<.2&&s.y1>e[0]&&s.y1{const s=function*(){for(const t of e)yield t}(),[i,n]=t;return i.map(e=>n.map(t=>e&&t?s.next().value:null))},_t=(e,t)=>{const s=function*(){for(const t of e)yield t}();return t.map((e,i)=>t.map((t,n)=>e&&t&&n{const s=Array(e).fill(null).map((e,s)=>t.findIndex(e=>e.includes(s)));return Array(e).fill(null).map((t,i)=>Array(e).fill(null).map((e,t)=>{if(t>=i)return null;const n=s[i],r=s[t];return n<0||r<0?null:n===r?1:0}))};var Ft;!function(e){e[e.None=0]="None",e.Mordent="mordent",e.Prall="prall",e.Turn="turn",e.Trill="trill",e.Tremolo="tremolo",e.Arpeggio="arpeggio"}(Ft||(Ft={}));const Pt={64:"Sustain",65:"Portamento",66:"Sostenuto",67:"Soft"};class P{static parseMidi(e,{fixOverlap:t=!0,logger:s=null}={}){const i=[],n={},r={},a=[],o=[];let c=0,l=5e3,u=0,h=4,m=0;const d={low:null,high:null};let f,p=0,g=0;const y=[],v=e.header.ticksPerBeat;let x=((e,{timeWarp:t=1}={})=>{const s=[];let i=120;const n=e.header.ticksPerBeat;for(let t=0;t0&&(e=a.ticksToEvent/n/(i/60)),"meta"==a.event.type&&"setTempo"==a.event.subtype&&(i=6e7/a.event.microsecondsPerBeat);const s=1e3*e*t||0;o.push([a,s]),a=r()}if(a=r())for(;a;)e()}(),o})(e);t&&(x=(e=>{const t=new Map;return e.filter(([{event:e,ticksToEvent:s}])=>{if(s>0&&t.clear(),"channel"!==e.type)return!0;const i=`${e.subtype}|${e.channel}|${e.noteNumber}`;return!t.get(i)&&(t.set(i,e),!0)})})((e=>{const t=new Map,s=new Map,i=[];let n=-1;return e.forEach(([{event:e,ticksToEvent:r}],a)=>{if(r>0&&(n=a),"channel"!==e.type)return;const o=`${e.channel}|${e.noteNumber}`;switch(e.subtype){case"noteOn":t.get(o)?s.set(o,n):t.set(o,n);break;case"noteOff":s.get(o)?(i.push([s.get(o),a]),s.delete(o)):t.delete(o)}}),i.forEach((e,t)=>{for(let s=t-1;s>=0;--s){const t=i[s];if(t[1]t[0]&&++e[0]}}),i.forEach(([t,s])=>{if(s>=e.length-1||t<0)return;const i=e[s],n=e[s+1],r=e[t];if(!r[0].ticksToEvent)return void console.warn("invalid front index:",t,s,r);const a=r[1]/r[0].ticksToEvent;n[1]+=i[1],n[0].ticksToEvent+=i[0].ticksToEvent,i[0].ticksToEvent=r[0].ticksToEvent-1,r[0].ticksToEvent=1,i[1]=i[0].ticksToEvent*a,r[1]=r[0].ticksToEvent*a,e.splice(s,1),e.splice(t,0,i)}),e})(x)));const S=x.map(e=>({data:e[0].event,track:e[0].track,deltaTime:e[1],deltaTicks:e[0].ticksToEvent}));let k=0;for(const e of S){if(p+=e.deltaTicks,g=Math.round(1*p),e.deltaTicks>0){const t=e.deltaTicks/v;for(let e=Math.ceil(u);es.channel==t.channel&&s.pitch==e);if(n>=0){const s=i.splice(n,1)[0];a[t.channel].push({channel:t.channel,startTick:s.startTick,endTick:g,pitch:e,start:s.start,duration:c-s.start,velocity:s.velocity,beats:s.beats,track:s.track,finger:s.finger})}else s&&s.debug&&s.debug("unexpected noteOff: ",c,t);d.high=Math.max(d.high||e,e)}break;case"controller":switch(t.controllerType){case 64:case 65:case 66:case 67:const e=Pt[t.controllerType];n[t.channel]=n[t.channel]||{},r[t.channel]=r[t.channel]||[];const s=n[t.channel][e];s&&r[t.channel].push({type:e,start:s.start,duration:c-s.start,value:s.value}),n[t.channel][e]={start:c,value:t.value}}}break;case"meta":switch(t.subtype){case"setTempo":l=t.microsecondsPerBeat/1e3,y.push({tempo:t.microsecondsPerBeat,tick:g,time:c});break;case"timeSignature":h=t.numerator,m=0;break;case"text":if(!f&&/^find-corres:/.test(t.text)){const e=t.text.match(/:([\d\,-]+)/);f=(e&&e[1]||"").split(",").map(e=>Number(e))}else if(/fingering\(.*\)/.test(t.text)){const[e,s]=t.text.match(/\((.+)\)/),n=Number(s);if(!Number.isNaN(n)){const e=i[i.length-1];e&&(e.finger=n);const t=S.find(e=>e.index==k-1);t&&(t.data.finger=n)}}break;case"copyrightNotice":s&&s.log&&s.log("MIDI copyright:",t.text)}}}return i.forEach(e=>{s&&s.debug&&s.debug("unclosed noteOn event at",e.startTick,e),a[e.channel]=a[e.channel]||[],a[e.channel].push({startTick:e.startTick,endTick:g,pitch:e.pitch,start:e.start,duration:c-e.start,velocity:e.velocity,beats:e.beats,track:e.track,finger:e.finger})}),new P({channels:a,keyRange:d,pedals:r,bars:o,endTime:c,endTick:g,correspondences:f,events:S,tempos:y,ticksPerBeat:v,meta:{},logger:s})}constructor(e){Object.assign(this,e),this.notes=[];for(const e of this.channels)if(e)for(const t of e)this.notes.push(t);this.notes.sort(function(e,t){return e.start-t.start});for(const e in this.notes)this.notes[e].index=Number(e);this.duration=this.notes.length>0?this.endTime-this.notes[0].start:0,this.pitchMap=[];for(const e in this.channels)for(const t in this.channels[e]){const s=this.channels[e][t].pitch;this.pitchMap[s]=this.pitchMap[s]||[],this.pitchMap[s].push(this.channels[e][t])}if(this.pitchMap.forEach(e=>e.sort((e,t)=>e.start-t.start)),this.meta.beatInfos)for(let e=0;e0){const s=this.meta.beatInfos[e-1];t.beatIndex=s.beatIndex+Math.ceil((t.tick-s.tick)/this.ticksPerBeat)}else t.beatIndex=0}{let e=0,t=0,s=5e5;for(const i of this.tempos){e+=s/1e3*(i.tick-t)/this.ticksPerBeat,t=i.tick,s=i.tempo,i.time=e}}}findChordBySoftindex(e,t=.8){return this.notes.filter(s=>Math.abs(s.softIndex-e)e.from,"range is invalid:",e);const t=t=>{const s=Math.max(e.from,this.tempos[t].tick),i=te+s.tempo*t(i),0)/(e.to-e.from))}ticksToTime(e){this.logger&&this.logger.assert(Number.isFinite(e),"invalid tick value:",e),this.logger&&this.logger.assert(!!this.tempos&&!!this.tempos.length,"no tempos.");const t=this.tempos.findIndex(t=>t.tick>e),s=t<0?this.tempos.length-1:Math.max(t-1,0),i=this.tempos[s];return i.time+(e-i.tick)*i.tempo*.001/this.ticksPerBeat}timeToTicks(e){this.logger&&this.logger.assert(Number.isFinite(e),"invalid time value:",e),this.logger&&this.logger.assert(!!this.tempos&&!!this.tempos.length,"no tempos.");const t=this.tempos.findIndex(t=>t.time>e),s=t<0?this.tempos.length-1:Math.max(t-1,0),i=this.tempos[s];return i.tick+(e-i.time)*this.ticksPerBeat/(.001*i.tempo)}tickRangeToTimeRange(e){return this.logger&&this.logger.assert(e.to>=e.from,"invalid tick range:",e),{from:this.ticksToTime(e.from),to:this.ticksToTime(e.to)}}scaleTempo({factor:e,headTempo:t}){this.logger&&this.logger.assert(!!this.tempos&&!!this.tempos.length,"[Notation.scaleTempo] tempos is empty."),t&&(e=t/this.tempos[0].tempo),this.logger&&this.logger.assert(Number.isFinite(e)&&e>0,"[Notation.scaleTempo] invalid factor:",e),this.tempos.forEach(t=>{t.tempo*=e,t.time*=e}),this.events.forEach(t=>{t.deltaTime*=e,t.time*=e}),this.notes.forEach(t=>{t.start*=e,t.duration*=e}),this.endTime*=e}}const Dt=Object.freeze(Object.defineProperty({__proto__:null,Notation:P},Symbol.toStringTag,{value:"Module"})),qt={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",decodeArrayBuffer:function(e){const t=Math.ceil(3*e.length/4),s=new ArrayBuffer(t);return this.decode(e,s),s},decode:function(e,t){const s=this._keyStr.indexOf(e.charAt(e.length-1)),i=this._keyStr.indexOf(e.charAt(e.length-1));let n=Math.ceil(3*e.length/4);64===s&&n--,64===i&&n--;let r,a,o,c,l,u,h,m,d=0,f=0;for(r=t?new Uint8Array(t):new Uint8Array(n),e=e.replace(/[^A-Za-z0-9+/=]/g,""),d=0;d>4,o=(15&u)<<4|h>>2,c=(3&h)<<6|m,r[d]=a,64!==h&&(r[d+1]=o),64!==m&&(r[d+2]=c);return r}},Lt=window.MIDI||{};window.MIDI=Lt;const $t=function(e){Lt.api=e.api,Lt.setVolume=e.setVolume,Lt.programChange=e.programChange,Lt.noteOn=e.noteOn,Lt.noteOff=e.noteOff,Lt.chordOn=e.chordOn,Lt.chordOff=e.chordOff,Lt.stopAllNotes=e.stopAllNotes,Lt.getInput=e.getInput,Lt.getOutputs=e.getOutputs};!function(){var e=null,t=null;const s=Lt.WebMIDI={api:"webmidi"};s.setVolume=function(e,s){t.send([176+e,7,s])},s.programChange=function(e,s){t.send([192+e,s])},s.noteOn=function(e,s,i,n){t.send([144+e,s,i],1e3*n)},s.noteOff=function(e,s,i){t.send([128+e,s,0],1e3*i)},s.chordOn=function(e,s,i,n){for(var r=0;rProcessing: "+(i/87*100|0)+"%
"+u),s.id=l,n[i]=s,n.length===t.length){for(;n.length;){if(!(s=n.pop()))continue;const e=Lt.keyToNote[s.id];a[c+""+e]=s}r(e)}})},c=e=>Math.max(.001*(e-performance.now())+s.currentTime,0);t.getContextState=function(){return s?s.state:null},t.needsWarmup=function(){return!!s&&"running"!==s.state},t.awaitWarmup=function(){return s&&"running"!==s.state&&"function"==typeof s.resume?(i||(i=Promise.resolve(s.resume()).catch(()=>null).then(()=>{i=null})),i):Promise.resolve()},t.setVolume=function(e,t){r=t},t.empty=function(){return!Object.keys(a).length},t.hasPending=function(){return!Object.keys(t.pendingInstruments).length},t.programChange=function(e,t){Lt.channels[e].instrument=t};t.noteOn=function(e,t,i,o=0){return function(e,t,i,o=0){if(!Lt.channels[e])return;const l=Lt.channels[e].instrument;if(!a[l+""+t])return;const u=c(o),h=s.createBufferSource();n[e+""+t]=h,h.buffer=a[l+""+t],h.connect(s.destination),s.createGain?h.gainNode=s.createGain():h.gainNode=s.createGainNode();const m=i/127*(r/127)*2-1;return h.gainNode.connect(s.destination),h.gainNode.gain.setTargetAtTime(Math.max(-1,m),s.currentTime,0),h.connect(h.gainNode),h.noteOn?h.noteOn(u):h.start(u),h}(e,t,i,o)},t.noteOff=function(e,t,s=0){return function(e,t,s=0){const i=c(s),r=n[e+""+t];if(r){if(r.gainNode){const e=r.gainNode.gain;e.linearRampToValueAtTime(e.value,i),e.linearRampToValueAtTime(-1,i+.2)}r.noteOff?r.noteOff(i+.3):r.stop(i+.3),delete n[e+""+t]}}(e,t,s)},t.chordOn=function(e,s,i,n){for(var r,a={},o=0,c=s.length;o"u"&&(s=[{src:e.src,verify:e.verify}]);const i=document.getElementsByTagName("head")[0],n=function(e,s){t.loaded[e.src]||s&&typeof window[s]>"u"||(t.loaded[e.src]=!0,t.loading[e.src]&&t.loading[e.src](),delete t.loading[e.src],e.callback&&e.callback(),typeof getNext<"u"&&getNext())},r=[],a=function(s){if("string"==typeof s&&(s={src:s,verify:e.verify}),/([\w\d.])$/.test(s.verify))if(s.test=s.verify,"object"==typeof s.test)for(const e in s.test)r.push(s.test[e]);else r.push(s.test);if(t.loaded[s.src])return;const a=document.createElement("script");a.onreadystatechange=function(){"loaded"!==this.readyState&&"complete"!==this.readyState||n(s)},a.onload=function(){n(s)},a.onerror=function(){},a.setAttribute("type","text/javascript"),a.setAttribute("src",s.src),i.appendChild(a),t.loading[s.src]=function(){}},o=function(t){if(t)n(t,t.test);else for(let e=0;e"u")continue;2===t.length?typeof e[t[1]]>"u"&&(i=!1):3===t.length&&typeof e[t[1]][t[2]]>"u"&&(i=!1)}else typeof window[t]>"u"&&(i=!1)}!e.strictOrder&&i?e.callback&&e.callback():setTimeout(function(){o(t)},10)};if(e.strictOrder){let i=-1;const n=function(){if(i++,s[i]){const e=s[i],r=e.src;t.loading[r]?t.loading[r]=function(){e.callback&&e.callback(),n()}:t.loaded[r]?n():(a(e),o(e))}else e.callback&&e.callback()};n()}else{for(let e=0;ee.text()).then(t=>{e.onload&&e.onload({responseText:t})}).catch(t=>{console.warn("DOMLoader.sendRequest error:",t),e.onerror&&e.onerror(t,!1)})}};Lt.Soundfont=window.MIDI&&window.MIDI.Soundfont||{},window.MIDI=Lt,Lt.audioDetect=function(e){if(typeof Audio>"u")return e({});const t=new Audio;if(typeof t.canPlayType>"u")return e(jt);let s=t.canPlayType('audio/ogg; codecs="vorbis"');s="probably"===s||"maybe"===s;let i=t.canPlayType("audio/mpeg");if(i="probably"===i||"maybe"===i,!s&&!i)return void e(jt);s&&Wt("audio/ogg;base64,T2dnUwACAAAAAAAAAADqnjMlAAAAAOyyzPIBHgF2b3JiaXMAAAAAAUAfAABAHwAAQB8AAEAfAACZAU9nZ1MAAAAAAAAAAAAA6p4zJQEAAAANJGeqCj3//////////5ADdm9yYmlzLQAAAFhpcGguT3JnIGxpYlZvcmJpcyBJIDIwMTAxMTAxIChTY2hhdWZlbnVnZ2V0KQAAAAABBXZvcmJpcw9CQ1YBAAABAAxSFCElGVNKYwiVUlIpBR1jUFtHHWPUOUYhZBBTiEkZpXtPKpVYSsgRUlgpRR1TTFNJlVKWKUUdYxRTSCFT1jFloXMUS4ZJCSVsTa50FkvomWOWMUYdY85aSp1j1jFFHWNSUkmhcxg6ZiVkFDpGxehifDA6laJCKL7H3lLpLYWKW4q91xpT6y2EGEtpwQhhc+211dxKasUYY4wxxsXiUyiC0JBVAAABAABABAFCQ1YBAAoAAMJQDEVRgNCQVQBABgCAABRFcRTHcRxHkiTLAkJDVgEAQAAAAgAAKI7hKJIjSZJkWZZlWZameZaouaov+64u667t6roOhIasBACAAAAYRqF1TCqDEEPKQ4QUY9AzoxBDDEzGHGNONKQMMogzxZAyiFssLqgQBKEhKwKAKAAAwBjEGGIMOeekZFIi55iUTkoDnaPUUcoolRRLjBmlEluJMYLOUeooZZRCjKXFjFKJscRUAABAgAMAQICFUGjIigAgCgCAMAYphZRCjCnmFHOIMeUcgwwxxiBkzinoGJNOSuWck85JiRhjzjEHlXNOSuekctBJyaQTAAAQ4AAAEGAhFBqyIgCIEwAwSJKmWZomipamiaJniqrqiaKqWp5nmp5pqqpnmqpqqqrrmqrqypbnmaZnmqrqmaaqiqbquqaquq6nqrZsuqoum65q267s+rZru77uqapsm6or66bqyrrqyrbuurbtS56nqqKquq5nqq6ruq5uq65r25pqyq6purJtuq4tu7Js664s67pmqq5suqotm64s667s2rYqy7ovuq5uq7Ks+6os+75s67ru2rrwi65r66os674qy74x27bwy7ouHJMnqqqnqq7rmarrqq5r26rr2rqmmq5suq4tm6or26os67Yry7aumaosm64r26bryrIqy77vyrJui67r66Ys67oqy8Lu6roxzLat+6Lr6roqy7qvyrKuu7ru+7JuC7umqrpuyrKvm7Ks+7auC8us27oxuq7vq7It/KosC7+u+8Iy6z5jdF1fV21ZGFbZ9n3d95Vj1nVhWW1b+V1bZ7y+bgy7bvzKrQvLstq2scy6rSyvrxvDLux8W/iVmqratum6um7Ksq/Lui60dd1XRtf1fdW2fV+VZd+3hV9pG8OwjK6r+6os68Jry8ov67qw7MIvLKttK7+r68ow27qw3L6wLL/uC8uq277v6rrStXVluX2fsSu38QsAABhwAAAIMKEMFBqyIgCIEwBAEHIOKQahYgpCCKGkEEIqFWNSMuakZM5JKaWUFEpJrWJMSuaclMwxKaGUlkopqYRSWiqlxBRKaS2l1mJKqcVQSmulpNZKSa2llGJMrcUYMSYlc05K5pyUklJrJZXWMucoZQ5K6iCklEoqraTUYuacpA46Kx2E1EoqMZWUYgupxFZKaq2kFGMrMdXUWo4hpRhLSrGVlFptMdXWWqs1YkxK5pyUzDkqJaXWSiqtZc5J6iC01DkoqaTUYiopxco5SR2ElDLIqJSUWiupxBJSia20FGMpqcXUYq4pxRZDSS2WlFosqcTWYoy1tVRTJ6XFklKMJZUYW6y5ttZqDKXEVkqLsaSUW2sx1xZjjqGkFksrsZWUWmy15dhayzW1VGNKrdYWY40x5ZRrrT2n1mJNMdXaWqy51ZZbzLXnTkprpZQWS0oxttZijTHmHEppraQUWykpxtZara3FXEMpsZXSWiypxNhirLXFVmNqrcYWW62ltVprrb3GVlsurdXcYqw9tZRrrLXmWFNtBQAADDgAAASYUAYKDVkJAEQBAADGMMYYhEYpx5yT0ijlnHNSKucghJBS5hyEEFLKnINQSkuZcxBKSSmUklJqrYVSUmqttQIAAAocAAACbNCUWByg0JCVAEAqAIDBcTRNFFXVdX1fsSxRVFXXlW3jVyxNFFVVdm1b+DVRVFXXtW3bFn5NFFVVdmXZtoWiqrqybduybgvDqKqua9uybeuorqvbuq3bui9UXVmWbVu3dR3XtnXd9nVd+Bmzbeu2buu+8CMMR9/4IeTj+3RCCAAAT3AAACqwYXWEk6KxwEJDVgIAGQAAgDFKGYUYM0gxphhjTDHGmAAAgAEHAIAAE8pAoSErAoAoAADAOeecc84555xzzjnnnHPOOeecc44xxhhjjDHGGGOMMcYYY4wxxhhjjDHGGGOMMcYYY0wAwE6EA8BOhIVQaMhKACAcAABACCEpKaWUUkoRU85BSSmllFKqFIOMSkoppZRSpBR1lFJKKaWUIqWgpJJSSimllElJKaWUUkoppYw6SimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaVUSimllFJKKaWUUkoppRQAYPLgAACVYOMMK0lnhaPBhYasBAByAwAAhRiDEEJpraRUUkolVc5BKCWUlEpKKZWUUqqYgxBKKqmlklJKKbXSQSihlFBKKSWUUkooJYQQSgmhlFRCK6mEUkoHoYQSQimhhFRKKSWUzkEoIYUOQkmllNRCSB10VFIpIZVSSiklpZQ6CKGUklJLLZVSWkqpdBJSKamV1FJqqbWSUgmhpFZKSSWl0lpJJbUSSkklpZRSSymFVFJJJYSSUioltZZaSqm11lJIqZWUUkqppdRSSiWlkEpKqZSSUmollZRSaiGVlEpJKaTUSimlpFRCSamlUlpKLbWUSkmptFRSSaWUlEpJKaVSSksppRJKSqmllFpJKYWSUkoplZJSSyW1VEoKJaWUUkmptJRSSymVklIBAEAHDgAAAUZUWoidZlx5BI4oZJiAAgAAQABAgAkgMEBQMApBgDACAQAAAADAAAAfAABHARAR0ZzBAUKCwgJDg8MDAAAAAAAAAAAAAACAT2dnUwAEAAAAAAAAAADqnjMlAgAAADzQPmcBAQA="),i&&Wt("audio/mpeg;base64,/+MYxAAAAANIAUAAAASEEB/jwOFM/0MM/90b/+RhST//w4NFwOjf///PZu////9lns5GFDv//l9GlUIEEIAAAgIg8Ir/JGq3/+MYxDsLIj5QMYcoAP0dv9HIjUcH//yYSg+CIbkGP//8w0bLVjUP///3Z0x5QCAv/yLjwtGKTEFNRTMuOTeqqqqqqqqqqqqq/+MYxEkNmdJkUYc4AKqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq");const n=(new Date).getTime(),r=window.setInterval(function(){const t=(new Date).getTime()-n>5e3;(!Ht||t)&&(window.clearInterval(r),e(jt))},1)};const Ut={};Lt.loadPlugin=function(e={}){"function"==typeof e&&(e={callback:e});var t=e.instruments||e.instrument||"acoustic_grand_piano";"object"!=typeof t&&(t=[t]);for(var s=0;se.callback=t)},Ut.webmidi=function(e,t,s){Lt.loader&&Lt.loader.message("Web MIDI API..."),Lt.WebMIDI.connect(s)},Ut.flash=function(e,t,s){Lt.loader&&Lt.loader.message("Flash API..."),Gt.script.add({src:s.soundManagerUrl||"./inc/SoundManager2/script/soundmanager2.js",verify:"SoundManager",callback:function(){Lt.Flash.connect(t,s)}})},Ut.audiotag=function(e,t,s){Lt.loader&&Lt.loader.message("HTML5 Audio API...");const i=Zt({items:t,getNext(t){Lt.Soundfont[t]?i.getNext():Gt.sendRequest({url:Lt.soundfontUrl+t+"-"+e+".js",onprogress:Yt,onload(e){Kt(e.responseText),Lt.loader&&Lt.loader.update(null,"Downloading",100),i.getNext()}})},onComplete(){Lt.AudioTag.connect(s)}})},Ut.webaudio=function(e,t,s){Lt.loader&&Lt.loader.message("Web Audio API...");const i=Zt({items:t,getNext(s){Lt.Soundfont[s]?i.getNext():(Lt.WebAudio.pendingInstruments[t]=!0,Gt.sendRequest({url:Lt.soundfontUrl+s+"-"+e+".js",onprogress:Yt,onload(e){Kt(e.responseText),Lt.loader&&Lt.loader.update(null,"Downloading...",100),i.getNext(),delete Lt.WebAudio.pendingInstruments[t]},onerror(e){Lt.loader&&Lt.loader.update(e,"Download failed."),delete Lt.WebAudio.pendingInstruments[t]}}))},onComplete(){Lt.WebAudio.connect(s)}})};const zt={webmidi:!0,webaudio:!0,audiotag:!0,flash:!0},Kt=function(e){var t=document.createElement("script");t.language="javascript",t.type="text/javascript",t.text=e,document.body.appendChild(t)},Yt=function(e){this.totalSize||(this.getResponseHeader("Content-Length-Raw")?this.totalSize=parseInt(this.getResponseHeader("Content-Length-Raw")):this.totalSize=e.total);const t=this.totalSize?Math.round(e.loaded/this.totalSize*100):"";Lt.loader&&Lt.loader.update(null,"Downloading...",t)},Zt=function(e){const t={queue:[]};for(const s in e.items)e.items.hasOwnProperty(s)&&t.queue.push(e.items[s]);return t.getNext=function(){if(!t.queue.length)return e.onComplete();e.getNext(t.queue.shift())},setTimeout(t.getNext,1),t};Lt.loadPlugin;const Jt=["id","ids","pitch","velocity","track","channel","rest","tied","overlapped","implicitType","afterGrace","contextIndex","staffTrack","chordPosition","division"];class MetaNotation{static fromAbsoluteNotes(e,t,s){const i=new MetaNotation(s);return i.measures=Array(t.length).fill(null).map((s,i)=>{const n=t[i],r=t[i+1]?t[i+1]-n:0,a=e.filter(e=>e.measure===i+1).map(e=>({tick:e.startTick-n,duration:e.endTick-e.startTick,...f.default(e,Jt),subNotes:[]}));return a.forEach(e=>["rest","tied","implicitType","afterGrace"].forEach(t=>{e[t]||delete e[t]})),{tick:n,duration:r,notes:a}}),i.idTrackMap=e.reduce((e,t)=>(t.id&&(e[t.id]=t.track),e),{}),i}static performAbsoluteNotes(e,{withRestTied:t=!1}={}){const s=e.filter(e=>(t||!e.rest&&!e.tied)&&!e.overlapped).map(e=>({measure:e.measure,channel:e.channel,track:e.track,start:e.start,startTick:e.startTick,endTick:e.endTick,pitch:e.pitch,duration:e.duration,velocity:e.velocity||127,id:e.id,ids:e.ids,staffTrack:e.staffTrack,contextIndex:e.contextIndex,implicitType:e.implicitType,chordPosition:e.chordPosition})).reduce((e,t)=>{const s=`${t.channel}|${t.start}|${t.pitch}`,i=e[s];return i?i.ids.push(...t.ids):e[s]=t,e},{});return Object.values(s)}constructor(e){this.ripe=!1,e&&Object.assign(this,e)}get trackTickBias(){const e=this.measures[0];return this.trackNames.reduce((t,s,i)=>{if(t[s]=0,e){const n=e.notes.find(e=>e.track===i);n&&(t[s]=Math.min(n.tick,0))}return t},{})}get idSet(){return this.measures.reduce((e,t)=>(t.notes.filter(e=>!e.rest).forEach(t=>t.ids.forEach(t=>e.add(t))),e),new Set)}toJSON(){return{__prototype:"LilyNotation",measures:this.measures,idTrackMap:this.idTrackMap,trackNames:this.trackNames,ripe:this.ripe}}toAbsoluteNotes(e){let t=0;const s=e.map(e=>{const s=this.measures[e-1];console.assert(!!s,"invalid measure index:",e,this.measures.length);const i=s.notes.map(s=>({startTick:t+s.tick,endTick:t+s.tick+s.duration,start:t+s.tick,duration:s.duration,measure:e,...f.default(s,Jt)}));return t+=s.duration,i});return[].concat(...s)}toPerformingNotation(e,t={}){const s=this.toAbsoluteNotes(e),i=MetaNotation.performAbsoluteNotes(s,t),n=Math.max(...i.map(e=>e.start+e.duration)),r=e.reduce((e,t)=>e+this.measures[t-1].duration,0);return new Dt.Notation({ticksPerBeat:480,meta:{},tempos:[],channels:[i],endTime:n,endTick:r})}toPerformingMIDI(e,{trackList:t}={}){if(!e.length)return null;const s=-Math.min(0,...this.measures[0]?.events.map(e=>e.ticks)||[],...this.measures[0]?.notes.map(e=>e.tick)||[]);let i=s;const n=e.map(e=>{const t=this.measures[e-1];console.assert(!!t,"invalid measure index:",e,this.measures.length);const s=t.events.map(t=>({ticks:i+t.ticks,track:t.track,data:{...t.data,measure:e}}));return i+=t.duration,s}),r=e=>e.ticks+("noteOff"===e.subtype?-1e-8:0),a=[].concat(...n).reduce((e,t)=>(e[t.track]=e[t.track]||[],e[t.track].push({ticks:t.ticks,...t.data}),e),[]);a[0]=a[0]||[],i=s,e.map(e=>{const s=this.measures[e-1];console.assert(!!s,"invalid measure index:",e,this.measures.length),Number.isFinite(s.duration)&&(s.notes.forEach(s=>{if(t&&!t[s.track])return;if(s.rest)return;const n=i+s.tick,r=a[s.track]=a[s.track]||[];s.subNotes.forEach(t=>{r.push({ticks:n+t.startTick,measure:e,ids:s.ids,type:"channel",subtype:"noteOn",channel:s.channel,noteNumber:t.pitch,velocity:t.velocity,staffTrack:s.staffTrack,staff:s.staff}),r.push({ticks:n+t.endTick,measure:e,ids:s.ids,type:"channel",subtype:"noteOff",channel:s.channel,noteNumber:t.pitch,velocity:0,staffTrack:s.staffTrack,staff:s.staff})})}),i+=s.duration)});const o=i;for(let e=0;e{e.sort((e,t)=>r(e)-r(t));let t=0;e.forEach(e=>{e.deltaTime=e.ticks-t,Number.isFinite(e.deltaTime)?t=e.ticks:e.deltaTime=0}),e.push({deltaTime:Math.max(o-t,0),type:"meta",subtype:"endOfTrack"})}),{header:{formatType:0,ticksPerBeat:480},tracks:a,zeroTick:s}}toPerformingNotationWithEvents(e,t={}){if(!e.length)return null;const{zeroTick:s,...i}=this.toPerformingMIDI(e,t),n=Dt.Notation.parseMidi(i);Xt(n);let r=s;return n.measures=e.map(e=>{const t=r;return r+=this.measures[e-1].duration,{index:e,startTick:t,endTick:r}}),n}setTempo(e){let t=!1;for(const s of this.measures)for(const i of s.events)"setTempo"===i.data.subtype&&(i.data.microsecondsPerBeat=6e7/e,t=!0);return t}}const Xt=(e,t=["ids","measure","staffTrack"])=>{const s=(e,t,s)=>`${e}|${t}|${s}`,i=e.notes.reduce((e,t)=>(e[s(t.channel,t.pitch,t.startTick)]=t,e),{});e.events.forEach(e=>{if("noteOn"===e.data.subtype){const n=s(e.data.channel,e.data.noteNumber,e.ticks),r=i[n];console.assert(!!r,"cannot find note of",n),r&&Object.assign(r,f.default(e.data,t))}})};var Qt,es={exports:{}},ts={exports:{}};ts.exports=(Qt=Qt||function(e,t){var s;if("undefined"!=typeof window&&window.crypto&&(s=window.crypto),"undefined"!=typeof self&&self.crypto&&(s=self.crypto),"undefined"!=typeof globalThis&&globalThis.crypto&&(s=globalThis.crypto),!s&&"undefined"!=typeof window&&window.msCrypto&&(s=window.msCrypto),!s&&"undefined"!=typeof global&&global.crypto&&(s=global.crypto),!s)try{s=require("crypto")}catch(e){}var i=function(){if(s){if("function"==typeof s.getRandomValues)try{return s.getRandomValues(new Uint32Array(1))[0]}catch(e){}if("function"==typeof s.randomBytes)try{return s.randomBytes(4).readInt32LE()}catch(e){}}throw new Error("Native crypto module could not be used to get secure random number.")},n=Object.create||function(){function e(){}return function(t){var s;return e.prototype=t,s=new e,e.prototype=null,s}}(),r={},a=r.lib={},o=a.Base={extend:function(e){var t=n(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},c=a.WordArray=o.extend({init:function(e,s){e=this.words=e||[],this.sigBytes=s!=t?s:4*e.length},toString:function(e){return(e||u).stringify(this)},concat:function(e){var t=this.words,s=e.words,i=this.sigBytes,n=e.sigBytes;if(this.clamp(),i%4)for(var r=0;r>>2]>>>24-r%4*8&255;t[i+r>>>2]|=a<<24-(i+r)%4*8}else for(var o=0;o>>2]=s[o>>>2];return this.sigBytes+=n,this},clamp:function(){var t=this.words,s=this.sigBytes;t[s>>>2]&=4294967295<<32-s%4*8,t.length=e.ceil(s/4)},clone:function(){var e=o.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var t=[],s=0;s>>2]>>>24-n%4*8&255;i.push((r>>>4).toString(16)),i.push((15&r).toString(16))}return i.join("")},parse:function(e){for(var t=e.length,s=[],i=0;i>>3]|=parseInt(e.substr(i,2),16)<<24-i%8*4;return new c.init(s,t/2)}},h=l.Latin1={stringify:function(e){for(var t=e.words,s=e.sigBytes,i=[],n=0;n>>2]>>>24-n%4*8&255;i.push(String.fromCharCode(r))}return i.join("")},parse:function(e){for(var t=e.length,s=[],i=0;i>>2]|=(255&e.charCodeAt(i))<<24-i%4*8;return new c.init(s,t)}},m=l.Utf8={stringify:function(e){try{return decodeURIComponent(escape(h.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return h.parse(unescape(encodeURIComponent(e)))}},d=a.BufferedBlockAlgorithm=o.extend({reset:function(){this._data=new c.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=m.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var s,i=this._data,n=i.words,r=i.sigBytes,a=this.blockSize,o=r/(4*a),l=(o=t?e.ceil(o):e.max((0|o)-this._minBufferSize,0))*a,u=e.min(4*l,r);if(l){for(var h=0;h>>7)^(f<<14|f>>>18)^f>>>3,g=l[d-2],y=(g<<15|g>>>17)^(g<<13|g>>>19)^g>>>10;l[d]=p+l[d-7]+y+l[d-16]}var v=i&n^i&r^n&r,x=(i<<30|i>>>2)^(i<<19|i>>>13)^(i<<10|i>>>22),S=m+((o<<26|o>>>6)^(o<<21|o>>>11)^(o<<7|o>>>25))+(o&u^~o&h)+c[d]+l[d];m=h,h=u,u=o,o=a+S|0,a=r,r=n,n=i,i=S+(x+v)|0}s[0]=s[0]+i|0,s[1]=s[1]+n|0,s[2]=s[2]+r|0,s[3]=s[3]+a|0,s[4]=s[4]+o|0,s[5]=s[5]+u|0,s[6]=s[6]+h|0,s[7]=s[7]+m|0},_doFinalize:function(){var e=this._data,s=e.words,i=8*this._nDataBytes,n=8*e.sigBytes;return s[n>>>5]|=128<<24-n%32,s[14+(n+64>>>9<<4)]=t.floor(i/4294967296),s[15+(n+64>>>9<<4)]=i,e.sigBytes=4*s.length,this._process(),this._hash},clone:function(){var e=r.clone.call(this);return e._hash=this._hash.clone(),e}});s.SHA256=r._createHelper(u),s.HmacSHA256=r._createHmacHelper(u)}(Math),e.SHA256}(ts.exports);var ss=es.exports;class HashVector{static fromHash(e){const t=[];for(const s of e)for(let e=0;e<8;++e)t.push(s>>e&1?1:-1);return new HashVector(t)}static fromString(e){const t=(e=>{const{words:t,sigBytes:s}=ss(e),i=t.map(e=>e<0?e+4294967296:e),n=s/t.length;return new Uint8Array(s).map((e,t)=>i[Math.floor(t/n)]>>8*(3-t%n)&255)})(e);return HashVector.fromHash(t)}static fromWords(e){return e.map(e=>HashVector.fromString(e)).reduce((e,t)=>e.add(t),HashVector.zero)}static concat(...e){const t=e.map(e=>e.fields).flat(1);return new HashVector(t)}constructor(e=null){this.fields=e||Array(256).fill(0)}get length(){return this.fields.length}toHash(){return Uint8Array.from(Array(this.length/8).fill(0).map((e,t)=>this.fields.slice(8*t,8*(t+1)).reduce((e,t,s)=>e|(t>0?1:0)<this.fields[s]=t+e.fields[s]),this}scale(e){return this.fields=this.fields.map(t=>t*e),this}sub(e){const t=e>0?this.fields.slice(0,e):this.fields.slice(e);return new HashVector(t)}static get zero(){return new HashVector}}const is=Array(256).fill(0).map((e,t)=>(e=>{let t=0;for(let s=e;s>0;s>>=1)s%2&&++t;return t})(t));is.reduce((e,t,s)=>({...e,[("0"+s.toString(16)).slice(-2)]:t}),{});const ns=(e,t)=>{const s=8*e.length,i=((e,t)=>e.map((e,s)=>e^t[s]))(e,t);return(s-2*i.reduce((e,t)=>e+is[t],0))/s},rs=e=>("0"+e.toString(16)).slice(-2),as=(e,t=!1)=>({empty:!0,duration:e.duration,tickMap:{0:EventTerm.space({duration:e.duration,tick:0})},timeSignature:e.timeSignature,timeSigNumeric:e.timeSigNumeric,keySignature:e.keySignature,contextedTerms:e.terms.filter(e=>e instanceof ContextedTerm&&(!e.staffLevel||t)),marks:[]}),os=e=>{const t=[].concat(...e.measures.map(e=>Object.values(e.tickMap).filter(e=>e instanceof EventTerm)));for(let e=1;ee.type===Z.SlurBegin)&&i.accessories.some(e=>e.type===Z.SlurEnd)){const e=s.pitches.filter(e=>i.pitches.some(t=>t.note===e.note&&t.alter===e.alter));e.length>0&&(s.tying=!0,i.tied=!0,e.forEach(e=>{e.tying=!0;i.pitches.find(t=>t.note===e.note&&t.alter===e.alter).tied=!0}),e.forEach(()=>{const e=s.accessories.findIndex(e=>e.type===Z.SlurBegin);e>=0&&s.accessories.splice(e,1);const t=i.accessories.findIndex(e=>e.type===Z.SlurEnd);t>=0&&i.accessories.splice(t,1)}))}}};class Spartito extends SimpleClass{constructor(e){super(),super.assign(e),this.measures.forEach(e=>e.staffGroups=this.staffGroups)}get regulated(){return this.measures.every(e=>e.regulated)}get solidMeasureCount(){return this.measures.filter(e=>!e.empty).length}get measureIndexMapping(){let e=0;return this.measures.map(t=>t.empty?null:e++)}get headBPM(){for(const e of this.measures)if(e.marks){const t=e.marks.find(e=>e instanceof TempoTerm&&e.isValid());if(t)return t.bpm}return null}get measureLayoutCode(){const e=this.measures.filter(e=>!e.empty).map((e,t)=>({index:t+1,vb:e.voltaBegin,ve:e.voltaEnd,alter:e.alternative,leftSign:"",rightSign:""}));return e.forEach((t,s)=>{if(t.vb){const i=e.slice(s+1).findIndex(e=>e.vb),n=i>=0?s+i:e.length;e.slice(s,n-1).some(e=>e.ve)&&(t.leftSign="2*[")}if(t.ve){const i=e.slice(0,s+1).reverse(),n=i.slice(1).findIndex(e=>e.ve);if(n>=0&&!i.slice(1,n+1).some(e=>e.vb))return;if(t.alter){const n=i.findIndex(e=>!e.alter);n>0&&(i[n].rightSign="]",i[n-1].leftSign="{[",t.rightSign="],",e[s+1]&&(e[s+1].rightSign="},"))}else t.rightSign="],";i.some(e=>e.vb)||(e[0].leftSign="2*[")}}),e.map(e=>e.leftSign+e.index.toString()+e.rightSign+(e.rightSign?"":",")).join(" ").replace(/,$/,"")}get qualityScore(){const e=this.measures.filter(e=>!e.empty),t=e.map(qe).map(e=>e.qualityScore).reduce((e,t)=>e+t,0);return e.length?t/e.length:null}dumpEvaluations(){const e=this.measures.filter(e=>!e.empty).map(e=>({measureIndex:e.measureIndex,...qe(e)})),t=e.map(e=>e.qualityScore).reduce((e,t)=>e+t,0);console.log("qualityScore:",t/e.length),console.table(e)}regulate(e={}){this.measures.forEach(t=>t.regulated||t.regulate(e))}cleanupRegulation(){this.measures.forEach(e=>e.voices=null)}rectifyTimeSignatures(e=new DummyLogger){const t=this.measures.map((e,t)=>({measure:e,index:t})).filter(({measure:e,index:t})=>!t||e.timeSignatureChanged).map(({index:e})=>e);t.map((e,s)=>this.measures.slice(e,se.filter(e=>e.estimatedDuration>0)).filter(e=>e.length>=3||e.some(e=>e.doubtfulTimesig)).forEach(t=>{if(t[0].patched){const s=t[0].timeSignature,i=t.slice(1).filter(e=>!e.patched&&q(e.timeSignature)!==q(s));if(i.length){const t=i[0].timeSignature;i.forEach(e=>e.basics.forEach(e=>e.timeSignature=s)),e.info("[rectifyTimeSignatures]\ttimesignator overwrote by patched head:",`${q(t)} -> ${q(s)}`,i.map(e=>e.measureIndex))}return}const s=t[0].timeSignature,i=Number.isInteger(Math.log2(s.denominator));let n=i?4:8;i&&(n=Math.max(n,t[0].timeSignature.denominator));const r=t.map(e=>Math.round(e.estimatedDuration*n/we)),a=Object.entries(r.reduce((e,t)=>(e[t]=(e[t]||0)+1,e),{})).sort((e,t)=>t[1]-e[1]),o=a[0][1],c=a.filter(([e,t])=>t>.6*o).reduce((e,t)=>Number(t[0])>Number(e[0])?t:e);if(c[1]>1){let r=Number(c[0]);if(!i||s.denominator*r!==s.numerator*n){if(i&&n!==s.denominator){const e=r*s.denominator/n;Number.isInteger(e)&&(r=e,n=s.denominator)}const a=t.filter(e=>!e.patched),o=F(r,n);a.forEach(e=>e.basics.forEach(e=>e.timeSignature=o)),e.info("[rectifyTimeSignatures]\ttimesignator overwrote by estimation:",`${q(s)} -> ${r}/${n}`,a.map(e=>e.measureIndex))}}})}makeVoiceStaves(){this.regulate();const e=Math.max(...this.measures.map(e=>e.voices.length?e.voices.length:e.events?.some(e=>e?.grace)?1:0));if(!e||!Number.isFinite(e))return null;this.measures.filter(e=>e.patched).forEach(e=>{e.events.forEach(e=>{e.tied&&e.pitches.forEach(e=>e.tied=!0)})});for(let e=0;et.staff===e)||[]).reduce((e,t)=>Math.max(e,t.x||0),-1/0);if(!Number.isFinite(n))continue;const r=[];t.contexts[e]=i.filter(e=>!(0===e.type&&e.x>n)||(r.push(e),!1)),r.length>0&&s.contexts[e]&&(r.forEach(e=>e.tick=0),s.contexts[e]=[...r,...s.contexts[e]])}}const t=this.measures.map(t=>{console.assert(t.validRegulated,"[makeVoiceStaves] measure is invalid:",t);const s={};t.events.forEach(e=>s[e.id]=e);const i=new Set(Array(t.contexts.length).fill(null).map((e,t)=>t));let n=null;if(t.barType)switch(t.barType){case"Segment":n="||";break;case"Terminal":n="|."}const r=(t.voices.length?t.voices:t.events?.some(e=>e?.grace)?[t.events.filter(e=>e?.grace).map(e=>e.id)]:[]).map(e=>{const r=e.map(e=>s[e]);r.sort((e,t)=>e.tick-t.tick);const a={},o=e=>{let t=`t${e.tick}`,s=1;for(;a[t];)t=`t${e.tick}:${s++}`;a[t]=e},c=r.find(e=>e&&!e.zeroHolder&&!e.grace),l=r.filter(e=>e?.grace&&(!c||e.xe.id);if(l.length&&(!c||0!==c.tick)){const e=EventTerm.space({tick:0,duration:0});e.staff=r.find(e=>e?.grace&&0===e.tick)?.staff??0,e.graceIds=l,e.placeholder=!0,o(e),l.forEach(e=>{const s=t.eventMap[e];s&&o(s)})}let u=0,h=null;for(const e of r)Number.isFinite(e?.tick)?l.includes(e.id)||(e.tick>u?o(EventTerm.space({tick:u,duration:e.tick-u})):!e.grace&&e.tick{const s=t.eventMap[e];s&&o(s)}))):console.warn("invalid event tick:",e);t.endEvent&&t.endEvent.graceIds&&t.endEvent.graceIds.forEach(e=>{const s=t.eventMap[e];!s||h&&s.staff!==h.staff||o(s)}),h&&ut.duration&&Number.isFinite(t.duration)&&(h.timeWarp=D(t.duration-h.tick,h.duration)),console.assert(!h||!h.timeWarp||Number.isInteger(h.timeWarp.numerator)&&Number.isInteger(h.timeWarp.denominator),"invalid time warp:",h);const m=r[0]?r[0].staff:0;i.delete(m);const d=t.basics[m],f=t.contexts[m],p=r[r.length-1],g=p?p.staff:0;return{tickMap:a,duration:t.duration,...d,contextedTerms:f,marks:[],break:t.break,pageBreak:t.pageBreak,headStaff:m,tailStaff:g,bar:n}});for(;r.lengtht.headStaff!==e),o=as({terms:n,duration:t.duration,...s,break:t.break,pageBreak:t.pageBreak},a);o.headStaff=e,o.tailStaff=e,r.push(o)}return t.marks?.length&&(r[0].marks=t.marks),r});t.forEach(e=>e.forEach(e=>{const t=[];e.empty||(t.push(`s${e.headStaff}`),t.push(`s${e.tailStaff}`)),Object.values(e.tickMap).forEach(e=>{if(e instanceof EventTerm){if(t.push(`s${e.staff}`),e.stemDirection){const s=`st${e.staff}-${e.stemDirection}`;t.push(s,s)}e.grace?t.push(`gd${e.mainDuration}`):t.push(`d${e.mainDuration}`),e.rest?t.push("r-"+e.rest):e.pitches.forEach(e=>{t.push(`p1-${e.note}`),t.push(`p8-${Math.round(e.note/8)}`)})}}),e.trait=HashVector.fromWords(t)}));const s=this.staffGroups.flat(1).reduce((e,t)=>(e[t]=this.staffGroups.findIndex(e=>e.includes(t)),e),{}),i=Array(e).fill(null).map((e,t)=>({vector:HashVector.zero,index:t,weight:0,headStaff:null}));t.forEach((e,t)=>{i.sort((e,t)=>t.weight-e.weight);const n=new Set(e);i.forEach(e=>{const i=[...n];let r=i[0];if(t>0&&i.length>1){const t=i.map(t=>s[t.headStaff]===s[e.headStaff]?ns(e.vector.toHash(),t.trait.toHash()):-1);r=i[G(t)]}n.delete(r),r.voiceIndex=e.index,e.vector.scale(.4).add(r.trait),e.weight=Object.keys(r.tickMap).length,0===t&&(e.headStaff=r.headStaff)}),e.sort((e,t)=>e.voiceIndex-t.voiceIndex)});const n=Array(this.stavesCount).fill(null).map(()=>[]);i.forEach(e=>{n[e.headStaff].push(e.index)});const r=Array(this.stavesCount).fill(null).map((e,s)=>{if(!t[0])return{voices:[]};return{voices:n[s].map(e=>({mode:"relative",measures:t.map(t=>t[e])}))}}),a=this.measures.find(e=>!e.empty)?.position?.systemIndex,o=Number.isFinite(a)?this.measures.findIndex(e=>!e.empty&&e.position?.systemIndex!==a):0;return(e=>{if(!e[0]||!e[0].voices[0])return void console.warn("empty voices:",e);const t=e[0].voices[0].measures.length;Array(t).fill(null).map((t,s)=>{for(const t of e)for(const e of t.voices)if(!e.measures[s].empty)return!1;return!0}).forEach((t,s)=>{t&&e.forEach(e=>e.voices.forEach(e=>{e.measures[s].tickMap={}}))})})(r),((e,t)=>{const s=e[0]?.voices[0]?.measures[0];if(s&&!(t<=0))for(const i of e)for(const e of i.voices)for(const i of e.measures.slice(0,t)){const e=i?.marks?.findIndex(e=>e instanceof TempoTerm);if(e>=0){const[t]=i.marks.splice(e,1);return t.tick=0,void(s.marks=[t,...s.marks.filter(e=>!(e instanceof TempoTerm))])}}})(r,o<0?this.measures.length:o),(e=>{const t=Array(e.length).fill(0),s=Math.max(0,...e.flatMap(e=>e.voices.map(e=>e.measures.length)));for(let i=0;ie.measures[i]).filter(Boolean);if(!n.length)continue;let r=t[s];for(const e of n)e.contextedTerms=e.contextedTerms.filter(e=>{if(!(e instanceof ContextedTerm)||e.type!==Oe.OctaveShift)return!0;const t=e.octaveShift;return!(e.tokenType===Z.OctaveShift0&&!e.id&&0===e.x&&0===r||(r=t,0))});t[s]=r}})(r),r.forEach(e=>e.voices.forEach(os)),r}perform(){const e=this.makeVoiceStaves();if(!e)return null;const t=new Map,s=Array(this.stavesCount).fill(null).reduce((e,t,s)=>(e[s]=s,e),{}),i=[].concat(...e.map((e,t)=>e.voices.map(()=>s[t])));let n=!1,r=0,a=null;const o=this.measures.filter(e=>!e.empty).map(s=>{const{systemIndex:o,right:c}=s.position,l=s.measureIndex,u=[].concat(...e.map(e=>e.voices.map(e=>e.measures[l]))),h=u[0],m=r;r+=h.duration;const d=[].concat(...u.map((e,s)=>{const n=i[s],r=Object.values(e.tickMap).filter(e=>e instanceof EventTerm&&!e.rest).map(e=>{const s=Math.round(1*e.duration);console.assert(Number.isFinite(e.tick),"invalid event term tick:",e),console.assert(Number.isFinite(s),"invalid event term duration:",e),e.tick>=0&&e.noteIds.forEach(s=>{t.set(s,{system:o,measure:l,x:e.roundX,endX:c})});const i=this.staffGroups.findIndex(t=>t.includes(e.staff));return{tick:Math.round(1*e.tick),duration:s,pitches:e.pitches,noteIds:e.noteIds,part:i,staff:e.staff}});return[].concat(...r.map(e=>{const t=e.pitches.reduce((e,t)=>(e[V(t)]=t,e),{});return Object.values(t).sort((e,t)=>e.note-t.note).filter(e=>!e.tied).map((t,s)=>{const i=V(t),r=e.noteIds&&e.noteIds[s];return{tick:e.tick,pitch:i,duration:e.duration,chordPosition:{index:s,count:e.pitches.length},tied:t.tied,id:r,ids:[r],track:e.part,staff:e.staff,channel:n,subNotes:[{startTick:0,endTick:e.duration,pitch:i,velocity:127}]}})}))})),f=[];a=a||f,s.marks&&s.marks.forEach(e=>{if(e instanceof TempoTerm){const t=e.bpm;if(e.isValid()){const s=n?f:a,i=n?e.tick:0;s.push({track:0,ticks:i,data:{type:"meta",subtype:"setTempo",microsecondsPerBeat:Math.round(6e7/t)}}),n=!0}}});const p=s.basics[0];return{tick:m,duration:s.duration,notes:d,events:f,timeSignature:p&&p.timeSignature,keySignature:p&&p.keySignature}});n||o[0].events.push({track:0,ticks:0,data:{type:"meta",subtype:"setTempo",microsecondsPerBeat:5e5}});return{notation:new MetaNotation({measures:o}),tokenMap:t}}performByEstimation(){const e=new Map;let t=0;const s=this.measures.filter(e=>e.events.some(e=>e.predisposition)).map(s=>{const i=t,n=Math.round(s.estimatedDuration||L(we,s.timeSignature)),r=s.basics[0];t+=n;const{systemIndex:a,right:o}=s.position,c=s.measureIndex;return{tick:i,duration:n,notes:s.events.filter(e=>e.predisposition&&e.predisposition.fake<.5&&!e.rest).map(t=>{const s=Math.round(t.predisposition.tick);return t.noteIds.forEach(s=>{e.set(s,{system:a,measure:c,x:t.roundX,endX:o})}),t.pitches.map((e,i)=>{const n=V(e),r=t.noteIds&&t.noteIds[i],a=this.staffGroups.findIndex(e=>e.includes(t.staff));return{tick:s,pitch:n,duration:t.duration,chordPosition:{index:i,count:t.pitches.length},tied:e.tied,id:r,ids:[r],track:a,staff:t.staff,channel:0,subNotes:[{startTick:0,endTick:t.duration,pitch:n,velocity:127}]}})}).flat(1),events:[],timeSignature:r&&r.timeSignature,keySignature:r&&r.keySignature}});return{notation:new MetaNotation({measures:s}),tokenMap:e}}featureHash(){const e=this.measures.slice(0,16).map(e=>e.featureWords),t=[1,4,16].map(t=>{const s=e.slice(0,t).filter(Boolean),i=s.map(e=>e[0]).flat(1),n=s.map(e=>e[1]).flat(1),r=s.map(e=>e[2]).flat(1),[a,o,c]=[i,n,r].map(HashVector.fromWords);return HashVector.concat(a,o.sub(128),c.sub(128))});return HashVector.concat(...t).toHash()}featureHashHex(){return e=this.featureHash(),Array.from(e).map(rs).join("");var e}featureHashBigInt(){return e=this.featureHash(),Array.from(e).reduce((e,t)=>0x100n*e+BigInt(t),0n);var e}assignMeasureNumbers(){let e=null;for(const t of this.measures)(t.discard||t.events.length)&&(t.indent&&(e=null),Number.isFinite(e)||(e=t.partialDuration?0:1),t.measureNumber=e++)}}Spartito.className="Spartito";const cs=[0,2,4,5,7,9,11],ls=e=>{let t=e%7;for(;t<0;)t+=7;return t},us=e=>{let t=e%12;for(;t<0;)t+=12;return t},hs={[-2]:"♭♭",[-1]:"♭",0:"♮",1:"♯",2:"𝄪"};class StaffContext{constructor(){this.logger=new DummyLogger,this.clef=-3,this.keyAlters=[],this.octaveShift=0,this.alters=[],this.timeSignature={numerator:4,denominator:4},this.timeSigNumeric=!1,this.timeSigNumSet=!1,this.timeSigDenSet=!1,this.doubtingTimesig=!0}change(e){switch(e.type){case Oe.Clef:this.clef=e.clef;break;case Oe.KeyAcc:this.keyAlters[ls(this.yToNote(e.y))]=e.alter;break;case Oe.Acc:this.alters[this.yToNote(e.y)]=e.alter;break;case Oe.OctaveShift:this.octaveShift=e.octaveShift;break;case Oe.TimeSignatureC:switch(this.timeSigNumeric=!1,e.tokenType){case"timesig-C44":this.timeSignature.numerator=4,this.timeSignature.denominator=4;break;case"timesig-C22":this.timeSignature.numerator=2,this.timeSignature.denominator=2}this.doubtingTimesig=this.partialTimeSignature;break;case Oe.TimeSignatureN:switch(this.timeSigNumeric=!0,e.y){case 1:this.timeSigDenSet?this.timeSignature.denominator=10*this.timeSignature.denominator+e.number:this.timeSignature.denominator=e.number,this.timeSigDenSet=!0;break;case-1:this.timeSigNumSet?this.timeSignature.numerator=10*this.timeSignature.numerator+e.number:this.timeSignature.numerator=e.number,this.timeSigNumSet=!0;break;default:this.logger.warn("unexpected time signature Y:",e.y)}this.doubtingTimesig=this.partialTimeSignature}}resetMeasure(){this.alters=[],this.timeSigNumSet=!1,this.timeSigDenSet=!1}resetSystem(){this.keyAlters=[]}get keySignature(){return this.keyAlters.filter(e=>Number.isInteger(e)).reduce((e,t)=>e+t,0)}get partialTimeSignature(){return!this.timeSigNumSet!=!this.timeSigDenSet}noteToY(e){return-e/2-this.clef-3.5*this.octaveShift}pitchToNote(e,{preferredAlter:t=null}={}){t||(t=this.keySignature<0?-1:1);const s=Math.floor((e-60)/12),i=us(e),n=cs.includes(i)?i:us(i-t),r=cs.indexOf(n);this.logger.assert(r>=0,"invalid preferredAlter:",e,t,n);const a=7*s+r,o=i-n,c=this.keyAlters[r]||0;return{note:a,alter:Number.isInteger(this.alters[a])?o:o===c?null:o}}pitchToY(e,{preferredAlter:t=null}={}){const{note:s,alter:i}=this.pitchToNote(e,{preferredAlter:t});return{y:this.noteToY(s),alter:i}}yToNote(e){return this.logger.assert(Number.isInteger(2*e),"invalid y:",e),2*(-e-3.5*this.octaveShift-this.clef)}alterOnNote(e){if(Number.isInteger(this.alters[e]))return this.alters[e];const t=ls(e);return Number.isInteger(this.keyAlters[t])?this.keyAlters[t]:0}noteToPitch(e){const t=Math.floor(e/7),s=ls(e),i=60+12*t+cs[s]+this.alterOnNote(e);return Number.isFinite(i)?i:(this.logger.warn("invalid pitch value:",i,e,t,s),-1)}yToPitch(e){return this.noteToPitch(this.yToNote(e))}yToPitchName(e){const t=this.yToNote(e),s=Math.floor(t/7),i=ls(t);let n=this.alterOnNote(t);return n||Number.isInteger(this.alters[t])||(n=null),`${hs[n]?hs[n]:""}${"CDEFGAB"[i]}${s+4}`}}const ms=e=>e.reduce((e,t,s)=>t?e|1<{if(e.version<3){const{version:t,stavesCount:s,layoutTemplate:i,...n}=e;let r=s>1?Array(s-1).fill(",").join(""):"";2===s&&(r="{-}"),e={version:3,staffLayoutCode:r,...n}}return e.version<8&&(e.pages.forEach(e=>{e.systems.forEach(e=>{if(e.semantics){const t=e.semantics.filter(e=>e.semantic===T.vline_BarMeasure);e.semantics=[].concat(...e.staves.map(e=>{const s=e.top+e.staffY;return t.map(e=>({...e,y:e.y+s,extension:{...e.extension,y1:e.extension.y1+s,y2:e.extension.y2+s}}))}))}})}),e.version=8),e.version<9&&(e.spartito=null,e.version=9),e})(e)),this.pages=this.pages||[],this.headers=this.headers||{},this.instrumentDict=this.instrumentDict||{},this.pageSize=this.pageSize||{width:794,height:1122},this.unitSize=this.unitSize||null,this.staffLayoutCode=this.staffLayoutCode||(2===this.maxStavesCount?"{-}":Array(this.maxStavesCount).fill("").join(","))}get systems(){return[].concat(...this.pages.map(e=>e.systems))}get measureCount(){return this.systems.reduce((e,t)=>e+(t.measureCount||0),0)}get imageKeys(){return[...this.pages.map(e=>e.source?.url),...this.systems.map(e=>e.backgroundImage),...[].concat(...this.systems.map(e=>[...e.staves.map(e=>e.backgroundImage),...e.staves.map(e=>e.maskImage)].filter(Boolean)))].filter(Boolean)}get breakSystemIndices(){const e=[];let t=0;return this.pages.forEach((s,i)=>{ie.staves.length),0)}get sidBlackList(){const e=[].concat(...this.systems.map(e=>e.sidBlackList));return new Set(e)}get sidWhiteList(){const e=[].concat(...this.systems.map(e=>e.sidWhiteList));return new Set(e)}get semanticHash(){const e=[].concat(...this.systems.map(e=>[].concat(...e.staves.map(t=>t.semantics?e.qualifiedSemantics(t.semantics).map(e=>e.id):[]))));return p.default(e.join(""))}eventSystemsToTermStaves(e,t=new DummyLogger){const s=Array(this.maxStavesCount).fill(null).map((t,s)=>({rows:e.map((e,t)=>e.columns.map((i,n)=>{const r=i.rows[s];console.assert(r,"[eventSystemsToTermStaves] measure is null:",s,i.rows);const a=r.contexts;0===n&&(a.some(e=>e.type===Oe.OctaveShift)||a.unshift(new ContextedTerm({staff:s,x:0,y:0,tokenType:Z.OctaveShift0,tick:0})));const o=[...r.events||[],...a].sort((e,t)=>e.x-t.x),c=0===s&&n===e.columns.length-1&&this.breakSystemIndices.includes(t);return{terms:o,duration:i.duration,pageBreak:c}}))}));return s.forEach(e=>((e,t=new DummyLogger)=>{const s=new StaffContext;s.logger=t;for(const t of e.rows){for(const e of t){const t=e.terms.find(e=>e instanceof EventTerm);let i=t?Math.min(t.tick,0):0;e.terms.forEach(e=>{if(e instanceof ContextedTerm)e.tick=i,s.change(e);else if(e instanceof EventTerm){const t=e.tick+(e.duration||0);t>i&&(i=t),e.ys&&(e.pitches=e.ys.map(e=>{const t=s.yToNote(e);return{note:t,alter:s.alterOnNote(t),octaveShift:s.octaveShift}}))}}),e.timeSignature={...s.timeSignature},e.timeSigNumeric=s.timeSigNumeric,e.doubtfulTimesig=s.doubtingTimesig||!Number.isInteger(Math.log2(e.timeSignature.denominator))||e.timeSignature.numerator<=e.timeSignature.denominator/4,e.keySignature=s.keySignature,0===e.duration&&(e.duration=we*e.timeSignature.numerator/e.timeSignature.denominator),s.resetMeasure()}s.resetSystem()}})(e,t)),s}resetPageLayout(e){const{unitSize:t=this.unitSize,pageSize:s=this.pageSize}=e,i=.5*s.width/t,n=.5*s.height/t;this.pages.forEach(e=>{const r=i-e.width/2,a=n-e.height/2;e.systems.forEach(e=>{e.left+=r,e.top+=a}),e.semantics&&e.semantics.forEach(e=>{e.x+=r,e.y+=a}),e.width=s.width/t,e.height=s.height/t,e.assemble({textAnnotations:this.textAnnotations})}),this.unitSize=t,this.pageSize=s}getMeasure(e){let t=e;for(const s of this.systems){if(te&&e.measures[t]);return{measureIndex:e,system:s,localIndex:t,left:n.left,right:n.right,measures:r}}t-=s.measureCount}return null}getRawCluster(e,t,{timeSignature:s}={}){const i=this.getMeasure(e);if(!i)return null;const{system:n,left:r,right:a}=i,o=[It];s&&o.push(...Ct(s));const c=n.staves[0].top+n.staves[0].staffY-2;return n.staves.forEach(e=>{let s=n.qualifiedSemantics(e.semantics,t).filter(e=>e.x>r&&e.xe.semantic===T.TempoNotehead).forEach(e=>{const t=s.findIndex(t=>/^Notehead/.test(t.semantic)&&_(e,t)<.3);t>=0&&s.splice(t,1)});const i=e.top+e.staffY-c;s.forEach(t=>{const s=ft[t.semantic];if(s){let n=t.y,a=t.y;s===ft.vline_Stem&&(n=t.extension.y1,a=t.extension.y2),o.push({id:t.id,type:s,staff:e.index,x:t.x-r,y1:n+i,y2:a+i})}})}),new SemanticCluster({index:e,elements:o})}getRawClusters(e=1){return Array(this.measureCount).fill(null).map((t,s)=>this.getRawCluster(s,e))}makeSpartito(e=new DummyLogger){let t=this.systems.map(e=>e.getEvents(this.maxStavesCount));const s=this.eventSystemsToTermStaves(t,e);t.forEach((e,t)=>{e.columns.forEach((e,i)=>{e.basics=s.map(e=>{const{timeSignature:s,timeSigNumeric:n,keySignature:r,doubtfulTimesig:a}=e.rows[t][i];return{timeSignature:s,timeSigNumeric:n,keySignature:r,doubtfulTimesig:a}})})});const i=[].concat(...t.map(e=>e.columns.map(t=>{const s=t.measureIndex,{system:i,localIndex:n,left:r,right:a}=this.getMeasure(s),o=[];i.staves.forEach(e=>o[e.index]=e.top+e.staffY);const c=this.patches&&this.patches.find(e=>e.measureIndex===s),l=c?c.events:SpartitoMeasure.reorderEvents([].concat(...t.rows.map(e=>e.events)),o),u=Object.fromEntries(Object.entries(t.barTypes).map(([e,t])=>[e,t/i.staves.length])),h=0===n&&i.indent;return new SpartitoMeasure({measureIndex:s,staffMask:e.staffMask,position:{systemIndex:i.index,localIndex:n,left:r,right:a,staffYs:i.staves.map(e=>e.top+e.staffY),staffYsFull:o},duration:c?c.duration:t.duration,events:l,contexts:t.rows.map(e=>e.contexts),marks:t.marks,break:t.break,pageBreak:t.pageBreak,voltaBegin:t.voltaBegin,voltaEnd:t.voltaEnd,alternative:t.alternative,barTypes:u,indent:h,basics:c?c.basics:t.basics,matrixH:null,matrixV:null,voices:c?c.voices:null,patched:!!c})}))),n=this.staffLayout,r=n.standaloneGroups.map(e=>e.map(e=>n.staffIds.indexOf(e)));return this.spartito=new Spartito({stavesCount:this.maxStavesCount,staffGroups:r,measures:i}),this.spartito}makeMusicSheet(){const e=this.spartito||this.makeSpartito();e.regulated||console.warn("[makeMusicSheet]\tspartito not regulated.");const t=e.makeVoiceStaves(),{lanes:s,diagnostics:i}=this.makeLyricLanes(t);s.length&&console.debug("[makeMusicSheet]\tlyric lanes:",s.length,i);const{title:n,pageSize:r,unitSize:a,staffLayout:o,paperOptions:c,headers:l,instrumentDict:u}=this;return{title:n,pageSize:r,unitSize:a,measureLayout:this.getMeasureLayout(),staffLayout:o,paperOptions:c,headers:l,voiceStaves:t,instrumentDict:u,lyricLanes:s,lyricDiagnostics:i}}makeLyricLanes(e){const t={total:0,matched:0,unmatched:0,ambiguousVoice:0,duplicateEventAssignments:0,outOfOrderAssignments:0},s=this.spartito;if(!(s&&s.measures&&s.measures.length&&e&&e.length))return{lanes:[],diagnostics:t};const i=[];this.pages.forEach((e,t)=>{(e.lyricTokens||[]).forEach(e=>{i.push({pageIndex:t,x:e.x,y:e.y,text:e.text,sid:e.id})})});const n={...t,total:i.length,unmatchedSids:[]};if(!i.length)return{lanes:[],diagnostics:n};const r=[];i.forEach(e=>{const t=this.pages[e.pageIndex];if(!t||!t.systems||!t.systems.length)return n.unmatched++,void(e.sid&&n.unmatchedSids.push(e.sid));let s=null;for(const i of t.systems)i.top>e.y||e.xi.left+i.width||(!s||i.top>s.top)&&(s=i);if(!s)return n.unmatched++,void(e.sid&&n.unmatchedSids.push(e.sid));const i=s.getStaffArray(this.maxStavesCount);let a=-1,o=-1/0,c=0;for(let t=0;to&&(o=r,a=t,c=n.height)}if(a<0||e.y-o>(l=c,Math.max(2*l,12)))return n.unmatched++,void(e.sid&&n.unmatchedSids.push(e.sid));var l;const u=e.x-s.left;let h=0;const m=s.measureBars||[];for(;h=s.measureCount&&(h=s.measureCount-1);const d=(s.headMeasureIndex||0)+h;r.push({...e,systemIndex:s.index,staffIndex:a,measureIndex:d,localIndex:h,systemX:u,voiceIndex:-1,verse:0})});r.forEach(e=>{const t=s.measures[e.measureIndex];if(!t||!t.events)return n.unmatched++,void(e.sid&&n.unmatchedSids.push(e.sid));const i=t.events.filter(t=>(e=>!!e&&e instanceof EventTerm&&!e.rest&&!e.grace&&!e.zeroHolder&&Number.isFinite(e.x))(t)&&t.staff===e.staffIndex);if(!i.length)return n.unmatched++,void(e.sid&&n.unmatchedSids.push(e.sid));let r=null,a=1/0;for(const t of i){const s=Math.abs(t.x-e.systemX);s{if(!t.event)return;const s=e[t.staffIndex];if(!s||!s.voices||!s.voices.length)return n.unmatched++,void(t.sid&&n.unmatchedSids.push(t.sid));const i=s.voices[0]?.measures?.[t.measureIndex];if(!i)return n.unmatched++,void(t.sid&&n.unmatchedSids.push(t.sid));let r=-1,a=!1;s.voices.forEach((e,s)=>{const i=e.measures?.[t.measureIndex];if(!i||!i.tickMap)return;Object.values(i.tickMap).find(e=>e===t.event||e&&null!=e.id&&null!=t.event.id&&e.id===t.event.id)&&(r>=0&&r!==s&&(a=!0),r<0&&(r=s))}),a&&n.ambiguousVoice++,r<0&&(r=0),t.voiceIndex=r,n.matched++});const a=new Map;r.forEach(e=>{if(!e.event)return;const t=a.get(e.staffIndex)||[];t.push(e),a.set(e.staffIndex,t)});const o=[];a.forEach((e,t)=>{const s=new Map;e.forEach(e=>{const t=s.get(e.systemIndex)||[];t.push(e),s.set(e.systemIndex,t)});let i=1;const n=new Map;s.forEach((t,s)=>{t.sort((e,t)=>e.y-t.y);const r=t.map(e=>e.y),a=r.length>1?Math.max(...r)-Math.min(...r):2,o=Math.max(a/4,1.5),c=[];t.forEach(e=>{const t=c.find(t=>Math.abs(t.y-e.y)<=o);t?t.members.push(e):c.push({y:e.y,members:[e]})}),c.sort((e,t)=>e.y-t.y);const l=new Map;c.forEach((t,s)=>t.members.forEach(t=>l.set(e.indexOf(t),s))),n.set(s,l),c.length>i&&(i=c.length)});for(let s=0;s{const r=n.get(e.systemIndex);(r?r.get(t)??0:0)===s&&i.push({text:e.text,sid:e.sid,measureIndex:e.measureIndex,tick:e.event.tick,staffIndex:e.staffIndex,voiceIndex:e.voiceIndex,eventId:e.event.id,verse:s,source:{pageIndex:e.pageIndex,systemIndex:e.systemIndex,x:e.x,y:e.y}})}),i.length&&(i.sort((e,t)=>e.measureIndex-t.measureIndex||e.tick-t.tick),o.push({staffIndex:t,voiceIndex:e[0].voiceIndex,verse:s,syllables:i}))}});for(const e of o){const t=new Set;let s=-1/0,i=-1;for(const r of e.syllables){const e=`${r.staffIndex}:${r.voiceIndex}:${r.measureIndex}:${r.tick}`;t.has(e)&&n.duplicateEventAssignments++,t.add(e),(r.measureIndext.id===e);if(i){return{point:i,pageIndex:this.pages.findIndex(e=>e.systems.includes(t)),systemIndex:t.index,staffIndex:s}}}return null}getMeasureSemantics(e,t){const s=this.systems[e];if(!s)return null;const i=t?s.measureBars[t-1]:0,n=s.measureBars[t]||s.width;return s.staves.map((e,t)=>{const s=e.top+e.staffY;return e.semantics.filter(e=>e.x>=i&&e.x{const[i,n]=Number.isFinite(e.extension?.y1)?[e.extension.y1,e.extension.y2]:[e.y,e.y];return{...e,staff:t,sy1:i+s,sy2:n+s}})}).flat(1)}makeTimewiseGraph({store:e=!1}={}){if(!this.spartito)return null;return{measures:this.spartito.measures.filter(e=>e.events.length>0).map(t=>{const s=this.getMeasureSemantics(t.position.systemIndex,t.position.localIndex),i={measureIndex:t.measureIndex,left:t.position.left,right:t.position.right,points:s};return e&&(t.graph=i),i})}}getTokenMap(){const e=new Map;return this.systems.forEach(t=>t.staves.forEach(t=>t.measures.forEach(t=>t.tokens.forEach(t=>e.set(t.id,t))))),e}assemble(e=1,t=new DummyLogger){const s=new Map;this.pages.forEach((e,t)=>e.index=t);let i=0;this.systems.forEach((n,r)=>{n.index=r,n.headMeasureIndex=i,n.prev=this.systems[r-1]||null,n.next=this.systems[r+1]||null,n.semantics&&n.semantics.length&&n.semantics.forEach(e=>((e,i,n)=>{const r=C(e,i,n);t.assert(!s.has(r),"semantic point hash conflicted:",r,n,s.get(r)),s.set(r,n)})(r,null,e)),n.assemble(e,t),i+=n.measureCount}),this.pages.forEach((e,s)=>{e.systems.forEach(e=>e.pageIndex=s),e.assemble({textAnnotations:this.textAnnotations},t)})}assembleSystem(e,t=1){this.systems.forEach((e,t)=>e.index=t);const s=e.index;e.semantics&&e.semantics.length&&(e.semantics.forEach(e=>C(s,null,e)),e.assemble(t))}markVoices(e){const t=this.getTokenMap();for(const e of t.values())e.voice=0;const s=[].concat(...e.map((e,t)=>(e.voices||[]).map((e,s)=>[t,s]))).sort(([e,t],[s,i])=>t-i||e-s).map(([e,t])=>`${e}|${t}`);e.forEach((e,i)=>(e.voices||[]).forEach((e,n)=>e.measures.forEach(e=>{const r=s.indexOf(`${i}|${n}`);Object.values(e.tickMap).filter(e=>e instanceof EventTerm).forEach(e=>{const s=e.noteIds?e.noteIds.map(e=>t.get(e)).filter(Boolean):[],i=e.accessories?e.accessories.map(e=>t.get(e.id)).filter(Boolean):[];[...s,...i].forEach(e=>e.voice|=1<e.timeWarped=!0)})})))}async replaceImageKeys(e){await Promise.all([...this.pages.map(async t=>{t.source&&(t.source.url=await e(t.source.url))}),...this.systems.map(t=>Promise.all([e(t.backgroundImage).then(e=>t.backgroundImage=e),...t.staves.map(async t=>{t.backgroundImage=await e(t.backgroundImage),t.maskImage=await e(t.maskImage)})]))])}inferenceStaffLayout(){const e=Math.max(...this.systems.map(e=>e.staves.length),0);this.staffLayoutCode=Array(e).fill("").join(",");const t=this.systems.filter(t=>t.staves.length===e&&t.bracketsAppearance);if(!t.length)return;const s=t.map(e=>{try{return it(e.bracketsAppearance).staffIds.length!==e.staves.length?null:e.bracketsAppearance}catch(e){return null}}).filter(Boolean);if(!s.length)return;const i=s.reduce((e,t)=>{const s=e[t]||0;return e[t]=s+1,e},{}),n=Math.max(...Object.values(i)),r=Object.entries(i).find(([e,t])=>t===n)[0].replace(/\{,*\}/g,e=>e.replace(/,/g,"-")),a=it(r);this.staffLayoutCode=r;let o=null;for(const t of this.systems)if(o&&t.staves.length===o.staves.length&&t.bracketsAppearance===o.bracketsAppearance)t.staffMaskChanged=null;else{if(t.staves.length{if(s.length>a.staffIds.length)return null;if(s.reduce((e,t)=>e+t,0)===t.staves.length)return ms(s);for(const i of[1,0]){const n=[...s,i],r=a.partialMaskCode(n);if(r===t.bracketsAppearance)return ms(n);if(t.bracketsAppearance.startsWith(r)){const t=e(n);if(t)return t}}return null},s=e([]);t.staffMaskChanged=o&&s===o.staffMask?null:s}o=t}}assignBackgroundForMeasure(e){e.backgroundImages=[];const t=this.systems[e.position.systemIndex];t.backgroundImage&&e.backgroundImages.push({url:t.backgroundImage,position:t.imagePosition,original:!0}),t.staves.forEach(s=>{!t.backgroundImage&&s.backgroundImage&&e.backgroundImages.push({url:s.backgroundImage.toString(),position:{...s.imagePosition,y:s.imagePosition.y+s.top},original:!0}),s.maskImage&&e.backgroundImages.push({url:s.maskImage.toString(),position:{...s.imagePosition,y:s.imagePosition.y+s.top}})})}blackoutFakeNotes(e="patched"){if(!this.spartito)return;let t=e=>!0;switch(e){case"patched":t=e=>e.patched;break;case"perfect":t=e=>e.patched||e.regulated&&qe(e).perfect}const s=this.spartito.measures.filter(t).reduce((e,t)=>{if(!t.regulated)return;const s=t.voices.flat(1);return t.events.filter(e=>!e.rest&&!e.grace&&!s.includes(e.id)).forEach(t=>t.noteIds&&e.push(...t.noteIds)),e},[]),i=new Set(s);return this.systems.forEach(e=>e.staves.forEach(t=>{const s=t.semantics.filter(e=>i.has(e.id)).map(e=>e.id);e.sidBlackList.push(...s)})),s}getMeasureLayout(){const e=this.spartito&&this.spartito.measureLayoutCode;if(e)try{return(e=>{const t=Ve(e);return t?.data?S(t.data,He):null})(e)}catch(e){console.debug("invalid measure layout code:",e)}return null}*splitToSingleScoresGen(){this.assemble();const e=this.systems.filter(e=>e.index>0&&e.indent&&e.timeSignatureOnHead).map(e=>e.index);if(!e.length)return void(yield this.deepCopy());const t=new Score({...this,pages:[],topology:void 0,spartito:void 0,patches:void 0});this.pages.forEach(e=>{delete e.tokens,e.systems.forEach(e=>{delete e.tokens,e.staves.forEach(e=>{e.measures=[]})})});let s=0;for(const i of[...e,this.systems.length]){const e=e=>e.index>=s&&e.indext.systems.some(e)).map(t=>{const{systems:s,...i}=t;return new Page({...i,systems:s.filter(e).map(e=>new System({...e}))})}),r=t.deepCopy();r.headers.SubScoreSystem=`${s}-${i-1}`,r.headers.SubScorePage=`${n[0].index}-${n[n.length-1].index}`,r.pages=n,r.assemble(),r.inferenceStaffLayout(),s=i,yield r}}splitToSingleScores(){return[...this.splitToSingleScoresGen()]}}var ds;Score.className="Score",function(e){e.Pass="i",e.Division="d",e.Dots="o"}(ds||(ds={}));const fs=["whole","half","quarter","eighth","sixteenth","thirtysecond","sixtyfourth","128th","256th"],ps=.4/we,gs=1e-12,ys=[void 0,"u","d"],vs=[void 0,Ae.Open,Ae.Continue,Ae.Close],xs=e=>({elements:e.elements.map(e=>({tick:e.tick,division:e.division,dots:e.dots,beam:e.beam,stemDirection:e.stemDirection,grace:e.grace,timeWarped:e.timeWarped,fullMeasure:e.fullMeasure,fake:e.fake,order:e.order,predisposition:e.predisposition}))});class BeadNode{constructor(e){Object.assign(this,e),this.children={},this.accessCount=0}nextBranch(){const e=this.possibilities.map((e,t)=>e/(this.children[t]?this.children[t].accessCount+1:1));return e.every(e=>!e)?(this.accessCount=1/0,null):G(e)}get currentElem(){return this.cluster.elements[this.elemIndex]}branchID(e){switch(this.type){case ds.Pass:return`i_${e}`;case ds.Division:return fs[e];case ds.Dots:return"o"+".".repeat(e)}return""}async deduce({picker:e,logger:t,ptFactor:s},i=0){++this.accessCount;const n=this.nextBranch();if(t.debug(String.fromCodePoint(127817)+" ".repeat(i),this.branchID(n),this.accessCount>1?`[${this.accessCount}]`:""),!Number.isInteger(n)||n<0)return this.accessCount=1/0,ks(this.cluster,this.currentElem.order+1,this.pretentiousness);if(this.pretentiousness+=(e=>Math.min(100,-Math.log(e)))(this.possibilities[n]),this.pretentiousness>100*s)return this.accessCount=1/0,ks(this.cluster,this.currentElem.order+1,this.pretentiousness);let r=null;switch(this.type){case ds.Pass:{const t=this.currentElem.order+1,s=this.cluster.elements[n];if(console.assert(s,"null element:",n,this.cluster.elements.length),s.type===Y.EOS){if(r=ks(this.cluster,t,this.pretentiousness),!r.residue||r.fatalError)return this.accessCount=1/0,r;if(this.cluster.elements[0].order=t,!this.children[n]){if(!e.quota)return r;const s=(await e.predictCluster(this.cluster,t+1)).map((e,s)=>this.cluster.elements[s].orderMath.max(gs,e));this.children[n]=new BeadNode({cluster:this.cluster,elemIndex:n,type:ds.Division,possibilities:e,pretentiousness:this.pretentiousness})}}break;case ds.Division:if(this.currentElem.division=n,!this.children[n]){const e=this.currentElem.predisposition.dotsVector.map(e=>Math.max(gs,e));this.children[n]=new BeadNode({cluster:this.cluster,elemIndex:this.elemIndex,type:ds.Dots,possibilities:e,pretentiousness:this.pretentiousness})}break;case ds.Dots:if(this.currentElem.dots=n,r=ks(this.cluster,this.currentElem.order+1,this.pretentiousness),!r.residue||r.fatalError)return this.accessCount=1/0,r;if(!this.children[n]){if(!e.quota)return r;const t=this.currentElem.order+1,s=(await e.predictCluster(this.cluster,t)).map((e,s)=>this.cluster.elements[s].order{t.order>e&&(t.order=void 0)}),this.cluster.elements.forEach(e=>e.order=e.order>this.currentElem.order?void 0:e.order),this.cluster.elements[this.cluster.elements.length-1].tick=r.endTick,r}return a}}const Ss=e=>we*2**-e.division*(2-2**-e.dots),ks=(e,t,s)=>{const i=e.elements.filter(e=>[Y.CHORD,Y.REST].includes(e.type)&&Number.isInteger(e.order)&&e.ordere.order-t.order);const n=e.elements[e.elements.length-1];let r=0,a=0,o=0,c=1;const l=[[n.x,e.signatureDuration,e.signatureDuration]];let u=0;i.forEach(e=>{e.order>a+1&&(r=0,++c);const t=l.find(e=>e[1]>=r);if(t&&e.x>t[0]+3){const t=l.reduce((t,s)=>Math.abs(e.predisposition.tick-s[2])t[0]>e.x));l.splice(s,0,[e.x,e.tick,e.predisposition.tick]);let i=Ss(e);e.predisposition.timeWarped>.5&&(i=2*i/3),r+=i,u+=i,o=Math.max(o,r),a=e.order}),o>0&&(e.elements[e.elements.length-1].tick=o);const h=e.elements[e.elements.length-1].pivotX-e.elements[1].pivotX,m=Math.max(...i.map(e=>e.tick),o),d=[...i].sort((e,t)=>e.pivotX-t.pivotX),f=d.slice(1).map((e,t)=>{const s=d[t],i=e.pivotX-s.pivotX,n=e.tick-s.tick;if(!n)return i/h;return(4*Math.atan2(n/m,i/h)/Math.PI-1)**2}),p=Math.max(...f,0),g=i.map(e=>(e.tick-e.predisposition.tick)**2),y=g.length?Math.sqrt(g.reduce((e,t)=>e+t,0)/g.length):0,v=e.elements.filter(e=>[Y.CHORD,Y.REST].includes(e.type)&&!(Number.isInteger(e.order)&&e.order.5)).length,x=p>=1||o>e.signatureDuration,S=Math.max(0,e.signatureDuration-u/c);return{tickErr:y,twist:p,residue:v,endTick:o,fatalError:x,voiceN:c,spaceDuration:S,pretentiousness:s,loss:y/we+p+.2*v+.002*c+S*ps+.02*s}},bs=async(e,t,s,i=200,n=0,r=1)=>{e.elements.forEach((e,t)=>e.order=t?void 0:0);const a=await t.predictCluster(e,1),o=new BeadNode({cluster:e,elemIndex:0,pretentiousness:0,type:ds.Pass,possibilities:a});let c=null,l=null;for(t.quota=i;t.quota;){e.elements.forEach((e,t)=>e.order=t?void 0:0);const i=await o.deduce({picker:t,logger:s,ptFactor:r});if(s.debug("loss:",i),(!c||i.loss{e.elements.forEach((e,s)=>Object.assign(e,t.elements[s]))})(e,l);const u=e.elements.filter(e=>[Y.CHORD,Y.REST].includes(e.type)&&Number.isInteger(e.order)),h=e.elements.filter(e=>[Y.CHORD,Y.REST].includes(e.type)&&!Number.isInteger(e.order));u.length&&h.forEach(e=>{if(e.tick=void 0,e.predisposition.fakeP<.5){const t=Ss(e),s=u.filter(e=>e.tick+t<=c.endTick);if(s.length){const t=s.reduce((t,s)=>Math.abs(s.x-e.x)e.order-t.order),[...u,...h].forEach(e=>{e.grace=!Number.isFinite(e.tick)&&e.predisposition.grace,e.timeWarped=e.predisposition.timeWarped>.5,e.fullMeasure=e.predisposition.fullMeasure>.5,e.stemDirection=ys[G(e.predisposition.stemDirectionVector)],e.beam=vs[G(e.predisposition.beamVector)]});const m=e.elements.map(e=>e.index),d=e=>m.indexOf(e);return e.matrixH=e.elements.map(()=>Array(e.elements.length).fill(0)),u.forEach((t,s)=>{const i=u[s-1];!i||i.order{const{stopLoss:s=.09,quotaMax:i=1e3,quotaFactor:n=5,ptFactor:r=1,logger:a=new DummyLogger}=t;let o=0;const c=e.createClusters();for(const l of c){const c=Math.min(i,Math.ceil(l.elements.length*n));a.info(`[measure-${e.measureIndex}]`,c);const{loss:u}=await bs(l,t.picker,a,c,s,r);o=Math.max(o,u)}const l=[],u=[],h=[];c.forEach(t=>{const s=t.elements.filter(e=>[Y.CHORD,Y.REST].includes(e.type)&&Number.isInteger(e.order));if(s.sort((e,t)=>e.order-t.order),!s.length)return;let i=[];l.push(i);let n=0;s.forEach(e=>{e.fullMeasure||e.grace||e.tremoloCatcher||(e.order>n+1?(i=[e.index],l.push(i)):i.push(e.index),n=e.order)});let r=s[s.length-1];const a=t.elements.filter(e=>[Y.CHORD,Y.REST].includes(e.type)&&Number.isFinite(e.tick)&&!Number.isInteger(e.order));for(;a.length;){const e=a.findIndex(e=>e.tick>=r.tick+Ss(r));e>=0?i.push(a.splice(e,1)[0].index):(r=a.splice(0,1)[0],i=[r.index],l.push(i))}if(s.some(e=>!e.fullMeasure&&Number.isInteger(e.order))){const e=t.elements.find(e=>e.type===Y.EOS);u.push(e.tick)}const o=e.eventMap,c=t.elements.reduce((e,t)=>(Number.isFinite(t.tick)&&e.add(t.tick),e),new Set),m=Array.from(c).sort((e,t)=>e-t);s.forEach(e=>{const t=o[e.index];t&&h.push({id:t.id,tick:e.tick,tickGroup:m.indexOf(e.tick),division:e.division!==t.division?e.division:void 0,dots:e.dots!==t.dots?e.dots:void 0,timeWarp:e.timeWarped?F(2,3):void 0,beam:e.beam!==t.beam?e.beam:void 0,grace:e.grace!==!!t.grace?e.grace:void 0,fullMeasure:e.fullMeasure||void 0})})});const m=Math.max(...c.map(e=>e.estimatedDuration));return{voices:l.filter(e=>e.length),duration:Math.max(...u),events:h,priority:-o,estimatedDuration:m}},ws=async(e,{picker:t,resetSignatureForDoubtfulOnly:s})=>{const i=e.createClusters(),n=e.eventMap;for(const r of i)s&&!e.doubtfulTimesig||(r.signatureDuration=0),r.elements.forEach((e,t)=>e.order=t?void 0:0),await t.predictCluster(r,1),r.elements.filter(e=>[Y.CHORD,Y.REST].includes(e.type)).forEach(e=>{n[e.index].predisposition=e.predisposition});e.estimatedDuration=Math.max(...i.map(e=>e.estimatedDuration))},Ms=async(e,t)=>ws(e,{picker:t,resetSignatureForDoubtfulOnly:!0});var Es=Object.freeze({__proto__:null,solveCluster:bs,solveMeasure:Ts,estimateMeasure:Ms,glimpseMeasure:ws}),As=Object.freeze({__proto__:null,beadSolver:Es,recoverJSON:S,SimpleClass:SimpleClass,EditableEvent:EditableEvent,EditableMeasure:EditableMeasure,get EventElementType(){return Y},EventCluster:EventCluster,EventClusterSet:EventClusterSet,get PageLayoutMethod(){return Fe},get TextType(){return Pe},evaluateMeasure:qe,PatchMeasure:PatchMeasure,VERSION:14,Score:Score,Page:Page,System:System,Staff:Staff,Measure:Measure,SemanticGraph:SemanticGraph,get SemanticType(){return T},glyphSemanticMapping:{"rests.1":"Rest1","rests.0o":"Rest0","rests.1o":"Rest1","rests.M1":"RestM1","rests.2":"Rest2","rests.3":"Rest3","rests.4":"Rest4","rests.5":"Rest5","rests.6":"Rest6","accidentals.sharp":"AccSharp","accidentals.doublesharp":"AccDoublesharp","accidentals.natural":"AccNatural","accidentals.flat":"AccFlat","accidentals.flatflat":"AccFlatflat","dots.dot":"Dot","scripts.ufermata":"ScriptFermata","scripts.dfermata":"ScriptFermata","scripts.ushortfermata":"ScriptShortFermata","scripts.dshortfermata":"ScriptShortFermata","scripts.staccato":"ScriptStaccato","scripts.ustaccatissimo":"ScriptStaccatissimo","scripts.dstaccatissimo":"ScriptStaccatissimo","scripts.turn":"ScriptTurn","scripts.trill":"ScriptTrill","scripts.segno":"ScriptSegno","scripts.coda":"ScriptCoda","scripts.arpeggio":"ScriptArpeggio","scripts.prall":"ScriptPrall","scripts.mordent":"ScriptMordent","scripts.umarcato":"ScriptMarcato","scripts.dmarcato":"ScriptMarcato","scripts.uportato":"ScriptPortato","scripts.dportato":"ScriptPortato","scripts.tenuto":"ScriptTenuto","scripts.sforzato":"ScriptSforzato","clefs.C":"ClefC","clefs.F":"ClefF","clefs.G":"ClefG","clefs.F_change":"ClefF","clefs.G_change":"ClefG","timesig.C44":"TimesigC44","timesig.C22":"TimesigC22","pedal.*":"PedalStar","pedal.Ped":"PedalPed","noteheads.s0":"NoteheadS0","noteheads.s1":"NoteheadS1","noteheads.s2":"NoteheadS2",f:"f",m:"m",p:"p",r:"r",s:"s",z:"z"},semanticPriorities:{ClefG:0,ClefF:0,TimesigFour:0,TimesigThree:0,TimesigTwo:0,NoteheadS0:0,NoteheadS1:0,NoteheadS2:0,Dot:0,vline_BarMeasure:0,vline_Stem:0,Flag3:0,TimesigC44:1,TimesigC22:1,TimesigEight:1,TimesigSix:1,AccNatural:1,AccSharp:1,AccFlat:1,KeyAcc:1,Rest0:1,Rest1:1,Rest2:1,Rest3:1,Rest4:1,OctaveShift8:1,OctaveShift0:1,AccDoublesharp:2,AccFlatflat:2,TimesigOne:2,TimesigNine:2,Rest5:2,Rest6:2,SlurBegin:2,SlurEnd:2,VoltaLeft:2,VoltaRight:2,vline_BarTerminal:2,vline_BarSegment:2,TempoNotehead:2,GraceNotehead:2,SignLined:2,SignInterval:2,BeamLeft:2,BeamRight:2,BeamContinue:2,TremoloLeft:2,TremoloRight:2,TremoloMiddle:2,StemTip:2,StemHead:2,f:3,p:3,m:3,ScriptFermata:3,ScriptSforzato:3,ScriptStaccato:3,ScriptStaccatissimo:3,ScriptTurn:3,ScriptTrill:3,ScriptSegno:3,ScriptCoda:3,ScriptArpeggio:3,ScriptPrall:3,ScriptMordent:3,ScriptTenuto:3,PedalStar:3,PedalPed:3,TimesigFive:3,TimesigSeven:3,TimesigZero:3,One:3,Two:3,Three:3,Four:3,Five:3,rect_Text:3,rect_Lyric:3,CrescendoBegin:3,CrescendoEnd:3,DecrescendoBegin:3,DecrescendoEnd:3,RestM1:4,ClefC:4,ScriptShortFermata:4,ScriptMarcato:4,ScriptPortato:4,s:4,r:4,z:4,Zero:4,Six:4,Seven:4,Eight:4,Nine:4},NOTEHEAD_WIDTHS:w,glyphCenters:M,ONE_D_SEMANTICS:["OctaveShift8va","OctaveShift8vb","OctaveShift8","OctaveShift0","vline_VoltaLeft","vline_VoltaRight","VoltaAlternativeBegin","vline_BarMeasure","vline_BarTerminal","vline_BarSegment"],SYSTEM_SEMANTIC_TYPES:E,CONFLICTION_GROUPS:N,STAMP_SEMANTICS:I,STAMP_RECTS:{ClefG:[-.0625,-1.125,3.6,8.6],ClefF:[.25,.5625,3.6,3.8],ClefC:[.25,0,3.25,4.5],NoteheadS0:[.0625,0,2.55,1.4],NoteheadS1:[.0625,0,1.8,1.4],NoteheadS2:[.0625,-.0625,1.65,1.35],Dot:[.25,0,.6,.6],Rest0:[0,-.75,3.25,.9],Rest1:[0,-.25,3.25,.9],Rest2:[-.0625,-.1875,1.6,3.375],Rest3:[0,.0625,1.2,2.25],Rest4:[.0625,.5625,1.65,3.375],Rest5:[.0625,.0625,1.95,4.375],Rest6:[.0625,.5625,1.95,5.375],RestM1:[-.4375,-1.5,.75,1.2],AccNatural:[0,0,.9,3.5],AccSharp:[0,0,1.5,3.5],AccDoublesharp:[0,0,1.5,1.5],AccFlat:[0,-.5625,1.2,3.125],AccFlatflat:[.1875,-.5625,1.95,3.125],TimesigC44:[-.0625,0,2.25,2.3],TimesigC22:[-.0625,0,2.25,3.2],TimesigZero:[0,0,1.8,2.2],TimesigOne:[-.125,0,1.5,2.2],TimesigTwo:[0,0,2.2,2.2],TimesigThree:[-.0625,0,1.9,2.4],TimesigFour:[.0625,0,1.95,2.2],TimesigFive:[0,0,1.8,2.3],TimesigSix:[0,0,2,2.4],TimesigSeven:[0,0,1.8,2.2],TimesigEight:[0,0,1.9,2.2],TimesigNine:[0,0,1.9,2.2],One:[-.0625,0,.75,1.6],Two:[0,0,1.2,1.6],Three:[0,0,1.2,1.6],Four:[0,0,1.2,1.6],Five:[0,0,1.2,1.6],OctaveShift8:[2.125,-.1875,4.75,3.6],OctaveShift0:[-.4,0,1.8,4.2],f:[.0625,-.125,2.55,3],p:[-.0625,.25,2.55,2.1],m:[-.125,-.0625,2.4,1.35],n:[-.3125,-.0625,1.95,1.35],r:[0,-.125,1.5,1.5],s:[0,-.0625,1.2,1.35],z:[.0625,0,1.35,1.5],ScriptFermata:[0,0,3.25,3.9],ScriptShortFermata:[0,0,2.4,4.95],ScriptSforzato:[-.0625,0,2.5,1.2],ScriptStaccato:[0,-.0625,.6,.45],ScriptStaccatissimo:[0,0,1.2,2.6],ScriptTurn:[0,0,2.7,1.5],ScriptTrill:[-.125,-.5,3,2.7],ScriptSegno:[0,0,2.4,3.5],ScriptCoda:[0,0,2.7,3.25],ScriptArpeggio:[-.0625,0,1.05,1.8],ScriptPrall:[0,0,2.4,1.2],ScriptMordent:[0,0,2.4,1.5],ScriptMarcato:[0,0,1.2,2.475],ScriptTenuto:[0,-.0625,1.5,.15],ScriptPortato:[0,0,1.5,1.65],PedalStar:[0,0,3.2,3.2],PedalPed:[0,-.25,4.7,2.4]},hashSemanticPoint:C,hashPageSemanticPoint:O,get SemanticElementType(){return ft},SemanticCluster:SemanticCluster,SemanticClusterSet:class SemanticClusterSet{constructor(e){if(e&&(this.clusters=e.clusters,e.vocab)){const t=e.vocab.map((e,t)=>[t,ft[e]]).filter(([e,t])=>e!==t).reduce((e,[t,s])=>(e[t]=s,e),{});this.clusters.forEach(e=>e.elements.forEach(e=>{Number.isFinite(t[e.type])&&(e.type=t[e.type])}))}}toJSON(){return{__prototype:"SemanticClusterSet",vocab:Object.entries(ft).filter(e=>Number.isFinite(e[1])).map(e=>e[0]),clusters:this.clusters.map(e=>e.toJSON())}}},ELEMENT_TOKEN_NAMES:vt,NOTEHEAD_ELEMENT_TYPES:St,NOTE_ELEMENT_TYPES:Tt,BOS_ELEMENT:It,fractionToElems:Ct,expandMatrixByMasks:Bt,expandMatrixByMaskTriu:_t,matrixFromGroups:Rt,emptyVoiceFromStaffMeasure:as,SpartitoMeasure:SpartitoMeasure,Spartito:Spartito,mod7:ls,Term:Term,EventTerm:EventTerm,ContextedTerm:ContextedTerm,MarkTerm:MarkTerm,TempoTerm:TempoTerm,GlyphTerm:GlyphTerm,TextTerm:TextTerm,LyricTerm:LyricTerm,CommandTerm:CommandTerm,ChordmodeTerm:ChordmodeTerm,get ContextType(){return Oe},get GraceType(){return Ee},get GlissandoStyle(){return Ie},get ArpeggioStyle(){return Ce},get AccessoryDirection(){return Me},WHOLE_DURATION:we,get StemBeam(){return Ae},get TremoloLink(){return Ne},TokenTypes:X,TokenClefs:Q,TokenTimesigs:ee,TokenTimesigsC:te,TokenTimesigsN:se,TokenOctshifts:ie,TokenNumbers:ne,TokenAccidentals:re,TokenNoteheads:ae,TokenBareNoteheads:oe,TokenDirectionalNoteheads:ce,TokenRests:le,TokenFlags:ue,TokenVolta:he,TokenDynamics:me,TokenScripts:de,TokenPedals:fe,TokenDots:pe,TokenArcs:ge,TokenBeams:ye,TokenWedges:ve,TokenAccessories:xe,TokenDirectionless:Se,TokenGlyphs:ke,get TokenType(){return Z},Token:Token,TextToken:TextToken,TOKEN_Y_ROUND:be,TOKEN_Y_FIXED:Te});const Ns=[Z.ClefG,Z.ClefF,Z.ClefC],Is=e=>{let t=null;switch(e.tokenType){case Z.ClefG:t="Treble";break;case Z.ClefF:t="Bass";break;case Z.ClefC:t=-1===e.y?"Tenor":"Alto"}return t};var Cs,Os={exports:{}},Bs="object"==typeof Reflect?Reflect:null,_s=Bs&&"function"==typeof Bs.apply?Bs.apply:function(e,t,s){return Function.prototype.apply.call(e,t,s)};Cs=Bs&&"function"==typeof Bs.ownKeys?Bs.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var Rs=Number.isNaN||function(e){return e!=e};function Fs(){Fs.init.call(this)}Os.exports=Fs,Os.exports.once=function(e,t){return new Promise(function(s,i){function n(s){e.removeListener(t,r),i(s)}function r(){"function"==typeof e.removeListener&&e.removeListener("error",n),s([].slice.call(arguments))}Gs(e,t,r,{once:!0}),"error"!==t&&function(e,t,s){"function"==typeof e.on&&Gs(e,"error",t,s)}(e,n,{once:!0})})},Fs.EventEmitter=Fs,Fs.prototype._events=void 0,Fs.prototype._eventsCount=0,Fs.prototype._maxListeners=void 0;var Ps=10;function Ds(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function qs(e){return void 0===e._maxListeners?Fs.defaultMaxListeners:e._maxListeners}function Ls(e,t,s,i){var n,r,a,o;if(Ds(s),void 0===(r=e._events)?(r=e._events=Object.create(null),e._eventsCount=0):(void 0!==r.newListener&&(e.emit("newListener",t,s.listener?s.listener:s),r=e._events),a=r[t]),void 0===a)a=r[t]=s,++e._eventsCount;else if("function"==typeof a?a=r[t]=i?[s,a]:[a,s]:i?a.unshift(s):a.push(s),(n=qs(e))>0&&a.length>n&&!a.warned){a.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=a.length,o=c,console&&console.warn&&console.warn(o)}return e}function $s(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function js(e,t,s){var i={fired:!1,wrapFn:void 0,target:e,type:t,listener:s},n=$s.bind(i);return n.listener=s,i.wrapFn=n,n}function Hs(e,t,s){var i=e._events;if(void 0===i)return[];var n=i[t];return void 0===n?[]:"function"==typeof n?s?[n.listener||n]:[n]:s?function(e){for(var t=new Array(e.length),s=0;s{s=e,i=n,t>=0&&setTimeout(i,t,"timeout")}),s,i]}Object.defineProperty(Fs,"defaultMaxListeners",{enumerable:!0,get:function(){return Ps},set:function(e){if("number"!=typeof e||e<0||Rs(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");Ps=e}}),Fs.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},Fs.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||Rs(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},Fs.prototype.getMaxListeners=function(){return qs(this)},Fs.prototype.emit=function(e){for(var t=[],s=1;s0&&(r=t[0]),r instanceof Error)throw r;var a=new Error("Unhandled error."+(r?" ("+r.message+")":""));throw a.context=r,a}var o=n[e];if(void 0===o)return!1;if("function"==typeof o)_s(o,this,t);else{var c=o.length,l=Vs(o,c);for(s=0;s=0;r--)if(s[r]===t||s[r].listener===t){a=s[r].listener,n=r;break}if(n<0)return this;0===n?s.shift():function(e,t){for(;t+1=0;i--)this.removeListener(e,t[i]);return this},Fs.prototype.listeners=function(e){return Hs(this,e,!0)},Fs.prototype.rawListeners=function(e){return Hs(this,e,!1)},Fs.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):Ws.call(e,t)},Fs.prototype.listenerCount=Ws,Fs.prototype.eventNames=function(){return this._eventsCount>0?Cs(this._events):[]};class AsyncQueue extends Os.exports.EventEmitter{constructor(){super(),this.working=!1,this.working=!1,this.tasks=[],process.nextTick(()=>{this.emit("idle")})}async _digest(e){this.working=!0;const[t,s,i,n]=e;await t(s).then(i,n),this.tasks.length>0?await this._digest(this.tasks.shift()):(this.working=!1,this.emit("idle"))}addTask(e,{timeout:t=6e5}={}){const[s,i,n]=Us({timeout:t});return this.working?this.tasks.push([...e,i,n]):this._digest([...e,i,n]),s}}class ZeroClient{constructor(e=console){this.queue=new AsyncQueue,this.logger=e}bind(e){e&&(this.url=e),this.socket=new n.Request({sendTimeout:15e3,receiveTimeout:3e5}),this.socket.connect(this.url)}__request(e){let t=0;const s=async e=>{try{return this.socket.closed&&this.bind(),await this.socket.send(i.pack(e)).then(()=>this.socket.receive())}catch(i){if(t<2)return t++,console.log(`请求失败,${i.stack}`),console.error(`3s后重试第${t}次`),this.socket.close(),await new Promise(e=>setTimeout(e,3e3)),s(e);throw i}};return s(e)}async request(e,t=null,s=null){const[n,r]=Array.isArray(t)?[t,s]:[void 0,t],a={method:e};return n&&(a.args=n),r&&(a.kwargs=r),this.queue.addTask([async e=>{const[t]=await this.__request(e),s=i.unpack(t);return 0===s.code?s.data:Promise.reject(s.msg)},a])}}class PyProcessor extends ZeroClient{constructor(e,t={},s=console){super(s),this.retryCount=0,this.retryDelay=3e3,this.scriptPath=e,this.options=t}async bind(e){const t=e||await r.getPortPromise({port:12022,stopPort:12122}),s=o.defaultsDeep({args:[...this.options.args||[],"-p",`${t}`]},this.options);this.logger.info(`[python-shell]: starting python shell. path: ${this.scriptPath}`),this.pyShell=new a.PythonShell(this.scriptPath,s),this.pyShell.stdout.on("data",e=>this.logger.info(e)),this.pyShell.on("pythonError",e=>this.logger.error(`[python-shell]: ${this.scriptPath} pythonError:`,e)),this.pyShell.on("stderr",e=>this.logger.error(`[python-shell]: ${this.scriptPath} stderr:`,e)),this.pyShell.on("error",e=>this.logger.error(`[python-shell]: ${this.scriptPath} error:`,e)),this.pyShell.on("close",()=>{this.retryCount<5&&(this.retryCount++,this.logger.info(`[python-shell]: ${this.scriptPath} will retry ${this.retryCount}th time after 3 seconds`),setTimeout(()=>{this.bind()},this.retryDelay))}),super.bind(`tcp://127.0.0.1:${t}`)}}var zs={},Ks=function(e){return e instanceof Buffer},Ys={exports:{}},Zs={exports:{}};"function"==typeof Object.create?Zs.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:Zs.exports=function(e,t){e.super_=t;var s=function(){};s.prototype=t.prototype,e.prototype=new s,e.prototype.constructor=e};try{var Js=require("util");if("function"!=typeof Js.inherits)throw"";Ys.exports=Js.inherits}catch(e){Ys.exports=Zs.exports}!function(e){var t=Object.getOwnPropertyDescriptors||function(e){for(var t=Object.keys(e),s={},i=0;i=a)return e;switch(e){case"%s":return String(n[i++]);case"%d":return Number(n[i++]);case"%j":try{return JSON.stringify(n[i++])}catch(e){return"[Circular]"}default:return e}}),c=n[i];i=3&&(i.depth=arguments[2]),arguments.length>=4&&(i.colors=arguments[3]),m(s)?i.showHidden=s:s&&e._extend(i,s),g(i.showHidden)&&(i.showHidden=!1),g(i.depth)&&(i.depth=2),g(i.colors)&&(i.colors=!1),g(i.customInspect)&&(i.customInspect=!0),i.colors&&(i.stylize=a),c(i,t,i.depth)}function a(e,t){var s=r.styles[t];return s?"["+r.colors[s][0]+"m"+e+"["+r.colors[s][1]+"m":e}function o(e,t){return e}function c(t,s,i){if(t.customInspect&&s&&k(s.inspect)&&s.inspect!==e.inspect&&(!s.constructor||s.constructor.prototype!==s)){var n=s.inspect(i,t);return p(n)||(n=c(t,n,i)),n}var r=function(e,t){if(g(t))return e.stylize("undefined","undefined");if(p(t)){var s="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(s,"string")}if(f(t))return e.stylize(""+t,"number");if(m(t))return e.stylize(""+t,"boolean");if(d(t))return e.stylize("null","null")}(t,s);if(r)return r;var a=Object.keys(s),o=function(e){var t={};return e.forEach(function(e,s){t[e]=!0}),t}(a);if(t.showHidden&&(a=Object.getOwnPropertyNames(s)),S(s)&&(a.indexOf("message")>=0||a.indexOf("description")>=0))return l(s);if(0===a.length){if(k(s)){var v=s.name?": "+s.name:"";return t.stylize("[Function"+v+"]","special")}if(y(s))return t.stylize(RegExp.prototype.toString.call(s),"regexp");if(x(s))return t.stylize(Date.prototype.toString.call(s),"date");if(S(s))return l(s)}var b,T="",w=!1,E=["{","}"];(h(s)&&(w=!0,E=["[","]"]),k(s))&&(T=" [Function"+(s.name?": "+s.name:"")+"]");return y(s)&&(T=" "+RegExp.prototype.toString.call(s)),x(s)&&(T=" "+Date.prototype.toUTCString.call(s)),S(s)&&(T=" "+l(s)),0!==a.length||w&&0!=s.length?i<0?y(s)?t.stylize(RegExp.prototype.toString.call(s),"regexp"):t.stylize("[Object]","special"):(t.seen.push(s),b=w?function(e,t,s,i,n){for(var r=[],a=0,o=t.length;a60)return s[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+s[1];return s[0]+t+" "+e.join(", ")+" "+s[1]}(b,T,E)):E[0]+T+E[1]}function l(e){return"["+Error.prototype.toString.call(e)+"]"}function u(e,t,s,i,n,r){var a,o,l;if((l=Object.getOwnPropertyDescriptor(t,n)||{value:t[n]}).get?o=l.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):l.set&&(o=e.stylize("[Setter]","special")),M(i,n)||(a="["+n+"]"),o||(e.seen.indexOf(l.value)<0?(o=d(s)?c(e,l.value,null):c(e,l.value,s-1)).indexOf("\n")>-1&&(o=r?o.split("\n").map(function(e){return" "+e}).join("\n").substr(2):"\n"+o.split("\n").map(function(e){return" "+e}).join("\n")):o=e.stylize("[Circular]","special")),g(a)){if(r&&n.match(/^\d+$/))return o;(a=JSON.stringify(""+n)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(a=a.substr(1,a.length-2),a=e.stylize(a,"name")):(a=a.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),a=e.stylize(a,"string"))}return a+": "+o}function h(e){return Array.isArray(e)}function m(e){return"boolean"==typeof e}function d(e){return null===e}function f(e){return"number"==typeof e}function p(e){return"string"==typeof e}function g(e){return void 0===e}function y(e){return v(e)&&"[object RegExp]"===b(e)}function v(e){return"object"==typeof e&&null!==e}function x(e){return v(e)&&"[object Date]"===b(e)}function S(e){return v(e)&&("[object Error]"===b(e)||e instanceof Error)}function k(e){return"function"==typeof e}function b(e){return Object.prototype.toString.call(e)}function T(e){return e<10?"0"+e.toString(10):e.toString(10)}e.debuglog=function(t){if(g(i)&&(i=process.env.NODE_DEBUG||""),t=t.toUpperCase(),!n[t])if(new RegExp("\\b"+t+"\\b","i").test(i)){var s=process.pid;n[t]=function(){var i=e.format.apply(e,arguments);console.error("%s %d: %s",t,s,i)}}else n[t]=function(){};return n[t]},e.inspect=r,r.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},r.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},e.isArray=h,e.isBoolean=m,e.isNull=d,e.isNullOrUndefined=function(e){return null==e},e.isNumber=f,e.isString=p,e.isSymbol=function(e){return"symbol"==typeof e},e.isUndefined=g,e.isRegExp=y,e.isObject=v,e.isDate=x,e.isError=S,e.isFunction=k,e.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},e.isBuffer=Ks;var w=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function M(e,t){return Object.prototype.hasOwnProperty.call(e,t)}e.log=function(){var t,s;console.log("%s - %s",(t=new Date,s=[T(t.getHours()),T(t.getMinutes()),T(t.getSeconds())].join(":"),[t.getDate(),w[t.getMonth()],s].join(" ")),e.format.apply(e,arguments))},e.inherits=Ys.exports,e._extend=function(e,t){if(!t||!v(t))return e;for(var s=Object.keys(t),i=s.length;i--;)e[s[i]]=t[s[i]];return e};var E="undefined"!=typeof Symbol?Symbol("util.promisify.custom"):void 0;function A(e,t){if(!e){var s=new Error("Promise was rejected with a falsy value");s.reason=e,e=s}return t(e)}e.promisify=function(e){if("function"!=typeof e)throw new TypeError('The "original" argument must be of type Function');if(E&&e[E]){var s;if("function"!=typeof(s=e[E]))throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(s,E,{value:s,enumerable:!1,writable:!1,configurable:!0}),s}function s(){for(var t,s,i=new Promise(function(e,i){t=e,s=i}),n=[],r=0;r>>32-t},rotr:function(e,t){return e<<32-t|e>>>t},endian:function(e){if(e.constructor==Number)return 16711935&ei.rotl(e,8)|4278255360&ei.rotl(e,24);for(var t=0;t0;e--)t.push(Math.floor(256*Math.random()));return t},bytesToWords:function(e){for(var t=[],s=0,i=0;s>>5]|=e[s]<<24-i%32;return t},wordsToBytes:function(e){for(var t=[],s=0;s<32*e.length;s+=8)t.push(e[s>>>5]>>>24-s%32&255);return t},bytesToHex:function(e){for(var t=[],s=0;s>>4).toString(16)),t.push((15&e[s]).toString(16));return t.join("")},hexToBytes:function(e){for(var t=[],s=0;s>>6*(3-n)&63)):t.push("=");return t.join("")},base64ToBytes:function(e){e=e.replace(/[^A-Z0-9+\/]/gi,"");for(var t=[],s=0,i=0;s>>6-2*i);return t}},si.exports=ei;var ii={utf8:{stringToBytes:function(e){return ii.bin.stringToBytes(unescape(encodeURIComponent(e)))},bytesToString:function(e){return decodeURIComponent(escape(ii.bin.bytesToString(e)))}},bin:{stringToBytes:function(e){for(var t=[],s=0;s>5]|=128<<24-n%32,i[15+(n+64>>>9<<4)]=n;for(var h=0;h>>31}var x=(a<<5|a>>>27)+u+(r[y]>>>0)+(y<20?1518500249+(o&c|~o&l):y<40?1859775393+(o^c^l):y<60?(o&c|o&l|c&l)-1894007588:(o^c^l)-899497514);u=l,l=c,c=o<<30|o>>>2,o=a,a=x}a+=m,o+=d,c+=f,l+=p,u+=g}return[a,o,c,l,u]}(i));return n&&n.asBytes?r:n&&n.asString?s.bytesToString(r):e.bytesToHex(r)};i._blocksize=16,i._digestsize=20,ti.exports=i}();var ri=ti.exports;const ai=({page:e,backgroundImage:t,detection:s,imageSize:i,position:n})=>{const r=(s.phi2-s.phi1)/s.interval,a=i.height/s.interval,o=e.systems[e.systems.length-1],c=n?n.y:(o?o.top+o.height:0)+4,l=n?n.x:4,u=[0,...Array(s.middleRhos.length-1).fill(0).map((e,t)=>(s.middleRhos[t]+s.middleRhos[t+1])/2/s.interval)],h=[r],m=u.map((e,t)=>new Staff({top:e,height:(u[t+1]||a)-e,staffY:s.middleRhos[t]/s.interval-e,measureBars:h})),d={x:-s.phi1/s.interval,y:0,width:i.width/s.interval,height:i.height/s.interval};return new System({staves:m,left:l,top:c,width:r,backgroundImage:t,imagePosition:d,measureBars:h})};async function oi(e,{format:t="webp",maxHeight:s=1080,quality:i=80}={}){let n=await(async e=>"string"==typeof e?/^https?:\/\//.test(e)?(await x.default(e,{responseType:"buffer",decompress:!0,https:{rejectUnauthorized:!1}})).body:/^data:image\//.test(e)?Buffer.from(e.split(",")[1],"base64"):Buffer.from(e):e)(e);const r=await new Promise(e=>{v.default(n).resize({width:s,height:s,fit:"inside",withoutEnlargement:!0}).toFormat(t,{quality:i}).toBuffer((t,s)=>{e(s)})});return{buffer:r,filename:`${y.default.ArrayBuffer.hash(r)}.${t}`}}globalThis.OffscreenCanvas=globalThis.OffscreenCanvas||c.Canvas,globalThis.Image=globalThis.Image||c.Image,globalThis.btoa=globalThis.btoa||(e=>Buffer.from(e,"binary").toString("base64"));const ci=32,li={viewportHeight:256,viewportUnit:8},ui=192,hi=8,mi={viewportHeight:192,viewportUnit:8};const di=e=>Promise.all(e.map(e=>e())),fi=async(e,t,{paddingLeft:s=0,scaling:i=1,spec:n})=>{if(!e||!e.backgroundImage)return null;const r=e.staves[t];if(!r)return null;const a=n.viewportHeight/n.viewportUnit/2,o=e.imagePosition.width*n.viewportUnit,l=e.imagePosition.height*n.viewportUnit,u=e.imagePosition.x*n.viewportUnit+s,h=(e.imagePosition.y-(r.top+r.staffY-a))*n.viewportUnit,m=new c.Canvas(Math.round(o+u)*i,n.viewportHeight*i),d=m.getContext("2d");return d.fillStyle="white",d.fillRect(0,0,m.width,m.height),d.drawImage(await c.loadImage(e.backgroundImage),u*i,h*i,o*i,l*i),m};async function pi({system:e,staff:t,staffIndex:s}){const i=await fi(e,s,{paddingLeft:ci,spec:mi});t.backgroundImage=i.toBufferSync("png"),t.imagePosition={x:-32/mi.viewportUnit,y:t.staffY-mi.viewportHeight/2/mi.viewportUnit,width:i.width/mi.viewportUnit,height:i.height/mi.viewportUnit}}async function gi({system:e,staff:t,staffIndex:s,gaugeImage:i,pyClients:n}){const r=(await fi(e,s,{paddingLeft:ci,spec:li,scaling:2})).toBufferSync("png"),a=(e.middleY-(t.top+t.staffY))*li.viewportUnit+li.viewportHeight/2,{buffer:o,size:c}=await n.predictScoreImages("gaugeRenderer",[r,i,a]);t.backgroundImage=o,t.imagePosition={x:-32/li.viewportUnit,y:t.staffY-c.height/2/li.viewportUnit,width:c.width/li.viewportUnit,height:c.height/li.viewportUnit},t.maskImage=null}async function yi({staff:e,staffIndex:t,maskImage:s}){const i=await c.loadImage(s);e.maskImage=s,e.imagePosition={x:-32/hi,y:e.staffY-ui/2/hi,width:i.width/hi,height:i.height/hi}}async function vi({score:e,staffIndex:t,system:s,staff:i,graph:n}){n.offset(-32/mi.viewportUnit,0),s.assignSemantics(t,n),i.assignSemantics(n),i.clearPredictedTokens(),e.assembleSystem(s,e.settings?.semanticConfidenceThreshold||1)}function xi(e,t){[[e.source,"url"],...e.systems.map(e=>[[e,"backgroundImage"],...e.staves.map(e=>[[e,"backgroundImage"],[e,"maskImage"]]).flat()]).flat()].map(([e,s])=>{e[s]=t(e[s])})}class OMRProgress{constructor(e){this.state={},this.onChange=e}setTotal(e,t){this.state[e]=this.state[e]||{total:t,finished:0}}increase(e,t=1){(this.state[e]||{finished:0}).finished+=t,this.onChange(this.state)}}const Si=new l.WeakLRUCache,ki={get:async e=>Si.getValue(e),async set(e,t){Si.setValue(e,t)}},bi=async e=>{if(e instanceof Buffer||"string"==typeof e&&(/^https?:\/\//.test(e)||/^data:image\//.test(e))){return`data:image/webp;base64,${(await oi(e)).buffer.toString("base64")}`}return e},Ti=e=>{const t=Math.random();let s=0;for(let i=0;it)return i;return e.length-1},wi=(e,t=.9)=>{const s=e.map(e=>Math.log(e)*t).map(Math.exp),i=s.reduce((e,t)=>e+t,0);return s.map(e=>e/i)},Mi=e=>{if(!e.predisposition?.divisionVector&&!e.predisposition?.dotsVector)return e;const t=e.predisposition?.divisionVector?wi(e.predisposition.divisionVector):null,s=e.predisposition?.dotsVector?wi(e.predisposition.dotsVector):null;return new EventTerm({...e,predisposition:{...e.predisposition,divisionVector:t,dotsVector:s}})};class MeasureRectification{constructor(e){Object.assign(this,e)}toString(){return this.events.map(e=>{if(!e)return"";const{division:t="",dots:s=""}=e;return`${t}|${s}`}).join(",")}static default(e){return new MeasureRectification({events:e.map(e=>{if(!e.predisposition?.divisionVector&&!e.predisposition?.dotsVector)return null;const t=e.predisposition.divisionVector?e.division:void 0,s=e.predisposition.dotsVector?e.dots:void 0;return{id:e.id,division:t,dots:s}})})}static roll(e){return new MeasureRectification({events:e.map(e=>{if(!e.predisposition?.divisionVector&&!e.predisposition?.dotsVector)return null;let t,s;return e.predisposition.divisionVector&&(t=Ti(e.predisposition.divisionVector)),e.predisposition.dotsVector&&(s=Ti(e.predisposition.dotsVector)),{id:e.id,division:t,dots:s}})})}}const Ei=new l.WeakLRUCache,Ai={get:async e=>Ei.getValue(e),async set(e,t){Ei.setValue(e,t)},batchGet:async e=>e.map(e=>Ei.getValue(e))};var Ni;!function(e){e[e.ErrorOnly=0]="ErrorOnly",e[e.NotFine=1]="NotFine",e[e.Imperfect=2]="Imperfect"}(Ni||(Ni={}));const Ii=async(e,t,s,i,n=Ni.NotFine,r=0,a)=>{const o=e.filter(({evaluation:e})=>!e||((e,t)=>{switch(t){case Ni.ErrorOnly:return e.error;case Ni.Imperfect:return!e.perfect}return!e.fine})(e,n));s?.write(".".repeat(o.length)),s?.write("\b".repeat(o.length));const c=o.length;let l=0;for(const e of o){const s=e.current.deepCopy();s.staffGroups=e.current.staffGroups;const n=await Ts(s,{picker:e.picker,...i});s.applySolution(n);const o=qe(s),u=!e.evaluation||o.fine>e.evaluation.fine||o.qualityScore>e.evaluation.qualityScore&&o.fine===e.evaluation.fine;u&&(e.evaluation=o,Object.assign(e.current,s)),t(e.current,o,u),l++,a?.(e.current,o,u,{pass:r,remaining:c-l,total:c})}return o.length&&s?.write("\n"),o.length};globalThis.btoa=globalThis.btoa||(e=>Buffer.from(e,"binary").toString("base64"));const Ci=parseInt(process.env.RECTIFICATION_SEARCH_ITERATIONS||"30"),Oi=parseInt(process.env.BASE_QUOTA_FACTOR||"40"),Bi=parseInt(process.env.RECTIFICATION_QUOTA_FACTOR||"80"),_i=(e,t,s)=>Math.min(Math.ceil((e+1)*t*Math.log(e+2)),Math.ceil(s*Math.min(1,(24/(e+1))**2)));async function Ri(e,{solver:t,quotaMax:s=1e3,quotaFactor:i=Oi,solutionStore:n=Ai,ignoreCache:r=!1,logger:a}={}){let o=0,c=0;return a?.info(`[solveMeasures] begin, measure total: ${e.length}.`),await Promise.all(e.map(async l=>{if(!r){const e=await n.get(l.regulationHash);if(e)return l.applySolution(e),void++o}const u=_i(l.events.length,i,s);await l.regulate({policy:"equations",quota:u,solver:t});const h=qe(l);h.error||n.set(l.regulationHash0,{...l.asSolution(),priority:-l?.solutionStat?.loss}),h.perfect&&++c,a?.info(`[solveMeasures] measure[${l.measureIndex}/${e.length}] regulated: ${h.perfect?"solved":h.error?"error":"issue"}, ${l.regulationHash}`)})),a?.info(`[solveMeasures] ${o}/${e.length} cache hit, ${c} solved.`),{cached:o,computed:e.length-o,solved:c}}const Fi=async(e,{solver:t,quotaMax:s=4e3})=>{let i=qe(e),n=e.asSolution();const r=_i(e.events.length,Bi,s);let a=0;for(const s of function*(e){const t=new Set,s=MeasureRectification.default(e.events);t.add(s.toString()),yield s;let i=0,n=e.events;for(;i<100;){i&&i%10==0&&(n=n.map(Mi));const e=MeasureRectification.roll(n),s=e.toString();t.has(s)?++i:(i=0,t.add(s),yield e)}}(e)){const o=await Re.regulateMeasureWithRectification(e,s,{solver:t,quota:r}),c=e.deepCopy();c.applySolution(o);const l=qe(c);if((l.perfect>i.perfect||l.error=i.perfect&&o.priority>n.priority)&&(i=l,n=o),l.perfect)break;if(++a,a>Ci)break}return n};const Pi=async(e,{solver:t,solutionStore:s=Ai,logger:i,quotaMax:n=240,quotaFactor:r=16})=>{e.assemble();const a=e.spartito||e.makeSpartito(),o=a.measures.filter(e=>!e.regulated);await Ri(o,{solver:t,quotaMax:n,quotaFactor:r,solutionStore:s,logger:i}),console.assert(e.spartito?.regulated,"doSimpleRegulate: regulation incomplete:",a.measures.filter(e=>!e.regulated).length)};console.info("%cstarry-omr%c v1.0.0 2026-07-24T04:03:31.660Z","color:#fff; background-color: #555;padding: 5px;border-radius: 3px 0 0 3px;","color: #fff; background-color: #007dc6;padding: 5px;border-radius: 0 3px 3px 0;"),exports.DefaultSolutionStore=Ai,exports.PyClients=class PyClients{constructor(e,t=console){this.options=e,this.logger=t,this.clients=new Map}async getClient(e){if(this.clients.has(e))return this.clients.get(e);const[t,s,i]=Us(),n=this.options[e];if(!n)throw new Error(`no config for client \`${e}\` found`);try{if("string"==typeof n){const e=new ZeroClient;e.bind(n),s(e)}else{const{scriptPath:e,...t}=n,i=new PyProcessor(e,t,this.logger);await i.bind(`${await Xs()}`),s(i)}this.logger.info(`PyClients: ${e} started`)}catch(t){this.logger.error(`PyClients: ${e} start fail: ${JSON.stringify(t)}`),i(t)}return this.clients.set(e,t),t}async checkHost(e){return(await this.getClient(e)).request("checkHost")}async warmup(){const e=Object.keys(this.options);await Promise.all(e.map(e=>this.getClient(e)))}async predictScoreImages(e,...t){const s=e.split("$")[0],i=await this.getClient(s);let n=null;this.logger.info(`[predictor]: ${e} py start..`);const r=Date.now();switch(e){case"layout":n=await i.request("predictDetection",t);break;case"layout$reinforce":n=await i.request("predictReinforce",t);break;case"gauge":case"mask":n=await i.request("predict",t,{by_buffer:!0});break;case"semantic":case"textLoc":n=await i.request("predict",t);break;case"textOcr":case"brackets":case"topo":case"gaugeRenderer":case"jianpu":n=await i.request("predict",...t);break;default:this.logger.error(`[predictor]: no predictor ${e}`)}return this.logger.info(`[predictor]: ${e} py duration: ${Date.now()-r}ms`),n}},exports.abstractOMRStats=e=>{const{costTotal:t,pagesCostTotal:s,pagesTotal:i}=e.reduce((e,t)=>({costTotal:e.costTotal+t.cost,pagesCostTotal:e.pagesCostTotal+t.pagesCost,pagesTotal:e.pagesTotal+t.pages}),{costTotal:0,pagesCostTotal:0,pagesTotal:0});return{costTotal:t,costPerPage:i?t/i:null,pagesTotal:i,scoreN:e.length}},exports.abstractRegulationBeadStats=e=>{const{totalCost:t,pickerCost:s,measureN:i,timeN:n}=e.reduce((e,t)=>({totalCost:e.totalCost+t.totalCost,pickerCost:e.pickerCost+t.pickerCost,measureN:e.measureN+t.measures.computed,timeN:e.timeN+t.measures.tryTimes}),{totalCost:0,pickerCost:0,measureN:0,timeN:0}),r=i>0?t/i:null,a=n>0?t/n:null,{cached:o,simple:c,computed:l,tryTimes:u,solved:h,issue:m,fatal:d}=e.reduce((e,t)=>({cached:e.cached+t.measures.cached,simple:e.simple+t.measures.simple,computed:e.computed+t.measures.computed,tryTimes:e.tryTimes+t.measures.tryTimes,solved:e.solved+t.measures.solved,issue:e.issue+t.measures.issue,fatal:e.fatal+t.measures.fatal}),{cached:0,simple:0,computed:0,tryTimes:0,solved:0,issue:0,fatal:0});return{scoreN:e.length,totalCost:t,pickerCost:s,costPerMeasure:r,costPerTime:a,cached:o,simple:c,computed:l,tryTimes:u,solved:h,issue:m,fatal:d}},exports.abstractRegulationStats=e=>{const{baseCostTotal:t,topoCostTotal:s,baseMeasures:i,topoMeasures:n}=e.reduce((e,t)=>({baseCostTotal:e.baseCostTotal+t.baseCost,topoCostTotal:e.topoCostTotal+t.topoCost,baseMeasures:e.baseMeasures+t.baseMeasures.computed,topoMeasures:e.topoMeasures+(t.topoMeasures.solved+t.topoMeasures.issue+t.topoMeasures.fatal)}),{baseCostTotal:0,topoCostTotal:0,baseMeasures:0,topoMeasures:0}),r=i>0?t/i:null,a=n>0?s/n:null,{cached:o,baseComputed:c,baseSolved:l,topoSolved:u,topoIssue:h,topoFatal:m}=e.reduce((e,t)=>({cached:e.cached+t.baseMeasures.cached,baseComputed:e.baseComputed+t.baseMeasures.computed,baseSolved:e.baseSolved+t.baseMeasures.solved,topoSolved:e.topoSolved+t.topoMeasures.solved,topoIssue:e.topoIssue+t.topoMeasures.issue,topoFatal:e.topoFatal+t.topoMeasures.fatal}),{cached:0,baseComputed:0,baseSolved:0,topoSolved:0,topoIssue:0,topoFatal:0});return{scoreN:e.length,baseCostTotal:t,topoCostTotal:s,baseCostPerMeasure:r,topoCostPerMeasure:a,cached:o,baseComputed:c,baseSolved:l,topoSolved:u,topoIssue:h,topoFatal:m}},exports.constructSystem=ai,exports.convertImage=oi,exports.doRegulate=async(e,{pyClients:t,solver:s,solutionStore:i=Ai,onSaveIssueMeasure:n})=>{t?.logger?.info(`[doRegulate] score: ${e.title}`),e.spartito=void 0,e.assemble();const r=e.makeSpartito();r.measures.forEach(t=>e.assignBackgroundForMeasure(t));const a=Date.now(),o=await Ri(r.measures,{solver:s,quotaMax:1e3,solutionStore:i,logger:t?.logger}),c=Date.now(),l=t?await async function(e,{pyClients:t,solver:s,solutionStore:i=Ai,onSaveIssueMeasure:n}){t.logger.info(`[RegulateWithTopo] regulate score: ${e.title}, measures: ${e.spartito.measures.length}`);const r=e.spartito.measures.filter(e=>!qe(e).perfect);if(t.logger.info(`[RegulateWithTopo] basic issues: ${r.length}`),0===r.length)return{solved:0,issue:0,fatal:0};const a=[].concat(...r.map(e=>e.createClusters())),o=await t.predictScoreImages("topo",{clusters:a});console.assert(o.length===a.length,"prediction number mismatch:",a.length,o.length),a.forEach((e,t)=>{const s=o[t];console.assert(s,"no result for cluster:",e.index),e.assignPrediction(s)}),r.forEach(e=>{const t=a.filter(t=>t.index===e.measureIndex);e.applyClusters(t);const{matrixH:s}=Re.estiamteMeasure(e);s.forEach((t,s)=>t.forEach((t,i)=>{e.matrixH[s][i]=.9*e.matrixH[s][i]+t*(1-.9)}))});const c=[],l=[];await Promise.all(r.map(async e=>{const r=e.regulationHash0,a=await Fi(e,{solver:s});a&&(e.applySolution(a),i.set(r,a),i.set(e.regulationHash,e.asSolution()),t.logger.info(`[RegulateWithTopo] solutionStore set: ${e.measureIndex}, ${r}, ${e.regulationHash}`));const o=qe(e);n?.({measureIndex:e.measureIndex,measure:new EditableMeasure(e),status:o.error?2:1}),o.perfect?c.push(e.measureIndex):o.error&&l.push(e.measureIndex)}));const u=r.length-c.length-l.length;return t.logger.info(`[RegulateWithTopo] score: ${e.title}, solved/issue/fatal: ${c.length}/${u}/${l.length}`),c.length&&t.logger.info(`[RegulateWithTopo] solved measures: ${c.join(", ")}`),l.length&&t.logger.info(`[RegulateWithTopo] error measures: ${l.join(", ")}`),{solved:c.length,issue:u,fatal:l.length}}(e,{pyClients:t,solver:s,solutionStore:i,onSaveIssueMeasure:n}):void 0;return{baseCost:c-a,topoCost:Date.now()-c,baseMeasures:o,topoMeasures:l,qualityScore:r.qualityScore}},exports.doSimpleRegulate=Pi,exports.encodeFindResource=function(e){const t=e.spartito.perform(),s=e.systems.map(e=>e.staves.map(e=>e?.maskImage)).flat(),i=s.filter(Boolean).length>s.length/2,n={},r=new Map,a=new Map,o=new Map;n.unitSize=e.unitSize,n.title={title:e.title};const c=e.pages[0].tokens;if(Array.isArray(c)&&c.length>0){const[t,...s]=c.filter(e=>e.type===Z.Text&&"Title"===e.textType).sort((e,t)=>t.fontSize-e.fontSize);t&&(n.title.title=t.text,n.title.t={size:t.fontSize}),s?.length>0&&(s.sort((e,t)=>e.y-t.y),n.title.subtitle=s.map(e=>e.text).join("\n"),n.title.s={size:s.reduce((e,t)=>e+t.fontSize,0)/s.length});const i=c.filter(t=>t.type===Z.Text&&"Author"===t.textType&&t.x>e.pages[0].width/2);i.length>0&&(n.title.composer=i.map(e=>e.text).join("\n"),n.title.c={size:i.reduce((e,t)=>e+t.fontSize,0)/i.length})}if(n.page={w:e.pages[0].width,h:e.pages[0].height},n.pages=e.pages.map(t=>{const s=t.source.dimensions.width/t.source.interval,i=t.source.dimensions.height/t.source.interval,[n,r,a,o]=t.source.matrix;return{src:t.source.url,w:s,h:i,x:0,y:0,l1:e.systems.indexOf(t.systems[0]),ls:t.systems.length,matrix:[n,r,a,o,-.5*n*s+-.5*i*a+.5*t.width||0,-.5*r*s+-.5*i*o+.5*t.height||0]}}),n.parts=[],n.lines=[],i){const t=e.staffLayout.partGroups.map(e=>e.range[0]===e.range[1]?[e.range[0]]:e.range),s=e.getTokenMap(),i=[];for(const[c,l]of t.entries()){const u=t.slice(0,c).flat().length,h={measures:[]};e.systems.forEach((n,m)=>{const d=n.staves.slice(),f=t.flat().map(e=>1<m+1&&(p[m+1]=p[m]);continue}const g=[];for(const e of l){const t=f[e];t&&g.push(...t.measures[m].getChords().map(t=>({chord:t,staffIndexInPart:e-u})))}let y=0;const v=p[m],x=[];g.forEach(({staffIndexInPart:l,chord:u})=>{const h=[];let f=u.tip?u.tip.x:u.right-u.left/2;u.noteIds.forEach((e,i)=>{const n=s.get(e),m=`n_${t.length>1?c+"_":""}${d}_${y}`;y++,r.set(n.id,m),a.set(n.id,(n.left+n.right)/2-v),o.set(n.id,l+1),h.push({line:2*-u.ys[i],id:m,staff:l+1,x:(n.left+n.right)/2-f})}),i[d]=i[d]||[],i[d].push(f-v);const p=e.spartito.measures[n.headMeasureIndex+m].events.filter(e=>e.noteIds.some(e=>u.noteIds.includes(e)));x.push({elems:h,x:f-v,type:2**u.division,...p.some(e=>e.grace)?{grace:{}}:{}})}),h.measures[d]={w:p[m+1]-p[m],staves:l.length,notes:x}}});let m=null;e.spartito.measures.forEach((s,i)=>{const n=e.spartito.measureIndexMapping[i],r=s.contexts.flat().filter(e=>Ns.includes(e.tokenType)&&l.includes(e.staff)).map(e=>{const s=t.find(t=>t.includes(e.staff));return{x:e.x,clef:Is(e),staff:s.indexOf(e.staff)+1,tick:e.tick}});r.length>0&&h.measures[n]&&(h.measures[n].clefs=r);const a=s.basics.filter((e,t)=>1<0&&(n.parts[c]=h)}e.systems.forEach((s,i)=>{const r=[],a=s.staves[0],o=s.staves[s.staves.length-1],c=a.top+a.staffY-2,l=o.top+o.staffY-2,u=s.staves.slice(),h=t.flat().map(e=>!(1<h.find(t=>t?.index===e)||null),a=t.map((e,t)=>[t,!e]).filter(e=>e[1]);let o=null;a.length>0&&(o=Object.fromEntries(a.map(e=>[e[0]+1,{hide:e[1]}])));let l=0,u=0;const d=t.filter(e=>!!e);if(d.length>0){const e=d[0],t=d[d.length-1],s=e.top+e.staffY-2,i=t.top+t.staffY-2;l=s-c,u=i-s+4}const{list:f,last:p}=t.reduce((e,t,s)=>(null===e.last||null===t?0===s&&l>0?e.list.push(l-4):e.list.push(0):e.list.push(t.top+t.staffY-(e.last.top+e.last.staffY)-4),e.last=t||e.last,e),{last:m,list:[]});m=p;const g=t.map(e=>{if(e?.maskImage){const t=e.imagePosition;return{src:e.maskImage,x:t.x,y:s.top+e.top+t.y-(s.top+e.top+e.staffY-2),w:t.width,h:t.height}}return null}),y=e.spartito.measures[s.headMeasureIndex];r.push({distances:f,imgs:g,y:l,staves:n.length,parti:i,height:u,...o?{details:o}:{},clef:Object.fromEntries(e.spartito.measures[s.headMeasureIndex]?.contexts.flat().filter(e=>Ns.includes(e.tokenType)&&n.includes(e.staff)).map(e=>[e.staff,Is(e)])),fifths:y.basics.filter((e,t)=>1<e.spartito.measureIndexMapping[s.headMeasureIndex+i]).filter(e=>Number.isFinite(e));n.lines[i]={m1:d[0],m2:d.length>0?d[d.length-1]+1:void 0,x:s.left,y:s.top+c,w:s.measureBars[s.measureBars.length-1],h:l-c+4,lineStaves:r}});const c={0:"default",1:"brace",2:"bracket",3:"square"},l=it(e.staffLayoutCode),u=l.partGroups.map(e=>({sort:e.range[0],part:e})).sort((e,t)=>e.sort-t.sort).map(e=>e.part);n.groups=l.groups.filter(e=>0!==e.group.type).map((e,t)=>({type:c[e.group.type],p1:u.findIndex(t=>t.range.includes(e.range[0])),p2:u.findIndex(t=>t.range.includes(e.range[e.range.length-1]))})).filter(e=>"default"!==e.type)}let l;if(t&&(n.measInfo=t.notation.measures.map((e,t)=>{const s=new Map;return e.notes.forEach(e=>{s.set(e.tick,[...s.get(e.tick)||[],a.get(e.id)])}),Array.from(s.entries()).sort((e,t)=>+e[0]-t[0]).reduce((e,t,s)=>{const i=t[1].find(t=>t>e.last)||t[1][0];return e.list.push(i),e.last=i,e},{last:null,list:[]}).list.filter(Number.isFinite)})),t){l={};const s=new Map;let i,n;t.notation.measures.forEach((e,t)=>{const{numerator:s,denominator:r}=e.timeSignature;l.beats||l.beatsUnit||(l.beats=s,l.beatsUnit=r,i=s,n=r),l.beatInfos=l.beatInfos||[],i===s&&n===r||(i=s,n=r,l.beatInfos.push({tick:e.tick,beats:s,beatsUnit:r})),l.tempos=l.tempos||[],e.events.forEach(t=>{"meta"===t.data.type&&"setTempo"===t.data.subtype&&l.tempos.push({tick:e.tick,tempo:t.data.microsecondsPerBeat})})}),l.measures=t.notation.measures.reduce((e,t,i)=>{const n=Array.from(new Set(t.notes.map(e=>e.tick))).sort((e,t)=>e-t);return t.notes.forEach(e=>{s.set(e.id,n.indexOf(e.tick))}),e[t.tick]={measure:i,duration:t.duration,note_ticks:n},e},{}),l.measureInfos=t.notation.measures.map((e,t)=>({number:String(t+1),fifths:e.keySignature,beats:e.timeSignature.numerator,beatUnit:e.timeSignature.denominator}));const a=t.notation.toPerformingMIDI(t.notation.measures.map((e,t)=>t+1)).tracks,{partGroups:c}=e.staffLayout;let u=a.map((t,s)=>{const i=c[s].key;let n;switch(i){case"vi":case"vi1":case"vi2":n=40;break;case"viola":n=42;break;case"vo":n=55;break;case"basso":n=71;break;default:n=0}return{program:n,channel:s,name:e.instrumentDict[i]??"Piano",track:t}});if(c.some(e=>e.group.grand)){const t=/l\.?h\.?|左手|left hand/i,s=/r\.?h\.?|右手|right hand/i,i=Object.entries(e.instrumentDict).filter(([e,i])=>t.test(i)||s.test(i)).map(([e,s])=>({key:e,hand:t.test(s)?"left":"right"}));let n,r=null;if(2===i.length&&i[0].hand!==i[1].hand){const t=i.find(e=>"left"===e.hand),s=i.find(e=>"right"===e.hand);r=[e.staffLayout.staffIds.findIndex(e=>e===s?.key),e.staffLayout.staffIds.findIndex(e=>e===t?.key)],n=c.findIndex(e=>e.range[0]<=Math.min(...r)&&e.range[1]>=Math.max(...r))}if(Number.isFinite(n)&&n>-1){const e=u[n],t=[];e.track.forEach(e=>{Number.isFinite(e.staff)&&(t[e.staff]||(t[e.staff]=[]),t[e.staff].push(e)),"meta"===e.type&&t.forEach(t=>{t.push(e)})}),u.splice(n,1,t.filter(Boolean).map(t=>({...e,track:t}))),u=u.flat(),l.rightHandTrack=r[0],l.leftHandTrack=r[1]}else u.sort((e,t)=>e===u[n]?-1:0)}l.tracks=u.map(({program:e,channel:t,name:s})=>({program:e,channel:t,name:s}));const h=u.map(({track:e})=>{const t=new Map;return e.map(e=>{if("noteOn"===e.subtype&&t.set(e.noteNumber,e),"noteOff"===e.subtype){const s=t.get(e.noteNumber);s?.noteNumber===e.noteNumber&&(s.duration=e.ticks-s.ticks)}return e})}),m=new Map(Object.entries(l.measures).map(([e,t])=>[t.measure,+e]));l.events=h.map((e,t)=>e.filter(e=>"channel"===e.type).map(e=>{e?.ids?.[0]&&(e.numId=r.get(e.ids[0]));let i=[0,0,0];switch(e.subtype){case"noteOn":i=[144|e.channel,e.noteNumber,e.velocity];break;case"noteOff":i=[128|e.channel,e.noteNumber,e.velocity?e.velocity:0];break;case"noteAftertouch":i=[160|e.channel,e.noteNumber,e.amount];break;case"controller":i=[176|e.channel,e.controllerType,e.value];break;case"programChange":i=[192|e.channel,e.programNumber,0];break;case"channelAftertouch":i=[208|e.channel,e.amount,0];break;case"pitchBend":i=[224|e.channel,255&e.value,e.value>>7&255];break;default:throw new Error("unhandled event subtype:"+e.subtype)}return{..."noteOn"===e.subtype?{id:r.get(e?.ids?.[0])}:{},tick:e.ticks,channel:e.channel,duration:e.duration,track:t,event:i,elem_ids:e?.ids.map(e=>r.get(e)),measure:e.measure-1,meas_start_tick:m.get(e.measure-1),staff:o.get(e.ids[0]),note:s.get(e.ids[0])}})).flat(1).sort((e,t)=>{for(const s of["tick","measure","track"])if(e[s]!==t[s])return e[s]-t[s];return 0})}return{scoreJson:n,midiJson:l}},exports.evaluateScoreQuality=async(e,t)=>(e.spartito?.regulated||await Pi(e,t),e.spartito.regulated?e.spartito.qualityScore:null),exports.getScoreJsonImages=e=>[...e.pages.map(e=>e?.src),...e.lines.map(e=>e.lineStaves.map(e=>e.imgs)).flat(2).map(e=>e?.src).filter(Boolean)],exports.predictPages=async(e,t,s={outputWidth:1200,pageStore:ki,onReplaceImage:bi})=>{const i=e.logger;s.outputWidth=s.outputWidth||1200,s.pageStore=s.pageStore||ki,s.onReplaceImage=s.onReplaceImage||bi,s.processes=Array.isArray(s.processes)&&s.processes.length>0?s.processes:["layout","text","gauge","mask","semantic","brackets"];const n=new OMRProgress(s.onProgress),r=Date.now();t.forEach(e=>{e.layout?.detection?e.layout.detection.areas=e.layout.detection?.areas?.filter(e=>e?.staves?.middleRhos?.length>0):delete e.layout});const a=new Score({title:s?.title,stavesCount:2,paperOptions:{raggedLast:!0,raggedLastBottom:!0},headers:{},instrumentDict:{},settings:{enabledGauge:s.processes.includes("gauge"),semanticConfidenceThreshold:1}});i.info(`[predictor]: download_source_images-${t.length}`);const o=await Promise.all(t.map(e=>c.loadImage(e.url)));i.info(`[predictor]: source_images_downloaded-${t.length}`);const l=o.map((e,s)=>function(e,t){let s=e.height/e.width*t;const i=new c.Canvas(t,s);return i.getContext("2d").drawImage(e,0,0,t,t*e.height/e.width),i}(e,t[s].layout?.sourceSize?.width??e.width));n.setTotal("layout",o.length),n.setTotal("text",o.length);const u=await Promise.all(l.map(async(s,i)=>t[i].layout?!t[i].enableGauge&&t[i]?.layout?.detection?.areas?.length?(await e.predictScoreImages("layout$reinforce",[s.toBufferSync("png")],[t[i].layout]))?.[0]:t[i].layout:(await e.predictScoreImages("layout",[s.toBufferSync("png")]))?.[0]));u.forEach(e=>{e.detection.areas=e.detection?.areas?.filter(e=>e?.staves?.middleRhos?.length>0)});const h=new Map,m=async e=>{const t=await s.onReplaceImage(e);h.set(e,t)};async function d(e,i){const{url:r,key:o,layout:u,enableGauge:h}=t[i],m=ri(JSON.stringify({key:o||r,layout:u,enableGauge:h})),d=await s.pageStore.get(m),f=!s.renew&&(d&&!t[i].renew||!e.detection.areas?.length),p=a.pages[i]=f&&d?S(d,As):new Page({source:{name:o||("string"==typeof r&&/https?:\/\//.test(r)?r:null),size:0,url:r,crop:{unit:"%",x:0,y:0,width:100,height:100},dimensions:e.sourceSize,matrix:[Math.cos(e.theta),-Math.sin(e.theta),Math.sin(e.theta),Math.cos(e.theta),0,0],interval:e.interval,needGauge:t[i].enableGauge},layout:e.detection}),g=f?null:await async function({page:e,score:t,pageCanvas:s}){if(!e?.layout?.areas?.length)return null;e.width=t.pageSize.width/t.unitSize,e.height=t.pageSize.height/t.unitSize;const i=new c.Canvas(s.width,s.height),n=i.getContext("2d");n.save();const{width:r,height:a}=i,[o,l,u,h]=e.source.matrix;n.setTransform(o,l,u,h,-.5*r+.5*o*r+.5*l*a,-.5*a+.5*u*r+.5*h*a),n.drawImage(s,0,0),n.restore();const m=e.source.interval;return e.layout.areas.map((t,i)=>{console.assert(t.staves?.middleRhos?.length,"[shootImageByDetection] empty area:",t);const r=n.getImageData(t.x,t.y,t.width,t.height),a=new c.Canvas(t.width,t.height);a.getContext("2d").putImageData(r,0,0);const o=t.staves,l={width:t.width,height:t.height},u=s.width/2/m,h=s.height/2/m,d={x:(t.x+t.staves.phi1)/m-u+e.width/2,y:t.y/m-h+e.height/2};e.systems[i]=ai({page:e,backgroundImage:a.toBufferSync("png"),detection:o,imageSize:l,position:d})}),i}({score:a,page:p,pageCanvas:l[i]});return n.increase("layout"),{page:p,omit:f,hash:m,correctCanvas:g}}!function(e,t,s){const i=t.filter(e=>e&&e.detection&&e.detection.areas?.length).map((e,t)=>{const s=Math.min(...e.detection.areas.filter(e=>e.staves?.middleRhos?.length).map(e=>e.staves.interval)),i=e.sourceSize;return{...e,index:t,vw:i.width/s,hwr:i.height/i.width}});if(!i.length)throw new Error("empty result");const n=i.sort((e,t)=>t.vw-e.vw)[0],r=Math.max(...i.map(e=>e.hwr));e.unitSize=s/n.vw,e.pageSize={width:s,height:s*r}}(a,u,s.outputWidth);const f=u.reduce((e,t)=>e+(t.detection.areas?.length??0),0),p=u.reduce((e,t)=>e+(t.detection.areas?.reduce?.((e,t)=>e+(t.staves?.middleRhos?.length??0),0)??0),0);n.setTotal("gauge",p),n.setTotal("mask",p),n.setTotal("semantic",p),n.setTotal("brackets",f);const g=[],y=[],v=Date.now();let x=0;for(const r of u.keys()){const o=[],{page:l,correctCanvas:f,omit:p,hash:v}=await d(u[r],r);if(o.push(m(l.source.url)),o.push(...l.systems.map(e=>m(e.backgroundImage))),i.info(`[predictor]: check_cache_pageIndex-${r} omit: ${p}`),p)y.push(r);else{const u=l.systems.map((e,t)=>e.staves.map((s,i)=>({pageIndex:r,systemIndex:t,staffIndex:i,page:l,system:e,staff:s}))).flat(1);await di([async()=>{if(!s.processes.includes("brackets"))return;const t=l.layout,a=l.source.interval,o=Date.now(),u=l.systems.map((e,s)=>{const{x:i,y:n,staves:{middleRhos:r,phi1:o}}=t.areas[s],l=r[0],u=r[r.length-1],h={x:i+o-4*a,y:n+l-4*a,width:8*a,height:u-l+8*a},m=new c.Canvas(64,h.height/a*8);return m.getContext("2d").drawImage(f,h.x,h.y,h.width,h.height,0,0,m.width,m.height),{system:e,buffer:m.toBufferSync("png")}});i.info(`[predictor]: brackets js [pageIndex-${r}] duration: ${Date.now()-o}`);const h=await e.predictScoreImages("brackets",{buffers:u.map(e=>e.buffer)});n.increase("brackets",u.length),u.forEach(({system:e},t)=>{h[t]&&(e.bracketsAppearance=h[t])})},async()=>{if(s.processes.includes("text"))try{const t=Date.now(),o=f.toBufferSync("png"),c=(await e.predictScoreImages("textLoc",[o]))[0].filter(e=>e.score>0);if(c.length>0){const[t]=await e.predictScoreImages("textOcr",{buffers:[o],location:c});l.assignTexts(t.areas,t.imageSize),l.assemble()}if(i.info(`[predictor]: text js [pageIndex-${r}] duration: ${Date.now()-t}`),n.increase("text"),!s.title){const e=a.pages[0].tokens;if(Array.isArray(e)&&e.length>0){const[t]=e.filter(e=>e.type===Z.Text&&"Title"===e.textType).sort((e,t)=>t.fontSize-e.fontSize);t&&(a.title=t.text)}}}catch(e){i.error(`[predictor]: text js [pageIndex-${r}] ${JSON.stringify(e)}`)}},async()=>{var c;await(c=async()=>{if(s.processes.includes("gauge")&&!1!==t[r].enableGauge){const t=await e.predictScoreImages("gauge",await Promise.all(u.map(async({staffIndex:e,system:t})=>{const s=Date.now(),n=await fi(t,e,{paddingLeft:ci,spec:li});return i.info(`[predictor]: gauge js shoot [page-${r}, staff-${e}] duration: ${Date.now()-s}`),n.toBufferSync("png")})));for(const[s,{system:r,staff:a,pageIndex:c,staffIndex:l}]of u.entries()){const u=Date.now();i.info(`[predictor]: gauge js [page-${c}, staff-${l}] start..`),await gi({pyClients:e,system:r,staff:a,staffIndex:l,gaugeImage:t[s].image}),i.info(`[predictor]: gauge js [page-${c}, staff-${l}] duration: ${Date.now()-u}`),n.increase("gauge"),o.push(m(a.backgroundImage))}}else for(const[e,{system:t,staff:s,staffIndex:i}]of u.entries())await pi({system:t,staff:s,staffIndex:i}),o.push(m(s.backgroundImage))},c()),await di([async()=>{if(!s.processes.includes("mask"))return;const t=await e.predictScoreImages("mask",u.map(({staff:e})=>e.backgroundImage));for(const[e,{staff:s,staffIndex:a}]of u.entries()){const c=Date.now();await yi({staff:s,staffIndex:a,maskImage:t[e].image}),i.info(`[predictor]: mask js [page-${r}, ${e}, staff-${a}] duration: ${Date.now()-c}`),n.increase("mask"),o.push(m(s.maskImage))}},async()=>{if(!s.processes.includes("semantic"))return;const t=S(await e.predictScoreImages("semantic",u.map(({staff:e})=>e.backgroundImage)),As);u.forEach(({system:e})=>e.clearTokens());for(const[e,{staffIndex:s,system:o,staff:c}]of u.entries()){const l=Date.now();await vi({score:a,system:o,staff:c,staffIndex:s,graph:t[e]}),i.info(`[predictor]: semantic js [page-${r}, system-${o.index}, staff-${c.index}] duration: ${Date.now()-l}`),n.increase("semantic")}}])}]),++x}g.push(Promise.all(o).then(()=>(xi(l,e=>h.get(e)),i.info(`[predictor]: pageStore set: [${r}]`),s.pageStore.set(v,JSON.stringify(l)))))}const k=Date.now();await Promise.all(g),i.info(`[predictor]: inferenceStaffLayout: ${a.title}, [${a.systems.length}]`),a.inferenceStaffLayout(),i.info(`[predictor]: done: ${a.title}`),a.assemble();const b=Date.now();return{score:a,omitPages:y,stat:{cost:b-r,pagesCost:k-v,pages:x}}},exports.regulateWithBeadSolver=async(e,{logger:t,pickers:s,solutionStore:i=Ai,ignoreCache:n,freshOnly:r,onSaveIssueMeasure:a,onProgress:o,onPassStart:c})=>{e.spartito=void 0,e.assemble();const l=e.makeSpartito();l.measures.forEach(t=>e.assignBackgroundForMeasure(t));const u=Date.now();t?.info(`[regulateWithBeadSolver] begin, measure total: ${l.measures.length}.`,n?"ignoreCache":"",r?"freshOnly":"");const h=l.measures.filter(e=>e.events?.length&&!e.patched).map(e=>({origin:e.deepCopy(),current:e,evaluation:void 0,baseQuality:0}));for(const e of l.measures.filter(e=>e.events?.length)){const t=s.find(t=>t.n_seq>e.events.length+1);t&&await Ms(e,t)}l.rectifyTimeSignatures(t),s.forEach(e=>e.cost=0);const m={cached:0,simple:0,computed:0,tryTimes:0,solved:0,issue:0,fatal:0};if(t?.info("[regulateWithBeadSolver] measures estimation finished."),i&&!n)for(const e of h){const t=await i.get(e.origin.regulationHash0);t&&(e.current.applySolution(t),++m.cached,e.evaluation=qe(e.current),e.baseQuality=e.evaluation.qualityScore)}t?.info("[regulateWithBeadSolver]",`${m.cached}/${h.length}`,"solutions loaded.");const d=t?null:process.stdout;m.cached&&d?.write(`${m.cached}c`),h.forEach(e=>{const i=s.find(t=>t.n_seq>e.current.events.length+1);i?e.picker=i:t?.info(`[regulateWithBeadSolver] measure[${e.current.measureIndex}] size out of range:`,e.current.events.length)});const f=h.filter(e=>e.picker&&(!e.evaluation||!e.evaluation.fine&&!r));f.forEach(e=>{const s=e.current.deepCopy();s.staffGroups=e.current.staffGroups,s.regulate({policy:"simple"});const i=qe(s);(!e.evaluation||i.qualityScore>e.evaluation.qualityScore)&&(e.evaluation=i,Object.assign(e.current,s),i.perfect&&(t?.info(`[regulateWithBeadSolver] measure[${e.current.measureIndex}] regulated by simple policy.`),++m.simple))}),m.computed=f.length-m.simple,m.simple&&d?.write(`${m.simple}s`);const p=(e,s,i)=>{t?.info(`[regulateWithBeadSolver] measure[${e.measureIndex}/${l.measures.length}] regulated${i?"+":"-"}: ${s.qualityScore.toFixed(3)}, ${s.fine?"solved":s.error?"error":"issue"}, ${e.regulationHash}`),d?.write(`[${s.fine?"32":s.error?"31":"33"}m${i?"+":"-"}`)},g=l.measures.length,y=()=>f.filter(e=>!e.evaluation?.fine).length,v=o?(e,t,s,i)=>{o(e,t,s,{pass:i.pass,remaining:y(),total:g})}:void 0;c?.(1,"Imperfect",y()),m.tryTimes+=await Ii(f,p,d,{stopLoss:.05,quotaMax:200,quotaFactor:3,ptFactor:1},Ni.Imperfect,1,v),c?.(2,"NotFine",y()),m.tryTimes+=await Ii(f,p,d,{stopLoss:.08,quotaMax:1e3,quotaFactor:20,ptFactor:1.6},Ni.NotFine,2,v),c?.(3,"ErrorOnly",y()),m.tryTimes+=await Ii(f,p,d,{stopLoss:.08,quotaMax:1e3,quotaFactor:40,ptFactor:3},Ni.ErrorOnly,3,v),f.forEach(({evaluation:e,baseQuality:t,current:s,origin:n})=>{e.fine?++m.solved:e.error?++m.fatal:++m.issue,(e.qualityScore>t||!t)&&(i.set(n.regulationHash0,{...s.asSolution(n),priority:-s?.solutionStat?.loss}),s.regulationHash!==n.regulationHash0&&i.set(s.regulationHash,{...s.asSolution(),priority:-s?.solutionStat?.loss})),e.fine||a?.({measureIndex:s.measureIndex,measure:new EditableMeasure(s),status:e.error?2:1})});const x=Date.now(),S=s.reduce((e,t)=>e+t.cost,0),k=l.qualityScore,b=x-u;return t?.info("[regulateWithBeadSolver] done in ",b,"ms, qualityScore:",k),r&&(m.cached=0),{totalCost:x-u,pickerCost:S,measures:m,qualityScore:k}},exports.replaceScoreJsonImages=(e,t=e=>e)=>{const s=JSON.parse(JSON.stringify(e));return s.pages.forEach(e=>{e?.src&&(e.src=t(e?.src))}),s.lines.forEach(e=>{e.lineStaves.forEach(e=>{e.imgs.forEach(e=>{e?.src&&(e.src=t(e.src))})})}),s},exports.saveEditableMeasures=async(e,t,s,{status:i=2,solutionStore:n}={})=>{e.assemble();const r=e.spartito||e.makeSpartito(),a=t.map(e=>r.measures.find(t=>t.measureIndex===e)).filter(Boolean);if(n){const e=await n.batchGet(a.map(e=>e.regulationHash0));a.forEach((t,s)=>{const i=e[s];i&&t.applySolution(i)})}a.forEach(e=>{s({measureIndex:e.measureIndex,measure:new EditableMeasure(e),status:i})})},exports.starry=As,exports.updateScorePatches=(e,t,s={})=>{if(console.assert(t.every(e=>e.validRegulated),"[updateScorePatches] some measures not valid regulated:",t.filter(e=>!e.validRegulated)),e.patches=t.map(e=>e.createPatch()),s?.solutionStore){e.assemble();const i=e.makeSpartito();t.forEach(e=>{if(s.solutionStore.set(e.regulationHash,{...e.asSolution(),priority:1}),e.regulationHash0!==e.regulationHash){const t=i.measures.find(t=>t.measureIndex===e.measureIndex);s.solutionStore.set(e.regulationHash0,{...e.asSolution(t),priority:1})}})}}; +"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("lodash/pick"),t=require("js-sha1"),s=require("math-erf"),i=require("msgpackr"),n=require("zeromq"),r=require("portfinder"),a=require("python-shell"),o=require("lodash"),c=require("skia-canvas"),l=require("weak-lru-cache"),u=require("spark-md5"),h=require("sharp"),m=require("got");function d(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var f=d(e),p=d(t),g=d(s),y=d(u),v=d(h),x=d(m);globalThis.window=globalThis.window||globalThis,globalThis.btoa=e=>Buffer.from(e,"binary").toString("base64"),globalThis.atob=e=>Buffer.from(e,"base64").toString("binary");const S=(e,t)=>("object"==typeof e&&(e=JSON.stringify(e)),JSON.parse(e,(e,s)=>{if(s&&"object"==typeof s&&s.__prototype){const e=t[s.__prototype];if(e){const{__prototype:t,...i}=s;return new e(i)}}return s})),k=(e,t=null)=>{if((t=t||new Map).get(e))return t.get(e);if(Array.isArray(e)){const s=[];return t.set(e,s),e.forEach(e=>s.push(k(e,t))),s}if(e&&"object"==typeof e){const s={};return t.set(e,s),Object.entries(e).forEach(([e,i])=>s[e]=k(i,t)),Object.setPrototypeOf(s,e.__proto__),s}return e};class SimpleClass{assign(e){e&&Object.assign(this,e)}toJSON(){const e=this.constructor,t=e.serializedKeys||e.blackKeys&&Object.keys(this).filter(t=>!e.blackKeys.includes(t)),s=t?f.default(this,t):this;return{__prototype:e.className,...s}}deepCopy(){return k(this)}}var b={Matrix:function(){}};b.Matrix.create=function(e){return(new b.Matrix).setElements(e)},b.Matrix.I=function(e){for(var t,s=[],i=e;i--;)for(t=e,s[i]=[];t--;)s[i][t]=i===t?1:0;return b.Matrix.create(s)},b.Matrix.prototype={dup:function(){return b.Matrix.create(this.elements)},isSquare:function(){var e=0===this.elements.length?0:this.elements[0].length;return this.elements.length===e},toRightTriangular:function(){if(0===this.elements.length)return b.Matrix.create([]);var e,t,s,i,n=this.dup(),r=this.elements.length,a=this.elements[0].length;for(t=0;t=r&&l[a].push(n);for(o.elements[a]=s,e=a;e--;){for(s=[],t=0;t{const i=Math.round(10*s.x),n=Math.round(10*s.y),r=`${e}|${t}|${s.semantic}|${i}|${n}`,a=p.default.array(r).slice(12),o=globalThis.btoa(String.fromCharCode(...a)).substring(0,11);return s.id=o,o},O=(e,t)=>{const s=Math.round(t.x),i=Math.round(t.y),n=`p-${e}|${t.semantic}|${s}|${i}`,r=p.default.array(n).slice(12),a=globalThis.btoa(String.fromCharCode(...r)).substring(0,11);return t.id=a,a},B=(e,t,s=-1/0)=>Math.max(Math.round(e/t)*t,s),_=(e,t)=>{const s=e.x-t.x,i=e.y-t.y;return Math.sqrt(s*s+i*i)},R=(e,t)=>Number.isInteger(e)&&Number.isInteger(t)?0===t?e:R(t,e%t):(console.error("non-integer gcd:",e,t),1),F=(e,t)=>({numerator:e,denominator:t}),D=(e,t)=>{e=Math.round(e),t=Math.round(t);const s=0!==e?R(e,t):t;return F(e/s,t/s)},q=e=>`${e.numerator}/${e.denominator}`,L=(e,t)=>t?e*t.numerator/t.denominator:e,$=(e,t)=>{const s=[...e].sort((e,s)=>e[t]-s[t]);let i=null,n=null;return s.reduce((e,r,a)=>(n?r[t]-n[t]<.4?i.push(r):(i.length>1&&e.push(i),n=r,i=[r]):(n=r,i=[r]),i.length>1&&a===s.length-1&&e.push(i),e),[])},j=e=>{if(e.length<=1)return[];let t=e.slice(1);const s=N.find(t=>t.includes(e[0].semantic));if(!s)return j(t);const i=t.filter(e=>s.includes(e.semantic));return t=t.filter(e=>!s.includes(e.semantic)),[...i,...j(t)]},H=e=>{const t=new Set(e),s=$(e,"x"),i=[].concat(...s.map(e=>$(e,"y")));return i.forEach(e=>e.sort((e,t)=>t.confidence-e.confidence)),i.forEach(e=>{j(e).forEach(e=>t.delete(e))}),Array.from(t)},W=[0,2,4,5,7,9,11],V=({note:e,alter:t})=>{const s=Math.floor(e/7),i=(e=>{let t=e%7;for(;t<0;)t+=7;return t})(e);return 60+12*s+W[i]+t},G=e=>{const t=Math.max(...e);return e.indexOf(t)};class DummyLogger{debug(...e){}group(...e){}groupCollapsed(...e){}groupEnd(){}info(...e){}warn(...e){}assert(...e){}}const U=1921920,z=e=>1===e?null:(e=>{const t=Math.round(1920*e);return D(t,1920)})(e);var K,Y,Z;!function(e){e[e.PLACE=0]="PLACE",e[e.VERTICAL=1]="VERTICAL",e[e.HORIZONTAL=2]="HORIZONTAL"}(K||(K={}));class Action{constructor(e){Object.assign(this,e)}static P(e){return new Action({type:K.PLACE,e1:e})}static V(e,t,s=1){return new Action({type:K.VERTICAL,e1:s>0?e:t,e2:s>0?t:e})}static H(e,t){return new Action({type:K.HORIZONTAL,e1:e,e2:t})}get id(){switch(this.type){case K.PLACE:return this.e1.toString();case K.VERTICAL:return`${this.e1}|${this.e2}`;case K.HORIZONTAL:return`${this.e1}-${this.e2>=0?this.e2:"."}`}}get events(){return[this.e1,this.e2].filter(Number.isFinite)}}class StageMatrix{static fromNode(e,t){const s=Array(e.stages.length).fill(null).map(()=>Array(e.stages.length).fill(null).map(()=>new Set));e.actions.filter(e=>e.type===K.HORIZONTAL).forEach(t=>{const i=e.stages.findIndex(e=>e.events.includes(t.e1)),n=e.stages.findIndex(e=>e.events.includes(t.e2));console.assert(i>=0&&n>=0,"invalid stages for H action:",e.id,e.stages,t),s[i][n].add(t.e1)}),s[0][e.stages.length-1].add(0);const i=e.stagedEvents,n=t.matrixH[t.matrixH.length-1].filter((e,t)=>!i.has(t)),r=Math.max(0,Math.max(...n)-.01),a=e.actions.filter(e=>e.type===K.HORIZONTAL),o=Object.keys(t.eventMap).map(Number).filter(e=>!a.find(t=>t.e2===e));return e.stages.forEach(i=>{i.events.forEach(n=>{if(n>0){!a.find(e=>e.e1===n)&&t.matrixH[t.matrixH.length-1][n]>=r&&(o.some(e=>t.matrixH[e][n]>0)||s[i.index][e.stages.length-1].add(n))}})}),new StageMatrix({matrix:s})}constructor(e){Object.assign(this,e)}pathOf(e,t,s,i=0){if(this.matrix[e][t].size){const n=[...this.matrix[e][t]][i];if(t===s)return[n];for(let e=t+1;e<=s;++e){const i=this.pathOf(t,e,s);if(i)return[n,...i]}}return null}findDoublePath(e,t){const s=[];for(let i=t;i>=e+1;--i)for(let n=0;nt.forEach(t=>e.forEach(e=>t.delete(e))))}toEquations(e){const t=[];for(let s=1;sr[e]=1),n.forEach(e=>r[e]=-1),t.push(r),this.reducePath(i.length>n.length?i:n)}}}return t}}class PathNode{constructor(e){Object.assign(this,e),console.assert(this.logger,"logger is null:",e)}get actions(){const e=this.parent?this.parent.actions:[];return this.action?[...e,this.action]:e}get id(){return this.actions.map(e=>e.id).sort().join(" ")}get stagedEvents(){const e=new Set;return this.stages&&this.stages.forEach(t=>t.events.forEach(t=>t>=0&&e.add(t))),e}like(e){return e.split(" ").sort().join(" ")===this.id}constructStages(e){this.stages=[{events:[-1]}];for(const t of this.actions)switch(t.type){case K.PLACE:this.stages.unshift({events:[t.e1]});break;case K.VERTICAL:{const e=this.stages.find(e=>e.events.includes(t.e1)),s=this.stages.find(e=>e.events.includes(t.e2));console.assert(e||s,"invalid V action:",this.stages,t),e&&s?(e.events.push(...s.events),s.events=null,this.stages=this.stages.filter(e=>e.events)):e?s||e.events.push(t.e2):s.events.unshift(t.e1)}break;case K.HORIZONTAL:{const s=this.stages.find(e=>e.events.includes(t.e1)),i=this.stages.find(e=>e.events.includes(t.e2));console.assert(s||i,"invalid H action:",this.stages,t);const n=s=>{console.assert(e.eventMap[s],"invalid event id:",t.id,s,e.eventMap);const i=e.eventMap[s].x,n=this.stages.find(t=>t.events.some(t=>t>0&&e.eventMap[t].x<=i)&&t.events.some(t=>t>0&&e.eventMap[t].x>=i));if(n)n.events.push(s);else{const t={events:[s]},n=this.stages.findIndex(t=>-1===t.events[0]||e.eventMap[t.events[0]].x>=i);this.stages.splice(n,0,t)}};s||n(t.e1),i||n(t.e2)}}this.stages.forEach((e,t)=>e.index=t)}constructConstraints(e){const t=Object.keys(e.eventMap).length,s=StageMatrix.fromNode(this,e).toEquations(t),i=Array(t).fill(null).map((t,s)=>e.eventMap[s].duration);this.constraints=s.map(e=>e.map((e,t)=>e*i[t]))}inbalancesConstraints(e){console.assert(this.constraints,"constraints not constructed.");const t=Object.keys(e.eventMap).length,s=Array(t).fill(!0),i=Array(t).fill(!1),n=[];for(const e of this.constraints){const t=e.reduce((e,t)=>e+t,0);if(0!==t){const r=t<0?e.map(e=>-e):e;if(r[0]>0)continue;n.push(r),r.forEach((e,t)=>{i[t]=i[t]||e<0,e&&(s[t]=e<0||i[t])})}}return this.constraints.forEach(e=>{const t=e.reduce((e,t)=>e+t,0);0!==t||e[0]||e.some((e,t)=>e&&!s[t])&&(e.forEach((e,t)=>e&&(s[t]=!1)),n.push(e))}),{ones:s,inbalances:n}}solveEquations({ones:e,inbalances:t}){if(!t.length)return e.map(()=>1);const s=e.map((e,t)=>({fixed:e,i:t})).filter(({fixed:e})=>!e).map(({i:e})=>e).filter(e=>t.some(t=>0!==t[e]));if(!s.length)return e.map(()=>1);const i=s.map(e=>Math.abs(t.find(t=>0!==t[e])[e])),n=new Map;let r=!1;const a=t.map(e=>{const t=e.filter((e,t)=>s.includes(t)),i=-e.reduce((e,t,i)=>e+(s.includes(i)?0:t),0);return{line:t,bias:i}}).filter(({line:e,bias:t})=>{if(e.every(e=>0===e))return!1;const s=e.join(",");return n.has(s)?(r=n.get(s)!==t,!1):(n.set(s,t),!0)});if(r)return null;const o=a.slice(0,s.length),c=a.slice(s.length);if(o.lengths===t?1:s===n?-1:0),bias:0,prior:(i[t]+i[n])/U};o.some(e=>e.line[t]&&e.line[n])&&(r.prior-=10),o.some(e=>1===e.line.filter(Number).length&&(e.line[t]||e.line[n]))&&(r.prior+=1),e.push(r)}e.sort((e,t)=>e.prior-t.prior),o.push(...e.slice(0,s.length-o.length))}const l=o.map(({line:e})=>e),u=o.map(({bias:e})=>e),h=function(e){const t=b.Matrix.create(e).inverse();return null!==t?t.elements:null}(l);if(!h)return this.logger.warn("null invert:",l),null;const m=h.map(e=>e.reduce((e,t,s)=>e+t*u[s],0));if(c.length&&c.some(e=>Math.abs(e.line.reduce((e,t,s)=>e+t*m[s],0))>.001))return null;const d=e.map(()=>1);return s.forEach((e,t)=>d[e]=m[t]),d}optimallySolve(e){const{ones:t,inbalances:s}=this.inbalancesConstraints(e),i=t.map((t,s)=>t?-1:B(e.eventMap[s].shrinkness,.01)).reduce((e,t,s)=>(t>=0&&(e[t]=e[t]||[],e[t].push(s)),e),{}),n=Object.entries(i).sort((e,t)=>Number(t[0])-Number(e[0])).map(e=>e[1]);for(let i=1;i!r.includes(t)),o=this.solveEquations({ones:a,inbalances:s});if(o&&o.every((t,s)=>t<=1&&t>e.eventMap[s].lowWarp))return o}return this.solveEquations({ones:t,inbalances:s})}isConflicted(e){const{ones:t,inbalances:s}=this.inbalancesConstraints(e);for(const i of s){const s=i.reduce((s,i,n)=>s+i*(t[n]||i<=0?1:e.eventMap[n].lowWarp),0);if(s>=0)return i.forEach((t,s)=>{t&&(e.eventTendencies[s]+=t>0?1:-1)}),!0}if(!s.length)return!1;const i=this.solveEquations({ones:t,inbalances:s});return!i||!i.every((t,s)=>t>e.eventMap[s].lowWarp&&t<=1)}getSolution(e){const t=t=>e.eventMap[t.e2]?e.eventMap[t.e2].x+.06*Math.abs(e.eventMap[t.e2].x-e.eventMap[t.e1].x):e.eventMap[t.e1].x+1e4,s=this.actions.filter(e=>e.type===K.HORIZONTAL).sort((e,s)=>t(e)-t(s)),i=s.reduce((e,t)=>({...e,[t.e1]:t.e2}),{}),n=new Set([...Object.keys(i)].map(Number));s.forEach(e=>n.delete(e.e2)),this.stages[0].events.forEach(e=>e>0&&n.add(e));let r=[...n].map(e=>{const t=[e];let s=e;for(;i[s]&&(s=i[s],!(s<0||t.includes(s)));)t.push(s);return t});const a=Object.values(e.eventMap).filter(e=>e.id>0).map(e=>({id:e.id,tick:null,endTick:null,tickGroup:null,timeWarp:null})),o=a.filter(e=>r.some(t=>t.includes(e.id))||s.some(t=>[t.e1,t.e2].includes(e.id))).reduce((e,t)=>({...e,[t.id]:t}),{});this.stages.forEach((e,t)=>e.events.forEach(e=>o[e]&&(o[e].tickGroup=t))),this.stages[0].tick=0,this.stages[0].events.forEach(e=>o[e]&&(o[e].tick=0));const c=this.optimallySolve(e);a.forEach(e=>e.timeWarp=z(c[e.id]));const l=this.stages.slice(0,this.stages.length-1),u=()=>{if(l.every(e=>Number.isFinite(e.tick)))return!1;let t=!1;return s.forEach(s=>{const i=this.stages.find(e=>e.events.includes(s.e1)),n=this.stages.find(e=>e.events.includes(s.e2));Number.isFinite(i.tick)&&!Number.isFinite(n.tick)&&(n.tick=i.tick+L(e.eventMap[s.e1].duration,o[s.e1].timeWarp),n.events.forEach(e=>o[e]&&(o[e].tick=n.tick)),t=!0)}),[...s].reverse().forEach(s=>{const i=this.stages.find(e=>e.events.includes(s.e1)),n=this.stages.find(e=>e.events.includes(s.e2));!Number.isFinite(i.tick)&&Number.isFinite(n.tick)&&(i.tick=n.tick-L(e.eventMap[s.e1].duration,o[s.e1].timeWarp),i.events.forEach(e=>o[e]&&(o[e].tick=i.tick)),t=!0)}),t};for(;u(););console.assert(l.every(e=>Number.isFinite(e.tick)),"stage ticks not all solved:",this.stages,this.id),a.filter(e=>Number.isFinite(e.tick)).forEach(t=>t.endTick=t.tick+L(e.eventMap[t.id].duration,t.timeWarp));const h=e.eventMap[0].duration;r.forEach(e=>{const t=e.findIndex(e=>o[e].endTick>h);if(t>=0){e.splice(t,e.length-t).forEach(e=>{o[e].tick=null,o[e].endTick=null})}}),r=r.filter(e=>e.length);const m=Math.max(0,...a.map(e=>e.endTick).filter(Number.isFinite));return this.logger.debug(String.fromCodePoint(127822),this.id,c),{voices:r,events:a,duration:m,actions:this.actions.map(e=>e.id).join(" ")}}deduce(e,t){this.stages||this.constructStages(e);const s=e.actionAccessing.get(this.id)||{times:0};if(++s.times,e.actionAccessing.set(this.id,s),this.constructConstraints(e),this.isConflicted(e))return s.closed=!0,this.logger.info(this.action.id,"❌"),null;if(this.logger.group(this.action&&this.action.id),t.credits>0){if(--t.credits,this.children||this.expand(e),this.children=this.children.filter(t=>!e.actionAccessing.get(t.id)||!e.actionAccessing.get(t.id).closed),this.children.length){const s=t=>t.possibility/((e.actionAccessing.get(t.id)||{times:0}).times+1);this.children.sort((e,t)=>s(t)-s(e));for(const s of this.children){const i=s.deduce(e,t);if(i)return this.logger.groupEnd(),i;if(t.credits<=0)break}}}else this.logger.debug("quota exhausted.");return this.logger.groupEnd(),s.closed=!0,this.getSolution(e)}expand(e){this.constructStages(e);const{eventMap:t,matrixV:s,matrixH:i}=e,n=this.stagedEvents,r=[],a=e=>{if(!this.actions.some(t=>t.id===e.action.id)&&!r.some(t=>t.action.id===e.action.id)){const t=this.stages.find(t=>t.events.includes(e.action.e1)),i=this.stages.find(t=>t.events.includes(e.action.e2));if(t===i||t&&i&&t.index>=i.index)return;if(t&&i)if(e.action.type===K.VERTICAL){if(i.index-t.index>1)return;if(this.actions.some(e=>t.events.includes(e.e1)&&i.events.includes(e.e2)))return}else if(e.action.type===K.HORIZONTAL&&t.index>i.index)return;if(e.action.type===K.HORIZONTAL&&this.actions.some(t=>t.type===K.HORIZONTAL&&(t.e1===e.action.e1||t.e2===e.action.e2||t.e1===e.action.e2&&t.e2===e.action.e1)))return;if(e.action.type===K.VERTICAL){if(t&&(e.possibility=Math.min(e.possibility,...t.events.map(t=>s[e.action.e2][t])),e.possibility<=0))return;if(i&&(e.possibility=Math.min(e.possibility,...i.events.map(t=>s[t][e.action.e1])),e.possibility<=0))return}r.push(e)}};for(const e of n)e<0||(s[e].forEach((t,s)=>{t>0&&e!==s&&a({action:Action.V(s,e),possibility:t})}),s.forEach((t,s)=>{const i=t[e];i>0&&a({action:Action.V(e,s),possibility:i})}),i[e].forEach((t,s)=>{t>0&&a({action:Action.H(s,e),possibility:t})}),i.forEach((s,i)=>{i=i>=Object.keys(t).length?-1:i;const n=s[e];n>0&&a({action:Action.H(e,i),possibility:n})}));r.some(e=>[K.HORIZONTAL,K.PLACE].includes(e.action.type)||!n.has(e.action.e1)||!n.has(e.action.e2))?this.children=r.map(e=>new PathNode({logger:this.logger,parent:this,...e})):this.children=[]}}class Solver{constructor(e,{quota:t=1e3,logger:s=new DummyLogger}={}){this.quota=t,this.logger=s;const i={id:0,x:0,confidence:1,shrinkness:e.measureShrinkness,duration:e.expectedDuration,lowWarp:0};this.events=[i,...e.events.map(e=>({id:e.id,x:e.x,confidence:e.confidence,shrinkness:e.shrinkness,staff:e.staff,duration:e.duration,lowWarp:.5}))],this.eventMap=this.events.reduce((e,t)=>({...e,[t.id]:t}),{}),this.matrixH=e.matrixH,this.matrixV=e.matrixV,this.xSpan=e.endX-Math.min(e.endX-1,...e.events.map(e=>e.x)),this.actionAccessing=new Map}solve(){this.pathRoot=new PathNode({logger:this.logger,action:null}),this.pathRoot.children=this.events.slice(1).map(e=>new PathNode({logger:this.logger,parent:this.pathRoot,action:Action.P(e.id),possibility:this.matrixV[e.id].reduce((e,t)=>e+t,0)}));let e=null;this.logger.groupCollapsed("solve");const t=Array(this.events.length).fill(0),s={credits:this.quota,times:0};for(;s.credits>0;){++s.times;const i={eventMap:this.eventMap,matrixH:this.matrixH,matrixV:this.matrixV,actionAccessing:this.actionAccessing,eventTendencies:t},n=this.pathRoot.deduce(i,s);if(n.credits=this.quota-s.credits,n.times=s.times,this.evaluateSolution(n),this.logger.debug("loss:",n.loss),e=!e||n.losse/s.times)),e}evaluateSolution(e){e.loss=0;const t=e.events.reduce((e,t)=>({...e,[t.id]:{...t,...this.eventMap[t.id]}}),{}),s=e.events.filter(e=>Number.isFinite(e.tick)).map(e=>t[e.id]),i=s.reduce((e,t)=>(e[t.staff]=e[t.staff]||[],e[t.staff].push(t),e),{});Object.values(i).forEach(t=>{t.sort((e,t)=>e.x-t.x).slice(0,t.length-1).forEach((s,i)=>{t[i+1].tick{if(Number.isFinite(s.tick)&&!e.voices.every(e=>!e.includes(s.id))||(e.loss+=100*t[s.id].confidence),s.timeWarp){const{numerator:e,denominator:i}=s.timeWarp,r=t[s.id].shrinkness;n.set(e,Math.max(n.get(e)||0,1-r)),n.set(i,Math.max(n.get(i)||0,1-r))}});const r=D(e.duration,this.eventMap[0].duration);n.set(r.numerator,Math.max(n.get(r.numerator)||0,1-this.eventMap[0].shrinkness)),n.set(r.denominator,Math.max(n.get(r.denominator)||0,1-this.eventMap[0].shrinkness));for(const[t,s]of n.entries())t>1&&(e.loss+=Math.log(t)*s);let a=0,o=0;e.voices.forEach(s=>{console.assert(t[s[0]],"invalid voice:",s,Object.keys(t));const i=Math.abs(t[s[0]].tick),n=t[s[s.length-1]].endTick;a+=Math.max(0,i+e.duration-n);let r=null;s.forEach(e=>{const s=t[e];s.staff!==r&&(null!==r&&++o,r=s.staff)})}),e.loss+=10*a/U,e.loss+=5**o-1;const c=[...s].sort((e,t)=>e.x-t.x),l=c.slice(1).map((t,s)=>{const i=c[s],n=t.x-i.x,r=t.tick-i.tick;if(!r)return n/this.xSpan;return(4*Math.atan2(r/e.duration,n/this.xSpan)/Math.PI-1)**2}),u=Math.max(...l,0);e.loss+=u**2,console.assert(e.loss>=0,"Invalid solution loss!!!",e.loss,n,a,o),e.loss<0&&(e.loss=1/0)}}!function(e){e[e.PAD=0]="PAD",e[e.BOS=1]="BOS",e[e.EOS=2]="EOS",e[e.CHORD=3]="CHORD",e[e.REST=4]="REST"}(Y||(Y={}));class EventCluster extends SimpleClass{constructor(e){super(),super.assign(e)}get regular(){return this.elements.some(e=>[Y.CHORD,Y.REST].includes(e.type)&&!e.fake)&&this.elements.every(e=>[e.x,e.y1,e.y2,e.tick].every(Number.isFinite))&&this.elements.slice(1).every((e,t)=>e.fake||this.elements[t].fake||e.grace||this.elements[t].grace||e.fullMeasure||this.elements[t].fullMeasure||e.tick<=this.elements[t].tick||e.x>this.elements[t].x)}get grant(){return this.annotation&&this.annotation.grant}get feature(){return{index:this.index,elements:this.elements}}get estimatedDuration(){const e=this.elements.find(e=>e.type===Y.EOS),t=e?.predisposition?e.predisposition?.tick:e?.tick;return Number.isFinite(t)?t:this.duration}assignPrediction(e){console.assert(e.index===this.index,"index mismatch:",e.index,this.index),this.matrixH=e.matrixH,e.elements.forEach(e=>{const{index:t,...s}=e,i=this.elements.find(e=>e.index===t);console.assert(i,"element not found:",t),i&&(i.predisposition=s)})}}EventCluster.className="EventCluster",EventCluster.blackKeys=["id"];class EventClusterSet extends SimpleClass{constructor(e){super(),super.assign(e)}trimIrregular(){let e=0;return this.clusters=this.clusters.filter(t=>{const s=t.regular;return s||(console.debug("irregular cluster:",t),++e),s}),e?console.debug("Irregular clusters trimmed:",`${e}/${this.clusters.length+e}`):console.debug(`The EventClusterSet (${this.clusters.length}) is fine.`),e}}EventClusterSet.className="EventClusterSet";class PatchMeasure extends SimpleClass{constructor(e){super(),Object.assign(this,e)}get staffN(){return Math.floor(Math.log2(this.staffMask))+1}get basics(){return Array(this.staffN).fill(this.basic)}get duration(){return Math.max(0,...(this.voices||[]).map(e=>e.map(e=>this.events.find(t=>t.id===e)).reduce((e,t)=>e+t.duration,0)))}}PatchMeasure.className="PatchMeasure",function(e){e.ClefG="clefs-G",e.ClefF="clefs-F",e.ClefC="clefs-C",e.TimesigC44="timesig-C44",e.TimesigC22="timesig-C22",e.TimesigZero="zero|timesig0",e.TimesigOne="one|timesig1",e.TimesigTwo="two|timesig2",e.TimesigThree="three|timesig3",e.TimesigFour="four|timesig4",e.TimesigFive="five|timesig5",e.TimesigSix="six|timesig6",e.TimesigSeven="seven|timesig7",e.TimesigEight="eight|timesig8",e.TimesigNine="nine|timesig9",e.OctaveShift8va="octave-a",e.OctaveShift8vb="octave-b",e.OctaveShift0="octave-0",e.Zero="zero|n0",e.One="one|n1",e.Two="two|n2",e.Three="three|n3",e.Four="four|n4",e.Five="five|n5",e.Six="six|n6",e.Seven="seven|n7",e.Eight="eight|n8",e.Nine="nine|n9",e.AccNatural="accidentals-natural",e.AccSharp="accidentals-sharp",e.AccDoublesharp="accidentals-doublesharp",e.AccFlat="accidentals-flat",e.AccFlatflat="accidentals-flatflat",e.KeyNatural="accidentals-natural|key-natural",e.KeySharp="accidentals-sharp|key-sharp",e.KeyFlat="accidentals-flat|key-flat",e.NoteheadS0="noteheads-s0",e.NoteheadS1="noteheads-s1",e.NoteheadS2="noteheads-s2",e.NoteheadS1stemU="noteheads-s1|noteheads-s1-u",e.NoteheadS1stemD="noteheads-s1|noteheads-s1-d",e.NoteheadS2stemU="noteheads-s2|noteheads-s2-u",e.NoteheadS2stemD="noteheads-s2|noteheads-s2-d",e.Rest0="rests-0o",e.Rest1="rests-1o",e.Rest2="rests-2",e.Rest3="rests-3",e.Rest4="rests-4",e.Rest5="rests-5",e.Rest6="rests-6",e.Rest0W="rests-0",e.RestM1="rests-M1",e.Flag3="flags-u3",e.Flag4="flags-u4",e.Flag5="flags-u5",e.Flag6="flags-u6",e.Flag7="flags-u7",e.Flag8="flags-u8",e.BeamLeft="|beam-left",e.BeamRight="|beam-right",e.BeamContinue="|beam-continue",e.TremoloLeft="|tremolo-left",e.TremoloRight="|tremolo-right",e.TremoloMiddle="|tremolo-middle",e.SlurBegin="|slur-begin",e.SlurEnd="|slur-end",e.TieBegin="|tie-begin",e.TieEnd="|tie-end",e.VoltaLeft="|volta-left",e.VoltaRight="|volta-right",e.VoltaAlternativeBegin="|volta-alter-begin",e.BarTerminal="|bar-terminal",e.BarSegment="|bar-segment",e.Dot="|dot",e.DotDot="|dotdot",e.f="f",e.p="p",e.m="m",e.r="r",e.s="s",e.z="z",e.WedgeCrescendo="|wedge-crescendo",e.WedgeDiminuendo="|wedge-diminuendo",e.WedgeClose="|wedge-close",e.CrescendoBegin="|wedge-crescendo",e.DecrescendoBegin="|wedge-diminuendo",e.CrescendoEnd="|wedge-close",e.DecrescendoEnd="|wedge-close",e.ScriptFermata="scripts-ufermata",e.ScriptShortFermata="scripts-ushortfermata",e.ScriptSforzato="scripts-sforzato",e.ScriptStaccato="scripts-staccato",e.ScriptStaccatissimo="scripts-ustaccatissimo",e.ScriptTurn="scripts-turn",e.ScriptTrill="scripts-trill",e.ScriptSegno="scripts-segno",e.ScriptCoda="scripts-coda",e.ScriptArpeggio="scripts-arpeggio",e.ScriptPrall="scripts-prall",e.ScriptMordent="scripts-mordent",e.ScriptMarcato="scripts-umarcato",e.ScriptTenuto="scripts-tenuto",e.ScriptPortato="scripts-uportato",e.PedalStar="pedal-star",e.PedalPed="pedal-Ped",e.Text="|text",e.GraceNotehead="|grace-notehead"}(Z||(Z={}));const J=Z,X=Object.values(Z),Q=X.filter(e=>/clefs-/.test(e)),ee=X.filter(e=>/timesig/.test(e)),te=X.filter(e=>/timesig-/.test(e)),se=X.filter(e=>/timesig\d/.test(e)),ie=X.filter(e=>/octave-/.test(e)),ne=X.filter(e=>/n\d/.test(e)),re=X.filter(e=>/accidentals-/.test(e)),ae=X.filter(e=>/noteheads-/.test(e)),oe=[J.NoteheadS0,J.NoteheadS1,J.NoteheadS2],ce=X.filter(e=>/noteheads-.+-[ud]/.test(e)),le=X.filter(e=>/rests-/.test(e)),ue=X.filter(e=>/flags-/.test(e)),he=X.filter(e=>/volta-/.test(e)),me=X.filter(e=>/^[a-z]$/.test(e)),de=X.filter(e=>/scripts-/.test(e)),fe=X.filter(e=>/pedal-/.test(e)),pe=[J.Dot,J.DotDot],ge=[J.SlurBegin,J.SlurEnd,J.TieBegin,J.TieEnd],ye=X.filter(e=>/beam-/.test(e)),ve=X.filter(e=>/wedge-/.test(e)),xe=[...ne,...me,...ve,...fe,...ge,J.ScriptFermata,J.ScriptShortFermata,J.ScriptSforzato,J.ScriptStaccato,J.ScriptStaccatissimo,J.ScriptTurn,J.ScriptTrill,J.ScriptPrall,J.ScriptMordent,J.ScriptMarcato,J.ScriptTenuto,J.ScriptPortato],Se=[...fe],ke=[...Q,...ee,...ne,...re,J.NoteheadS0,J.NoteheadS1,J.NoteheadS2,...le,...me,...de,...fe,...pe],be={};Q.forEach(e=>be[e]=1),se.forEach(e=>be[e]=1),re.forEach(e=>be[e]=.5),ae.forEach(e=>be[e]=.5),le.forEach(e=>be[e]=.5),pe.forEach(e=>be[e]=.5);const Te={};te.forEach(e=>Te[e]=0),he.forEach(e=>Te[e]=0);class Token{constructor(e){Object.assign(this,e)}get typeId(){return this.type.split("|").reverse()[0]}get isPredicted(){return Number.isFinite(this.confidence)}get isNotehead(){return ce.includes(this.type)||this.type===Z.NoteheadS0}get isContexted(){return Q.includes(this.type)||ee.includes(this.type)||ie.includes(this.type)||re.includes(this.type)}get isAccessory(){return ne.includes(this.type)||me.includes(this.type)||de.includes(this.type)||fe.includes(this.type)}get division(){switch(this.type){case J.NoteheadS0:return 0;case J.NoteheadS1stemU:case J.NoteheadS1stemD:return 1;case J.NoteheadS2stemU:case J.NoteheadS2stemD:return 2;case J.Flag3:return 3;case J.Flag4:return 4;case J.Flag5:return 5;case J.Flag6:return 6;case J.Flag7:return 7;case J.Flag8:return 8;case J.RestM1:return-1;case J.Rest0:return 0;case J.Rest1:return 1;case J.Rest2:return 2;case J.Rest3:return 3;case J.Rest4:return 4;case J.Rest5:return 5;case J.Rest6:return 6}return null}get dots(){switch(this.type){case J.Dot:return 1;case J.DotDot:return 2}return null}get direction(){switch(this.type){case J.NoteheadS1stemU:case J.NoteheadS2stemU:return"u";case J.NoteheadS1stemD:case J.NoteheadS2stemD:return"d"}return null}get width(){switch(this.type){case J.NoteheadS0:return w.NoteheadS0;case J.NoteheadS1stemU:case J.NoteheadS1stemD:return w.NoteheadS1;case J.NoteheadS2stemU:case J.NoteheadS2stemD:return w.NoteheadS2}}get left(){switch(this.type){case J.NoteheadS0:return this.x-this.width/2;case J.NoteheadS1stemU:case J.NoteheadS2stemU:return this.x-this.width;case J.NoteheadS1stemD:case J.NoteheadS2stemD:return this.x}return this.x}get right(){switch(this.type){case J.NoteheadS0:return this.x+this.width/2;case J.NoteheadS1stemU:case J.NoteheadS2stemU:return this.x;case J.NoteheadS1stemD:case J.NoteheadS2stemD:return this.x+this.width}return this.x}get voiceIndices(){return!this.voice||this.voice<0?[]:Array(Math.floor(Math.log2(this.voice))+1).fill(null).reduce((e,t,s)=>this.voice&1<"CDEFGAB"[(e.note+700)%7]).join("")}get zeroHolder(){return!!this.grace||this.tremoloCatcher}}var Oe;EventTerm.className="EventTerm",function(e){e[e.Clef=0]="Clef",e[e.KeyAcc=1]="KeyAcc",e[e.Acc=2]="Acc",e[e.OctaveShift=3]="OctaveShift",e[e.TimeSignatureC=4]="TimeSignatureC",e[e.TimeSignatureN=5]="TimeSignatureN"}(Oe||(Oe={}));class ContextedTerm extends Term{constructor(e){super(),Object.assign(this,e)}get type(){return Q.includes(this.tokenType)?Oe.Clef:/\|key-/.test(this.tokenType)?Oe.KeyAcc:/accidentals-/.test(this.tokenType)?Oe.Acc:ie.includes(this.tokenType)?Oe.OctaveShift:te.includes(this.tokenType)?Oe.TimeSignatureC:se.includes(this.tokenType)?Oe.TimeSignatureN:null}get staffLevel(){return[Oe.OctaveShift,Oe.Clef,Oe.KeyAcc].includes(this.type)}get prior(){return this.tick-.1}get clef(){switch(this.tokenType){case Z.ClefG:return-this.y-2;case Z.ClefF:return 2-this.y;case Z.ClefC:return-this.y}return null}get alter(){switch(this.tokenType){case Z.AccNatural:case Z.KeyNatural:return 0;case Z.AccSharp:case Z.KeySharp:return 1;case Z.AccFlat:case Z.KeyFlat:return-1;case Z.AccDoublesharp:return 2;case Z.AccFlatflat:return-2}return null}get octaveShift(){switch(this.tokenType){case Z.OctaveShift8va:return-1;case Z.OctaveShift0:return 0;case Z.OctaveShift8vb:return 1}return null}get number(){switch(this.tokenType){case Z.TimesigZero:return 0;case Z.TimesigOne:return 1;case Z.TimesigTwo:return 2;case Z.TimesigThree:return 3;case Z.TimesigFour:return 4;case Z.TimesigFive:return 5;case Z.TimesigSix:return 6;case Z.TimesigSeven:return 7;case Z.TimesigEight:return 8;case Z.TimesigNine:return 9}return null}}ContextedTerm.className="ContextedTerm";class MarkTerm extends Term{get prior(){return this.tick+.01}}MarkTerm.className="MarkTerm";const Be=Array(7).fill(0).map((e,t)=>String.fromCodePoint(119133+t));class TempoTerm extends MarkTerm{static fromNumeralText(e){if(/.+=.*\d+/.test(e)){const[t,s]=e.split("=");let i=Be.findIndex(e=>t.includes(e));i=i>=0?i:2;let n=(2**i).toString();return t.includes(".")&&(n+="."),new TempoTerm({tick:0,duration:n,beats:s})}return null}constructor(e){super(),Object.assign(this,e)}get prior(){return this.tick-.01}get durationMagnitude(){const[e,t,s]=this.duration.match(/^(\d+)(\.)?$/);return we/Number(t)*(s?1.5:1)}get bpm(){const[e]=this.beats.match(/\d+/)||[90];return Number(e)*this.durationMagnitude*4/we}isValid(e=[10,400]){const t=this.bpm;return Number.isFinite(this.bpm)&&t>=e[0]&&t{const t=(e=>{const t=new Map;return e.rows.forEach(e=>{if(1===e.events.length){const t=e.events[0];t.rest&&0===t.division&&(t.rest="R")}}),e.events.forEach(e=>{const s=Math.round(10*e.pivotX)/10;let i=0;i=e.fullMeasureRest?Math.min(s,...t.keys()):[...t.keys()].find(s=>{const i=t.get(s),n=Math.min(...i.map(e=>e.left)),r=Math.max(...i.map(e=>e.right));return Math.min(r,e.right)-Math.max(n,e.left)>.62*w.NoteheadS1})||s,e.roundX=i;const n=t.get(i)||[];t.set(i,n),n.push(e)}),t})(e);let s=0;const i=new Set([s]),n=[...t.entries()].sort(([e],[t])=>e-t);for(const[e,t]of n)t.forEach(e=>{e.predisposition&&(e.rest=e.rest&&e.predisposition.fullMeasure>.5?"R":e.rest,e.grace=e.predisposition.grace?Ee.Grace:null,e.division=G(e.predisposition.divisionVector),e.dots=G(e.predisposition.dotsVector),e.predisposition.timeWarped>.5&&(e.timeWarp=F(2,3))),e.fullMeasureRest?e.tick=0:(e.zeroHolder&&(s-=e.duration),!e.zeroHolder&&e.predisposition&&Number.isInteger(e.predisposition.tick)?e.tick=e.predisposition.tick:e.tick=s,i.add(e.tick+e.duration))}),i.delete(s),i.size&&(s=Math.min(...i));Number.isInteger(e.estimatedDuration)?e.duration=e.estimatedDuration:e.duration=Math.max(...i,0)},e.computeMeasureVoices=e=>{e.voices=[];for(const t of e.rows){const s=t.events.filter(e=>!(e.grace||e.tremoloCatcher||e.fullMeasureRest||e.predisposition&&e.predisposition.fake>.5)),i=new Set(s);for(;i.size;){let t=0;const n=[],r=e=>{n.push(e.id),e.zeroHolder||(t+=e.duration),i.delete(e)},a=s.find(e=>i.has(e));for(a.alignedTick>0&&(t=a.alignedTick),r(a);;){const e=s.find(e=>i.has(e)&&e.alignedTick===t);if(!e)break;r(e)}e.voices.push(n)}}}}(_e||(_e={}));var Re,Fe,Pe;!function(e){const t=1921920,s=.7071067811865475,i=[[null,null],[null,Ae.Open],[Ae.Open,Ae.Continue],[Ae.Open,Ae.Close],[Ae.Continue,Ae.Continue],[Ae.Continue,Ae.Close],[Ae.Close,null],[Ae.Close,Ae.Open]].map(e=>e.join("-")),n=(e,t)=>{if(!e.events.length)return{events:[],voices:[],duration:0};return new Solver(e,t).solve()};e.estiamteMeasure=e=>{const n=e.events.filter(e=>!e.zeroHolder).map(s=>({id:s.id,staff:s.staff,x:s.x,tickEstimated:s.predisposition&&Number.isFinite(s.predisposition.tick)?s.predisposition.tick:s.x,tipX:s.tipX,y:s.tipY+100*s.staff,duration:s.mainDuration*t/we,division:s.division,dots:s.dots,stemDirection:s.stemDirection,beam:s.beam,rest:s.rest,pR:"R"===s.rest?1:"r"===s.rest&&0===s.division?Math.tanh(s.x-e.eventStartX):0,fakeP:s.predisposition&&s.predisposition.fakeP||0,shrinkness:s.predisposition?s.predisposition.timeWarped:null}));let r=t*e.timeSignature.numerator/e.timeSignature.denominator;Number.isFinite(e.estimatedDuration)&&(r=Math.max(r,B(e.estimatedDuration,480480)));const a=e.staffGroups.reduce((e,t,s)=>(t.forEach(t=>e[t]=s),e),{}),o=[0,...n.map(e=>e.id)],c=n.map(t=>({...t,id:o.indexOf(t.id),x:t.x-e.startX,confidence:(1-t.pR)*(1-t.fakeP),shrinkness:Number.isFinite(t.shrinkness)?t.shrinkness:Math.tanh((t.division-.1*t.dots)/4),staffGroup:a[t.staff]})),l=Array(o.length+1).fill(null).map(()=>Array(o.length).fill(0)),u=Array(o.length).fill(null).map(()=>Array(o.length).fill(0)),h=e=>g.default(e/1.6)*g.default(1.6/e);for(const t of c){for(const e of c){if(u[t.id][e.id]=t!==e&&t.tickEstimated>=e.tickEstimated?1-g.default((t.tickEstimated-e.tickEstimated)*s/.6):0,t.staffGroup!==e.staffGroup)l[t.id][e.id]=0;else if(t.x<=e.x)l[t.id][e.id]=0;else{const s=Math.exp(2*-Math.abs(t.staff-e.staff)),i=t.staff===e.staff?Math.exp(-Math.abs(t.y-e.y)/16):1,n=t.x-e.x,r=t.tipX-e.tipX;l[t.id][e.id]=(s*i*Math.min(h(n),h(r)))**(1/3)}const n=(1-t.pR)*(1-e.pR);u[t.id][e.id]*=n,l[t.id][e.id]*=n,u[t.id][e.id]<.01&&(u[t.id][e.id]=0),t.stemDirection&&e.stemDirection&&t.stemDirection!==e.stemDirection&&(l[t.id][e.id]*=.9),t.rest||e.rest||i.includes([e.beam,t.beam].join("-"))||(l[t.id][e.id]*=.2)}l[o.length][t.id]=h(e.width-t.x)**(1/3)}return{ids:o,events:c,expectedDuration:r,measureShrinkness:0,endX:e.position.right,matrixH:l,matrixV:u}},e.regulateMeasure=async(s,{solver:i=null,...r})=>{const a=e.estiamteMeasure(s),{ids:o,matrixH:c,matrixV:l}=a;if(s.matrixH){console.assert(s.matrixH.length>o[o.length-1]&&s.matrixH[0].length>o[o.length-1],"matrix shape mismatch:",o.length,`${s.matrixH.length}x${s.matrixH[0].length}`,`${c.length}x${c[0].length}`);for(let e=0;ee.forEach((e,i)=>{const n=s.matrixV[o[t]][o[i]];Number.isFinite(n)&&(l[t][i]=n)})),Number.isFinite(s.estimatedDuration)&&(a.measureShrinkness=Math.tanh(-3*Math.log(Math.min(1,s.estimatedDuration/s.duration)))),r.logger&&r.logger.info("--- MEASURE",s.measureIndex,"---",a);const u=i?await i(a,r):n(a,r),h=u.events.map(e=>({...e,id:a.ids[e.id]}));h.forEach(e=>{const i=s.events.find(t=>t.id===e.id);i.tick=Number.isFinite(e.tick)?Math.round(e.tick*we/t):null,i.tickGroup=e.tickGroup,i.timeWarp=e.timeWarp}),s.duration=Math.round(u.duration*we/t),s.voices=u.voices.map(e=>e.map(e=>a.ids[e])),s.solutionStat={loss:u.loss,solverCredits:u.credits,solverTimes:u.times},s.events.forEach(e=>{const t=h.find(t=>t.id===e.id);t&&(Number.isFinite(t.tick)||"r"!==e.rest||0!==e.division?"R"===e.rest&&(e.tick=0,e.tickGroup=0,e.duration=s.duration,s.voices.push([e.id])):(e.tick=0,e.tickGroup=0,e.rest="R",e.duration=s.duration,s.voices.push([e.id])))})},e.regulateMeasureWithRectification=async(e,i,{solver:r=null,...a})=>{const o=e.events.filter(e=>!e.zeroHolder).map(s=>{const n=i.events.find(e=>e&&e.id===s.id),r=Number.isFinite(n?.division)?n.division:s.division,a=Number.isFinite(n?.dots)?n.dots:s.dots,o=t*2**-r*(2-2**-a);return{id:s.id,staff:s.staff,x:s.x,tickEstimated:s.predisposition?.tick,y:s.tipY+100*s.staff,duration:o,pR:"R"===s.rest?1:"r"===s.rest&&0===s.division?Math.tanh(s.x-e.eventStartX):0,fakeP:s.predisposition&&s.predisposition.fakeP||0,shrinkness:s.predisposition?.timeWarped||0}});let c=t*e.timeSignature.numerator/e.timeSignature.denominator;Number.isFinite(e.estimatedDuration)&&(c=Math.max(c,B(e.estimatedDuration,480480)));const l=e.staffGroups.reduce((e,t,s)=>(t.forEach(t=>e[t]=s),e),{}),u=[0,...o.map(e=>e.id)],h=o.map(t=>({...t,id:u.indexOf(t.id),x:t.x-e.startX,confidence:(1-t.pR)*(1-t.fakeP),shrinkness:t.shrinkness,staffGroup:l[t.staff]})),m=Array(u.length+1).fill(null).map(()=>Array(u.length).fill(0)),d=Array(u.length).fill(null).map(()=>Array(u.length).fill(0));for(const e of h)for(const t of h){d[e.id][t.id]=e!==t&&e.tickEstimated>=t.tickEstimated?1-g.default((e.tickEstimated-t.tickEstimated)*s/.6):0;const i=(1-e.pR)*(1-t.pR);d[e.id][t.id]*=i,d[e.id][t.id]<.01&&(d[e.id][t.id]=0)}console.assert(e.matrixH&&e.matrixH.length>u[u.length-1]&&e.matrixH[0].length>u[u.length-1],"matrix shape mismatch:",u.length,`${e.matrixH.length}x${e.matrixH[0].length}`,`${m.length}x${m[0].length}`);for(let t=0;t{const a=i.events.find(t=>t&&t.id===e),o=Number.isFinite(s)?Math.round(s*we/t):s;return{id:e,tick:o,tickGroup:n,timeWarp:r,division:a?.division,dots:a?.dots}}),S=Math.round(y.duration*we/t);return{events:x,voices:y.voices,duration:S,priority:v}}}(Re||(Re={}));class SpartitoMeasure extends SimpleClass{static reorderEvents(e,t){const s=[],i=e.map(e=>({id:e.id,staff:e.staff,x:e.x/.7,rx:0,ry:t[e.staff]+e.tipY,tipY:e.tipY,prior:0}));i.sort((e,t)=>e.x-t.x),i.slice(1).forEach((e,t)=>{const s=Math.min(Math.round(e.x-i[t].x),2);e.rx=i[t].rx+s}),i.forEach(e=>{e.prior=1e4*e.staff+e.rx+.01*e.tipY,s.includes(e.ry)||s.push(e.ry)}),i.sort((e,t)=>e.prior-t.prior),s.sort((e,t)=>e-t);let n=0;const r=s.map((e,t)=>(!t||s[t]-s[t-1]<.5||++n,n)),a=i.map(t=>new EventTerm({...e.find(e=>e.id===t.id),intX:t.rx,intY:r[s.indexOf(t.ry)]}));return a.forEach((e,t)=>e.id=t+1),a}constructor(e){super(),super.assign(e),this.originalRegulationHash||this.regulated||(this.originalRegulationHash=this.regulationHash),this.barTypes=this.barTypes||{},this.regulated&&this.position&&this.postRegulate()}get timeSignature(){return this.basics&&this.basics[0].timeSignature}get keySignature(){return this.basics&&this.basics[0].keySignature}get timeSignatureChanged(){return this.contexts.filter(Boolean)[0].some(e=>[Oe.TimeSignatureC,Oe.TimeSignatureN].includes(e.type))}get doubtfulTimesig(){return this.basics&&this.basics[0].doubtfulTimesig}get regulated(){return!!this.voices}get validRegulated(){return!!this.voices&&this.voices.flat(1).every(e=>Number.isFinite(this.events.find(t=>t.id===e)?.tick))}get rows(){return this.contexts.map((e,t)=>({events:this.events.filter(e=>e.staff===t),contexts:e}))}get eventStartX(){return this.events.length?Math.min(...this.events.map(e=>e.x)):this.startX}get startX(){return this.position.left}get width(){return this.position.right-this.position.left}get tickMap(){return this.events.concat([this.endEvent]).filter(Boolean).reduce((e,t)=>(Number.isFinite(t.tick)&&(e.has(t.tick)||e.set(t.tick,[]),e.get(t.tick).push(t)),e),new Map)}get tickToX(){return[...this.tickMap.entries()].reduce((e,[t,s])=>{if((s=s.filter(e=>!e.fullMeasureRest&&!e.grace)).length){const i=Math.min(...s.map(e=>e.x));e[t]=i}return e},{})}get tickRates(){const e=this.events.filter(e=>Number.isFinite(e.tick)&&!e.fullMeasureRest);return e.sort((e,t)=>e.x-t.x),e.slice(0,e.length-1).map((t,s)=>{const i=e[s+1];return(i.tick-t.tick)/Math.max(i.x-t.x,.001)})}get tickRatesInStaves(){const e=this.events.filter(e=>Number.isFinite(e.tick)&&!e.fullMeasureRest&&!e.grace).reduce((e,t)=>(e[t.staff]=e[t.staff]||[],e[t.staff].push(t),e),{}),t=Object.values(e).map(e=>e.sort((e,t)=>e.x-t.x).slice(0,e.length-1).map((t,s)=>{const i=e[s+1];return(i.tick-t.tick)/Math.max(i.x-t.x,.001)}));return[].concat(...t)}get tickRatesInGroups(){const e=this.events.filter(e=>Number.isFinite(e.tick)&&!e.fullMeasureRest).reduce((e,t)=>{const s=this.staffGroups.findIndex(e=>e.includes(t.staff));return e[s]=e[s]||[],e[s].push(t),e},{}),t=Object.values(e).map(e=>e.sort((e,t)=>e.x-t.x).slice(0,e.length-1).map((t,s)=>{const i=e[s+1];return(i.tick-t.tick)/Math.max(i.x-t.x,.001)}));return[].concat(...t)}get tickTwist(){if(!this.duration||!this.staffGroups)return;const e=this.events.filter(e=>Number.isFinite(e.tick)&&!e.fullMeasureRest&&!e.grace&&!e.tremoloCatcher&&!(e.rest&&0===e.division)).reduce((e,t)=>{const s=this.staffGroups.findIndex(e=>e.includes(t.staff));return e[s]=e[s]||[],e[s].push(t),e},{}),t=Object.values(e).map(e=>{const t=[...e].sort((e,t)=>e.pivotX-t.pivotX),s=this.position.right-t[0].x,i=t.slice(1).map((e,i)=>{const n=t[i],r=e.pivotX-n.pivotX,a=e.tick-n.tick;if(!a)return r/s;return(4*Math.atan2(a/this.duration,r/s)/Math.PI-1)**2});return Math.max(0,...i)});return Math.max(0,...t)}get eventMap(){return this.events.reduce((e,t)=>(e[t.id]=t,e),{})}get empty(){return!this.events?.length||!this.voices?.length}get hasIllEvent(){const e=this.voices.flat(1),t=this.eventMap;return this.regulated&&e.some(e=>{const s=t[e];return!s.zeroHolder&&!Number.isFinite(s.tick)&&!s.fullMeasureRest})}get brief(){return[`${this.timeSignature.numerator}/${this.timeSignature.denominator}`,...this.events.map(e=>[e.staff,e.intX,Math.round(e.tip?e.tip.y:e.ys?.[0]??0),e.fullMeasureRest?0:e.division,e.fullMeasureRest?0:e.dots,e.rest?"r":"",e.grace||"",e.stemDirection,e.beam||""].join("|"))].join("\n")}get regulationHash(){return p.default(this.brief)}get regulationHash0(){return this.originalRegulationHash||this.regulationHash}get regulationHashes(){return Array.from(new Set([this.originalRegulationHash,this.regulationHash].filter(Boolean)))}get featureWords(){if(!this.regulated||!this.voices||!this.voices.length)return null;const e=this.tickRatesInStaves.some(e=>e<0),t=this.events.filter(e=>!e.zeroHolder&&!e.rest).map(e=>e.ys).flat(1).map(e=>"Y"+2*-e),s=Array.from(new Set(t));this.keySignature&&s.push(`K${this.keySignature}`);const i=this.voices.map(e=>e.map(e=>this.events.find(t=>t.id===e)).filter(e=>!e.zeroHolder&&!e.rest)).filter(e=>e.length),n=e?[]:i.map(e=>e.map(e=>e.scaleChord).join("-")),r=e?[]:i.map(e=>e.map(e=>e.division).join(""));return this.timeSignature&&r.push(`T${this.timeSignature.numerator}/${this.timeSignature.denominator}`),[s,n,r]}get barType(){if(this.voltaEnd)return"VoltaRight";const e=Object.entries(this.barTypes).sort((e,t)=>t[1]-e[1]);return e[0]&&e[0][1]>=1?e[0][0]:null}get partialDuration(){if(!Number.isFinite(this.duration))return!1;const e=L(we,this.timeSignature);return this.duration{const t=e.events.filter(e=>e.grace);if(!t.length)return;const s=[...e.tickMap.entries()].reduce((e,[t,s])=>(s.forEach(s=>{if(!s.grace){e[s.staff]=e[s.staff]||{};const i=e[s.staff][t];e[s.staff][t]=!i||i.x>s.x?s:i}}),e),{}),i=Object.entries(s).reduce((t,[s,i])=>{t[s]=Object.entries(i).map(([e,t])=>({event:t,tick:Number(e),preTick:-240,graces:[]})).sort((e,t)=>e.event.x-t.event.x),t[s].push({tick:e.duration,event:e.endEvent,preTick:0,graces:[]});let n=0;return t[s].forEach(e=>{e.tick>n&&(e.preTick=n,n=e.tick)}),t},{});t.forEach(e=>{const t=i[e.staff];if(t){const s=t.find(t=>t.event.x>e.x);s&&s.graces.push(e),e.roundX=e.x}}),Object.values(i).forEach(e=>e.forEach(e=>{if(e.graces.length){e.event.graceIds=e.graces.map(e=>e.id);const t=e.graces.reduce((e,t)=>e+t.duration,0),s=Math.min(t,e.tick-e.preTick)/t;let i=e.tick;[...e.graces].reverse().forEach(e=>{e.tick=Math.round(i-e.duration*s),i=e.tick})}}))})(this),(e=>{const t=e.events.filter(e=>e.tremoloCatcher&&!e.grace),s=e.events.filter(e=>e.tremoloLink===Ne.Pitcher&&!e.grace);t.forEach(t=>{let i=s.filter(e=>e.division===t.division&&e.xNumber.isFinite(e.tick)&&!e.grace&&!e.rest&&e.division===t.division&&e.dots===t.dots&&e.xt.x-e.x),i.length){const e=i[0];e.catcherId=t.id;const n=Math.max(e.tremolo||3,t.tremolo||3);e.tremolo=n,t.tremolo=n,t.tick||(t.tick=e.tick+e.duration/2);const r=s.indexOf(e);r>=0&&s.splice(r,1)}})})(this),this.updateContextTick()}updateRoundX(){const e=this.tickToX;e&&this.events.forEach(t=>{const s=e[t.tick];Number.isFinite(s)&&(t.roundX=s)})}updateContextTick(){if(!this.staffGroups)return;const e=this.contexts.flat(1);this.staffGroups.flat(1).forEach(t=>{const s=[...this.events.filter(e=>e.staff===t),...e.filter(e=>e.staff===t)];s.sort((e,t)=>t.x-e.x);let i=this.duration;s.forEach(e=>{e instanceof EventTerm?e.fullMeasureRest||e.zeroHolder||(i=e.tick):e instanceof ContextedTerm&&(e.tick=i)})})}asSolution(e=void 0){return this.regulated?{events:this.events.map(t=>{const s={id:t.id,tick:t.tick,tickGroup:t.tickGroup,timeWarp:t.timeWarp};if(e){const i=e.events.find(e=>e.id===t.id);i&&(t.division!==i.division&&(s.division=t.division),t.dots!==i.dots&&(s.dots=t.dots),t.grace!==i.grace&&(s.grace=!!t.grace),t.beam!==i.beam&&(s.beam=t.beam),t.fullMeasureRest!==i.fullMeasureRest&&(s.fullMeasure=t.fullMeasureRest))}return s}),voices:this.voices,duration:this.duration,priority:-this.solutionStat?.loss}:null}applySolution(e){e.timeSignature&&this.basics.forEach(t=>{t.timeSignature=e.timeSignature,t.doubtfulTimesig=!1}),this.voices=e.voices,this.duration=e.duration,this.events.forEach(t=>{t.timeWarp=null,t.tick=null,t.tickGroup=null;const s=e.events?.find(e=>e.id===t.id);s&&(t.tick=s.tick,t.timeWarp=s.timeWarp,t.tickGroup=s.tickGroup,Number.isFinite(s.division)&&(t.division=s.division),Number.isFinite(s.dots)&&(t.dots=s.dots),void 0!==s.beam&&(t.beam=s.beam),void 0!==s.grace&&(t.grace=s.grace?Ee.Grace:void 0),s.fullMeasure&&(t.rest="R"))}),Number.isFinite(e.priority)&&(this.solutionStat={loss:-e.priority}),this.postRegulate()}cleanupRegulation(){this.voices=null,this.duration=null,this.events.forEach(e=>{e.tick=null,e.tickGroup=null,e.timeWarp=null})}regulateTest(){this.duration=0,this.voices=this.rows.map(e=>e.events.map(e=>e.id)),this.voices.forEach(e=>{let t=0;e.map(e=>this.events.find(t=>t.id===e)).forEach((e,s)=>{e.tickGroup=s,e.tick=t,t+=e.duration}),this.duration=Math.max(this.duration,t)})}regulateSimple(){_e.computeMeasureTicks(this),_e.computeMeasureVoices(this)}async regulateEquations(e){await Re.regulateMeasure(this,e)}async regulate({policy:e="advanced",...t}={}){switch(e){case"test":this.regulateTest();break;case"equations":case"advanced":await this.regulateEquations(t);break;default:this.regulateSimple()}this.postRegulate()}createPatch(){return new PatchMeasure({measureIndex:this.measureIndex,staffMask:this.staffMask,basic:this.basics[0],events:this.events,contexts:this.contexts,marks:this.marks,voices:this.voices})}createClusters(){const e=this.voices&&new Set(this.voices.flat(1));return this.staffGroups.filter(e=>e.length).map(t=>{const s=this.position.staffYs[0],i=e=>this.position.staffYs[t.indexOf(e)]-s,n=this.events.filter(e=>t.includes(e.staff));if(!n.length)return null;const r=n.map(s=>({index:s.id,voice:(this.voices||[]).findIndex(e=>e.includes(s.id)),type:s.rest?Y.REST:Y.CHORD,staff:t.indexOf(s.staff),x:s.tipX,pivotX:s.pivotX,y1:i(s.staff)+("u"===s.stemDirection?s.tipY:s.ys[s.ys.length-1]),y2:i(s.staff)+("u"===s.stemDirection?s.ys[0]:s.tipY),headY:"u"===s.stemDirection?s.ys[0]:s.ys[s.ys.length-1],feature:s.feature,division:s.division,dots:s.dots,beam:s.beam||null,stemDirection:s.stemDirection,grace:!!s.grace,tremoloCatcher:s.tremoloCatcher,timeWarped:!!s.timeWarp,fullMeasure:s.fullMeasureRest,tick:s.tick||0,fake:!s.fullMeasureRest&&!s.grace&&this.voices&&!e.has(s.id)}));if(!r.some(e=>!e.fake))return null;const a=L(we,this.timeSignature);r.unshift({index:0,type:Y.BOS,staff:null,division:null,beam:null,dots:null,stemDirection:null,grace:!1,tremoloCatcher:!1,fullMeasure:!1,x:this.position.left,pivotX:this.position.left,y1:0,y2:0,headY:0,feature:null,timeWarped:this.durationr.map(()=>0)),this.voices.forEach(e=>{let t=0;e.forEach(e=>{const s=r.findIndex(t=>t.index===e);s>0&&t>=0&&(o[s][t]=1),t=s}),t>=0&&(o[r.length-1][t]=1)}));const c={...this.solutionStat,patched:this.patched},l=this.backgroundImages&&this.backgroundImages.map(({url:e,position:t})=>({url:e,position:{...t,y:t.y-s}}));return new EventCluster({index:this.measureIndex,duration:this.duration,signatureDuration:a,staffY0:s,elements:r,matrixH:o,annotation:c,backgroundImages:l})}).filter(Boolean)}applyClusters(e){const t=this.events.reduce((e,t)=>Math.max(e,t.id),0)+1;this.matrixH=Array(t+1).fill(null).map(()=>Array(t).fill(0)),e.forEach(e=>{const s=e.elements.map(e=>e.index);console.assert(e.matrixH.length===s.length-1,"unexpected matrixH size:",e.matrixH.length,s.length);for(let i=1;i{const t=this.events.find(t=>t.id===e.index);t&&(t.predisposition=e.predisposition,void 0!==t.predisposition.grace&&(t.grace=t.predisposition.grace?Ee.Grace:null))})}),this.estimatedDuration=e.reduce((e,t)=>e+t.estimatedDuration,0)/e.length}}SpartitoMeasure.className="SpartitoMeasure",SpartitoMeasure.blackKeys=["staffGroups","solutionStat","measureNumber","deposit"];class EditableEvent extends EventTerm{constructor(e){super(e)}get agent(){return new Proxy(this,{get(e,t){const s=e;switch(t){case"id":case"tick":case"duration":case"rest":case"division":case"dots":case"stemDirection":case"beam":case"tremolo":case"tremoloLink":case"arpeggioStyle":{const e=s[t];return void 0===e?null:e}case"tying":case"tied":case"glissando":{const e=s[t];return void 0!==e&&e}case"grace":return!!s.grace;case"timeWarp":return s.timeWarp?`${s.timeWarp.numerator}/${s.timeWarp.denominator}`:null;case"multiplier":return s.multiplier?`${s.multiplier.numerator}/${s.multiplier.denominator}`:null;case"pitches":return s.pitches}},set:(e,t,s)=>{const i=e;switch(t){case"tick":case"duration":case"rest":case"division":case"dots":case"stemDirection":case"tying":case"tied":case"beam":case"tremolo":case"tremoloLink":case"glissando":case"arpeggioStyle":return i[t]=s,!0;case"grace":return i.grace=s?Ee.Grace:null,!0;case"timeWarp":if(i.timeWarp=null,s&&"string"==typeof s){const e=s.match(/^(\d+)\/(\d+)/);e&&(i.timeWarp={numerator:parseInt(e[1]),denominator:parseInt(e[2])})}return!0;case"multiplier":if(i.multiplier=null,s&&"string"==typeof s){const e=s.match(/^(\d+)\/(\d+)/);e&&(i.multiplier={numerator:parseInt(e[1]),denominator:parseInt(e[2])})}return!0;case"id":case"pitches":return!0}return!1},ownKeys:()=>["id","duration","rest","division","dots","stemDirection","tying","tied","beam","timeWarp","multiplier","tremolo","tremoloLink","glissando","arpeggioStyle","tick","grace","pitches"],getOwnPropertyDescriptor:()=>({enumerable:!0,configurable:!0})})}}class EditableMeasure extends SpartitoMeasure{constructor(e){super(e),this.events=null,this.events=e.events,this.events?.some(e=>!(e instanceof EditableEvent))&&(this.events=this.events.map(e=>new EditableEvent(e))),this.voices&&this.syncVoiceToEvents()}syncVoiceToEvents(){this.events.forEach(e=>e.voice=-1),this.voices.forEach((e,t)=>{e.forEach(e=>{const s=this.events.find(t=>t.id===e);s?s.voice=t:console.warn("no event with id:",e,this.events.length)})})}syncVoiceFromEvents(){const e=[];this.events.forEach(t=>{t?.voice>=0&&(e[t.voice]=e[t.voice]||[],e[t.voice].push(t))}),e.forEach(e=>e.sort((e,t)=>e.tick-t.tick)),this.voices=e.map(e=>e.map(e=>e.id))}get agent(){return new Proxy(this,{get:(e,t)=>{const s=e;switch(t){case"measureIndex":case"duration":return s[t];case"voices":return s.voices?.map(e=>e.join(","))||null;case"timeSignature":case"keySignature":case"doubtfulTimesig":return s.basics[0][t];case"toJSON":return()=>({measureIndex:s.measureIndex,voices:s.voices,duration:s.duration,timeSignature:s.basics[0].timeSignature,keySignature:s.basics[0].keySignature})}},set:(e,t,s)=>{const i=e;switch(t){case"timeSignature":case"keySignature":case"doubtfulTimesig":return i.basics[0][t]=s,i.basics=i.basics.map(()=>i.basics[0]),!0;case"duration":return i.duration=s,!0;case"measureIndex":case"voices":return!0}return!1},ownKeys:()=>["measureIndex","timeSignature","doubtfulTimesig","keySignature","duration","voices"],getOwnPropertyDescriptor:()=>({enumerable:!0,configurable:!0})})}makeMIDI(e=120){if(!this.regulated)return null;const t=6e7/e,s=this.voices.map((e,s)=>{const i=e.map(e=>{const t=this.events.find(t=>t.id===e);if(t){const e=t.graceIds?t.graceIds.map(e=>this.events.find(t=>t.id===e)):[];return[...e,t]}return[]}).flat(1),n=i.filter(e=>!e.rest&&Number.isFinite(e.tick)&&e.tick>=0&&Number.isFinite(e.duration)).map(e=>e.pitches.map(t=>[{id:e.id,time:e.tick,type:"channel",subtype:"noteOn",channel:e.staff,noteNumber:V(t),velocity:96},{id:e.id,time:e.tick+e.duration,type:"channel",subtype:"noteOff",channel:e.staff,noteNumber:V(t)}])).flat(2);return n.sort(function(e,t){return e.time-t.time}),0===s&&n.unshift({time:0,type:"meta",subtype:"timeSignature",numerator:this.timeSignature.numerator,denominator:this.timeSignature.denominator,thirtyseconds:8},{time:0,type:"meta",subtype:"setTempo",microsecondsPerBeat:t}),n.forEach(e=>{e.ticks=Math.round(e.time-0)}),n.forEach((e,t)=>{e.deltaTime=e.ticks-(t>0?n[t-1].ticks:0)}),n.push({deltaTime:0,type:"meta",subtype:"endOfTrack"}),n});return{header:{formatType:0,ticksPerBeat:480},tracks:s}}}EditableMeasure.className="EditableMeasure",EditableMeasure.blackKeys=[],function(e){e.ByLines="ByLines",e.ByBlocks="ByBlocks"}(Fe||(Fe={})),function(e){e.Title="Title",e.Author="Author",e.TempoText="TempoText",e.TempoNumeral="TempoNumeral",e.TextualMark="TextualMark",e.Lyric="Lyric",e.Instrument="Instrument",e.MeasureNumber="MeasureNumber",e.Times="Times",e.Alternation1="Alternation1",e.Alternation2="Alternation2",e.Chord="Chord",e.PageMargin="PageMargin",e.Other="Other"}(Pe||(Pe={}));const De={[Ae.Open]:1,[Ae.Continue]:0,[Ae.Close]:-1},qe=e=>{if(!e.regulated)return;const t=e.eventMap,s=e.events.length,i=e.voices.flat(1).length,n=e.events.filter(e=>e.timeWarp).length,r=new Set(e.events.filter(e=>e.timeWarp&&!(e.rest&&0===e.division)).map(e=>`${e.timeWarp.numerator}/${e.timeWarp.denominator}`)),a=new Set(r);a.delete("2/3");const o=e.voices.some(e=>{const s=e.map(e=>t[e]);if(!s.some(e=>e.timeWarp))return!1;let i=0,n=0,r=0;return s.some((e,t)=>{const a=e.timeWarp?e.timeWarp.denominator:0;if(a!==i){if(i>0&&(n%i||r<2))return!0;n=0,r=0}return i=a,n+=e.duration,++r,!!(t===s.length-1&&i>0&&(n%i||r<2))})}),c=e.voices.some(e=>{const s=e.map(e=>t[e]);let i=0;return s.some(e=>!e.grace&&(e.ticke.timeWarp&&e.timeWarp.denominator>3).map(e=>e.duration)).size>1,u=L(we,e.timeSignature),h=e.doubtfulTimesig?e.duration:u,m=e.voices.flat(1).map(e=>t[e]),d=m.some(e=>!e||!Number.isFinite(e.tick)||!Number.isFinite(e.division)||e.division<0||!Number.isFinite(e.duration)||e.duration<=0),f=m.reduce((e,t)=>e||t.tick<0||t.tick+t.duration>h,!1),p=e.duration>u,g=m.some(e=>e.grace),y=e.events.filter(e=>e.grace).length,v=y>=m.length,x=m.some(e=>{let t=e.tick*2**(e.division+2);if(e.timeWarp&&(t*=e.timeWarp.denominator),!Number.isFinite(t))return!0;return R(Math.round(t),we)e.reduce(({status:e,broken:s},i,n)=>{const r=t[i];return r.beam?(0===n&&[Ae.Continue,Ae.Close].includes(r.beam)&&(e=1),e+=De[r.beam],s=s||!(e>=0&&e<=1)):r.rest||(s=s||0!==e),{status:e,broken:s}},{status:0,broken:!1})).some(({broken:e})=>e);let k=0,b=0;e.voices.forEach(s=>{const i=s.reduce((e,s)=>e+t[s].duration,0);k+=Math.max(0,e.duration-i),b+=Math.max(0,i-e.duration)}),k/=we;const T=e.events.filter(e=>!(e.grace||e.fullMeasureRest||e.tremoloCatcher||e.predisposition&&!(e.predisposition.fakeP<.1)||Number.isFinite(e.tick))).length,w=e.events.filter(e=>!(e.fullMeasureRest||e.grace||e.tremoloCatcher||m.includes(e))).length,{voiceRugged:M}=e.voices.flat(1).reduce((e,t)=>!e.voiceRugged&&e.es.has(t)?{voiceRugged:!0,es:e.es}:(e.es.add(t),e),{voiceRugged:!1,es:new Set}),E=e.tickTwist||0,A=d||E>=1||c||M||e.tickRatesInStaves.some(e=>e<0)||T>2||!e.timeSignature||f||e.duration>h||e.events.some(e=>e.timeWarp&&e.timeWarp.numerator/e.timeWarp.denominator<=.5),N=!A&&!p&&E<.2&&!o&&!a.size&&!x&&!k&&!b&&!!e.voices.length&&!S&&!g&&!v&&(e.duration===h||Number.isFinite(e.estimatedDuration)&&e.estimatedDuration<=.75*h),I=!(A||p||!(E<.3)||o||x||b||S||g);let C=Math.min(h,3840);Number.isFinite(e.estimatedDuration)&&(C=Math.max(0,Math.min(C,e.estimatedDuration)));const O=e.duration/C;let B=0;if(e.patched&&!d)B=1;else if(!A){const t=Math.tanh(1*Math.abs(k/Math.max(1,e.voices.length)));let s=Math.min(h,3840);Number.isFinite(e.estimatedDuration)&&(s=Math.max(0,Math.min(s,e.estimatedDuration)));B=(1-t)*(1-(s?Math.max(0,1-O)**2:0))*(1-Math.tanh(a.size))*(1-E**2)}return{events:s,validEvents:i,voiceRugged:M,nullEvents:T,fakeEvents:w,warpedEvents:n,complicatedTimewarp:l,spaceTime:k,surplusTime:b,durationRate:O,beamBroken:S,fractionalWarp:o,irregularWarpsN:a.size,irregularTick:x,tickTwist:E,tickOverlapped:c,graceInVoice:g,graceN:y,graceDominant:v,perfect:N,fine:I,error:A,qualityScore:B}};var Le;!function(e){e.Ordinary="ordinary",e.Full="full",e.Conservative="conservative",e.Once="once"}(Le||(Le={}));const $e=(e,t=Le.Ordinary)=>[].concat(...e.map(e=>e.serialize(t))),je=(e,{withBrackets:t=!1}={})=>{let s="",i=!1;for(let t=0;t0&&!i&&(s+=", "),i=!1,s+=e[t].code)}return t?`[${s}]`:s};class SingleMLayout extends SimpleClass{static from(e){const t=new SingleMLayout;return t.measure=e,t}constructor(e=void 0){super(),this.assign(e)}serialize(){return[this.measure]}get seq(){return[this]}get code(){return this.measure.toString()}}SingleMLayout.className="SingleMLayout";class BlockMLayout extends SimpleClass{static trimSeq(e){const t=[];for(const s of e)if(s instanceof BlockMLayout)for(const e of s.seq)t.push(e);else t.push(s);const s=[];let i=null;for(const e of t)e instanceof SingleMLayout?e.measure>i&&(s.push(e),i=e.measure):s.push(e);return s}static fromSeq(e){const t=new BlockMLayout;return t.seq=BlockMLayout.trimSeq(e),t}constructor(e=void 0){super(),this.assign(e)}serialize(e){return $e(this.seq,e)}get code(){return je(this.seq,{withBrackets:!0})}}BlockMLayout.className="BlockMLayout";class VoltaMLayout extends SimpleClass{constructor(e=void 0){super(),this.assign(e)}serialize(e){const t=$e(this.body);if(this.alternates){const s=this.alternates.map(e=>$e(e)),i=s[s.length-1];switch(e){case Le.Ordinary:return t.concat(...s);case Le.Conservative:case Le.Full:return[...[].concat(...Array(this.times-1).fill(null).map((e,i)=>[...t,...s[i%(this.times-1)]])),...t,...i];case Le.Once:return[...t,...i]}}else switch(e){case Le.Ordinary:case Le.Conservative:case Le.Once:return t;case Le.Full:return[].concat(...Array(this.times).fill(null).map(()=>t))}console.warn("the current case not handled:",e,this)}get seq(){const e=this.alternates?this.alternates[this.alternates.length-1]:[];return[...this.body,...e]}get code(){const e=je(this.body,{withBrackets:!0});let t=`${this.times}*${e}`;return this.alternates&&(t+="{"+this.alternates.map(e=>je(e,{withBrackets:e.length>1})).join(", ")+"}"),t}}VoltaMLayout.className="VoltaMLayout";class ABAMLayout extends SimpleClass{constructor(e=void 0){super(),this.assign(e)}serialize(e){const t=this.main.serialize(e),s=$e(this.main.seq,Le.Once),i=$e(this.rest,e);switch(e){case Le.Ordinary:return[...t,...i];case Le.Once:return[...i,...s];case Le.Conservative:case Le.Full:return[...t,...i,...s];default:console.warn("the current case not handled:",e,this)}}get seq(){return[this.main,...this.rest]}get code(){return"<"+this.main.code+", "+je(this.rest)+">"}}ABAMLayout.className="ABAMLayout";var He=Object.freeze({__proto__:null,get LayoutType(){return Le},SingleMLayout:SingleMLayout,BlockMLayout:BlockMLayout,VoltaMLayout:VoltaMLayout,ABAMLayout:ABAMLayout}),We=function(){var e=function(e,t,s,i){for(s=s||{},i=e.length;i--;s[e[i]]=t);return s},t=[1,13],s=[1,16],i=[1,15],n=[1,26],r=[1,29],a=[1,28],o=[1,30],c=[5,13,22,27,29],l=[2,15],u=[1,32],h=[5,14,21,22,27,28,29],m={trace:function(){},yy:{},symbols_:{error:2,start_symbol:3,measure_layout:4,EOF:5,index_wise_measure_layout:6,"i:":7,"s:":8,segment_wise_measure_layout:9,iw_sequence:10,iw_item:11,range:12,",":13,UNSIGNED:14,"..":15,single:16,iw_block_item:17,iw_volta:18,iw_aba:19,iw_block:20,"[":21,"]":22,"*":23,iw_optional_alternates:24,iw_alternates:25,"{":26,"}":27,"<":28,">":29,sw_sequence:30,sw_item:31,segment:32,sw_block_item:33,sw_volta:34,sw_aba:35,sw_block:36,sw_optional_alternates:37,sw_alternates:38,$accept:0,$end:1},terminals_:{2:"error",5:"EOF",7:"i:",8:"s:",13:",",14:"UNSIGNED",15:"..",21:"[",22:"]",23:"*",26:"{",27:"}",28:"<",29:">"},productions_:[0,[3,2],[4,1],[4,2],[4,2],[6,1],[10,1],[10,1],[10,3],[10,3],[12,3],[11,1],[11,1],[11,1],[11,1],[16,1],[17,1],[20,3],[18,4],[24,0],[24,1],[25,3],[19,5],[9,1],[30,1],[30,2],[31,1],[31,1],[31,1],[31,1],[32,1],[33,1],[36,3],[34,4],[37,0],[37,1],[38,3],[35,4]],performAction:function(e,t,s,i,n,r,a){var o=r.length-1;switch(n){case 1:return r[o-1];case 2:this.$=d(null,r[o]);break;case 3:this.$=d("index-wise",r[o]);break;case 4:this.$=d("segment-wise",k(r[o]));break;case 5:case 23:1===r[o].length&&"BlockMLayout"===r[o][0].__prototype?this.$=r[o][0]:this.$=p(r[o]);break;case 6:case 24:this.$=[r[o]];break;case 7:case 11:case 12:case 13:case 14:case 20:case 27:case 28:case 29:case 35:this.$=r[o];break;case 8:this.$=[...r[o-2],r[o]];break;case 9:this.$=[...r[o-2],...r[o]];break;case 10:this.$=S(r[o-2],r[o]);break;case 15:this.$=f(r[o]);break;case 16:case 31:this.$=p(r[o]);break;case 17:case 32:this.$=r[o-1];break;case 18:case 33:this.$=g(r[o-3],r[o-1],r[o]);break;case 19:case 34:this.$=null;break;case 21:case 36:this.$=x(r[o-1]);break;case 22:this.$=y(r[o-3],r[o-1]);break;case 25:this.$=[...r[o-1],r[o]];break;case 26:this.$=p([r[o]]);break;case 30:this.$=v(r[o]);break;case 37:this.$=y(r[o-2],r[o-1])}},table:[{3:1,4:2,6:3,7:[1,4],8:[1,5],10:6,11:7,12:8,14:t,16:9,17:10,18:11,19:12,20:14,21:s,28:i},{1:[3]},{5:[1,17]},{5:[2,2]},{6:18,10:6,11:7,12:8,14:t,16:9,17:10,18:11,19:12,20:14,21:s,28:i},{9:19,14:n,21:r,28:a,30:20,31:21,32:22,33:23,34:24,35:25,36:27},{5:[2,5],13:o},e(c,[2,6]),e(c,[2,7]),e(c,[2,11]),e(c,[2,12]),e(c,[2,13]),e(c,[2,14]),e(c,l,{15:[1,31],23:u}),e(c,[2,16]),{11:33,14:[1,34],16:9,17:10,18:11,19:12,20:14,21:s,28:i},{10:35,11:7,12:8,14:t,16:9,17:10,18:11,19:12,20:14,21:s,28:i},{1:[2,1]},{5:[2,3]},{5:[2,4]},{5:[2,23],14:n,21:r,28:a,31:36,32:22,33:23,34:24,35:25,36:27},e(h,[2,24]),e(h,[2,26]),e(h,[2,27]),e(h,[2,28]),e(h,[2,29]),e(h,[2,30],{23:[1,37]}),e(h,[2,31]),{14:n,21:r,28:a,31:38,32:22,33:23,34:24,35:25,36:27},{14:n,21:r,28:a,30:39,31:21,32:22,33:23,34:24,35:25,36:27},{11:40,12:41,14:t,16:9,17:10,18:11,19:12,20:14,21:s,28:i},{14:[1,42]},{20:43,21:s},{13:[1,44]},{13:l,23:u},{13:o,22:[1,45]},e(h,[2,25]),{21:r,36:46},{14:n,21:r,28:a,30:47,31:21,32:22,33:23,34:24,35:25,36:27},{14:n,21:r,22:[1,48],28:a,31:36,32:22,33:23,34:24,35:25,36:27},e(c,[2,8]),e(c,[2,9]),e(c,[2,10]),e(c,[2,19],{24:49,25:50,26:[1,51]}),{10:52,11:7,12:8,14:t,16:9,17:10,18:11,19:12,20:14,21:s,28:i},e([5,13,22,26,27,29],[2,17]),e(h,[2,34],{37:53,38:54,26:[1,55]}),{14:n,21:r,28:a,29:[1,56],31:36,32:22,33:23,34:24,35:25,36:27},e([5,14,21,22,26,27,28,29],[2,32]),e(c,[2,18]),e(c,[2,20]),{10:57,11:7,12:8,14:t,16:9,17:10,18:11,19:12,20:14,21:s,28:i},{13:o,29:[1,58]},e(h,[2,33]),e(h,[2,35]),{14:n,21:r,28:a,30:59,31:21,32:22,33:23,34:24,35:25,36:27},e(h,[2,37]),{13:o,27:[1,60]},e(c,[2,22]),{14:n,21:r,27:[1,61],28:a,31:36,32:22,33:23,34:24,35:25,36:27},e(c,[2,21]),e(h,[2,36])],defaultActions:{3:[2,2],17:[2,1],18:[2,3],19:[2,4]},parseError:function(e,t){if(!t.recoverable){var s=new Error(e);throw s.hash=t,s}this.trace(e)},parse:function(e){var t=this,s=[0],i=[null],n=[],r=this.table,a="",o=0,c=0,l=n.slice.call(arguments,1),u=Object.create(this.lexer),h={yy:{}};for(var m in this.yy)Object.prototype.hasOwnProperty.call(this.yy,m)&&(h.yy[m]=this.yy[m]);u.setInput(e,h.yy),h.yy.lexer=u,h.yy.parser=this,void 0===u.yylloc&&(u.yylloc={});var d=u.yylloc;n.push(d);var f=u.options&&u.options.ranges;"function"==typeof h.yy.parseError?this.parseError=h.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;for(var p,g,y,v,x,S,k,b,T=function(){var e;return"number"!=typeof(e=u.lex()||1)&&(e=t.symbols_[e]||e),e},w={};;){if(g=s[s.length-1],this.defaultActions[g]?y=this.defaultActions[g]:(null==p&&(p=T()),y=r[g]&&r[g][p]),void 0===y||!y.length||!y[0]){var M="";for(x in b=[],r[g])this.terminals_[x]&&x>2&&b.push("'"+this.terminals_[x]+"'");M=u.showPosition?"Parse error on line "+(o+1)+":\n"+u.showPosition()+"\nExpecting "+b.join(", ")+", got '"+(this.terminals_[p]||p)+"'":"Parse error on line "+(o+1)+": Unexpected "+(1==p?"end of input":"'"+(this.terminals_[p]||p)+"'"),this.parseError(M,{text:u.match,token:this.terminals_[p]||p,line:u.yylineno,loc:d,expected:b})}if(y[0]instanceof Array&&y.length>1)throw new Error("Parse Error: multiple actions possible at state: "+g+", token: "+p);switch(y[0]){case 1:s.push(p),i.push(u.yytext),n.push(u.yylloc),s.push(y[1]),p=null,c=u.yyleng,a=u.yytext,o=u.yylineno,d=u.yylloc;break;case 2:if(S=this.productions_[y[1]][1],w.$=i[i.length-S],w._$={first_line:n[n.length-(S||1)].first_line,last_line:n[n.length-1].last_line,first_column:n[n.length-(S||1)].first_column,last_column:n[n.length-1].last_column},f&&(w._$.range=[n[n.length-(S||1)].range[0],n[n.length-1].range[1]]),void 0!==(v=this.performAction.apply(w,[a,c,o,h.yy,y[1],i,n].concat(l))))return v;S&&(s=s.slice(0,-1*S*2),i=i.slice(0,-1*S),n=n.slice(0,-1*S)),s.push(this.productions_[y[1]][0]),i.push(w.$),n.push(w._$),k=r[s[s.length-2]][s[s.length-1]],s.push(k);break;case 3:return!0}}return!0}};const d=(e,t)=>({__prototype:"MesaureLayout",type:e,data:t}),f=e=>({__prototype:"SingleMLayout",measure:Number(e)}),p=e=>({__prototype:"BlockMLayout",seq:e}),g=(e,t,s)=>({__prototype:"VoltaMLayout",times:Number(e),body:t,alternates:s}),y=(e,t)=>({__prototype:"ABAMLayout",main:e,rest:t}),v=e=>({segment:!0,length:Number(e)}),x=e=>e.map(e=>"BlockMLayout"===e.__prototype?e.seq:[e]),S=(e,t)=>{if(e=Number(e),!((t=Number(t))>=e))throw new Error(`invalid measure range: ${e}..${t}`);return Array(t+1-e).fill(0).map((t,s)=>f(e+s))},k=(e,t={index:1})=>{const s=e=>[].concat(...e.map(e=>((e,t)=>{if(e.segment){const s=t.index;return t.index+=e.length,Array(e.length).fill(0).map((e,t)=>f(s+t))}return[k(e,t)]})(e,t)));switch(e.__prototype){case"BlockMLayout":e.seq=s(e.seq);break;case"VoltaMLayout":e.body=s(e.body),e.alternates=e.alternates&&e.alternates.map(s);break;case"ABAMLayout":e.main=k(e.main,t),e.rest=s(e.rest)}return e};var b={EOF:1,parseError:function(e,t){if(!this.yy.parser)throw new Error(e);this.yy.parser.parseError(e,t)},setInput:function(e,t){return this.yy=t||this.yy||{},this._input=e,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var e=this._input[0];return this.yytext+=e,this.yyleng++,this.offset++,this.match+=e,this.matched+=e,e.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),e},unput:function(e){var t=e.length,s=e.split(/(?:\r\n?|\n)/g);this._input=e+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-t),this.offset-=t;var i=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),s.length-1&&(this.yylineno-=s.length-1);var n=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:s?(s.length===i.length?this.yylloc.first_column:0)+i[i.length-s.length].length-s[0].length:this.yylloc.first_column-t},this.options.ranges&&(this.yylloc.range=[n[0],n[0]+this.yyleng-t]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},less:function(e){this.unput(this.match.slice(e))},pastInput:function(){var e=this.matched.substr(0,this.matched.length-this.match.length);return(e.length>20?"...":"")+e.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var e=this.match;return e.length<20&&(e+=this._input.substr(0,20-e.length)),(e.substr(0,20)+(e.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var e=this.pastInput(),t=new Array(e.length+1).join("-");return e+this.upcomingInput()+"\n"+t+"^"},test_match:function(e,t){var s,i,n;if(this.options.backtrack_lexer&&(n={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(n.yylloc.range=this.yylloc.range.slice(0))),(i=e[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=i.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:i?i[i.length-1].length-i[i.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+e[0].length},this.yytext+=e[0],this.match+=e[0],this.matches=e,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(e[0].length),this.matched+=e[0],s=this.performAction.call(this,this.yy,this,t,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),s)return s;if(this._backtrack){for(var r in n)this[r]=n[r];return!1}return!1},next:function(){if(this.done)return this.EOF;var e,t,s,i;this._input||(this.done=!0),this._more||(this.yytext="",this.match="");for(var n=this._currentRules(),r=0;rt[0].length)){if(t=s,i=r,this.options.backtrack_lexer){if(!1!==(e=this.test_match(s,n[r])))return e;if(this._backtrack){t=!1;continue}return!1}if(!this.options.flex)break}return t?!1!==(e=this.test_match(t,n[i]))&&e:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){var e=this.next();return e||this.lex()},begin:function(e){this.conditionStack.push(e)},popState:function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(e){return(e=this.conditionStack.length-1-Math.abs(e||0))>=0?this.conditionStack[e]:"INITIAL"},pushState:function(e){this.begin(e)},stateStackSize:function(){return this.conditionStack.length},options:{},performAction:function(e,t,s,i){switch(s){case 0:break;case 1:case 3:case 4:return t.yytext;case 2:return 14;case 5:return 5}},rules:[/^(?:\s+)/,/^(?:([*,\[\]<>{}]))/,/^(?:(([1-9])([0-9])*))/,/^(?:(([a-z])+):)/,/^(?:\.\.)/,/^(?:$)/],conditions:{INITIAL:{rules:[0,1,2,3,4,5],inclusive:!0}}};function T(){this.yy={}}return m.lexer=b,T.prototype=m,m.Parser=T,new T}();We.Parser;We.Parser;var Ve=function(){return We.parse.apply(We,arguments)};var Ge,Ue;!function(e){e[e.Default=0]="Default",e[e.Brace=1]="Brace",e[e.Bracket=2]="Bracket",e[e.Square=3]="Square"}(Ge||(Ge={})),function(e){e[e.Blank=0]="Blank",e[e.Dashed=1]="Dashed",e[e.Solid=2]="Solid"}(Ue||(Ue={}));const ze=e=>({type:Ge.Default,staff:e}),Ke={"{":Ge.Brace,"}":Ge.Brace,"<":Ge.Bracket,">":Ge.Bracket,"[":Ge.Square,"]":Ge.Square},Ye={",":Ue.Blank,"-":Ue.Solid,".":Ue.Dashed},Ze=()=>btoa(Math.random().toString().substr(2)).replace(/=/g,"").split("").reverse().slice(0,6).join(""),Je=(e,t)=>{let s=t;for(;s.length;){const t=s.shift(),i=Ke[t];if(i){if("}>]".includes(t)&&i===e.type)break;if("{<[".includes(t)){const t={type:i,level:Number.isFinite(e.level)?e.level+1:0};s=Je(t,s),e.subs=e.subs||[],e.subs.push(t)}}else e.subs=e.subs||[],e.subs.push(ze(t))}for(;e.type===Ge.Default&&e.subs&&1===e.subs.length;){const t=e.subs[0];e.type=t.type,e.subs=t.subs,e.staff=t.staff,e.level=t.level}for(;e.subs&&1===e.subs.length&&e.subs[0].type===Ge.Default;){const t=e.subs[0];e.subs=t.subs,e.staff=t.staff}return e.grand=e.type===Ge.Brace&&e.subs&&e.subs.every(e=>e.staff),s},Xe=e=>e.staff?e.staff:e.subs?Xe(e.subs[0]):void 0,Qe=e=>e.staff?e.staff:e.subs?Qe(e.subs[e.subs.length-1]):void 0,et=(e,t)=>{t[(e=>e.staff?e.staff:e.subs?`${Xe(e)}-${Qe(e)}`:void 0)(e)]=e,e.subs&&e.subs.forEach(e=>et(e,t))};class StaffLayout{constructor(e){const t=new Set;e.forEach((e,s)=>{e.id=((e,t,s)=>{let i=s;for(i?e.has(i)&&(i+="_"+t.toString()):i=t.toString();e.has(i);)i+="_"+Ze();return i})(t,s+1,e.id),t.add(e.id)}),this.staffIds=e.map(e=>e.id),this.conjunctions=e.slice(0,e.length-1).map(e=>e.conjunction?Ye[e.conjunction]:Ue.Blank);const s=[].concat(...e.map(e=>[...e.leftBounds,e.id,...e.rightBounds]));this.group={type:Ge.Default},Je(this.group,s);const i={};et(this.group,i),this.groups=Object.entries(i).map(([e,t])=>{let s=e.split("-");1===s.length&&(s=[s[0],s[0]]);return{group:t,range:s.map(e=>this.staffIds.indexOf(e)),key:e}}),this.maskCache=new Map}get stavesCount(){return this.staffIds?this.staffIds.length:null}get partGroups(){const e=this.groups.filter(e=>e.group.grand);return this.groups.filter(t=>{if(t.group.grand)return!0;if(t.range[0]===t.range[1]){const s=t.range[0];return!e.some(e=>e.range[0]<=s&&e.range[1]>=s)}return!1})}get standaloneGroups(){const e=[],t=s=>{s.grand?e.push(s.subs.map(e=>e.staff)):s.staff?e.push([s.staff]):s.subs&&s.subs.forEach(e=>t(e))};return t(this.group),e}conjunctionBetween(e,t){if(t<=e)return null;let s=Ue.Solid;for(let i=e;it&1<({ids:e.staffIds.slice(t.range[0],t.range[1]+1).filter(e=>s.includes(e)),...t})).filter(({ids:e})=>e.length).map(({ids:e,...t})=>({key:t.key,group:t.group,range:[s.indexOf(e[0]),s.indexOf(e[e.length-1])]})),n=s.slice(0,s.length-1).map((t,i)=>{const n=s[i+1];return e.conjunctionBetween(e.staffIds.indexOf(t),e.staffIds.indexOf(n))});return{staffIds:s,conjunctions:n,groups:i}}mask(e){return this.maskCache.get(e)||this.maskCache.set(e,StaffLayout.makeMaskLayout(this,e)),this.maskCache.get(e)}partialMaskCode(e,t=!1){const s=this.staffIds.map((t,s)=>s(e[this.staffIds[s]]=t,e),{}),i=e=>{if(e.staff)return[s[e.staff]?e.staff:null,null===s[e.staff]];const t=e.subs.map(e=>i(e)),n=t.map(e=>e[0]).filter(Boolean).join(","),r=t.some(([e,t])=>t),a=n?((e,t=!1)=>{if(e===Ge.Default)return e=>e;if(t)switch(e){case Ge.Brace:return e=>`{${e}`;case Ge.Bracket:return e=>`<${e}`;case Ge.Square:return e=>`[${e}`;default:return e=>e}switch(e){case Ge.Brace:return e=>`{${e}}`;case Ge.Bracket:return e=>`<${e}>`;case Ge.Square:return e=>`[${e}]`;default:return e=>e}})(e.type,r)(n):null;return[a,r]};let[n]=i(this.group);return n=n||"",t||(n=n.replace(/[_\w]+/g,"")),n}}var tt=function(){var e=function(e,t,s,i){for(s=s||{},i=e.length;i--;s[e[i]]=t);return s},t=[1,15],s=[1,16],i=[1,17],n=[1,11],r=[1,12],a=[1,13],o=[1,24],c=[1,25],l=[1,26],u=[5,11,12,13,15,16,17,21,22,23,24],h=[15,16,17,21,22,23,24],m=[11,12,13,15,16,17,21,22,23,24],d=[5,11,12,13,21,22,23,24],f={trace:function(){},yy:{},symbols_:{error:2,start_symbol:3,staff_layout:4,EOF:5,seq:6,seq_id:7,seq_br:8,seq_con:9,bound_left:10,"<":11,"[":12,"{":13,bound_right:14,">":15,"]":16,"}":17,bound_lefts:18,bound_rights:19,conjunction:20,"-":21,",":22,".":23,ID:24,seq_bl:25,$accept:0,$end:1},terminals_:{2:"error",5:"EOF",11:"<",12:"[",13:"{",15:">",16:"]",17:"}",21:"-",22:",",23:".",24:"ID"},productions_:[0,[3,2],[4,1],[6,0],[6,1],[6,1],[6,1],[10,1],[10,1],[10,1],[14,1],[14,1],[14,1],[18,1],[18,2],[19,1],[19,2],[20,1],[20,1],[20,1],[7,1],[7,2],[7,2],[7,2],[7,2],[25,1],[25,2],[25,2],[25,2],[8,2],[8,2],[8,2],[9,1],[9,2],[9,2],[9,2],[9,2]],performAction:function(e,t,s,i,n,r,a){var o=r.length-1;switch(n){case 1:return r[o-1];case 2:r[o].next(),this.$=r[o].toJSON();break;case 3:this.$=new Seq;break;case 13:case 15:this.$=[r[o]];break;case 14:case 16:this.$=[...r[o-1],r[o]];break;case 20:this.$=new Seq,this.$.tip.i(r[o]);break;case 21:case 23:r[o-1].next(),r[o-1].tip.i(r[o]),this.$=r[o-1];break;case 22:case 24:r[o-1].tip.i(r[o]),this.$=r[o-1];break;case 25:this.$=new Seq,this.$.tip.bl(r[o]);break;case 26:case 27:r[o-1].next(),r[o-1].tip.bl(r[o]),this.$=r[o-1];break;case 28:r[o-1].tip.bl(r[o]),this.$=r[o-1];break;case 29:case 30:case 31:r[o-1].tip.br(r[o]),this.$=r[o-1];break;case 32:this.$=new Seq,this.$.tip.con(r[o]),this.$.next();break;case 33:case 34:case 35:case 36:r[o-1].tip.con(r[o]),r[o-1].next(),this.$=r[o-1]}},table:[{3:1,4:2,5:[2,3],6:3,7:4,8:5,9:6,10:14,11:t,12:s,13:i,18:10,20:9,21:n,22:r,23:a,24:[1,7],25:8},{1:[3]},{5:[1,18]},{5:[2,2]},{5:[2,4],10:14,11:t,12:s,13:i,14:23,15:o,16:c,17:l,18:22,19:20,20:21,21:n,22:r,23:a,24:[1,19]},{5:[2,5],10:14,11:t,12:s,13:i,18:29,20:28,21:n,22:r,23:a,24:[1,27]},{5:[2,6],10:14,11:t,12:s,13:i,14:23,15:o,16:c,17:l,18:33,19:31,20:32,21:n,22:r,23:a,24:[1,30]},e(u,[2,20]),{14:23,15:o,16:c,17:l,19:35,20:36,21:n,22:r,23:a,24:[1,34]},e(u,[2,32]),e(h,[2,25],{10:37,11:t,12:s,13:i}),e(u,[2,17]),e(u,[2,18]),e(u,[2,19]),e(m,[2,13]),e(m,[2,7]),e(m,[2,8]),e(m,[2,9]),{1:[2,1]},e(u,[2,21]),e(d,[2,29],{14:38,15:o,16:c,17:l}),e(u,[2,33]),e(h,[2,26],{10:37,11:t,12:s,13:i}),e(u,[2,15]),e(u,[2,10]),e(u,[2,11]),e(u,[2,12]),e(u,[2,23]),e(u,[2,35]),e(h,[2,27],{10:37,11:t,12:s,13:i}),e(u,[2,24]),e(d,[2,31],{14:38,15:o,16:c,17:l}),e(u,[2,36]),e(h,[2,28],{10:37,11:t,12:s,13:i}),e(u,[2,22]),e(d,[2,30],{14:38,15:o,16:c,17:l}),e(u,[2,34]),e(m,[2,14]),e(u,[2,16])],defaultActions:{3:[2,2],18:[2,1]},parseError:function(e,t){if(!t.recoverable){var s=new Error(e);throw s.hash=t,s}this.trace(e)},parse:function(e){var t=this,s=[0],i=[null],n=[],r=this.table,a="",o=0,c=0,l=n.slice.call(arguments,1),u=Object.create(this.lexer),h={yy:{}};for(var m in this.yy)Object.prototype.hasOwnProperty.call(this.yy,m)&&(h.yy[m]=this.yy[m]);u.setInput(e,h.yy),h.yy.lexer=u,h.yy.parser=this,void 0===u.yylloc&&(u.yylloc={});var d=u.yylloc;n.push(d);var f=u.options&&u.options.ranges;"function"==typeof h.yy.parseError?this.parseError=h.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;for(var p,g,y,v,x,S,k,b,T=function(){var e;return"number"!=typeof(e=u.lex()||1)&&(e=t.symbols_[e]||e),e},w={};;){if(g=s[s.length-1],this.defaultActions[g]?y=this.defaultActions[g]:(null==p&&(p=T()),y=r[g]&&r[g][p]),void 0===y||!y.length||!y[0]){var M="";for(x in b=[],r[g])this.terminals_[x]&&x>2&&b.push("'"+this.terminals_[x]+"'");M=u.showPosition?"Parse error on line "+(o+1)+":\n"+u.showPosition()+"\nExpecting "+b.join(", ")+", got '"+(this.terminals_[p]||p)+"'":"Parse error on line "+(o+1)+": Unexpected "+(1==p?"end of input":"'"+(this.terminals_[p]||p)+"'"),this.parseError(M,{text:u.match,token:this.terminals_[p]||p,line:u.yylineno,loc:d,expected:b})}if(y[0]instanceof Array&&y.length>1)throw new Error("Parse Error: multiple actions possible at state: "+g+", token: "+p);switch(y[0]){case 1:s.push(p),i.push(u.yytext),n.push(u.yylloc),s.push(y[1]),p=null,c=u.yyleng,a=u.yytext,o=u.yylineno,d=u.yylloc;break;case 2:if(S=this.productions_[y[1]][1],w.$=i[i.length-S],w._$={first_line:n[n.length-(S||1)].first_line,last_line:n[n.length-1].last_line,first_column:n[n.length-(S||1)].first_column,last_column:n[n.length-1].last_column},f&&(w._$.range=[n[n.length-(S||1)].range[0],n[n.length-1].range[1]]),void 0!==(v=this.performAction.apply(w,[a,c,o,h.yy,y[1],i,n].concat(l))))return v;S&&(s=s.slice(0,-1*S*2),i=i.slice(0,-1*S),n=n.slice(0,-1*S)),s.push(this.productions_[y[1]][0]),i.push(w.$),n.push(w._$),k=r[s[s.length-2]][s[s.length-1]],s.push(k);break;case 3:return!0}}return!0}};class Item{constructor(){this.id=null,this.leftBounds=[],this.rightBounds=[],this.conjunction=null}i(e){return this.id=e,this}bl(e){return this.leftBounds=e,this}br(e){return this.rightBounds=e,this}con(e){return this.conjunction=e,this}}class Seq{constructor(){this.body=[],this.tip=new Item}next(){return this.body.push(this.tip),this.tip=new Item,this}toJSON(){return this.body}}var p={EOF:1,parseError:function(e,t){if(!this.yy.parser)throw new Error(e);this.yy.parser.parseError(e,t)},setInput:function(e,t){return this.yy=t||this.yy||{},this._input=e,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var e=this._input[0];return this.yytext+=e,this.yyleng++,this.offset++,this.match+=e,this.matched+=e,e.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),e},unput:function(e){var t=e.length,s=e.split(/(?:\r\n?|\n)/g);this._input=e+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-t),this.offset-=t;var i=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),s.length-1&&(this.yylineno-=s.length-1);var n=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:s?(s.length===i.length?this.yylloc.first_column:0)+i[i.length-s.length].length-s[0].length:this.yylloc.first_column-t},this.options.ranges&&(this.yylloc.range=[n[0],n[0]+this.yyleng-t]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},less:function(e){this.unput(this.match.slice(e))},pastInput:function(){var e=this.matched.substr(0,this.matched.length-this.match.length);return(e.length>20?"...":"")+e.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var e=this.match;return e.length<20&&(e+=this._input.substr(0,20-e.length)),(e.substr(0,20)+(e.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var e=this.pastInput(),t=new Array(e.length+1).join("-");return e+this.upcomingInput()+"\n"+t+"^"},test_match:function(e,t){var s,i,n;if(this.options.backtrack_lexer&&(n={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(n.yylloc.range=this.yylloc.range.slice(0))),(i=e[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=i.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:i?i[i.length-1].length-i[i.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+e[0].length},this.yytext+=e[0],this.match+=e[0],this.matches=e,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(e[0].length),this.matched+=e[0],s=this.performAction.call(this,this.yy,this,t,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),s)return s;if(this._backtrack){for(var r in n)this[r]=n[r];return!1}return!1},next:function(){if(this.done)return this.EOF;var e,t,s,i;this._input||(this.done=!0),this._more||(this.yytext="",this.match="");for(var n=this._currentRules(),r=0;rt[0].length)){if(t=s,i=r,this.options.backtrack_lexer){if(!1!==(e=this.test_match(s,n[r])))return e;if(this._backtrack){t=!1;continue}return!1}if(!this.options.flex)break}return t?!1!==(e=this.test_match(t,n[i]))&&e:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){var e=this.next();return e||this.lex()},begin:function(e){this.conditionStack.push(e)},popState:function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(e){return(e=this.conditionStack.length-1-Math.abs(e||0))>=0?this.conditionStack[e]:"INITIAL"},pushState:function(e){this.begin(e)},stateStackSize:function(){return this.conditionStack.length},options:{},performAction:function(e,t,s,i){switch(s){case 0:break;case 1:return t.yytext;case 2:return 24;case 3:return 5}},rules:[/^(?:\s+)/,/^(?:([-,.\[\]<>{}]))/,/^(?:([a-zA-Z_0-9]+))/,/^(?:$)/],conditions:{INITIAL:{rules:[0,1,2,3],inclusive:!0}}};function g(){this.yy={}}return f.lexer=p,g.prototype=f,f.Parser=g,new g}();tt.Parser;tt.Parser;var st=function(){return tt.parse.apply(tt,arguments)};const it=e=>{const t=st(e);return new StaffLayout(t)};class SemanticGraph extends SimpleClass{constructor(e){super(),super.assign(e)}static fromPoints(e=[]){const t=new SemanticGraph;return t.points=e,t}getLayer(e){return this.points.filter(t=>t.semantic===e)}getConfidentLayer(e,t){return this.points.filter(s=>s.semantic===e&&(!Number.isFinite(s.confidence)||s.confidence>=t))}getSystemPoints(){return this.points.filter(e=>E.includes(e.semantic))}getStaffPoints(){return this.points.filter(e=>!E.includes(e.semantic))}offset(e,t){this.points.forEach(s=>{s.x+=e,s.y+=t})}scale(e){this.points.forEach(t=>{t.x*=e,t.y*=e})}transform(e){this.points.forEach(t=>{let s=t.x*e[0][0]+t.y*e[1][0]+e[2][0];const i=t.x*e[0][1]+t.y*e[1][1]+e[2][1];if(t.extension){if(Number.isFinite(t.extension.y1)){const i=t.x*e[0][1]+t.extension.y1*e[1][1]+e[2][1],n=t.x*e[0][1]+t.extension.y2*e[1][1]+e[2][1];s=t.x*e[0][0]+.5*(t.extension.y1+t.extension.y2)*e[1][0]+e[2][0],t.extension.y1=i,t.extension.y2=n}if(Number.isFinite(t.extension.width)){const s=Math.sqrt(e[0][0]*e[1][1]-e[0][1]*e[1][0]);t.extension.width*=s,t.extension.height*=s}}t.x=s,t.y=i})}}SemanticGraph.className="SemanticGraph";const nt=[T.ClefG,T.ClefF,T.ClefC,T.TimesigC44,T.TimesigC22,T.TimesigZero,T.TimesigOne,T.TimesigTwo,T.TimesigThree,T.TimesigFour,T.TimesigFive,T.TimesigSix,T.TimesigSeven,T.TimesigEight,T.TimesigNine,T.OctaveShift8va,T.OctaveShift8vb,T.OctaveShift0,T.Zero,T.One,T.Two,T.Three,T.Four,T.Five,T.Six,T.Seven,T.Eight,T.Nine,T.AccNatural,T.AccSharp,T.AccDoublesharp,T.AccFlat,T.AccFlatflat,T.NoteheadS0,T.NoteheadS1,T.NoteheadS2,T.NoteheadS1stemU,T.NoteheadS1stemD,T.NoteheadS2stemU,T.NoteheadS2stemD,T.Rest0,T.Rest1,T.Rest2,T.Rest3,T.Rest4,T.Rest5,T.Rest6,T.Rest0W,T.RestM1,T.SlurBegin,T.SlurEnd,T.Dot,T.f,T.p,T.m,T.n,T.r,T.s,T.z,T.ScriptFermata,T.ScriptShortFermata,T.ScriptSforzato,T.ScriptStaccato,T.ScriptStaccatissimo,T.ScriptTurn,T.ScriptTrill,T.ScriptSegno,T.ScriptCoda,T.ScriptArpeggio,T.ScriptPrall,T.ScriptMordent,T.ScriptMarcato,T.ScriptTenuto,T.ScriptPortato,T.PedalStar,T.PedalPed,T.GraceNotehead,T.BeamLeft,T.BeamRight,T.BeamContinue,T.CrescendoBegin,T.CrescendoEnd,T.DecrescendoBegin,T.DecrescendoEnd,T.TremoloLeft,T.TremoloRight,T.TremoloMiddle],rt=[T.AccNatural,T.AccSharp,T.AccDoublesharp,T.AccFlat,T.AccFlatflat,T.NoteheadS0,T.NoteheadS1,T.NoteheadS2,T.NoteheadS1stemU,T.NoteheadS1stemD,T.NoteheadS2stemU,T.NoteheadS2stemD],at=[T.SignLined,T.SignInterval],ot=[T.NoteheadS1,T.NoteheadS2],ct={AccSharp:Z.KeySharp,AccNatural:Z.KeyNatural,AccFlat:Z.KeyFlat},lt={[T.NoteheadS1]:{up:T.NoteheadS1stemU,down:T.NoteheadS1stemD},[T.NoteheadS2]:{up:T.NoteheadS2stemU,down:T.NoteheadS2stemD}},ut=[T.Rest0,T.Rest1,T.Rest2,T.Rest3,T.Rest4,T.Rest5,T.Rest6],ht={[Z.BeamLeft]:"Open",[Z.BeamRight]:"Close",[Z.BeamContinue]:"Continue"},mt={Alter1:Pe.Alternation1,Alter2:Pe.Alternation2},dt=(e,t)=>{switch(e.length){case 0:return;case 1:return e[0];case 2:return"u"===t?Math.min(...e):Math.max(...e);default:{const s=e.reduce((e,t)=>e+t,0)/e.length;return e.sort((e,t)=>Math.abs(e-s)-Math.abs(t-s)),dt(e.slice(0,e.length-1),t)}}};class Measure extends SimpleClass{constructor(e){super(),super.assign(e),this.tokens=this.tokens||[],this.antiTokens=this.antiTokens||[],this.barTypes=this.barTypes||{}}get right(){return this.left+this.width}get noteheads(){return this.tokens.filter(e=>e.isNotehead).sort((e,t)=>e.x-t.x)}get chordRects(){const e=this.noteheads.filter(e=>[Z.NoteheadS0,Z.NoteheadS1stemU,Z.NoteheadS2stemU,Z.NoteheadS1stemD,Z.NoteheadS2stemD].includes(e.type));let t=0;const s=e.reduce((e,s)=>{const i=s.tip?`${s.tip.x}|${s.tip.y}`:`nul${t}`;let n=`${s.type}|${i}`;return!s.tip&&e[n]&&(e[n].some(e=>Math.abs(e.x-s.x){const t=Math.min(...e.map(e=>e.x)),s=Math.max(...e.map(e=>e.x)),i=Math.min(...e.map(e=>e.y)),n=Math.max(...e.map(e=>e.y)),r=e[0],a=r&&r.tip?r.tip.x:t;let o=t,c=s-t,l=null;switch(r.type){case Z.NoteheadS0:o-=w.NoteheadS0/2,c+=w.NoteheadS0;break;case Z.NoteheadS1stemU:case Z.NoteheadS2stemU:l="u",o-=w.NoteheadS1,c+=w.NoteheadS1;break;case Z.NoteheadS1stemD:case Z.NoteheadS2stemD:l="d",c+=w.NoteheadS1}return{x:o,width:c,stemX:a,stemDirection:l,top:i,bottom:n,tip:r.tip}})}get timeWarped(){return this.tokens&&this.tokens.some(e=>e.timeWarped)}get additionalLines(){const e=this.getChords();return[...e.filter(e=>e.ys.some(e=>e<=-3)).map(e=>({left:e.left,right:e.right,n:Math.ceil(Math.min(...e.ys))+2})),...e.filter(e=>e.ys.some(e=>e>=3)).map(e=>({left:e.left,right:e.right,n:Math.floor(Math.max(...e.ys))-2}))].map(e=>({left:e.left-.28,right:e.right+.28,n:e.n}))}getChords(){const e=this.tokens.filter(e=>ue.includes(e.type)),t=this.tokens.filter(e=>pe.includes(e.type)),s=this.tokens.filter(e=>ye.includes(e.type)),i=this.chordRects.map(e=>{const t=this.noteheads.filter(t=>t.direction===e.stemDirection&&t.left>=e.x&&t.right<=e.x+e.width+.2&&t.y>=e.top&&t.y<=e.bottom);t.sort((e,t)=>t.y-e.y);const s=t.map(e=>e.y),i=t.map(e=>e.id),n=t.reduce((e,t)=>Math.max(e,t.division),0);return{rect:e,left:e.x,right:e.x+e.width,pivotX:(r=t,dt(r.map(e=>Number.isFinite(e.pivotX)?e.pivotX:e.x),r[0].direction)),ys:s,tip:e.tip,noteIds:i,division:n,dots:null,rest:!1,stemDirection:e.stemDirection,beam:null};var r}).sort((e,t)=>t.left-e.left),n=new Set,r=i.map(({rect:i,...r})=>{if(r.division>=1){const t=[i.bottom,i.top];switch(i.stemDirection){case"u":t[0]=i.tip?i.tip.y-.2:i.top-6-.5;break;case"d":t[1]=i.tip?i.tip.y+.2:i.bottom+6+.5}const a=e.filter(e=>!n.has(e.id)&&e.x>i.stemX-.2&&e.xt[0]&&e.yMath.max(e,t.division),r.division),a.forEach(e=>n.add(e.id)),r.division>=3){const e=i.tip&&s.find(e=>Math.abs(i.tip.x-e.x)<.3&&Math.abs(i.tip.y-e.y)<.7);e&&(r.beam=ht[e.type])}}const a=t.filter(e=>!n.has(e.id)&&e.x>i.x+i.width-.2&&e.xi.top-1&&e.y<=i.bottom+.5);return r.dots=a.reduce((e,t)=>Math.max(e,t.dots),0),a.forEach(e=>n.add(e.id)),r});return r.reverse(),r}getRests(){const e=this.tokens.filter(e=>le.includes(e.type)),t=this.tokens.filter(e=>pe.includes(e.type));return e.map(e=>{const s=t.filter(t=>t.x>e.x+.5&&t.xe.y-1&&t.yMath.max(e,t.dots),0);return{left:e.x-.75,right:e.x+.75,pivotX:e.x,rest:!0,ys:[e.y],noteIds:[e.id],dots:s,division:e.division,stemDirection:null}})}getEvents(){return[...this.getChords(),...this.getRests()].sort((e,t)=>e.left-t.left)}getContexts(e={}){return this.tokens.filter(e=>e.isContexted).sort((e,t)=>e.x-t.x).map(t=>new ContextedTerm({x:t.x,y:t.y,tokenType:t.type,...e}))}assignAccessoriesOnEvents(e){e.forEach(e=>e.accessories=e.accessories||[]);this.tokens.filter(e=>xe.includes(e.type)).forEach(t=>{const s=e.filter(e=>t.x>e.left-1&&t.x0){let e=s[0];s.length>1&&(e=s.map(e=>({event:e,d:Math.min(...e.ys.map(e=>Math.abs(e-t.y)))})).sort(({d:e},{d:t})=>e-t).map(({event:e})=>e)[0]);let i=t.y>Math.max(...e.ys)?Me.Down:Me.Up;Se.includes(t.type)&&(i=null),e.accessories.push({type:t.type,id:t.id,direction:i,x:t.x-e.left})}});const t=[...e];t.sort((e,t)=>e.left-t.left);this.tokens.filter(e=>e.type===Z.ScriptArpeggio).forEach(e=>{const s=t.find(t=>e.xtt>e.y));s&&s.accessories.push({type:Z.ScriptArpeggio,id:e.id,x:e.x-s.left})});this.tokens.filter(e=>e.type===Z.GraceNotehead).forEach(t=>{const s=e.find(e=>t.x>e.left&&t.xMath.abs(t.y-e)<.4));s&&(s.grace=Ee.Grace)});const s=this.tokens.filter(e=>e.type===Z.TremoloLeft),i=this.tokens.filter(e=>e.type===Z.TremoloRight),n=this.tokens.filter(e=>e.type===Z.TremoloMiddle),r=e.filter(e=>!e.rest).map(e=>{const t=[...e.ys];e.tip?t.push(e.tip.y):(t.push(e.ys[0]+2),t.push(e.ys[e.ys.length-1]-2));const s=e.tip?e.tip.x:e.left,i=e.tip?e.tip.x:e.right;return{event:e,top:Math.min(...t),bottom:Math.max(...t),stemL:s,stemR:i}});n.forEach(e=>{const t=r.find(t=>!!t.event.tip&&(e.y>t.top&&e.y{const t=r.find(t=>e.y>t.top&&e.yt.stemR&&e.x{const t=r.find(t=>e.y>t.top&&e.yt.stemL-1.6);t&&(t.event.tremolo=t.event.tremolo||2,++t.event.tremolo,t.event.tremoloLink=Ne.Catcher)})}assignFeaturesOnEvents(e,t){const s=t.filter(e=>e.x>this.left&&e.xut.includes(e.semantic)),n=s.filter(e=>e.semantic===T.Flag3),r=s.filter(e=>e.semantic===T.Dot),a=s.filter(e=>e.semantic===T.BeamLeft),o=s.filter(e=>e.semantic===T.BeamContinue),c=s.filter(e=>e.semantic===T.BeamRight),l=s.filter(e=>e.semantic===T.GraceNotehead),u=s.filter(e=>e.semantic===T.TremoloRight),h=s.filter(e=>e.semantic===T.vline_Stem),m=s.filter(e=>e.semantic===T.NoteheadS0),d=s.filter(e=>e.semantic===T.NoteheadS1),f=s.filter(e=>e.semantic===T.NoteheadS2);e.forEach(e=>{const t=e.tip?e.tip.x:(e.left+e.right)/2,s=e.tip?Math.min(e.tip.y,e.ys[e.ys.length-1]):e.ys[e.ys.length-1],p=e.tip?Math.max(e.tip.y,e.ys[0]):e.ys[0],g=e.tip?e.tip.x:e.left,y=[0,0,0,0,0,0,0];if(e.rest){i.filter(s=>_(s,{x:t,y:e.ys[0]})<.5).forEach(e=>{const t=ut.indexOf(e.semantic);y[t]=Math.max(y[t],e.confidence)})}else{const i=[m,d,f].map(t=>t.filter(t=>t.x>e.left&&t.xs-.25&&t.yMath.max(0,...e.map(e=>e.confidence))),r=n.filter(e=>e.y>s-.2&&e.yt.confidence-e.confidence),y[0]=i[0],y[1]=i[1],y[2]=i[2],Array(y.length-3).fill(0).forEach((e,t)=>y[3+t]=r[t]?r[t].confidence:0)}const v=r.filter(s=>s.x>t&&s.xv.some(t=>e.x>t.x&&Math.abs(e.y-t.y)<.2)),S=[Math.max(0,...v.map(e=>e.confidence)),Math.max(0,...x.map(e=>e.confidence))],k=[a,o,c].map(e=>e.filter(e=>Math.abs(e.x-t)<.2&&e.y>s-.2&&e.yMath.max(0,...e.map(e=>e.confidence))),b=h.filter(s=>_({x:t,y:e.ys[0]},{x:s.x,y:s.extension.y2})<.5),T=h.filter(s=>_({x:t,y:e.ys[e.ys.length-1]},{x:s.x,y:s.extension.y1})<.5),w=[Math.max(0,...b.map(e=>e.confidence)),Math.max(0,...T.map(e=>e.confidence))],M=l.filter(s=>Math.abs(s.x-t)<.6&&e.ys.some(e=>Math.abs(s.y-e)<.4)),E=Math.max(0,...M.map(e=>e.confidence)),A=0===e.division?u.filter(t=>t.x>e.left-2&&t.xe.y>s-.04&&e.yg-2&&e.xe.confidence));e.feature={divisions:y,dots:S,beams:k,stemDirections:w,grace:E,tremoloCatcher:N}})}}Measure.className="Measure",Measure.blackKeys=["tokens","antiTokens"];class Staff extends SimpleClass{constructor({measureCount:e=null,measureBars:t=null,...s}={}){if(super(),super.assign(s),this.height=this.height||10,this.staffY=this.staffY||5,t){let e=0;this.measures=t.map(t=>{const s=new Measure({left:e,width:t-e,height:this.height});return e=t,s})}else this.measures=e?Array(e).fill(null).map(()=>new Measure):[]}get noteRange(){const e=[].concat(...this.measures.map(e=>e.noteheads)).map(e=>e.y);return{top:Math.min(-2,...e),bottom:Math.max(2,...e)}}get additionalLines(){return[].concat(...this.measures.map(e=>e.additionalLines))}rearrangeMeasures(e){if(!e.length)return void console.warn("rearrangeMeasures error, measureBars are empty.");const t=this.measures?.map(e=>e.tokens).flat(1)||[];let s=0;this.measures=e.map(e=>{const t=new Measure({left:s,width:e-s,height:this.height});return s=e,t}),this.reassignTokens(t)}reassignTokens(e=null){e||(e=[].concat(...this.measures.map(e=>e.tokens))),this.measures.forEach(e=>e.tokens=[]),e.forEach(e=>{for(const t of this.measures)if(e.xe.semantic===T.TempoNotehead).forEach(e=>{const t=i.findIndex(t=>/^Notehead/.test(t.semantic)&&_(e,t)<.3);t>=0&&i.splice(t,1)});const n=e=>t.displacementSemantics?.[e]?this.semantics.find(t=>t.id===e):null;i.filter(e=>nt.includes(e.semantic)).forEach(e=>this.appendPoint(e,{points:i}));const r=i.filter(e=>e.semantic===T.vline_Stem).filter(e=>e.extension.y2-e.extension.y1>1.5).map(e=>({x:e.x,y1:e.extension.y1,y2:e.extension.y2,direction:null})),a=i.filter(e=>ot.includes(e.semantic)&&e.y>this.semanticTop&&e.y{if((s?1:0)^(e.x{const t=a.filter(t=>Math.abs(t.x-e.x)-w[t.semantic]/2<.32&&Math.abs(t.x-e.x)-w[t.semantic]/2>-.44&&t.y>e.y1-.5&&t.ye.x&&t.y>e.y2)&&!(t.xe.y-t.y);const s=Math.min(...t.map(t=>t.y-e.y1)),r=Math.min(...t.map(t=>e.y2-t.y));if(Math.min(s,r)>.5)return;const a=s!o.has(e.id)).forEach(e=>{const a=r.filter(t=>Math.abs(t.x-e.x)<2&&e.y>t.y1&&e.yMath.abs(t.x-e.x)-Math.abs(s.x-e.x)),o=a[0];if(o){const t="d"===o.direction,s=t?lt[e.semantic].down:lt[e.semantic].up;this.appendPoint({id:e.id,semantic:s,x:o.x+c(e,o,t),y:e.y,pivotX:e.x,confidence:e.confidence},{tip:{x:o.x,y:t?o.y2:o.y1},antiPoint:n(e.id),points:i})}else s.debug("isolated notehead:",t.index,this.index,e)});const l=i.filter(e=>e.semantic===T.Flag3);l.sort((e,t)=>e.x-t.x),this.appendFlags(l,r);const u=i.filter(e=>e.semantic===T.Dot).map(e=>{const t=B(e.y,.5);return{x:e.x,y:t}}).reduce((e,t)=>(e[t.y]=e[t.y]||[],e[t.y].push(t),e),{});Object.entries(u).forEach(([e,t])=>{const s=Number(e);if(t.length>1){t.sort((e,t)=>e.x-t.x);for(let e=0;ee.x>r.x&&e.x-r.x<1.2)&&this.appendPoint({id:r.id,x:r.x,y:s,confidence:r.confidence},{type:Z.DotDot,antiPoint:n(r.id),points:i})}}});const h=i.filter(e=>e.semantic===T.KeyAcc);i.filter(e=>ct[e.semantic]).forEach(e=>{h.some(t=>Math.abs(e.x-t.x)<.5&&Math.abs(e.y-t.y)<1)&&this.appendPoint({id:e.id,semantic:e.semantic,x:e.x,y:e.y,confidence:e.confidence},{type:ct[e.semantic],points:i})});i.filter(e=>e.semantic===T.OctaveShift8).forEach(e=>{const t=e.y<0?Z.OctaveShift8va:Z.OctaveShift8vb;this.appendPoint({id:e.id,x:e.x,y:e.y,confidence:e.confidence},{type:t,points:i})});const m=this.semantics.filter(e=>[T.VoltaLeft,T.VoltaRight].includes(e.semantic));m.sort((e,t)=>e.x-t.x);const d=m.reduce((e,t)=>{const s=e[t.semantic],i=Array.from(Object.keys(s)).map(Number).find(e=>t.x{if(s.length>1){const i=s.reduce((e,t)=>e+t.confidence,0);s[0].y*s[1].y<0&&i>=2*e&&this.appendPoint(s[0],{type:Z[t]})}})}appendPoint(e,{type:t,points:s=null,antiPoint:i,...n}={}){const r=e.x,a=this.measures.find(e=>rat.includes(t.semantic)&&Math.abs(t.y-e.y)<.2&&Math.abs(t.x-e.x)<1.2);t.some(e=>e.semantic===T.SignLined)?o=!0:t.some(e=>e.semantic===T.SignInterval)&&(c=!0)}t=t||Z[e.semantic];const l=Te[t];let u=be[t];(o||c)&&(u=Math.max(u,1));let h=e.y;Number.isFinite(l)?h=l:u&&(h=c?B(h+.5,u)-.5:B(h,u));const m=a.tokens.find(e=>e.type===t&&Math.abs(e.x-r)<.1&&Math.abs(e.y-h)<.1);m?Number.isFinite(m.confidence)&&m.confidence3||(a.tokens.push(new Token({id:e.id,type:t,x:r,y:h,pivotX:e.pivotX,confidence:e.confidence,...n})),i&&a.antiTokens.push(new Token({id:i.id,type:t,x:r,y:i.y,confidence:i.confidence})))}appendFlags(e,t){t.map(t=>({...t,flags:e.filter(e=>Math.abs(e.x-t.x)<.3&&e.y>t.y1-.5&&e.ye.flags.length).forEach(e=>{const t=e.flags.reduce((e,t)=>e&&e.confidence>t.confidence?e:t,null),s="d"===e.direction,i=s?Math.min(e.y2,e.y1+6):Math.max(e.y1,e.y2-6),n=e.flags.map(e=>({tip:(i-e.y)*(s?1:-1),confidence:e.confidence})).filter(e=>e.tip<2||e.confidence>.7*t.confidence).length,r=ue[n-1];r&&this.appendPoint({id:e.flags[0].id,x:e.x,y:i,confidence:Math.min(...e.flags.map(e=>e.confidence))},{type:r})})}clearTokens(){this.measures.forEach(e=>e.tokens=[]),this.semantics=[]}clearPredictedTokens(){this.measures.forEach(e=>e.tokens=e.tokens.filter(e=>!e.isPredicted))}}Staff.className="Staff",Staff.blackKeys=["index","semanticTop","semanticBttom"];class System extends SimpleClass{constructor({stavesCount:e,...t}){if(super(),super.assign(t),!this.measureBars){const e=5,t=(this.width-e)/this.measureCount;this.measureBars=Array(this.measureCount).fill(0).map((s,i)=>e+t*(i+1))}!t.staves&&e&&(this.staves=Array(e).fill(null).map(()=>new Staff({measureBars:this.measureBars}))),this.arrangePosition(),this.measureCount=this.measureCount||this.measureBars.length,this.sidBlackList=this.sidBlackList||[],this.sidWhiteList=this.sidWhiteList||[]}get noteRange(){if(!this.staves.length)return null;const e=this.staves[0],t=this.staves[this.staves.length-1];return{top:e.top+e.staffY+e.noteRange.top,bottom:t.top+t.staffY+t.noteRange.bottom}}get staffPositions(){return this.staves.map(e=>({y:e.top+e.staffY,radius:2}))}get staffMask(){return this.staffMaskChanged?this.staffMaskChanged:this.prev&&this.staves.length===this.prev.staves.length?this.prev.staffMask:2**this.staves.length-1}get staffTop(){const e=this.staffPositions;return e.length?e[0].y-e[0].radius:0}get staffBottom(){const e=this.staffPositions;return e.length?e[e.length-1].y+e[e.length-1].radius:0}arrangePosition(){let e=0;for(const t of this.staves){if(Number.isFinite(t.top))break;t.top=e,e+=t.height}}tidyMeasureBars(){this.measureBars=this.measureBars.filter(e=>e>1),this.measureBars.sort((e,t)=>e-t);const e=this.width-this.measureBars[this.measureBars.length-1];e>12?this.measureBars.push(this.width):e<2&&(this.measureBars[this.measureBars.length-1]=this.width),this.measureBars=this.measureBars.filter((e,t)=>t<1||e-this.measureBars[t-1]>4)}rearrangeMeasures(){this.measureCount=this.measureBars.length,this.staves.forEach(e=>e.rearrangeMeasures(this.measureBars))}get height(){return this.staves.reduce((e,t)=>e+t.height,0)}get connectionLine(){const e=this.staves[0],t=this.staves[this.staves.length-1];return e&&{top:e.top+e.staffY-2,bottom:t.top+t.staffY+2}}get middleY(){if(!this.staves.length)return 0;return this.staves.reduce((e,t)=>e+t.top+t.staffY,0)/this.staves.length}get timeSignatureOnHead(){return this.staves.some(e=>e.measures[0]?.tokens.some(e=>ee.includes(e.type)))}getStaffArray(e){let t=0;return Array(e).fill(null).map((e,s)=>{const i=this.staffMask&1<0?this.measureBars[e-1]:0,s=this.measureBars[e];return[...(this.tokens??[]).filter(e=>e.x>=t&&e.xTempoTerm.fromNumeralText(e.text)).filter(Boolean)]}getEvents(e){if(console.assert(Number.isInteger(this.headMeasureIndex),"invalid headMeasureIndex:",this.headMeasureIndex),!this.measureBars?.length&&this.staves.every(e=>!e.measures?.length))return{staffMask:this.staffMask,columns:[]};const t=this.getStaffArray(e).map(e=>e?e.measures.map(t=>{const s=t.getEvents();return t.assignAccessoriesOnEvents(s),t.assignFeaturesOnEvents(s,e.semantics),{events:s.map(t=>new EventTerm({staff:e.index,system:this.index,...t,rest:t.rest?"r":null})),contexts:t.getContexts({staff:e.index}),voltaBegin:t.tokens.some(e=>e.type===Z.VoltaLeft),voltaEnd:t.tokens.some(e=>e.type===Z.VoltaRight),alternative:t.alternative,barTypes:t.barTypes}}):Array(this.measureCount).fill(null).map(()=>({events:[],contexts:[],voltaBegin:!1,voltaEnd:!1,alternative:!1,barTypes:{}})));for(let e=0;et[e]?.contexts?.filter(e=>[Oe.TimeSignatureC,Oe.TimeSignatureN].includes(e.type))).find(e=>e?.length);s&&t.forEach(t=>{!t[e]||t[e].contexts.length||t[e].events.length||t[e].contexts.push(...s)})}const s=Array(this.measureCount).fill(null).map((e,s)=>({measureIndex:this.headMeasureIndex+s,rows:t.map(e=>e[s]),marks:this.getMarksInMeasure(s),duration:0,voltaBegin:t.some(e=>e[s]?.voltaBegin),voltaEnd:t.some(e=>e[s]?.voltaEnd),alternative:t.some(e=>e[s]?.alternative),barTypes:t.reduce((e,t)=>({...e,...t[s]?.barTypes}),{})}));s.forEach(e=>{[].concat(...e.rows.filter(Boolean).map(e=>e.events)).forEach((e,t)=>e.id=t+1)});const i=s[s.length-1];return i&&(i.break=!0),{staffMask:this.staffMask,columns:s}}getEventsFunctional(e,t,s=[],{useXMap:i=!1}={}){const n=this.getStaffArray(e).map((e,s)=>e?e.measures.map((e,i)=>{const n=t(s,i);return n&&{events:n.map(e=>new EventTerm({system:this.index,...e,rest:e.rest?"r":null})),contexts:e.getContexts({staff:s}),voltaBegin:e.tokens.some(e=>e.type===Z.VoltaLeft),voltaEnd:e.tokens.some(e=>e.type===Z.VoltaRight),alternative:e.alternative,barTypes:e.barTypes}}):Array(this.measureCount).fill(null).map(()=>({events:[],contexts:[],voltaBegin:!1,voltaEnd:!1,alternative:!1,barTypes:{}}))),r=Array(this.measureCount).fill(null).map((e,t)=>{const s=n.map(e=>e[t]);if(s.some(e=>!e))return null;let r=null;if(i){const e=[].concat(...s.map(e=>e.events)).reduce((e,t)=>(Number.isFinite(t.tickGroup)&&(e[t.tickGroup]=e[t.tickGroup]||[]),e[t.tickGroup].push(t),e),{});r=Object.values(e).reduce((e,t)=>{const s=Math.min(...t.map(e=>(e.left+e.right)/2));return e.set(s,t),e},new Map)}return{measureIndex:this.headMeasureIndex+t,rows:s,marks:this.getMarksInMeasure(t),duration:0,xMap:r,voltaBegin:s.some(e=>e.voltaBegin),voltaEnd:s.some(e=>e.voltaEnd),alternative:s.some(e=>e.alternative),barTypes:s.reduce((e,t)=>({...e,...t.barTypes}),{})}});return s.forEach(e=>r.forEach(e)),{staffMask:this.staffMask,columns:r}}getContexts(e){const t=this.getStaffArray(e).map(e=>e?e.measures.map(e=>({events:null,contexts:e.getContexts(),voltaBegin:e.tokens.some(e=>e.type===Z.VoltaLeft),voltaEnd:e.tokens.some(e=>e.type===Z.VoltaRight),alternative:t.some(e=>e.alternative),barTypes:e.barTypes})):Array(this.measureCount).fill(null).map(()=>({events:null,contexts:[],voltaBegin:!1,voltaEnd:!1,alternative:!1,barTypes:{}})));for(let e=0;et[e]?.contexts.filter(e=>[Oe.TimeSignatureC,Oe.TimeSignatureN].includes(e.type))).find(e=>e?.length);s&&t.forEach(t=>{t[e].contexts.length||t[e].contexts.push(...s)})}const s=Array(this.measureCount).fill(null).map((e,s)=>({measureIndex:this.headMeasureIndex+s,rows:t.map(e=>e[s]),marks:[],duration:0,voltaBegin:t.some(e=>e[s].voltaBegin),voltaEnd:t.some(e=>e[s].voltaEnd),alternative:t.some(e=>e.alternative),barTypes:t.reduce((e,t)=>({...e,...t[s].barTypes}),{})}));return{staffMask:this.staffMask,columns:s}}assignSemantics(e,t){const s=this.staves[e];console.assert(s,"staff is null:",e,this.staves);const i=s.top+s.staffY;t.getSystemPoints().forEach(e=>{const t={...e};t.y+=i,t.extension&&(t.extension={...t.extension},Number.isFinite(t.extension.y1)&&(t.extension.y1+=i,t.extension.y2+=i)),this.semantics.push(t)})}assemble(e,t=new DummyLogger){if(this.measureBars=[],!this.semantics)return;const s=SemanticGraph.fromPoints(this.semantics).getConfidentLayer(T.vline_BarMeasure,e);s.sort((e,t)=>e.x-t.x);const i=this.staffTop,n=this.staffBottom;let r=0;const a=s.reduce((e,t)=>{const s=Number.isFinite(t.confidence)?Math.tanh(t.confidence):1,a=t.x-r>.4?t.x:r;r=t.x;let o=e[a]||0;return o+=(Math.min(t.extension.y2,n)-Math.max(t.extension.y1,i))*s,t.x!==a&&delete e[a],e[t.x]=o,e},{}),o=Object.entries(a).filter(([e,t])=>t>3*this.staves.length).map(([e])=>Number(e));if(this.sidWhiteList.length)for(const e of s)this.sidWhiteList.includes(e.id)&&!o.some(t=>Math.abs(t-e.x)<=2)&&o.push(e.x);o.sort((e,t)=>e-t),o.forEach((e,t)=>{(t<=0||e-o[t-1]>2)&&this.measureBars.push(e)}),this.measureBars.length||this.measureBars.push(this.width),this.tidyMeasureBars(),this.rearrangeMeasures();this.semantics.filter(e=>[T.vline_BarTerminal,T.vline_BarSegment].includes(e.semantic)).forEach(e=>{const t=this.staves[0].measures.find(t=>e.x>t.right-2&&e.x{for(;!(l&1<C(this.index,i,e)),s.clearPredictedTokens(),s.assemble(e,this,t))})}qualifiedSemantics(e,t=1){return e.filter(e=>this.sidWhiteList.includes(e.id)||!this.sidBlackList.includes(e.id)&&(e.confidence>=t||!Number.isFinite(e.confidence))).map(e=>this.displacementSemantics&&this.displacementSemantics[e.id]?{...e,...this.displacementSemantics[e.id]}:e)}clearTokens(){this.staves.forEach(e=>e.clearTokens()),this.semantics=[]}newPoint(e,t,s=1){const i=this.staves[e];console.assert(i,"staff index out of bound:",e,this.staves.length);const{semantic:n,x:r,y:a,confidence:o=0,extension:c=null}=t,l={semantic:n,x:r,y:a,confidence:o,extension:c};return l.extension||delete l.extension,C(this.index,e,l),i.semantics.push(l),i.clearPredictedTokens(),i.assemble(s,this),l}appendToken(e){switch(this.tokens.push(e),e.textType){case Pe.TempoNumeral:{const t=this.staves[0];if(t){const s=t.top+t.staffY;t.measures.forEach(t=>{t.tokens=t.tokens.filter(t=>!ae.includes(t.type)||Math.abs(t.x-e.x)>e.width/2||Math.abs(s+t.y-e.y)>e.fontSize/2)})}}break;case Pe.Alternation1:case Pe.Alternation2:this.staves[0].measures.forEach(t=>{const s=Math.min(t.left+t.width,e.x+e.width/2)-Math.max(t.left,e.x-e.width/2);t.alternative=t.alternative||s/t.width>.5})}}}System.className="System",System.blackKeys=["index","pageIndex","prev","next","headMeasureIndex","tokens","indent"];class Page extends SimpleClass{constructor(e){super(),super.assign(e),this.systems=this.systems||[],this.source&&(this.source.matrix=this.source.matrix||[1,0,0,1,0,0])}get sidBlackList(){const e=[].concat(...this.systems.map(e=>e.sidBlackList));return new Set(e)}get sidWhiteList(){const e=[].concat(...this.systems.map(e=>e.sidWhiteList));return new Set(e)}clearTokens(){this.semantics=null,this.tokens=null,this.lyricTokens=null,this.systems.forEach(e=>e.tokens=null)}assignTexts(e,[t,s]){const i=this.source&&this.source.interval?this.source.interval*(t/this.source.dimensions.height):t/this.height;this.semantics=e.map(e=>{const n={x:(e.cx-s/2)/i,y:(e.cy-t/2)/i},r=this.source&&this.source.matrix?(a=n,{x:(o=this.source.matrix)[0]*a.x+o[2]*a.y+o[4],y:o[1]*a.x+o[3]*a.y+o[5]}):n;var a,o;return this.createTextSemantic(e,r.x+this.width/2,r.y+this.height/2,i)})}assignPageTexts(e,[t,s]){const i=s/this.width,n=t/this.height;this.semantics=e.map(e=>this.createTextSemantic(e,e.cx/i,e.cy/n,i,n))}createTextSemantic(e,t,s,i,n=i){return{confidence:e.score,x:t,y:s,semantic:T.rect_Text,extension:{text:e.text,type:e.type,width:e.width/i,height:e.height/n,theta:e.theta,textFeature:e.feature_dict}}}assemble({textAnnotations:e=null}={},t=new DummyLogger){if(this.tokens=[],this.lyricTokens=[],this.systems.forEach(e=>e.tokens=[]),this.systems.length){const e=this.systems.map(e=>e.left),t=e[Math.floor((e.length-1)/2)];this.systems.forEach(e=>e.indent=e.left>t+2)}if(this.semantics){const t=this.source?this.source.name:this.index.toString();this.semantics.forEach(s=>{O(t,s);const i={id:s.id,type:Z.Text,confidence:s.confidence,textType:mt[s.extension.type]||s.extension.type,text:e&&e[s.id]||s.extension.text,textFeasure:s.extension.textFeature,width:s.extension.width,fontSize:s.extension.height};if(s.semantic===T.rect_Text)switch(i.textType){case Pe.Title:case Pe.Author:case Pe.PageMargin:case Pe.Other:this.tokens.push(new TextToken({x:s.x,y:s.y,...i}));break;case Pe.TempoNumeral:case Pe.Chord:case Pe.MeasureNumber:case Pe.Instrument:case Pe.Alternation1:case Pe.Alternation2:{const e=this.systems.find(e=>e.top+e.staffTop>s.y);e&&e.appendToken(new TextToken({x:s.x-e.left,y:s.y-e.top,...i}))}break;case Pe.Lyric:(this.lyricTokens||(this.lyricTokens=[])).push(new TextToken({x:s.x,y:s.y,...i}));break;case Pe.TextualMark:case Pe.Times:{const e=[...this.systems].reverse().find(e=>e.topt>=e.top&&tn>=e.left&&n[e,ft[`TimeD${e}`]])),gt=Object.fromEntries(Array(12).fill(null).map((e,t)=>t+1).map(e=>[e,ft[`TimeN${e}`]])),yt=ft,vt={[yt.BOS]:"BOS",[yt.NoteheadS0]:"noteheads-s0",[yt.NoteheadS1]:"noteheads-s1",[yt.NoteheadS2]:"noteheads-s2",[yt.NoteheadGrace]:"GraceNotehead",[yt.Flag3]:"flags-u3",[yt.BeamLeft]:"BeamLeft",[yt.BeamContinue]:"BeamContinue",[yt.BeamRight]:"BeamRight",[yt.Dot]:"dot",[yt.Rest0]:"rests-0o",[yt.Rest1]:"rests-1o",[yt.Rest2]:"rests-2",[yt.Rest3]:"rests-3",[yt.Rest4]:"rests-4",[yt.Rest5]:"rests-5",[yt.Rest6]:"rests-6"},xt={[yt.NoteheadS0]:0,[yt.NoteheadS1]:1,[yt.NoteheadS2]:2,[yt.NoteheadGrace]:2},St=[yt.NoteheadS0,yt.NoteheadS1,yt.NoteheadS2,yt.NoteheadGrace],kt=[yt.Rest0,yt.Rest1,yt.Rest2,yt.Rest3,yt.Rest4,yt.Rest5,yt.Rest6],bt=[yt.BeamLeft,yt.BeamContinue,yt.BeamRight],Tt=[...St,...kt],wt=[...St,...kt,yt.vline_Stem],Mt=[yt.BOS,yt.NoteheadS0,yt.vline_Stem,...kt],Et=[...Tt,yt.vline_Stem],At={[yt.BeamLeft]:"Open",[yt.BeamRight]:"Close"},Nt=e=>({type:e,staff:-1,x:0,y1:0,y2:0}),It=Nt(ft.BOS),Ct=e=>[Nt(gt[e.numerator]),Nt(pt[e.denominator])],Ot=(e,t)=>{const s=e.filter((e,s)=>t[s]),i=Math.max(...s);return e.findIndex(e=>e===i)};class SemanticCluster extends SimpleClass{static elementToJSON(e){const t={type:e.type,staff:e.staff,x:e.x,y1:e.y1,y2:e.y2};return e.id&&(t.id=e.id),t}constructor(e){super(),super.assign(e)}get sourceMask(){return this.elements.map(e=>wt.includes(e.type))}get targetMask(){return this.elements.map(e=>Mt.includes(e.type))}get vMask(){return this.elements.map(e=>Et.includes(e.type))}get compactMatrixH(){if(!this.matrixH)return null;const e=this.sourceMask,t=this.targetMask;return this.matrixH.filter((t,s)=>e[s]).map(e=>e.filter((e,s)=>t[s]))}set compactMatrixH(e){this.matrixH=Bt([].concat(...e),[this.sourceMask,this.targetMask])}get compactMatrixV(){if(!this._matrixV)return null;const e=this.vMask,t=this._matrixV.filter((t,s)=>e[s]).map(t=>t.filter((t,s)=>e[s]));return[].concat(...t.map((e,t)=>e.slice(0,t)))}set compactMatrixV(e){this.matrixV=e&&_t(e,this.vMask)}get matrixV(){return this.groupsV&&Rt(this.elements.length,this.groupsV)}set matrixV(e){if(!e)return this.groupsV=null,void(this._matrixV=e);const t=[],s=e.map((t,s)=>t.some(Number.isFinite)||e.some(e=>Number.isFinite(e[s])));e.forEach((e,i)=>{if(s[i]){let s=!1;for(let n=0;n=.5){const e=t.findIndex(e=>e.includes(n));t[e].push(i),s=!0;break}}s||t.push([i])}}),this.groupsV=t,this._matrixV=e}toJSON(){return{__prototype:"SemanticCluster",index:this.index,elements:this.elements.map(SemanticCluster.elementToJSON),compactMatrixH:this.compactMatrixH,compactMatrixV:this.compactMatrixV}}static mapMatrix(e,t,s){return t.reduce((t,s,i)=>(t[s]?t[s]=t[s].map((t,s)=>t+e[i][s]?1:0):t[s]=e[i],t),[]).map(e=>s.map(t=>e[t]))}mergeOverlapping(){const e=this.overlappedNoteheads();if(e.length){const t=this.elements.map((t,s)=>{const i=e.find(e=>s===e[1]),n=i?i[0]:s;return n-e.filter(e=>e[1]t.findIndex(e=>e===s));this.elements=s.map(e=>this.elements[e]),console.assert(this.elements.every(Boolean),"null element found:",this,t,s),this.matrixH=SemanticCluster.mapMatrix(this.matrixH,t,s),this.groupsV=this.groupsV.map(e=>Array.from(new Set(e.map(e=>t[e]))))}}overlappedNoteheads(){const e=[],t=this.elements.filter(e=>St.includes(e.type));for(let s=0;st),t=this.masks?this.masks[1]:e.map(e=>Mt.includes(this.elements[e].type)),s=e.map(e=>this.elements[e].type===yt.vline_Stem&&this.elements[e].y2-this.elements[e].y1>2),i=e.filter(e=>[yt.NoteheadS1,yt.NoteheadS2,yt.NoteheadGrace].includes(this.elements[e].type)),n=e.filter(e=>this.elements[e].type===yt.NoteheadS0),r=e.map(()=>!1),a={};i.forEach(t=>{const i=this.elements[t];e.filter(e=>s[e]).filter(e=>this.elements[e].y1-.5i.y1).sort((e,s)=>this.matrixH[t][s]-this.matrixH[t][e]).slice(0,2).filter((e,s)=>0===s||this.matrixH[t][e]>=.5).forEach(e=>{a[e]=a[e]||[],a[e].push(t)})}),n.forEach(e=>{const s=this.elements[e],i=Ot(this.matrixH[e],t),n=this.elements[i];n.type===yt.NoteheadS0&&Math.abs(s.x-n.x)<2.6?(r[e]=!0,a[i]=a[i]||[i],a[i].push(e)):a[e]=a[e]||[e]});const o={},c=e.filter(e=>a[e]||kt.includes(this.elements[e].type));c.sort((e,t)=>this.elements[e].x-this.elements[t].x);const l=e.map(e=>e===yt.BOS);c.forEach(e=>{const t=Ot(this.matrixH[e],l);o[e]=t,t&&!kt.includes(this.elements[t].type)&&(l[t]=!1),l[e]=!0});const u=this.elements.filter(e=>e.type===yt.Dot),h=this.elements.filter(e=>e.type===yt.Flag3),m=this.elements.filter(e=>bt.includes(e.type)),d=this.groupsV;return c.map(e=>{const t=this.elements[e],s=d?d.findIndex(t=>t.includes(e)):null;if(kt.includes(t.type)){const i=u.filter(e=>e.x>t.x+.5&&e.xt.y1-1&&e.y1this.elements[e]),n=Math.min(...i.map(e=>e.x-.7)),r=Math.max(...i.map(e=>e.x+.7));i.sort((e,t)=>t.y1-e.y1);const c=i.map(e=>e.y1),l=i.map(e=>e.id),d=c[0],f=c[c.length-1],p=u.filter(e=>e.x>r&&e.xd-1&&e.y1{const s=B(t.y1,.5);return e[s]=e[s]||[],e[s].push(t),e},{}),g=Math.max(...Object.values(p).map(e=>e.length),0);let y=xt[i[0].type],v=null,x=null,S=null;if(t.type===yt.vline_Stem){if(v=d-t.y1>t.y2-f?"u":"d",S={x:t.x,y:"u"===v?t.y1:t.y2},2===y){const e="u"===v?[t.y1-.4,t.y2-1]:[t.y1+1,t.y2+.4];y+=h.filter(s=>Math.abs(s.x-t.x)<.2&&s.y1>e[0]&&s.y1Math.abs(s.x-t.x)<.2&&s.y1>e[0]&&s.y1{const s=function*(){for(const t of e)yield t}(),[i,n]=t;return i.map(e=>n.map(t=>e&&t?s.next().value:null))},_t=(e,t)=>{const s=function*(){for(const t of e)yield t}();return t.map((e,i)=>t.map((t,n)=>e&&t&&n{const s=Array(e).fill(null).map((e,s)=>t.findIndex(e=>e.includes(s)));return Array(e).fill(null).map((t,i)=>Array(e).fill(null).map((e,t)=>{if(t>=i)return null;const n=s[i],r=s[t];return n<0||r<0?null:n===r?1:0}))};var Ft;!function(e){e[e.None=0]="None",e.Mordent="mordent",e.Prall="prall",e.Turn="turn",e.Trill="trill",e.Tremolo="tremolo",e.Arpeggio="arpeggio"}(Ft||(Ft={}));const Pt={64:"Sustain",65:"Portamento",66:"Sostenuto",67:"Soft"};class P{static parseMidi(e,{fixOverlap:t=!0,logger:s=null}={}){const i=[],n={},r={},a=[],o=[];let c=0,l=5e3,u=0,h=4,m=0;const d={low:null,high:null};let f,p=0,g=0;const y=[],v=e.header.ticksPerBeat;let x=((e,{timeWarp:t=1}={})=>{const s=[];let i=120;const n=e.header.ticksPerBeat;for(let t=0;t0&&(e=a.ticksToEvent/n/(i/60)),"meta"==a.event.type&&"setTempo"==a.event.subtype&&(i=6e7/a.event.microsecondsPerBeat);const s=1e3*e*t||0;o.push([a,s]),a=r()}if(a=r())for(;a;)e()}(),o})(e);t&&(x=(e=>{const t=new Map;return e.filter(([{event:e,ticksToEvent:s}])=>{if(s>0&&t.clear(),"channel"!==e.type)return!0;const i=`${e.subtype}|${e.channel}|${e.noteNumber}`;return!t.get(i)&&(t.set(i,e),!0)})})((e=>{const t=new Map,s=new Map,i=[];let n=-1;return e.forEach(([{event:e,ticksToEvent:r}],a)=>{if(r>0&&(n=a),"channel"!==e.type)return;const o=`${e.channel}|${e.noteNumber}`;switch(e.subtype){case"noteOn":t.get(o)?s.set(o,n):t.set(o,n);break;case"noteOff":s.get(o)?(i.push([s.get(o),a]),s.delete(o)):t.delete(o)}}),i.forEach((e,t)=>{for(let s=t-1;s>=0;--s){const t=i[s];if(t[1]t[0]&&++e[0]}}),i.forEach(([t,s])=>{if(s>=e.length-1||t<0)return;const i=e[s],n=e[s+1],r=e[t];if(!r[0].ticksToEvent)return void console.warn("invalid front index:",t,s,r);const a=r[1]/r[0].ticksToEvent;n[1]+=i[1],n[0].ticksToEvent+=i[0].ticksToEvent,i[0].ticksToEvent=r[0].ticksToEvent-1,r[0].ticksToEvent=1,i[1]=i[0].ticksToEvent*a,r[1]=r[0].ticksToEvent*a,e.splice(s,1),e.splice(t,0,i)}),e})(x)));const S=x.map(e=>({data:e[0].event,track:e[0].track,deltaTime:e[1],deltaTicks:e[0].ticksToEvent}));let k=0;for(const e of S){if(p+=e.deltaTicks,g=Math.round(1*p),e.deltaTicks>0){const t=e.deltaTicks/v;for(let e=Math.ceil(u);es.channel==t.channel&&s.pitch==e);if(n>=0){const s=i.splice(n,1)[0];a[t.channel].push({channel:t.channel,startTick:s.startTick,endTick:g,pitch:e,start:s.start,duration:c-s.start,velocity:s.velocity,beats:s.beats,track:s.track,finger:s.finger})}else s&&s.debug&&s.debug("unexpected noteOff: ",c,t);d.high=Math.max(d.high||e,e)}break;case"controller":switch(t.controllerType){case 64:case 65:case 66:case 67:const e=Pt[t.controllerType];n[t.channel]=n[t.channel]||{},r[t.channel]=r[t.channel]||[];const s=n[t.channel][e];s&&r[t.channel].push({type:e,start:s.start,duration:c-s.start,value:s.value}),n[t.channel][e]={start:c,value:t.value}}}break;case"meta":switch(t.subtype){case"setTempo":l=t.microsecondsPerBeat/1e3,y.push({tempo:t.microsecondsPerBeat,tick:g,time:c});break;case"timeSignature":h=t.numerator,m=0;break;case"text":if(!f&&/^find-corres:/.test(t.text)){const e=t.text.match(/:([\d\,-]+)/);f=(e&&e[1]||"").split(",").map(e=>Number(e))}else if(/fingering\(.*\)/.test(t.text)){const[e,s]=t.text.match(/\((.+)\)/),n=Number(s);if(!Number.isNaN(n)){const e=i[i.length-1];e&&(e.finger=n);const t=S.find(e=>e.index==k-1);t&&(t.data.finger=n)}}break;case"copyrightNotice":s&&s.log&&s.log("MIDI copyright:",t.text)}}}return i.forEach(e=>{s&&s.debug&&s.debug("unclosed noteOn event at",e.startTick,e),a[e.channel]=a[e.channel]||[],a[e.channel].push({startTick:e.startTick,endTick:g,pitch:e.pitch,start:e.start,duration:c-e.start,velocity:e.velocity,beats:e.beats,track:e.track,finger:e.finger})}),new P({channels:a,keyRange:d,pedals:r,bars:o,endTime:c,endTick:g,correspondences:f,events:S,tempos:y,ticksPerBeat:v,meta:{},logger:s})}constructor(e){Object.assign(this,e),this.notes=[];for(const e of this.channels)if(e)for(const t of e)this.notes.push(t);this.notes.sort(function(e,t){return e.start-t.start});for(const e in this.notes)this.notes[e].index=Number(e);this.duration=this.notes.length>0?this.endTime-this.notes[0].start:0,this.pitchMap=[];for(const e in this.channels)for(const t in this.channels[e]){const s=this.channels[e][t].pitch;this.pitchMap[s]=this.pitchMap[s]||[],this.pitchMap[s].push(this.channels[e][t])}if(this.pitchMap.forEach(e=>e.sort((e,t)=>e.start-t.start)),this.meta.beatInfos)for(let e=0;e0){const s=this.meta.beatInfos[e-1];t.beatIndex=s.beatIndex+Math.ceil((t.tick-s.tick)/this.ticksPerBeat)}else t.beatIndex=0}{let e=0,t=0,s=5e5;for(const i of this.tempos){e+=s/1e3*(i.tick-t)/this.ticksPerBeat,t=i.tick,s=i.tempo,i.time=e}}}findChordBySoftindex(e,t=.8){return this.notes.filter(s=>Math.abs(s.softIndex-e)e.from,"range is invalid:",e);const t=t=>{const s=Math.max(e.from,this.tempos[t].tick),i=te+s.tempo*t(i),0)/(e.to-e.from))}ticksToTime(e){this.logger&&this.logger.assert(Number.isFinite(e),"invalid tick value:",e),this.logger&&this.logger.assert(!!this.tempos&&!!this.tempos.length,"no tempos.");const t=this.tempos.findIndex(t=>t.tick>e),s=t<0?this.tempos.length-1:Math.max(t-1,0),i=this.tempos[s];return i.time+(e-i.tick)*i.tempo*.001/this.ticksPerBeat}timeToTicks(e){this.logger&&this.logger.assert(Number.isFinite(e),"invalid time value:",e),this.logger&&this.logger.assert(!!this.tempos&&!!this.tempos.length,"no tempos.");const t=this.tempos.findIndex(t=>t.time>e),s=t<0?this.tempos.length-1:Math.max(t-1,0),i=this.tempos[s];return i.tick+(e-i.time)*this.ticksPerBeat/(.001*i.tempo)}tickRangeToTimeRange(e){return this.logger&&this.logger.assert(e.to>=e.from,"invalid tick range:",e),{from:this.ticksToTime(e.from),to:this.ticksToTime(e.to)}}scaleTempo({factor:e,headTempo:t}){this.logger&&this.logger.assert(!!this.tempos&&!!this.tempos.length,"[Notation.scaleTempo] tempos is empty."),t&&(e=t/this.tempos[0].tempo),this.logger&&this.logger.assert(Number.isFinite(e)&&e>0,"[Notation.scaleTempo] invalid factor:",e),this.tempos.forEach(t=>{t.tempo*=e,t.time*=e}),this.events.forEach(t=>{t.deltaTime*=e,t.time*=e}),this.notes.forEach(t=>{t.start*=e,t.duration*=e}),this.endTime*=e}}const Dt=Object.freeze(Object.defineProperty({__proto__:null,Notation:P},Symbol.toStringTag,{value:"Module"})),qt={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",decodeArrayBuffer:function(e){const t=Math.ceil(3*e.length/4),s=new ArrayBuffer(t);return this.decode(e,s),s},decode:function(e,t){const s=this._keyStr.indexOf(e.charAt(e.length-1)),i=this._keyStr.indexOf(e.charAt(e.length-1));let n=Math.ceil(3*e.length/4);64===s&&n--,64===i&&n--;let r,a,o,c,l,u,h,m,d=0,f=0;for(r=t?new Uint8Array(t):new Uint8Array(n),e=e.replace(/[^A-Za-z0-9+/=]/g,""),d=0;d>4,o=(15&u)<<4|h>>2,c=(3&h)<<6|m,r[d]=a,64!==h&&(r[d+1]=o),64!==m&&(r[d+2]=c);return r}},Lt=window.MIDI||{};window.MIDI=Lt;const $t=function(e){Lt.api=e.api,Lt.setVolume=e.setVolume,Lt.programChange=e.programChange,Lt.noteOn=e.noteOn,Lt.noteOff=e.noteOff,Lt.chordOn=e.chordOn,Lt.chordOff=e.chordOff,Lt.stopAllNotes=e.stopAllNotes,Lt.getInput=e.getInput,Lt.getOutputs=e.getOutputs};!function(){var e=null,t=null;const s=Lt.WebMIDI={api:"webmidi"};s.setVolume=function(e,s){t.send([176+e,7,s])},s.programChange=function(e,s){t.send([192+e,s])},s.noteOn=function(e,s,i,n){t.send([144+e,s,i],1e3*n)},s.noteOff=function(e,s,i){t.send([128+e,s,0],1e3*i)},s.chordOn=function(e,s,i,n){for(var r=0;rProcessing: "+(i/87*100|0)+"%
"+u),s.id=l,n[i]=s,n.length===t.length){for(;n.length;){if(!(s=n.pop()))continue;const e=Lt.keyToNote[s.id];a[c+""+e]=s}r(e)}})},c=e=>Math.max(.001*(e-performance.now())+s.currentTime,0);t.getContextState=function(){return s?s.state:null},t.needsWarmup=function(){return!!s&&"running"!==s.state},t.awaitWarmup=function(){return s&&"running"!==s.state&&"function"==typeof s.resume?(i||(i=Promise.resolve(s.resume()).catch(()=>null).then(()=>{i=null})),i):Promise.resolve()},t.setVolume=function(e,t){r=t},t.empty=function(){return!Object.keys(a).length},t.hasPending=function(){return!Object.keys(t.pendingInstruments).length},t.programChange=function(e,t){Lt.channels[e].instrument=t};t.noteOn=function(e,t,i,o=0){return function(e,t,i,o=0){if(!Lt.channels[e])return;const l=Lt.channels[e].instrument;if(!a[l+""+t])return;const u=c(o),h=s.createBufferSource();n[e+""+t]=h,h.buffer=a[l+""+t],h.connect(s.destination),s.createGain?h.gainNode=s.createGain():h.gainNode=s.createGainNode();const m=i/127*(r/127)*2-1;return h.gainNode.connect(s.destination),h.gainNode.gain.setTargetAtTime(Math.max(-1,m),s.currentTime,0),h.connect(h.gainNode),h.noteOn?h.noteOn(u):h.start(u),h}(e,t,i,o)},t.noteOff=function(e,t,s=0){return function(e,t,s=0){const i=c(s),r=n[e+""+t];if(r){if(r.gainNode){const e=r.gainNode.gain;e.linearRampToValueAtTime(e.value,i),e.linearRampToValueAtTime(-1,i+.2)}r.noteOff?r.noteOff(i+.3):r.stop(i+.3),delete n[e+""+t]}}(e,t,s)},t.chordOn=function(e,s,i,n){for(var r,a={},o=0,c=s.length;o"u"&&(s=[{src:e.src,verify:e.verify}]);const i=document.getElementsByTagName("head")[0],n=function(e,s){t.loaded[e.src]||s&&typeof window[s]>"u"||(t.loaded[e.src]=!0,t.loading[e.src]&&t.loading[e.src](),delete t.loading[e.src],e.callback&&e.callback(),typeof getNext<"u"&&getNext())},r=[],a=function(s){if("string"==typeof s&&(s={src:s,verify:e.verify}),/([\w\d.])$/.test(s.verify))if(s.test=s.verify,"object"==typeof s.test)for(const e in s.test)r.push(s.test[e]);else r.push(s.test);if(t.loaded[s.src])return;const a=document.createElement("script");a.onreadystatechange=function(){"loaded"!==this.readyState&&"complete"!==this.readyState||n(s)},a.onload=function(){n(s)},a.onerror=function(){},a.setAttribute("type","text/javascript"),a.setAttribute("src",s.src),i.appendChild(a),t.loading[s.src]=function(){}},o=function(t){if(t)n(t,t.test);else for(let e=0;e"u")continue;2===t.length?typeof e[t[1]]>"u"&&(i=!1):3===t.length&&typeof e[t[1]][t[2]]>"u"&&(i=!1)}else typeof window[t]>"u"&&(i=!1)}!e.strictOrder&&i?e.callback&&e.callback():setTimeout(function(){o(t)},10)};if(e.strictOrder){let i=-1;const n=function(){if(i++,s[i]){const e=s[i],r=e.src;t.loading[r]?t.loading[r]=function(){e.callback&&e.callback(),n()}:t.loaded[r]?n():(a(e),o(e))}else e.callback&&e.callback()};n()}else{for(let e=0;ee.text()).then(t=>{e.onload&&e.onload({responseText:t})}).catch(t=>{console.warn("DOMLoader.sendRequest error:",t),e.onerror&&e.onerror(t,!1)})}};Lt.Soundfont=window.MIDI&&window.MIDI.Soundfont||{},window.MIDI=Lt,Lt.audioDetect=function(e){if(typeof Audio>"u")return e({});const t=new Audio;if(typeof t.canPlayType>"u")return e(jt);let s=t.canPlayType('audio/ogg; codecs="vorbis"');s="probably"===s||"maybe"===s;let i=t.canPlayType("audio/mpeg");if(i="probably"===i||"maybe"===i,!s&&!i)return void e(jt);s&&Wt("audio/ogg;base64,T2dnUwACAAAAAAAAAADqnjMlAAAAAOyyzPIBHgF2b3JiaXMAAAAAAUAfAABAHwAAQB8AAEAfAACZAU9nZ1MAAAAAAAAAAAAA6p4zJQEAAAANJGeqCj3//////////5ADdm9yYmlzLQAAAFhpcGguT3JnIGxpYlZvcmJpcyBJIDIwMTAxMTAxIChTY2hhdWZlbnVnZ2V0KQAAAAABBXZvcmJpcw9CQ1YBAAABAAxSFCElGVNKYwiVUlIpBR1jUFtHHWPUOUYhZBBTiEkZpXtPKpVYSsgRUlgpRR1TTFNJlVKWKUUdYxRTSCFT1jFloXMUS4ZJCSVsTa50FkvomWOWMUYdY85aSp1j1jFFHWNSUkmhcxg6ZiVkFDpGxehifDA6laJCKL7H3lLpLYWKW4q91xpT6y2EGEtpwQhhc+211dxKasUYY4wxxsXiUyiC0JBVAAABAABABAFCQ1YBAAoAAMJQDEVRgNCQVQBABgCAABRFcRTHcRxHkiTLAkJDVgEAQAAAAgAAKI7hKJIjSZJkWZZlWZameZaouaov+64u667t6roOhIasBACAAAAYRqF1TCqDEEPKQ4QUY9AzoxBDDEzGHGNONKQMMogzxZAyiFssLqgQBKEhKwKAKAAAwBjEGGIMOeekZFIi55iUTkoDnaPUUcoolRRLjBmlEluJMYLOUeooZZRCjKXFjFKJscRUAABAgAMAQICFUGjIigAgCgCAMAYphZRCjCnmFHOIMeUcgwwxxiBkzinoGJNOSuWck85JiRhjzjEHlXNOSuekctBJyaQTAAAQ4AAAEGAhFBqyIgCIEwAwSJKmWZomipamiaJniqrqiaKqWp5nmp5pqqpnmqpqqqrrmqrqypbnmaZnmqrqmaaqiqbquqaquq6nqrZsuqoum65q267s+rZru77uqapsm6or66bqyrrqyrbuurbtS56nqqKquq5nqq6ruq5uq65r25pqyq6purJtuq4tu7Js664s67pmqq5suqotm64s667s2rYqy7ovuq5uq7Ks+6os+75s67ru2rrwi65r66os674qy74x27bwy7ouHJMnqqqnqq7rmarrqq5r26rr2rqmmq5suq4tm6or26os67Yry7aumaosm64r26bryrIqy77vyrJui67r66Ys67oqy8Lu6roxzLat+6Lr6roqy7qvyrKuu7ru+7JuC7umqrpuyrKvm7Ks+7auC8us27oxuq7vq7It/KosC7+u+8Iy6z5jdF1fV21ZGFbZ9n3d95Vj1nVhWW1b+V1bZ7y+bgy7bvzKrQvLstq2scy6rSyvrxvDLux8W/iVmqratum6um7Ksq/Lui60dd1XRtf1fdW2fV+VZd+3hV9pG8OwjK6r+6os68Jry8ov67qw7MIvLKttK7+r68ow27qw3L6wLL/uC8uq277v6rrStXVluX2fsSu38QsAABhwAAAIMKEMFBqyIgCIEwBAEHIOKQahYgpCCKGkEEIqFWNSMuakZM5JKaWUFEpJrWJMSuaclMwxKaGUlkopqYRSWiqlxBRKaS2l1mJKqcVQSmulpNZKSa2llGJMrcUYMSYlc05K5pyUklJrJZXWMucoZQ5K6iCklEoqraTUYuacpA46Kx2E1EoqMZWUYgupxFZKaq2kFGMrMdXUWo4hpRhLSrGVlFptMdXWWqs1YkxK5pyUzDkqJaXWSiqtZc5J6iC01DkoqaTUYiopxco5SR2ElDLIqJSUWiupxBJSia20FGMpqcXUYq4pxRZDSS2WlFosqcTWYoy1tVRTJ6XFklKMJZUYW6y5ttZqDKXEVkqLsaSUW2sx1xZjjqGkFksrsZWUWmy15dhayzW1VGNKrdYWY40x5ZRrrT2n1mJNMdXaWqy51ZZbzLXnTkprpZQWS0oxttZijTHmHEppraQUWykpxtZara3FXEMpsZXSWiypxNhirLXFVmNqrcYWW62ltVprrb3GVlsurdXcYqw9tZRrrLXmWFNtBQAADDgAAASYUAYKDVkJAEQBAADGMMYYhEYpx5yT0ijlnHNSKucghJBS5hyEEFLKnINQSkuZcxBKSSmUklJqrYVSUmqttQIAAAocAAACbNCUWByg0JCVAEAqAIDBcTRNFFXVdX1fsSxRVFXXlW3jVyxNFFVVdm1b+DVRVFXXtW3bFn5NFFVVdmXZtoWiqrqybduybgvDqKqua9uybeuorqvbuq3bui9UXVmWbVu3dR3XtnXd9nVd+Bmzbeu2buu+8CMMR9/4IeTj+3RCCAAAT3AAACqwYXWEk6KxwEJDVgIAGQAAgDFKGYUYM0gxphhjTDHGmAAAgAEHAIAAE8pAoSErAoAoAADAOeecc84555xzzjnnnHPOOeecc44xxhhjjDHGGGOMMcYYY4wxxhhjjDHGGGOMMcYYY0wAwE6EA8BOhIVQaMhKACAcAABACCEpKaWUUkoRU85BSSmllFKqFIOMSkoppZRSpBR1lFJKKaWUIqWgpJJSSimllElJKaWUUkoppYw6SimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaVUSimllFJKKaWUUkoppRQAYPLgAACVYOMMK0lnhaPBhYasBAByAwAAhRiDEEJpraRUUkolVc5BKCWUlEpKKZWUUqqYgxBKKqmlklJKKbXSQSihlFBKKSWUUkooJYQQSgmhlFRCK6mEUkoHoYQSQimhhFRKKSWUzkEoIYUOQkmllNRCSB10VFIpIZVSSiklpZQ6CKGUklJLLZVSWkqpdBJSKamV1FJqqbWSUgmhpFZKSSWl0lpJJbUSSkklpZRSSymFVFJJJYSSUioltZZaSqm11lJIqZWUUkqppdRSSiWlkEpKqZSSUmollZRSaiGVlEpJKaTUSimlpFRCSamlUlpKLbWUSkmptFRSSaWUlEpJKaVSSksppRJKSqmllFpJKYWSUkoplZJSSyW1VEoKJaWUUkmptJRSSymVklIBAEAHDgAAAUZUWoidZlx5BI4oZJiAAgAAQABAgAkgMEBQMApBgDACAQAAAADAAAAfAABHARAR0ZzBAUKCwgJDg8MDAAAAAAAAAAAAAACAT2dnUwAEAAAAAAAAAADqnjMlAgAAADzQPmcBAQA="),i&&Wt("audio/mpeg;base64,/+MYxAAAAANIAUAAAASEEB/jwOFM/0MM/90b/+RhST//w4NFwOjf///PZu////9lns5GFDv//l9GlUIEEIAAAgIg8Ir/JGq3/+MYxDsLIj5QMYcoAP0dv9HIjUcH//yYSg+CIbkGP//8w0bLVjUP///3Z0x5QCAv/yLjwtGKTEFNRTMuOTeqqqqqqqqqqqqq/+MYxEkNmdJkUYc4AKqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq");const n=(new Date).getTime(),r=window.setInterval(function(){const t=(new Date).getTime()-n>5e3;(!Ht||t)&&(window.clearInterval(r),e(jt))},1)};const Ut={};Lt.loadPlugin=function(e={}){"function"==typeof e&&(e={callback:e});var t=e.instruments||e.instrument||"acoustic_grand_piano";"object"!=typeof t&&(t=[t]);for(var s=0;se.callback=t)},Ut.webmidi=function(e,t,s){Lt.loader&&Lt.loader.message("Web MIDI API..."),Lt.WebMIDI.connect(s)},Ut.flash=function(e,t,s){Lt.loader&&Lt.loader.message("Flash API..."),Gt.script.add({src:s.soundManagerUrl||"./inc/SoundManager2/script/soundmanager2.js",verify:"SoundManager",callback:function(){Lt.Flash.connect(t,s)}})},Ut.audiotag=function(e,t,s){Lt.loader&&Lt.loader.message("HTML5 Audio API...");const i=Zt({items:t,getNext(t){Lt.Soundfont[t]?i.getNext():Gt.sendRequest({url:Lt.soundfontUrl+t+"-"+e+".js",onprogress:Yt,onload(e){Kt(e.responseText),Lt.loader&&Lt.loader.update(null,"Downloading",100),i.getNext()}})},onComplete(){Lt.AudioTag.connect(s)}})},Ut.webaudio=function(e,t,s){Lt.loader&&Lt.loader.message("Web Audio API...");const i=Zt({items:t,getNext(s){Lt.Soundfont[s]?i.getNext():(Lt.WebAudio.pendingInstruments[t]=!0,Gt.sendRequest({url:Lt.soundfontUrl+s+"-"+e+".js",onprogress:Yt,onload(e){Kt(e.responseText),Lt.loader&&Lt.loader.update(null,"Downloading...",100),i.getNext(),delete Lt.WebAudio.pendingInstruments[t]},onerror(e){Lt.loader&&Lt.loader.update(e,"Download failed."),delete Lt.WebAudio.pendingInstruments[t]}}))},onComplete(){Lt.WebAudio.connect(s)}})};const zt={webmidi:!0,webaudio:!0,audiotag:!0,flash:!0},Kt=function(e){var t=document.createElement("script");t.language="javascript",t.type="text/javascript",t.text=e,document.body.appendChild(t)},Yt=function(e){this.totalSize||(this.getResponseHeader("Content-Length-Raw")?this.totalSize=parseInt(this.getResponseHeader("Content-Length-Raw")):this.totalSize=e.total);const t=this.totalSize?Math.round(e.loaded/this.totalSize*100):"";Lt.loader&&Lt.loader.update(null,"Downloading...",t)},Zt=function(e){const t={queue:[]};for(const s in e.items)e.items.hasOwnProperty(s)&&t.queue.push(e.items[s]);return t.getNext=function(){if(!t.queue.length)return e.onComplete();e.getNext(t.queue.shift())},setTimeout(t.getNext,1),t};Lt.loadPlugin;const Jt=["id","ids","pitch","velocity","track","channel","rest","tied","overlapped","implicitType","afterGrace","contextIndex","staffTrack","chordPosition","division"];class MetaNotation{static fromAbsoluteNotes(e,t,s){const i=new MetaNotation(s);return i.measures=Array(t.length).fill(null).map((s,i)=>{const n=t[i],r=t[i+1]?t[i+1]-n:0,a=e.filter(e=>e.measure===i+1).map(e=>({tick:e.startTick-n,duration:e.endTick-e.startTick,...f.default(e,Jt),subNotes:[]}));return a.forEach(e=>["rest","tied","implicitType","afterGrace"].forEach(t=>{e[t]||delete e[t]})),{tick:n,duration:r,notes:a}}),i.idTrackMap=e.reduce((e,t)=>(t.id&&(e[t.id]=t.track),e),{}),i}static performAbsoluteNotes(e,{withRestTied:t=!1}={}){const s=e.filter(e=>(t||!e.rest&&!e.tied)&&!e.overlapped).map(e=>({measure:e.measure,channel:e.channel,track:e.track,start:e.start,startTick:e.startTick,endTick:e.endTick,pitch:e.pitch,duration:e.duration,velocity:e.velocity||127,id:e.id,ids:e.ids,staffTrack:e.staffTrack,contextIndex:e.contextIndex,implicitType:e.implicitType,chordPosition:e.chordPosition})).reduce((e,t)=>{const s=`${t.channel}|${t.start}|${t.pitch}`,i=e[s];return i?i.ids.push(...t.ids):e[s]=t,e},{});return Object.values(s)}constructor(e){this.ripe=!1,e&&Object.assign(this,e)}get trackTickBias(){const e=this.measures[0];return this.trackNames.reduce((t,s,i)=>{if(t[s]=0,e){const n=e.notes.find(e=>e.track===i);n&&(t[s]=Math.min(n.tick,0))}return t},{})}get idSet(){return this.measures.reduce((e,t)=>(t.notes.filter(e=>!e.rest).forEach(t=>t.ids.forEach(t=>e.add(t))),e),new Set)}toJSON(){return{__prototype:"LilyNotation",measures:this.measures,idTrackMap:this.idTrackMap,trackNames:this.trackNames,ripe:this.ripe}}toAbsoluteNotes(e){let t=0;const s=e.map(e=>{const s=this.measures[e-1];console.assert(!!s,"invalid measure index:",e,this.measures.length);const i=s.notes.map(s=>({startTick:t+s.tick,endTick:t+s.tick+s.duration,start:t+s.tick,duration:s.duration,measure:e,...f.default(s,Jt)}));return t+=s.duration,i});return[].concat(...s)}toPerformingNotation(e,t={}){const s=this.toAbsoluteNotes(e),i=MetaNotation.performAbsoluteNotes(s,t),n=Math.max(...i.map(e=>e.start+e.duration)),r=e.reduce((e,t)=>e+this.measures[t-1].duration,0);return new Dt.Notation({ticksPerBeat:480,meta:{},tempos:[],channels:[i],endTime:n,endTick:r})}toPerformingMIDI(e,{trackList:t}={}){if(!e.length)return null;const s=-Math.min(0,...this.measures[0]?.events.map(e=>e.ticks)||[],...this.measures[0]?.notes.map(e=>e.tick)||[]);let i=s;const n=e.map(e=>{const t=this.measures[e-1];console.assert(!!t,"invalid measure index:",e,this.measures.length);const s=t.events.map(t=>({ticks:i+t.ticks,track:t.track,data:{...t.data,measure:e}}));return i+=t.duration,s}),r=e=>e.ticks+("noteOff"===e.subtype?-1e-8:0),a=[].concat(...n).reduce((e,t)=>(e[t.track]=e[t.track]||[],e[t.track].push({ticks:t.ticks,...t.data}),e),[]);a[0]=a[0]||[],i=s,e.map(e=>{const s=this.measures[e-1];console.assert(!!s,"invalid measure index:",e,this.measures.length),Number.isFinite(s.duration)&&(s.notes.forEach(s=>{if(t&&!t[s.track])return;if(s.rest)return;const n=i+s.tick,r=a[s.track]=a[s.track]||[];s.subNotes.forEach(t=>{r.push({ticks:n+t.startTick,measure:e,ids:s.ids,type:"channel",subtype:"noteOn",channel:s.channel,noteNumber:t.pitch,velocity:t.velocity,staffTrack:s.staffTrack,staff:s.staff}),r.push({ticks:n+t.endTick,measure:e,ids:s.ids,type:"channel",subtype:"noteOff",channel:s.channel,noteNumber:t.pitch,velocity:0,staffTrack:s.staffTrack,staff:s.staff})})}),i+=s.duration)});const o=i;for(let e=0;e{e.sort((e,t)=>r(e)-r(t));let t=0;e.forEach(e=>{e.deltaTime=e.ticks-t,Number.isFinite(e.deltaTime)?t=e.ticks:e.deltaTime=0}),e.push({deltaTime:Math.max(o-t,0),type:"meta",subtype:"endOfTrack"})}),{header:{formatType:0,ticksPerBeat:480},tracks:a,zeroTick:s}}toPerformingNotationWithEvents(e,t={}){if(!e.length)return null;const{zeroTick:s,...i}=this.toPerformingMIDI(e,t),n=Dt.Notation.parseMidi(i);Xt(n);let r=s;return n.measures=e.map(e=>{const t=r;return r+=this.measures[e-1].duration,{index:e,startTick:t,endTick:r}}),n}setTempo(e){let t=!1;for(const s of this.measures)for(const i of s.events)"setTempo"===i.data.subtype&&(i.data.microsecondsPerBeat=6e7/e,t=!0);return t}}const Xt=(e,t=["ids","measure","staffTrack"])=>{const s=(e,t,s)=>`${e}|${t}|${s}`,i=e.notes.reduce((e,t)=>(e[s(t.channel,t.pitch,t.startTick)]=t,e),{});e.events.forEach(e=>{if("noteOn"===e.data.subtype){const n=s(e.data.channel,e.data.noteNumber,e.ticks),r=i[n];console.assert(!!r,"cannot find note of",n),r&&Object.assign(r,f.default(e.data,t))}})};var Qt,es={exports:{}},ts={exports:{}};ts.exports=(Qt=Qt||function(e,t){var s;if("undefined"!=typeof window&&window.crypto&&(s=window.crypto),"undefined"!=typeof self&&self.crypto&&(s=self.crypto),"undefined"!=typeof globalThis&&globalThis.crypto&&(s=globalThis.crypto),!s&&"undefined"!=typeof window&&window.msCrypto&&(s=window.msCrypto),!s&&"undefined"!=typeof global&&global.crypto&&(s=global.crypto),!s)try{s=require("crypto")}catch(e){}var i=function(){if(s){if("function"==typeof s.getRandomValues)try{return s.getRandomValues(new Uint32Array(1))[0]}catch(e){}if("function"==typeof s.randomBytes)try{return s.randomBytes(4).readInt32LE()}catch(e){}}throw new Error("Native crypto module could not be used to get secure random number.")},n=Object.create||function(){function e(){}return function(t){var s;return e.prototype=t,s=new e,e.prototype=null,s}}(),r={},a=r.lib={},o=a.Base={extend:function(e){var t=n(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},c=a.WordArray=o.extend({init:function(e,s){e=this.words=e||[],this.sigBytes=s!=t?s:4*e.length},toString:function(e){return(e||u).stringify(this)},concat:function(e){var t=this.words,s=e.words,i=this.sigBytes,n=e.sigBytes;if(this.clamp(),i%4)for(var r=0;r>>2]>>>24-r%4*8&255;t[i+r>>>2]|=a<<24-(i+r)%4*8}else for(var o=0;o>>2]=s[o>>>2];return this.sigBytes+=n,this},clamp:function(){var t=this.words,s=this.sigBytes;t[s>>>2]&=4294967295<<32-s%4*8,t.length=e.ceil(s/4)},clone:function(){var e=o.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var t=[],s=0;s>>2]>>>24-n%4*8&255;i.push((r>>>4).toString(16)),i.push((15&r).toString(16))}return i.join("")},parse:function(e){for(var t=e.length,s=[],i=0;i>>3]|=parseInt(e.substr(i,2),16)<<24-i%8*4;return new c.init(s,t/2)}},h=l.Latin1={stringify:function(e){for(var t=e.words,s=e.sigBytes,i=[],n=0;n>>2]>>>24-n%4*8&255;i.push(String.fromCharCode(r))}return i.join("")},parse:function(e){for(var t=e.length,s=[],i=0;i>>2]|=(255&e.charCodeAt(i))<<24-i%4*8;return new c.init(s,t)}},m=l.Utf8={stringify:function(e){try{return decodeURIComponent(escape(h.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return h.parse(unescape(encodeURIComponent(e)))}},d=a.BufferedBlockAlgorithm=o.extend({reset:function(){this._data=new c.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=m.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var s,i=this._data,n=i.words,r=i.sigBytes,a=this.blockSize,o=r/(4*a),l=(o=t?e.ceil(o):e.max((0|o)-this._minBufferSize,0))*a,u=e.min(4*l,r);if(l){for(var h=0;h>>7)^(f<<14|f>>>18)^f>>>3,g=l[d-2],y=(g<<15|g>>>17)^(g<<13|g>>>19)^g>>>10;l[d]=p+l[d-7]+y+l[d-16]}var v=i&n^i&r^n&r,x=(i<<30|i>>>2)^(i<<19|i>>>13)^(i<<10|i>>>22),S=m+((o<<26|o>>>6)^(o<<21|o>>>11)^(o<<7|o>>>25))+(o&u^~o&h)+c[d]+l[d];m=h,h=u,u=o,o=a+S|0,a=r,r=n,n=i,i=S+(x+v)|0}s[0]=s[0]+i|0,s[1]=s[1]+n|0,s[2]=s[2]+r|0,s[3]=s[3]+a|0,s[4]=s[4]+o|0,s[5]=s[5]+u|0,s[6]=s[6]+h|0,s[7]=s[7]+m|0},_doFinalize:function(){var e=this._data,s=e.words,i=8*this._nDataBytes,n=8*e.sigBytes;return s[n>>>5]|=128<<24-n%32,s[14+(n+64>>>9<<4)]=t.floor(i/4294967296),s[15+(n+64>>>9<<4)]=i,e.sigBytes=4*s.length,this._process(),this._hash},clone:function(){var e=r.clone.call(this);return e._hash=this._hash.clone(),e}});s.SHA256=r._createHelper(u),s.HmacSHA256=r._createHmacHelper(u)}(Math),e.SHA256}(ts.exports);var ss=es.exports;class HashVector{static fromHash(e){const t=[];for(const s of e)for(let e=0;e<8;++e)t.push(s>>e&1?1:-1);return new HashVector(t)}static fromString(e){const t=(e=>{const{words:t,sigBytes:s}=ss(e),i=t.map(e=>e<0?e+4294967296:e),n=s/t.length;return new Uint8Array(s).map((e,t)=>i[Math.floor(t/n)]>>8*(3-t%n)&255)})(e);return HashVector.fromHash(t)}static fromWords(e){return e.map(e=>HashVector.fromString(e)).reduce((e,t)=>e.add(t),HashVector.zero)}static concat(...e){const t=e.map(e=>e.fields).flat(1);return new HashVector(t)}constructor(e=null){this.fields=e||Array(256).fill(0)}get length(){return this.fields.length}toHash(){return Uint8Array.from(Array(this.length/8).fill(0).map((e,t)=>this.fields.slice(8*t,8*(t+1)).reduce((e,t,s)=>e|(t>0?1:0)<this.fields[s]=t+e.fields[s]),this}scale(e){return this.fields=this.fields.map(t=>t*e),this}sub(e){const t=e>0?this.fields.slice(0,e):this.fields.slice(e);return new HashVector(t)}static get zero(){return new HashVector}}const is=Array(256).fill(0).map((e,t)=>(e=>{let t=0;for(let s=e;s>0;s>>=1)s%2&&++t;return t})(t));is.reduce((e,t,s)=>({...e,[("0"+s.toString(16)).slice(-2)]:t}),{});const ns=(e,t)=>{const s=8*e.length,i=((e,t)=>e.map((e,s)=>e^t[s]))(e,t);return(s-2*i.reduce((e,t)=>e+is[t],0))/s},rs=e=>("0"+e.toString(16)).slice(-2),as=(e,t=!1)=>({empty:!0,duration:e.duration,tickMap:{0:EventTerm.space({duration:e.duration,tick:0})},timeSignature:e.timeSignature,timeSigNumeric:e.timeSigNumeric,keySignature:e.keySignature,contextedTerms:e.terms.filter(e=>e instanceof ContextedTerm&&(!e.staffLevel||t)),marks:[]}),os=e=>{const t=[].concat(...e.measures.map(e=>Object.values(e.tickMap).filter(e=>e instanceof EventTerm)));for(let e=1;ee.type===Z.SlurBegin)&&i.accessories.some(e=>e.type===Z.SlurEnd)){const e=s.pitches.filter(e=>i.pitches.some(t=>t.note===e.note&&t.alter===e.alter));e.length>0&&(s.tying=!0,i.tied=!0,e.forEach(e=>{e.tying=!0;i.pitches.find(t=>t.note===e.note&&t.alter===e.alter).tied=!0}),e.forEach(()=>{const e=s.accessories.findIndex(e=>e.type===Z.SlurBegin);e>=0&&s.accessories.splice(e,1);const t=i.accessories.findIndex(e=>e.type===Z.SlurEnd);t>=0&&i.accessories.splice(t,1)}))}}};class Spartito extends SimpleClass{constructor(e){super(),super.assign(e),this.measures.forEach(e=>e.staffGroups=this.staffGroups)}get regulated(){return this.measures.every(e=>e.regulated)}get solidMeasureCount(){return this.measures.filter(e=>!e.empty).length}get measureIndexMapping(){let e=0;return this.measures.map(t=>t.empty?null:e++)}get headBPM(){for(const e of this.measures)if(e.marks){const t=e.marks.find(e=>e instanceof TempoTerm&&e.isValid());if(t)return t.bpm}return null}get measureLayoutCode(){const e=this.measures.filter(e=>!e.empty).map((e,t)=>({index:t+1,vb:e.voltaBegin,ve:e.voltaEnd,alter:e.alternative,leftSign:"",rightSign:""}));return e.forEach((t,s)=>{if(t.vb){const i=e.slice(s+1).findIndex(e=>e.vb),n=i>=0?s+i:e.length;e.slice(s,n-1).some(e=>e.ve)&&(t.leftSign="2*[")}if(t.ve){const i=e.slice(0,s+1).reverse(),n=i.slice(1).findIndex(e=>e.ve);if(n>=0&&!i.slice(1,n+1).some(e=>e.vb))return;if(t.alter){const n=i.findIndex(e=>!e.alter);n>0&&(i[n].rightSign="]",i[n-1].leftSign="{[",t.rightSign="],",e[s+1]&&(e[s+1].rightSign="},"))}else t.rightSign="],";i.some(e=>e.vb)||(e[0].leftSign="2*[")}}),e.map(e=>e.leftSign+e.index.toString()+e.rightSign+(e.rightSign?"":",")).join(" ").replace(/,$/,"")}get qualityScore(){const e=this.measures.filter(e=>!e.empty),t=e.map(qe).map(e=>e.qualityScore).reduce((e,t)=>e+t,0);return e.length?t/e.length:null}dumpEvaluations(){const e=this.measures.filter(e=>!e.empty).map(e=>({measureIndex:e.measureIndex,...qe(e)})),t=e.map(e=>e.qualityScore).reduce((e,t)=>e+t,0);console.log("qualityScore:",t/e.length),console.table(e)}regulate(e={}){this.measures.forEach(t=>t.regulated||t.regulate(e))}cleanupRegulation(){this.measures.forEach(e=>e.voices=null)}rectifyTimeSignatures(e=new DummyLogger){const t=this.measures.map((e,t)=>({measure:e,index:t})).filter(({measure:e,index:t})=>!t||e.timeSignatureChanged).map(({index:e})=>e);t.map((e,s)=>this.measures.slice(e,se.filter(e=>e.estimatedDuration>0)).filter(e=>e.length>=3||e.some(e=>e.doubtfulTimesig)).forEach(t=>{if(t[0].patched){const s=t[0].timeSignature,i=t.slice(1).filter(e=>!e.patched&&q(e.timeSignature)!==q(s));if(i.length){const t=i[0].timeSignature;i.forEach(e=>e.basics.forEach(e=>e.timeSignature=s)),e.info("[rectifyTimeSignatures]\ttimesignator overwrote by patched head:",`${q(t)} -> ${q(s)}`,i.map(e=>e.measureIndex))}return}const s=t[0].timeSignature,i=Number.isInteger(Math.log2(s.denominator));let n=i?4:8;i&&(n=Math.max(n,t[0].timeSignature.denominator));const r=t.map(e=>Math.round(e.estimatedDuration*n/we)),a=Object.entries(r.reduce((e,t)=>(e[t]=(e[t]||0)+1,e),{})).sort((e,t)=>t[1]-e[1]),o=a[0][1],c=a.filter(([e,t])=>t>.6*o).reduce((e,t)=>Number(t[0])>Number(e[0])?t:e);if(c[1]>1){let r=Number(c[0]);if(!i||s.denominator*r!==s.numerator*n){if(i&&n!==s.denominator){const e=r*s.denominator/n;Number.isInteger(e)&&(r=e,n=s.denominator)}const a=t.filter(e=>!e.patched),o=F(r,n);a.forEach(e=>e.basics.forEach(e=>e.timeSignature=o)),e.info("[rectifyTimeSignatures]\ttimesignator overwrote by estimation:",`${q(s)} -> ${r}/${n}`,a.map(e=>e.measureIndex))}}})}makeVoiceStaves(){this.regulate();const e=Math.max(...this.measures.map(e=>e.voices.length?e.voices.length:e.events?.some(e=>e?.grace)?1:0));if(!e||!Number.isFinite(e))return null;this.measures.filter(e=>e.patched).forEach(e=>{e.events.forEach(e=>{e.tied&&e.pitches.forEach(e=>e.tied=!0)})});for(let e=0;et.staff===e)||[]).reduce((e,t)=>Math.max(e,t.x||0),-1/0);if(!Number.isFinite(n))continue;const r=[];t.contexts[e]=i.filter(e=>!(0===e.type&&e.x>n)||(r.push(e),!1)),r.length>0&&s.contexts[e]&&(r.forEach(e=>e.tick=0),s.contexts[e]=[...r,...s.contexts[e]])}}const t=this.measures.map(t=>{console.assert(t.validRegulated,"[makeVoiceStaves] measure is invalid:",t);const s={};t.events.forEach(e=>s[e.id]=e);const i=new Set(Array(t.contexts.length).fill(null).map((e,t)=>t));let n=null;if(t.barType)switch(t.barType){case"Segment":n="||";break;case"Terminal":n="|."}const r=(t.voices.length?t.voices:t.events?.some(e=>e?.grace)?[t.events.filter(e=>e?.grace).map(e=>e.id)]:[]).map(e=>{const r=e.map(e=>s[e]);r.sort((e,t)=>e.tick-t.tick);const a={},o=e=>{let t=`t${e.tick}`,s=1;for(;a[t];)t=`t${e.tick}:${s++}`;a[t]=e},c=r.find(e=>e&&!e.zeroHolder&&!e.grace),l=r.filter(e=>e?.grace&&(!c||e.xe.id);if(l.length&&(!c||0!==c.tick)){const e=EventTerm.space({tick:0,duration:0});e.staff=r.find(e=>e?.grace&&0===e.tick)?.staff??0,e.graceIds=l,e.placeholder=!0,o(e),l.forEach(e=>{const s=t.eventMap[e];s&&o(s)})}let u=0,h=null;for(const e of r)Number.isFinite(e?.tick)?l.includes(e.id)||(e.tick>u?o(EventTerm.space({tick:u,duration:e.tick-u})):!e.grace&&e.tick{const s=t.eventMap[e];s&&o(s)}))):console.warn("invalid event tick:",e);t.endEvent&&t.endEvent.graceIds&&t.endEvent.graceIds.forEach(e=>{const s=t.eventMap[e];!s||h&&s.staff!==h.staff||o(s)}),h&&ut.duration&&Number.isFinite(t.duration)&&(h.timeWarp=D(t.duration-h.tick,h.duration)),console.assert(!h||!h.timeWarp||Number.isInteger(h.timeWarp.numerator)&&Number.isInteger(h.timeWarp.denominator),"invalid time warp:",h);const m=r[0]?r[0].staff:0;i.delete(m);const d=t.basics[m],f=t.contexts[m],p=r[r.length-1],g=p?p.staff:0;return{tickMap:a,duration:t.duration,...d,contextedTerms:f,marks:[],break:t.break,pageBreak:t.pageBreak,headStaff:m,tailStaff:g,bar:n}});for(;r.lengtht.headStaff!==e),o=as({terms:n,duration:t.duration,...s,break:t.break,pageBreak:t.pageBreak},a);o.headStaff=e,o.tailStaff=e,r.push(o)}return t.marks?.length&&(r[0].marks=t.marks),r});t.forEach(e=>e.forEach(e=>{const t=[];e.empty||(t.push(`s${e.headStaff}`),t.push(`s${e.tailStaff}`)),Object.values(e.tickMap).forEach(e=>{if(e instanceof EventTerm){if(t.push(`s${e.staff}`),e.stemDirection){const s=`st${e.staff}-${e.stemDirection}`;t.push(s,s)}e.grace?t.push(`gd${e.mainDuration}`):t.push(`d${e.mainDuration}`),e.rest?t.push("r-"+e.rest):e.pitches.forEach(e=>{t.push(`p1-${e.note}`),t.push(`p8-${Math.round(e.note/8)}`)})}}),e.trait=HashVector.fromWords(t)}));const s=this.staffGroups.flat(1).reduce((e,t)=>(e[t]=this.staffGroups.findIndex(e=>e.includes(t)),e),{}),i=Array(e).fill(null).map((e,t)=>({vector:HashVector.zero,index:t,weight:0,headStaff:null}));t.forEach((e,t)=>{i.sort((e,t)=>t.weight-e.weight);const n=new Set(e);i.forEach(e=>{const i=[...n];let r=i[0];if(t>0&&i.length>1){const t=i.map(t=>s[t.headStaff]===s[e.headStaff]?ns(e.vector.toHash(),t.trait.toHash()):-1);r=i[G(t)]}n.delete(r),r.voiceIndex=e.index,e.vector.scale(.4).add(r.trait),e.weight=Object.keys(r.tickMap).length,0===t&&(e.headStaff=r.headStaff)}),e.sort((e,t)=>e.voiceIndex-t.voiceIndex)});const n=Array(this.stavesCount).fill(null).map(()=>[]);i.forEach(e=>{n[e.headStaff].push(e.index)});const r=Array(this.stavesCount).fill(null).map((e,s)=>{if(!t[0])return{voices:[]};return{voices:n[s].map(e=>({mode:"relative",measures:t.map(t=>t[e])}))}}),a=this.measures.find(e=>!e.empty)?.position?.systemIndex,o=Number.isFinite(a)?this.measures.findIndex(e=>!e.empty&&e.position?.systemIndex!==a):0;return(e=>{if(!e[0]||!e[0].voices[0])return void console.warn("empty voices:",e);const t=e[0].voices[0].measures.length;Array(t).fill(null).map((t,s)=>{for(const t of e)for(const e of t.voices)if(!e.measures[s].empty)return!1;return!0}).forEach((t,s)=>{t&&e.forEach(e=>e.voices.forEach(e=>{e.measures[s].tickMap={}}))})})(r),((e,t)=>{const s=e[0]?.voices[0]?.measures[0];if(s&&!(t<=0))for(const i of e)for(const e of i.voices)for(const i of e.measures.slice(0,t)){const e=i?.marks?.findIndex(e=>e instanceof TempoTerm);if(e>=0){const[t]=i.marks.splice(e,1);return t.tick=0,void(s.marks=[t,...s.marks.filter(e=>!(e instanceof TempoTerm))])}}})(r,o<0?this.measures.length:o),(e=>{const t=Array(e.length).fill(0),s=Math.max(0,...e.flatMap(e=>e.voices.map(e=>e.measures.length)));for(let i=0;ie.measures[i]).filter(Boolean);if(!n.length)continue;let r=t[s];for(const e of n)e.contextedTerms=e.contextedTerms.filter(e=>{if(!(e instanceof ContextedTerm)||e.type!==Oe.OctaveShift)return!0;const t=e.octaveShift;return!(e.tokenType===Z.OctaveShift0&&!e.id&&0===e.x&&0===r||(r=t,0))});t[s]=r}})(r),r.forEach(e=>e.voices.forEach(os)),r}perform(){const e=this.makeVoiceStaves();if(!e)return null;const t=new Map,s=Array(this.stavesCount).fill(null).reduce((e,t,s)=>(e[s]=s,e),{}),i=[].concat(...e.map((e,t)=>e.voices.map(()=>s[t])));let n=!1,r=0,a=null;const o=this.measures.filter(e=>!e.empty).map(s=>{const{systemIndex:o,right:c}=s.position,l=s.measureIndex,u=[].concat(...e.map(e=>e.voices.map(e=>e.measures[l]))),h=u[0],m=r;r+=h.duration;const d=[].concat(...u.map((e,s)=>{const n=i[s],r=Object.values(e.tickMap).filter(e=>e instanceof EventTerm&&!e.rest).map(e=>{const s=Math.round(1*e.duration);console.assert(Number.isFinite(e.tick),"invalid event term tick:",e),console.assert(Number.isFinite(s),"invalid event term duration:",e),e.tick>=0&&e.noteIds.forEach(s=>{t.set(s,{system:o,measure:l,x:e.roundX,endX:c})});const i=this.staffGroups.findIndex(t=>t.includes(e.staff));return{tick:Math.round(1*e.tick),duration:s,pitches:e.pitches,noteIds:e.noteIds,part:i,staff:e.staff}});return[].concat(...r.map(e=>{const t=e.pitches.reduce((e,t)=>(e[V(t)]=t,e),{});return Object.values(t).sort((e,t)=>e.note-t.note).filter(e=>!e.tied).map((t,s)=>{const i=V(t),r=e.noteIds&&e.noteIds[s];return{tick:e.tick,pitch:i,duration:e.duration,chordPosition:{index:s,count:e.pitches.length},tied:t.tied,id:r,ids:[r],track:e.part,staff:e.staff,channel:n,subNotes:[{startTick:0,endTick:e.duration,pitch:i,velocity:127}]}})}))})),f=[];a=a||f,s.marks&&s.marks.forEach(e=>{if(e instanceof TempoTerm){const t=e.bpm;if(e.isValid()){const s=n?f:a,i=n?e.tick:0;s.push({track:0,ticks:i,data:{type:"meta",subtype:"setTempo",microsecondsPerBeat:Math.round(6e7/t)}}),n=!0}}});const p=s.basics[0];return{tick:m,duration:s.duration,notes:d,events:f,timeSignature:p&&p.timeSignature,keySignature:p&&p.keySignature}});n||o[0].events.push({track:0,ticks:0,data:{type:"meta",subtype:"setTempo",microsecondsPerBeat:5e5}});return{notation:new MetaNotation({measures:o}),tokenMap:t}}performByEstimation(){const e=new Map;let t=0;const s=this.measures.filter(e=>e.events.some(e=>e.predisposition)).map(s=>{const i=t,n=Math.round(s.estimatedDuration||L(we,s.timeSignature)),r=s.basics[0];t+=n;const{systemIndex:a,right:o}=s.position,c=s.measureIndex;return{tick:i,duration:n,notes:s.events.filter(e=>e.predisposition&&e.predisposition.fake<.5&&!e.rest).map(t=>{const s=Math.round(t.predisposition.tick);return t.noteIds.forEach(s=>{e.set(s,{system:a,measure:c,x:t.roundX,endX:o})}),t.pitches.map((e,i)=>{const n=V(e),r=t.noteIds&&t.noteIds[i],a=this.staffGroups.findIndex(e=>e.includes(t.staff));return{tick:s,pitch:n,duration:t.duration,chordPosition:{index:i,count:t.pitches.length},tied:e.tied,id:r,ids:[r],track:a,staff:t.staff,channel:0,subNotes:[{startTick:0,endTick:t.duration,pitch:n,velocity:127}]}})}).flat(1),events:[],timeSignature:r&&r.timeSignature,keySignature:r&&r.keySignature}});return{notation:new MetaNotation({measures:s}),tokenMap:e}}featureHash(){const e=this.measures.slice(0,16).map(e=>e.featureWords),t=[1,4,16].map(t=>{const s=e.slice(0,t).filter(Boolean),i=s.map(e=>e[0]).flat(1),n=s.map(e=>e[1]).flat(1),r=s.map(e=>e[2]).flat(1),[a,o,c]=[i,n,r].map(HashVector.fromWords);return HashVector.concat(a,o.sub(128),c.sub(128))});return HashVector.concat(...t).toHash()}featureHashHex(){return e=this.featureHash(),Array.from(e).map(rs).join("");var e}featureHashBigInt(){return e=this.featureHash(),Array.from(e).reduce((e,t)=>0x100n*e+BigInt(t),0n);var e}assignMeasureNumbers(){let e=null;for(const t of this.measures)(t.discard||t.events.length)&&(t.indent&&(e=null),Number.isFinite(e)||(e=t.partialDuration?0:1),t.measureNumber=e++)}}Spartito.className="Spartito";const cs=[0,2,4,5,7,9,11],ls=e=>{let t=e%7;for(;t<0;)t+=7;return t},us=e=>{let t=e%12;for(;t<0;)t+=12;return t},hs={[-2]:"♭♭",[-1]:"♭",0:"♮",1:"♯",2:"𝄪"};class StaffContext{constructor(){this.logger=new DummyLogger,this.clef=-3,this.keyAlters=[],this.octaveShift=0,this.alters=[],this.timeSignature={numerator:4,denominator:4},this.timeSigNumeric=!1,this.timeSigNumSet=!1,this.timeSigDenSet=!1,this.doubtingTimesig=!0}change(e){switch(e.type){case Oe.Clef:this.clef=e.clef;break;case Oe.KeyAcc:this.keyAlters[ls(this.yToNote(e.y))]=e.alter;break;case Oe.Acc:this.alters[this.yToNote(e.y)]=e.alter;break;case Oe.OctaveShift:this.octaveShift=e.octaveShift;break;case Oe.TimeSignatureC:switch(this.timeSigNumeric=!1,e.tokenType){case"timesig-C44":this.timeSignature.numerator=4,this.timeSignature.denominator=4;break;case"timesig-C22":this.timeSignature.numerator=2,this.timeSignature.denominator=2}this.doubtingTimesig=this.partialTimeSignature;break;case Oe.TimeSignatureN:switch(this.timeSigNumeric=!0,e.y){case 1:this.timeSigDenSet?this.timeSignature.denominator=10*this.timeSignature.denominator+e.number:this.timeSignature.denominator=e.number,this.timeSigDenSet=!0;break;case-1:this.timeSigNumSet?this.timeSignature.numerator=10*this.timeSignature.numerator+e.number:this.timeSignature.numerator=e.number,this.timeSigNumSet=!0;break;default:this.logger.warn("unexpected time signature Y:",e.y)}this.doubtingTimesig=this.partialTimeSignature}}resetMeasure(){this.alters=[],this.timeSigNumSet=!1,this.timeSigDenSet=!1}resetSystem(){this.keyAlters=[]}get keySignature(){return this.keyAlters.filter(e=>Number.isInteger(e)).reduce((e,t)=>e+t,0)}get partialTimeSignature(){return!this.timeSigNumSet!=!this.timeSigDenSet}noteToY(e){return-e/2-this.clef-3.5*this.octaveShift}pitchToNote(e,{preferredAlter:t=null}={}){t||(t=this.keySignature<0?-1:1);const s=Math.floor((e-60)/12),i=us(e),n=cs.includes(i)?i:us(i-t),r=cs.indexOf(n);this.logger.assert(r>=0,"invalid preferredAlter:",e,t,n);const a=7*s+r,o=i-n,c=this.keyAlters[r]||0;return{note:a,alter:Number.isInteger(this.alters[a])?o:o===c?null:o}}pitchToY(e,{preferredAlter:t=null}={}){const{note:s,alter:i}=this.pitchToNote(e,{preferredAlter:t});return{y:this.noteToY(s),alter:i}}yToNote(e){return this.logger.assert(Number.isInteger(2*e),"invalid y:",e),2*(-e-3.5*this.octaveShift-this.clef)}alterOnNote(e){if(Number.isInteger(this.alters[e]))return this.alters[e];const t=ls(e);return Number.isInteger(this.keyAlters[t])?this.keyAlters[t]:0}noteToPitch(e){const t=Math.floor(e/7),s=ls(e),i=60+12*t+cs[s]+this.alterOnNote(e);return Number.isFinite(i)?i:(this.logger.warn("invalid pitch value:",i,e,t,s),-1)}yToPitch(e){return this.noteToPitch(this.yToNote(e))}yToPitchName(e){const t=this.yToNote(e),s=Math.floor(t/7),i=ls(t);let n=this.alterOnNote(t);return n||Number.isInteger(this.alters[t])||(n=null),`${hs[n]?hs[n]:""}${"CDEFGAB"[i]}${s+4}`}}const ms=e=>e.reduce((e,t,s)=>t?e|1<{if(e.version<3){const{version:t,stavesCount:s,layoutTemplate:i,...n}=e;let r=s>1?Array(s-1).fill(",").join(""):"";2===s&&(r="{-}"),e={version:3,staffLayoutCode:r,...n}}return e.version<8&&(e.pages.forEach(e=>{e.systems.forEach(e=>{if(e.semantics){const t=e.semantics.filter(e=>e.semantic===T.vline_BarMeasure);e.semantics=[].concat(...e.staves.map(e=>{const s=e.top+e.staffY;return t.map(e=>({...e,y:e.y+s,extension:{...e.extension,y1:e.extension.y1+s,y2:e.extension.y2+s}}))}))}})}),e.version=8),e.version<9&&(e.spartito=null,e.version=9),e})(e)),this.pages=this.pages||[],this.headers=this.headers||{},this.instrumentDict=this.instrumentDict||{},this.pageSize=this.pageSize||{width:794,height:1122},this.unitSize=this.unitSize||null,this.staffLayoutCode=this.staffLayoutCode||(2===this.maxStavesCount?"{-}":Array(this.maxStavesCount).fill("").join(","))}get systems(){return[].concat(...this.pages.map(e=>e.systems))}get measureCount(){return this.systems.reduce((e,t)=>e+(t.measureCount||0),0)}get imageKeys(){return[...this.pages.map(e=>e.source?.url),...this.systems.map(e=>e.backgroundImage),...[].concat(...this.systems.map(e=>[...e.staves.map(e=>e.backgroundImage),...e.staves.map(e=>e.maskImage)].filter(Boolean)))].filter(Boolean)}get breakSystemIndices(){const e=[];let t=0;return this.pages.forEach((s,i)=>{ie.staves.length),0)}get sidBlackList(){const e=[].concat(...this.systems.map(e=>e.sidBlackList));return new Set(e)}get sidWhiteList(){const e=[].concat(...this.systems.map(e=>e.sidWhiteList));return new Set(e)}get semanticHash(){const e=[].concat(...this.systems.map(e=>[].concat(...e.staves.map(t=>t.semantics?e.qualifiedSemantics(t.semantics).map(e=>e.id):[]))));return p.default(e.join(""))}eventSystemsToTermStaves(e,t=new DummyLogger){const s=Array(this.maxStavesCount).fill(null).map((t,s)=>({rows:e.map((e,t)=>e.columns.map((i,n)=>{const r=i.rows[s];console.assert(r,"[eventSystemsToTermStaves] measure is null:",s,i.rows);const a=r.contexts;0===n&&(a.some(e=>e.type===Oe.OctaveShift)||a.unshift(new ContextedTerm({staff:s,x:0,y:0,tokenType:Z.OctaveShift0,tick:0})));const o=[...r.events||[],...a].sort((e,t)=>e.x-t.x),c=0===s&&n===e.columns.length-1&&this.breakSystemIndices.includes(t);return{terms:o,duration:i.duration,pageBreak:c}}))}));return s.forEach(e=>((e,t=new DummyLogger)=>{const s=new StaffContext;s.logger=t;for(const t of e.rows){for(const e of t){const t=e.terms.find(e=>e instanceof EventTerm);let i=t?Math.min(t.tick,0):0;e.terms.forEach(e=>{if(e instanceof ContextedTerm)e.tick=i,s.change(e);else if(e instanceof EventTerm){const t=e.tick+(e.duration||0);t>i&&(i=t),e.ys&&(e.pitches=e.ys.map(e=>{const t=s.yToNote(e);return{note:t,alter:s.alterOnNote(t),octaveShift:s.octaveShift}}))}}),e.timeSignature={...s.timeSignature},e.timeSigNumeric=s.timeSigNumeric,e.doubtfulTimesig=s.doubtingTimesig||!Number.isInteger(Math.log2(e.timeSignature.denominator))||e.timeSignature.numerator<=e.timeSignature.denominator/4,e.keySignature=s.keySignature,0===e.duration&&(e.duration=we*e.timeSignature.numerator/e.timeSignature.denominator),s.resetMeasure()}s.resetSystem()}})(e,t)),s}resetPageLayout(e){const{unitSize:t=this.unitSize,pageSize:s=this.pageSize}=e,i=.5*s.width/t,n=.5*s.height/t;this.pages.forEach(e=>{const r=i-e.width/2,a=n-e.height/2;e.systems.forEach(e=>{e.left+=r,e.top+=a}),e.semantics&&e.semantics.forEach(e=>{e.x+=r,e.y+=a}),e.width=s.width/t,e.height=s.height/t,e.assemble({textAnnotations:this.textAnnotations})}),this.unitSize=t,this.pageSize=s}getMeasure(e){let t=e;for(const s of this.systems){if(te&&e.measures[t]);return{measureIndex:e,system:s,localIndex:t,left:n.left,right:n.right,measures:r}}t-=s.measureCount}return null}getRawCluster(e,t,{timeSignature:s}={}){const i=this.getMeasure(e);if(!i)return null;const{system:n,left:r,right:a}=i,o=[It];s&&o.push(...Ct(s));const c=n.staves[0].top+n.staves[0].staffY-2;return n.staves.forEach(e=>{let s=n.qualifiedSemantics(e.semantics,t).filter(e=>e.x>r&&e.xe.semantic===T.TempoNotehead).forEach(e=>{const t=s.findIndex(t=>/^Notehead/.test(t.semantic)&&_(e,t)<.3);t>=0&&s.splice(t,1)});const i=e.top+e.staffY-c;s.forEach(t=>{const s=ft[t.semantic];if(s){let n=t.y,a=t.y;s===ft.vline_Stem&&(n=t.extension.y1,a=t.extension.y2),o.push({id:t.id,type:s,staff:e.index,x:t.x-r,y1:n+i,y2:a+i})}})}),new SemanticCluster({index:e,elements:o})}getRawClusters(e=1){return Array(this.measureCount).fill(null).map((t,s)=>this.getRawCluster(s,e))}makeSpartito(e=new DummyLogger){let t=this.systems.map(e=>e.getEvents(this.maxStavesCount));const s=this.eventSystemsToTermStaves(t,e);t.forEach((e,t)=>{e.columns.forEach((e,i)=>{e.basics=s.map(e=>{const{timeSignature:s,timeSigNumeric:n,keySignature:r,doubtfulTimesig:a}=e.rows[t][i];return{timeSignature:s,timeSigNumeric:n,keySignature:r,doubtfulTimesig:a}})})});const i=[].concat(...t.map(e=>e.columns.map(t=>{const s=t.measureIndex,{system:i,localIndex:n,left:r,right:a}=this.getMeasure(s),o=[];i.staves.forEach(e=>o[e.index]=e.top+e.staffY);const c=this.patches&&this.patches.find(e=>e.measureIndex===s),l=c?c.events:SpartitoMeasure.reorderEvents([].concat(...t.rows.map(e=>e.events)),o),u=Object.fromEntries(Object.entries(t.barTypes).map(([e,t])=>[e,t/i.staves.length])),h=0===n&&i.indent;return new SpartitoMeasure({measureIndex:s,staffMask:e.staffMask,position:{systemIndex:i.index,localIndex:n,left:r,right:a,staffYs:i.staves.map(e=>e.top+e.staffY),staffYsFull:o},duration:c?c.duration:t.duration,events:l,contexts:t.rows.map(e=>e.contexts),marks:t.marks,break:t.break,pageBreak:t.pageBreak,voltaBegin:t.voltaBegin,voltaEnd:t.voltaEnd,alternative:t.alternative,barTypes:u,indent:h,basics:c?c.basics:t.basics,matrixH:null,matrixV:null,voices:c?c.voices:null,patched:!!c})}))),n=this.staffLayout,r=n.standaloneGroups.map(e=>e.map(e=>n.staffIds.indexOf(e)));return this.spartito=new Spartito({stavesCount:this.maxStavesCount,staffGroups:r,measures:i}),this.spartito}makeMusicSheet(){const e=this.spartito||this.makeSpartito();e.regulated||console.warn("[makeMusicSheet]\tspartito not regulated.");const t=e.makeVoiceStaves(),{lanes:s,diagnostics:i}=this.makeLyricLanes(t);s.length&&console.debug("[makeMusicSheet]\tlyric lanes:",s.length,i);const{title:n,pageSize:r,unitSize:a,staffLayout:o,staffLayoutCode:c,paperOptions:l,headers:u,instrumentDict:h}=this;return{title:n,pageSize:r,unitSize:a,measureLayout:this.getMeasureLayout(),staffLayout:o,staffLayoutCode:c,paperOptions:l,headers:u,voiceStaves:t,instrumentDict:h,lyricLanes:s,lyricDiagnostics:i}}makeLyricLanes(e){const t={total:0,matched:0,unmatched:0,ambiguousVoice:0,duplicateEventAssignments:0,outOfOrderAssignments:0},s=this.spartito;if(!(s&&s.measures&&s.measures.length&&e&&e.length))return{lanes:[],diagnostics:t};const i=[];this.pages.forEach((e,t)=>{(e.lyricTokens||[]).forEach(e=>{i.push({pageIndex:t,x:e.x,y:e.y,text:e.text,sid:e.id})})});const n={...t,total:i.length,unmatchedSids:[]};if(!i.length)return{lanes:[],diagnostics:n};const r=[];i.forEach(e=>{const t=this.pages[e.pageIndex];if(!t||!t.systems||!t.systems.length)return n.unmatched++,void(e.sid&&n.unmatchedSids.push(e.sid));let s=null;for(const i of t.systems)i.top>e.y||e.xi.left+i.width||(!s||i.top>s.top)&&(s=i);if(!s)return n.unmatched++,void(e.sid&&n.unmatchedSids.push(e.sid));const i=s.getStaffArray(this.maxStavesCount);let a=-1,o=-1/0,c=0;for(let t=0;to&&(o=r,a=t,c=n.height)}if(a<0||e.y-o>(l=c,Math.max(2*l,12)))return n.unmatched++,void(e.sid&&n.unmatchedSids.push(e.sid));var l;const u=e.x-s.left;let h=0;const m=s.measureBars||[];for(;h=s.measureCount&&(h=s.measureCount-1);const d=(s.headMeasureIndex||0)+h;r.push({...e,systemIndex:s.index,staffIndex:a,measureIndex:d,localIndex:h,systemX:u,voiceIndex:-1,verse:0})});r.forEach(e=>{const t=s.measures[e.measureIndex];if(!t||!t.events)return n.unmatched++,void(e.sid&&n.unmatchedSids.push(e.sid));const i=t.events.filter(t=>(e=>!!e&&e instanceof EventTerm&&!e.rest&&!e.grace&&!e.zeroHolder&&Number.isFinite(e.x))(t)&&t.staff===e.staffIndex);if(!i.length)return n.unmatched++,void(e.sid&&n.unmatchedSids.push(e.sid));let r=null,a=1/0;for(const t of i){const s=Math.abs(t.x-e.systemX);s{if(!t.event)return;const s=e[t.staffIndex];if(!s||!s.voices||!s.voices.length)return n.unmatched++,void(t.sid&&n.unmatchedSids.push(t.sid));const i=s.voices[0]?.measures?.[t.measureIndex];if(!i)return n.unmatched++,void(t.sid&&n.unmatchedSids.push(t.sid));let r=-1,a=!1;s.voices.forEach((e,s)=>{const i=e.measures?.[t.measureIndex];if(!i||!i.tickMap)return;Object.values(i.tickMap).find(e=>e===t.event||e&&null!=e.id&&null!=t.event.id&&e.id===t.event.id)&&(r>=0&&r!==s&&(a=!0),r<0&&(r=s))}),a&&n.ambiguousVoice++,r<0&&(r=0),t.voiceIndex=r,n.matched++});const a=new Map;r.forEach(e=>{if(!e.event)return;const t=a.get(e.staffIndex)||[];t.push(e),a.set(e.staffIndex,t)});const o=[];a.forEach((e,t)=>{const s=new Map;e.forEach(e=>{const t=s.get(e.systemIndex)||[];t.push(e),s.set(e.systemIndex,t)});let i=1;const n=new Map;s.forEach((t,s)=>{t.sort((e,t)=>e.y-t.y);const r=t.map(e=>e.y),a=r.length>1?Math.max(...r)-Math.min(...r):2,o=Math.max(a/4,1.5),c=[];t.forEach(e=>{const t=c.find(t=>Math.abs(t.y-e.y)<=o);t?t.members.push(e):c.push({y:e.y,members:[e]})}),c.sort((e,t)=>e.y-t.y);const l=new Map;c.forEach((t,s)=>t.members.forEach(t=>l.set(e.indexOf(t),s))),n.set(s,l),c.length>i&&(i=c.length)});for(let s=0;s{const r=n.get(e.systemIndex);if((r?r.get(t)??0:0)!==s)return;const a=i.get(e.voiceIndex)||[];a.push({text:e.text,sid:e.sid,measureIndex:e.measureIndex,tick:e.event.tick,staffIndex:e.staffIndex,voiceIndex:e.voiceIndex,eventId:e.event.id,verse:s,source:{pageIndex:e.pageIndex,systemIndex:e.systemIndex,x:e.x,y:e.y}}),i.set(e.voiceIndex,a)}),i.forEach((e,i)=>{e.sort((e,t)=>e.measureIndex-t.measureIndex||e.tick-t.tick),o.push({staffIndex:t,voiceIndex:i,verse:s,syllables:e})})}});for(const e of o){const t=new Set;let s=-1/0,i=-1;for(const r of e.syllables){const e=`${r.staffIndex}:${r.voiceIndex}:${r.measureIndex}:${r.tick}`;t.has(e)&&n.duplicateEventAssignments++,t.add(e),(r.measureIndext.id===e);if(i){return{point:i,pageIndex:this.pages.findIndex(e=>e.systems.includes(t)),systemIndex:t.index,staffIndex:s}}}return null}getMeasureSemantics(e,t){const s=this.systems[e];if(!s)return null;const i=t?s.measureBars[t-1]:0,n=s.measureBars[t]||s.width;return s.staves.map((e,t)=>{const s=e.top+e.staffY;return e.semantics.filter(e=>e.x>=i&&e.x{const[i,n]=Number.isFinite(e.extension?.y1)?[e.extension.y1,e.extension.y2]:[e.y,e.y];return{...e,staff:t,sy1:i+s,sy2:n+s}})}).flat(1)}makeTimewiseGraph({store:e=!1}={}){if(!this.spartito)return null;return{measures:this.spartito.measures.filter(e=>e.events.length>0).map(t=>{const s=this.getMeasureSemantics(t.position.systemIndex,t.position.localIndex),i={measureIndex:t.measureIndex,left:t.position.left,right:t.position.right,points:s};return e&&(t.graph=i),i})}}getTokenMap(){const e=new Map;return this.systems.forEach(t=>t.staves.forEach(t=>t.measures.forEach(t=>t.tokens.forEach(t=>e.set(t.id,t))))),e}assemble(e=1,t=new DummyLogger){const s=new Map;this.pages.forEach((e,t)=>e.index=t);let i=0;this.systems.forEach((n,r)=>{n.index=r,n.headMeasureIndex=i,n.prev=this.systems[r-1]||null,n.next=this.systems[r+1]||null,n.semantics&&n.semantics.length&&n.semantics.forEach(e=>((e,i,n)=>{const r=C(e,i,n);t.assert(!s.has(r),"semantic point hash conflicted:",r,n,s.get(r)),s.set(r,n)})(r,null,e)),n.assemble(e,t),i+=n.measureCount}),this.pages.forEach((e,s)=>{e.systems.forEach(e=>e.pageIndex=s),e.assemble({textAnnotations:this.textAnnotations},t)})}assembleSystem(e,t=1){this.systems.forEach((e,t)=>e.index=t);const s=e.index;e.semantics&&e.semantics.length&&(e.semantics.forEach(e=>C(s,null,e)),e.assemble(t))}markVoices(e){const t=this.getTokenMap();for(const e of t.values())e.voice=0;const s=[].concat(...e.map((e,t)=>(e.voices||[]).map((e,s)=>[t,s]))).sort(([e,t],[s,i])=>t-i||e-s).map(([e,t])=>`${e}|${t}`);e.forEach((e,i)=>(e.voices||[]).forEach((e,n)=>e.measures.forEach(e=>{const r=s.indexOf(`${i}|${n}`);Object.values(e.tickMap).filter(e=>e instanceof EventTerm).forEach(e=>{const s=e.noteIds?e.noteIds.map(e=>t.get(e)).filter(Boolean):[],i=e.accessories?e.accessories.map(e=>t.get(e.id)).filter(Boolean):[];[...s,...i].forEach(e=>e.voice|=1<e.timeWarped=!0)})})))}async replaceImageKeys(e){await Promise.all([...this.pages.map(async t=>{t.source&&(t.source.url=await e(t.source.url))}),...this.systems.map(t=>Promise.all([e(t.backgroundImage).then(e=>t.backgroundImage=e),...t.staves.map(async t=>{t.backgroundImage=await e(t.backgroundImage),t.maskImage=await e(t.maskImage)})]))])}inferenceStaffLayout(){const e=Math.max(...this.systems.map(e=>e.staves.length),0);this.staffLayoutCode=Array(e).fill("").join(",");const t=this.systems.filter(t=>t.staves.length===e&&t.bracketsAppearance);if(!t.length)return;const s=t.map(e=>{try{return it(e.bracketsAppearance).staffIds.length!==e.staves.length?null:e.bracketsAppearance}catch(e){return null}}).filter(Boolean);if(!s.length)return;const i=s.reduce((e,t)=>{const s=e[t]||0;return e[t]=s+1,e},{}),n=Math.max(...Object.values(i)),r=Object.entries(i).find(([e,t])=>t===n)[0].replace(/\{,*\}/g,e=>e.replace(/,/g,"-")),a=it(r);this.staffLayoutCode=r;let o=null;for(const t of this.systems)if(o&&t.staves.length===o.staves.length&&t.bracketsAppearance===o.bracketsAppearance)t.staffMaskChanged=null;else{if(t.staves.length{if(s.length>a.staffIds.length)return null;if(s.reduce((e,t)=>e+t,0)===t.staves.length)return ms(s);for(const i of[1,0]){const n=[...s,i],r=a.partialMaskCode(n);if(r===t.bracketsAppearance)return ms(n);if(t.bracketsAppearance.startsWith(r)){const t=e(n);if(t)return t}}return null},s=e([]);t.staffMaskChanged=o&&s===o.staffMask?null:s}o=t}}assignBackgroundForMeasure(e){e.backgroundImages=[];const t=this.systems[e.position.systemIndex];t.backgroundImage&&e.backgroundImages.push({url:t.backgroundImage,position:t.imagePosition,original:!0}),t.staves.forEach(s=>{!t.backgroundImage&&s.backgroundImage&&e.backgroundImages.push({url:s.backgroundImage.toString(),position:{...s.imagePosition,y:s.imagePosition.y+s.top},original:!0}),s.maskImage&&e.backgroundImages.push({url:s.maskImage.toString(),position:{...s.imagePosition,y:s.imagePosition.y+s.top}})})}blackoutFakeNotes(e="patched"){if(!this.spartito)return;let t=e=>!0;switch(e){case"patched":t=e=>e.patched;break;case"perfect":t=e=>e.patched||e.regulated&&qe(e).perfect}const s=this.spartito.measures.filter(t).reduce((e,t)=>{if(!t.regulated)return;const s=t.voices.flat(1);return t.events.filter(e=>!e.rest&&!e.grace&&!s.includes(e.id)).forEach(t=>t.noteIds&&e.push(...t.noteIds)),e},[]),i=new Set(s);return this.systems.forEach(e=>e.staves.forEach(t=>{const s=t.semantics.filter(e=>i.has(e.id)).map(e=>e.id);e.sidBlackList.push(...s)})),s}getMeasureLayout(){const e=this.spartito&&this.spartito.measureLayoutCode;if(e)try{return(e=>{const t=Ve(e);return t?.data?S(t.data,He):null})(e)}catch(e){console.debug("invalid measure layout code:",e)}return null}*splitToSingleScoresGen(){this.assemble();const e=this.systems.filter(e=>e.index>0&&e.indent&&e.timeSignatureOnHead).map(e=>e.index);if(!e.length)return void(yield this.deepCopy());const t=new Score({...this,pages:[],topology:void 0,spartito:void 0,patches:void 0});this.pages.forEach(e=>{delete e.tokens,e.systems.forEach(e=>{delete e.tokens,e.staves.forEach(e=>{e.measures=[]})})});let s=0;for(const i of[...e,this.systems.length]){const e=e=>e.index>=s&&e.indext.systems.some(e)).map(t=>{const{systems:s,...i}=t;return new Page({...i,systems:s.filter(e).map(e=>new System({...e}))})}),r=t.deepCopy();r.headers.SubScoreSystem=`${s}-${i-1}`,r.headers.SubScorePage=`${n[0].index}-${n[n.length-1].index}`,r.pages=n,r.assemble(),r.inferenceStaffLayout(),s=i,yield r}}splitToSingleScores(){return[...this.splitToSingleScoresGen()]}}var ds;Score.className="Score",function(e){e.Pass="i",e.Division="d",e.Dots="o"}(ds||(ds={}));const fs=["whole","half","quarter","eighth","sixteenth","thirtysecond","sixtyfourth","128th","256th"],ps=.4/we,gs=1e-12,ys=[void 0,"u","d"],vs=[void 0,Ae.Open,Ae.Continue,Ae.Close],xs=e=>({elements:e.elements.map(e=>({tick:e.tick,division:e.division,dots:e.dots,beam:e.beam,stemDirection:e.stemDirection,grace:e.grace,timeWarped:e.timeWarped,fullMeasure:e.fullMeasure,fake:e.fake,order:e.order,predisposition:e.predisposition}))});class BeadNode{constructor(e){Object.assign(this,e),this.children={},this.accessCount=0}nextBranch(){const e=this.possibilities.map((e,t)=>e/(this.children[t]?this.children[t].accessCount+1:1));return e.every(e=>!e)?(this.accessCount=1/0,null):G(e)}get currentElem(){return this.cluster.elements[this.elemIndex]}branchID(e){switch(this.type){case ds.Pass:return`i_${e}`;case ds.Division:return fs[e];case ds.Dots:return"o"+".".repeat(e)}return""}async deduce({picker:e,logger:t,ptFactor:s},i=0){++this.accessCount;const n=this.nextBranch();if(t.debug(String.fromCodePoint(127817)+" ".repeat(i),this.branchID(n),this.accessCount>1?`[${this.accessCount}]`:""),!Number.isInteger(n)||n<0)return this.accessCount=1/0,ks(this.cluster,this.currentElem.order+1,this.pretentiousness);if(this.pretentiousness+=(e=>Math.min(100,-Math.log(e)))(this.possibilities[n]),this.pretentiousness>100*s)return this.accessCount=1/0,ks(this.cluster,this.currentElem.order+1,this.pretentiousness);let r=null;switch(this.type){case ds.Pass:{const t=this.currentElem.order+1,s=this.cluster.elements[n];if(console.assert(s,"null element:",n,this.cluster.elements.length),s.type===Y.EOS){if(r=ks(this.cluster,t,this.pretentiousness),!r.residue||r.fatalError)return this.accessCount=1/0,r;if(this.cluster.elements[0].order=t,!this.children[n]){if(!e.quota)return r;const s=(await e.predictCluster(this.cluster,t+1)).map((e,s)=>this.cluster.elements[s].orderMath.max(gs,e));this.children[n]=new BeadNode({cluster:this.cluster,elemIndex:n,type:ds.Division,possibilities:e,pretentiousness:this.pretentiousness})}}break;case ds.Division:if(this.currentElem.division=n,!this.children[n]){const e=this.currentElem.predisposition.dotsVector.map(e=>Math.max(gs,e));this.children[n]=new BeadNode({cluster:this.cluster,elemIndex:this.elemIndex,type:ds.Dots,possibilities:e,pretentiousness:this.pretentiousness})}break;case ds.Dots:if(this.currentElem.dots=n,r=ks(this.cluster,this.currentElem.order+1,this.pretentiousness),!r.residue||r.fatalError)return this.accessCount=1/0,r;if(!this.children[n]){if(!e.quota)return r;const t=this.currentElem.order+1,s=(await e.predictCluster(this.cluster,t)).map((e,s)=>this.cluster.elements[s].order{t.order>e&&(t.order=void 0)}),this.cluster.elements.forEach(e=>e.order=e.order>this.currentElem.order?void 0:e.order),this.cluster.elements[this.cluster.elements.length-1].tick=r.endTick,r}return a}}const Ss=e=>we*2**-e.division*(2-2**-e.dots),ks=(e,t,s)=>{const i=e.elements.filter(e=>[Y.CHORD,Y.REST].includes(e.type)&&Number.isInteger(e.order)&&e.ordere.order-t.order);const n=e.elements[e.elements.length-1];let r=0,a=0,o=0,c=1;const l=[[n.x,e.signatureDuration,e.signatureDuration]];let u=0;i.forEach(e=>{e.order>a+1&&(r=0,++c);const t=l.find(e=>e[1]>=r);if(t&&e.x>t[0]+3){const t=l.reduce((t,s)=>Math.abs(e.predisposition.tick-s[2])t[0]>e.x));l.splice(s,0,[e.x,e.tick,e.predisposition.tick]);let i=Ss(e);e.predisposition.timeWarped>.5&&(i=2*i/3),r+=i,u+=i,o=Math.max(o,r),a=e.order}),o>0&&(e.elements[e.elements.length-1].tick=o);const h=e.elements[e.elements.length-1].pivotX-e.elements[1].pivotX,m=Math.max(...i.map(e=>e.tick),o),d=[...i].sort((e,t)=>e.pivotX-t.pivotX),f=d.slice(1).map((e,t)=>{const s=d[t],i=e.pivotX-s.pivotX,n=e.tick-s.tick;if(!n)return i/h;return(4*Math.atan2(n/m,i/h)/Math.PI-1)**2}),p=Math.max(...f,0),g=i.map(e=>(e.tick-e.predisposition.tick)**2),y=g.length?Math.sqrt(g.reduce((e,t)=>e+t,0)/g.length):0,v=e.elements.filter(e=>[Y.CHORD,Y.REST].includes(e.type)&&!(Number.isInteger(e.order)&&e.order.5)).length,x=p>=1||o>e.signatureDuration,S=Math.max(0,e.signatureDuration-u/c);return{tickErr:y,twist:p,residue:v,endTick:o,fatalError:x,voiceN:c,spaceDuration:S,pretentiousness:s,loss:y/we+p+.2*v+.002*c+S*ps+.02*s}},bs=async(e,t,s,i=200,n=0,r=1)=>{e.elements.forEach((e,t)=>e.order=t?void 0:0);const a=await t.predictCluster(e,1),o=new BeadNode({cluster:e,elemIndex:0,pretentiousness:0,type:ds.Pass,possibilities:a});let c=null,l=null;for(t.quota=i;t.quota;){e.elements.forEach((e,t)=>e.order=t?void 0:0);const i=await o.deduce({picker:t,logger:s,ptFactor:r});if(s.debug("loss:",i),(!c||i.loss{e.elements.forEach((e,s)=>Object.assign(e,t.elements[s]))})(e,l);const u=e.elements.filter(e=>[Y.CHORD,Y.REST].includes(e.type)&&Number.isInteger(e.order)),h=e.elements.filter(e=>[Y.CHORD,Y.REST].includes(e.type)&&!Number.isInteger(e.order));u.length&&h.forEach(e=>{if(e.tick=void 0,e.predisposition.fakeP<.5){const t=Ss(e),s=u.filter(e=>e.tick+t<=c.endTick);if(s.length){const t=s.reduce((t,s)=>Math.abs(s.x-e.x)e.order-t.order),[...u,...h].forEach(e=>{e.grace=!Number.isFinite(e.tick)&&e.predisposition.grace,e.timeWarped=e.predisposition.timeWarped>.5,e.fullMeasure=e.predisposition.fullMeasure>.5,e.stemDirection=ys[G(e.predisposition.stemDirectionVector)],e.beam=vs[G(e.predisposition.beamVector)]});const m=e.elements.map(e=>e.index),d=e=>m.indexOf(e);return e.matrixH=e.elements.map(()=>Array(e.elements.length).fill(0)),u.forEach((t,s)=>{const i=u[s-1];!i||i.order{const{stopLoss:s=.09,quotaMax:i=1e3,quotaFactor:n=5,ptFactor:r=1,logger:a=new DummyLogger}=t;let o=0;const c=e.createClusters();for(const l of c){const c=Math.min(i,Math.ceil(l.elements.length*n));a.info(`[measure-${e.measureIndex}]`,c);const{loss:u}=await bs(l,t.picker,a,c,s,r);o=Math.max(o,u)}const l=[],u=[],h=[];c.forEach(t=>{const s=t.elements.filter(e=>[Y.CHORD,Y.REST].includes(e.type)&&Number.isInteger(e.order));if(s.sort((e,t)=>e.order-t.order),!s.length)return;let i=[];l.push(i);let n=0;s.forEach(e=>{e.fullMeasure||e.grace||e.tremoloCatcher||(e.order>n+1?(i=[e.index],l.push(i)):i.push(e.index),n=e.order)});let r=s[s.length-1];const a=t.elements.filter(e=>[Y.CHORD,Y.REST].includes(e.type)&&Number.isFinite(e.tick)&&!Number.isInteger(e.order));for(;a.length;){const e=a.findIndex(e=>e.tick>=r.tick+Ss(r));e>=0?i.push(a.splice(e,1)[0].index):(r=a.splice(0,1)[0],i=[r.index],l.push(i))}if(s.some(e=>!e.fullMeasure&&Number.isInteger(e.order))){const e=t.elements.find(e=>e.type===Y.EOS);u.push(e.tick)}const o=e.eventMap,c=t.elements.reduce((e,t)=>(Number.isFinite(t.tick)&&e.add(t.tick),e),new Set),m=Array.from(c).sort((e,t)=>e-t);s.forEach(e=>{const t=o[e.index];t&&h.push({id:t.id,tick:e.tick,tickGroup:m.indexOf(e.tick),division:e.division!==t.division?e.division:void 0,dots:e.dots!==t.dots?e.dots:void 0,timeWarp:e.timeWarped?F(2,3):void 0,beam:e.beam!==t.beam?e.beam:void 0,grace:e.grace!==!!t.grace?e.grace:void 0,fullMeasure:e.fullMeasure||void 0})})});const m=Math.max(...c.map(e=>e.estimatedDuration));return{voices:l.filter(e=>e.length),duration:Math.max(...u),events:h,priority:-o,estimatedDuration:m}},ws=async(e,{picker:t,resetSignatureForDoubtfulOnly:s})=>{const i=e.createClusters(),n=e.eventMap;for(const r of i)s&&!e.doubtfulTimesig||(r.signatureDuration=0),r.elements.forEach((e,t)=>e.order=t?void 0:0),await t.predictCluster(r,1),r.elements.filter(e=>[Y.CHORD,Y.REST].includes(e.type)).forEach(e=>{n[e.index].predisposition=e.predisposition});e.estimatedDuration=Math.max(...i.map(e=>e.estimatedDuration))},Ms=async(e,t)=>ws(e,{picker:t,resetSignatureForDoubtfulOnly:!0});var Es=Object.freeze({__proto__:null,solveCluster:bs,solveMeasure:Ts,estimateMeasure:Ms,glimpseMeasure:ws}),As=Object.freeze({__proto__:null,beadSolver:Es,recoverJSON:S,SimpleClass:SimpleClass,EditableEvent:EditableEvent,EditableMeasure:EditableMeasure,get EventElementType(){return Y},EventCluster:EventCluster,EventClusterSet:EventClusterSet,get PageLayoutMethod(){return Fe},get TextType(){return Pe},evaluateMeasure:qe,PatchMeasure:PatchMeasure,VERSION:14,Score:Score,Page:Page,System:System,Staff:Staff,Measure:Measure,SemanticGraph:SemanticGraph,get SemanticType(){return T},glyphSemanticMapping:{"rests.1":"Rest1","rests.0o":"Rest0","rests.1o":"Rest1","rests.M1":"RestM1","rests.2":"Rest2","rests.3":"Rest3","rests.4":"Rest4","rests.5":"Rest5","rests.6":"Rest6","accidentals.sharp":"AccSharp","accidentals.doublesharp":"AccDoublesharp","accidentals.natural":"AccNatural","accidentals.flat":"AccFlat","accidentals.flatflat":"AccFlatflat","dots.dot":"Dot","scripts.ufermata":"ScriptFermata","scripts.dfermata":"ScriptFermata","scripts.ushortfermata":"ScriptShortFermata","scripts.dshortfermata":"ScriptShortFermata","scripts.staccato":"ScriptStaccato","scripts.ustaccatissimo":"ScriptStaccatissimo","scripts.dstaccatissimo":"ScriptStaccatissimo","scripts.turn":"ScriptTurn","scripts.trill":"ScriptTrill","scripts.segno":"ScriptSegno","scripts.coda":"ScriptCoda","scripts.arpeggio":"ScriptArpeggio","scripts.prall":"ScriptPrall","scripts.mordent":"ScriptMordent","scripts.umarcato":"ScriptMarcato","scripts.dmarcato":"ScriptMarcato","scripts.uportato":"ScriptPortato","scripts.dportato":"ScriptPortato","scripts.tenuto":"ScriptTenuto","scripts.sforzato":"ScriptSforzato","clefs.C":"ClefC","clefs.F":"ClefF","clefs.G":"ClefG","clefs.F_change":"ClefF","clefs.G_change":"ClefG","timesig.C44":"TimesigC44","timesig.C22":"TimesigC22","pedal.*":"PedalStar","pedal.Ped":"PedalPed","noteheads.s0":"NoteheadS0","noteheads.s1":"NoteheadS1","noteheads.s2":"NoteheadS2",f:"f",m:"m",p:"p",r:"r",s:"s",z:"z"},semanticPriorities:{ClefG:0,ClefF:0,TimesigFour:0,TimesigThree:0,TimesigTwo:0,NoteheadS0:0,NoteheadS1:0,NoteheadS2:0,Dot:0,vline_BarMeasure:0,vline_Stem:0,Flag3:0,TimesigC44:1,TimesigC22:1,TimesigEight:1,TimesigSix:1,AccNatural:1,AccSharp:1,AccFlat:1,KeyAcc:1,Rest0:1,Rest1:1,Rest2:1,Rest3:1,Rest4:1,OctaveShift8:1,OctaveShift0:1,AccDoublesharp:2,AccFlatflat:2,TimesigOne:2,TimesigNine:2,Rest5:2,Rest6:2,SlurBegin:2,SlurEnd:2,VoltaLeft:2,VoltaRight:2,vline_BarTerminal:2,vline_BarSegment:2,TempoNotehead:2,GraceNotehead:2,SignLined:2,SignInterval:2,BeamLeft:2,BeamRight:2,BeamContinue:2,TremoloLeft:2,TremoloRight:2,TremoloMiddle:2,StemTip:2,StemHead:2,f:3,p:3,m:3,ScriptFermata:3,ScriptSforzato:3,ScriptStaccato:3,ScriptStaccatissimo:3,ScriptTurn:3,ScriptTrill:3,ScriptSegno:3,ScriptCoda:3,ScriptArpeggio:3,ScriptPrall:3,ScriptMordent:3,ScriptTenuto:3,PedalStar:3,PedalPed:3,TimesigFive:3,TimesigSeven:3,TimesigZero:3,One:3,Two:3,Three:3,Four:3,Five:3,rect_Text:3,rect_Lyric:3,CrescendoBegin:3,CrescendoEnd:3,DecrescendoBegin:3,DecrescendoEnd:3,RestM1:4,ClefC:4,ScriptShortFermata:4,ScriptMarcato:4,ScriptPortato:4,s:4,r:4,z:4,Zero:4,Six:4,Seven:4,Eight:4,Nine:4},NOTEHEAD_WIDTHS:w,glyphCenters:M,ONE_D_SEMANTICS:["OctaveShift8va","OctaveShift8vb","OctaveShift8","OctaveShift0","vline_VoltaLeft","vline_VoltaRight","VoltaAlternativeBegin","vline_BarMeasure","vline_BarTerminal","vline_BarSegment"],SYSTEM_SEMANTIC_TYPES:E,CONFLICTION_GROUPS:N,STAMP_SEMANTICS:I,STAMP_RECTS:{ClefG:[-.0625,-1.125,3.6,8.6],ClefF:[.25,.5625,3.6,3.8],ClefC:[.25,0,3.25,4.5],NoteheadS0:[.0625,0,2.55,1.4],NoteheadS1:[.0625,0,1.8,1.4],NoteheadS2:[.0625,-.0625,1.65,1.35],Dot:[.25,0,.6,.6],Rest0:[0,-.75,3.25,.9],Rest1:[0,-.25,3.25,.9],Rest2:[-.0625,-.1875,1.6,3.375],Rest3:[0,.0625,1.2,2.25],Rest4:[.0625,.5625,1.65,3.375],Rest5:[.0625,.0625,1.95,4.375],Rest6:[.0625,.5625,1.95,5.375],RestM1:[-.4375,-1.5,.75,1.2],AccNatural:[0,0,.9,3.5],AccSharp:[0,0,1.5,3.5],AccDoublesharp:[0,0,1.5,1.5],AccFlat:[0,-.5625,1.2,3.125],AccFlatflat:[.1875,-.5625,1.95,3.125],TimesigC44:[-.0625,0,2.25,2.3],TimesigC22:[-.0625,0,2.25,3.2],TimesigZero:[0,0,1.8,2.2],TimesigOne:[-.125,0,1.5,2.2],TimesigTwo:[0,0,2.2,2.2],TimesigThree:[-.0625,0,1.9,2.4],TimesigFour:[.0625,0,1.95,2.2],TimesigFive:[0,0,1.8,2.3],TimesigSix:[0,0,2,2.4],TimesigSeven:[0,0,1.8,2.2],TimesigEight:[0,0,1.9,2.2],TimesigNine:[0,0,1.9,2.2],One:[-.0625,0,.75,1.6],Two:[0,0,1.2,1.6],Three:[0,0,1.2,1.6],Four:[0,0,1.2,1.6],Five:[0,0,1.2,1.6],OctaveShift8:[2.125,-.1875,4.75,3.6],OctaveShift0:[-.4,0,1.8,4.2],f:[.0625,-.125,2.55,3],p:[-.0625,.25,2.55,2.1],m:[-.125,-.0625,2.4,1.35],n:[-.3125,-.0625,1.95,1.35],r:[0,-.125,1.5,1.5],s:[0,-.0625,1.2,1.35],z:[.0625,0,1.35,1.5],ScriptFermata:[0,0,3.25,3.9],ScriptShortFermata:[0,0,2.4,4.95],ScriptSforzato:[-.0625,0,2.5,1.2],ScriptStaccato:[0,-.0625,.6,.45],ScriptStaccatissimo:[0,0,1.2,2.6],ScriptTurn:[0,0,2.7,1.5],ScriptTrill:[-.125,-.5,3,2.7],ScriptSegno:[0,0,2.4,3.5],ScriptCoda:[0,0,2.7,3.25],ScriptArpeggio:[-.0625,0,1.05,1.8],ScriptPrall:[0,0,2.4,1.2],ScriptMordent:[0,0,2.4,1.5],ScriptMarcato:[0,0,1.2,2.475],ScriptTenuto:[0,-.0625,1.5,.15],ScriptPortato:[0,0,1.5,1.65],PedalStar:[0,0,3.2,3.2],PedalPed:[0,-.25,4.7,2.4]},hashSemanticPoint:C,hashPageSemanticPoint:O,get SemanticElementType(){return ft},SemanticCluster:SemanticCluster,SemanticClusterSet:class SemanticClusterSet{constructor(e){if(e&&(this.clusters=e.clusters,e.vocab)){const t=e.vocab.map((e,t)=>[t,ft[e]]).filter(([e,t])=>e!==t).reduce((e,[t,s])=>(e[t]=s,e),{});this.clusters.forEach(e=>e.elements.forEach(e=>{Number.isFinite(t[e.type])&&(e.type=t[e.type])}))}}toJSON(){return{__prototype:"SemanticClusterSet",vocab:Object.entries(ft).filter(e=>Number.isFinite(e[1])).map(e=>e[0]),clusters:this.clusters.map(e=>e.toJSON())}}},ELEMENT_TOKEN_NAMES:vt,NOTEHEAD_ELEMENT_TYPES:St,NOTE_ELEMENT_TYPES:Tt,BOS_ELEMENT:It,fractionToElems:Ct,expandMatrixByMasks:Bt,expandMatrixByMaskTriu:_t,matrixFromGroups:Rt,emptyVoiceFromStaffMeasure:as,SpartitoMeasure:SpartitoMeasure,Spartito:Spartito,mod7:ls,Term:Term,EventTerm:EventTerm,ContextedTerm:ContextedTerm,MarkTerm:MarkTerm,TempoTerm:TempoTerm,GlyphTerm:GlyphTerm,TextTerm:TextTerm,LyricTerm:LyricTerm,CommandTerm:CommandTerm,ChordmodeTerm:ChordmodeTerm,get ContextType(){return Oe},get GraceType(){return Ee},get GlissandoStyle(){return Ie},get ArpeggioStyle(){return Ce},get AccessoryDirection(){return Me},WHOLE_DURATION:we,get StemBeam(){return Ae},get TremoloLink(){return Ne},TokenTypes:X,TokenClefs:Q,TokenTimesigs:ee,TokenTimesigsC:te,TokenTimesigsN:se,TokenOctshifts:ie,TokenNumbers:ne,TokenAccidentals:re,TokenNoteheads:ae,TokenBareNoteheads:oe,TokenDirectionalNoteheads:ce,TokenRests:le,TokenFlags:ue,TokenVolta:he,TokenDynamics:me,TokenScripts:de,TokenPedals:fe,TokenDots:pe,TokenArcs:ge,TokenBeams:ye,TokenWedges:ve,TokenAccessories:xe,TokenDirectionless:Se,TokenGlyphs:ke,get TokenType(){return Z},Token:Token,TextToken:TextToken,TOKEN_Y_ROUND:be,TOKEN_Y_FIXED:Te});const Ns=[Z.ClefG,Z.ClefF,Z.ClefC],Is=e=>{let t=null;switch(e.tokenType){case Z.ClefG:t="Treble";break;case Z.ClefF:t="Bass";break;case Z.ClefC:t=-1===e.y?"Tenor":"Alto"}return t};var Cs,Os={exports:{}},Bs="object"==typeof Reflect?Reflect:null,_s=Bs&&"function"==typeof Bs.apply?Bs.apply:function(e,t,s){return Function.prototype.apply.call(e,t,s)};Cs=Bs&&"function"==typeof Bs.ownKeys?Bs.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var Rs=Number.isNaN||function(e){return e!=e};function Fs(){Fs.init.call(this)}Os.exports=Fs,Os.exports.once=function(e,t){return new Promise(function(s,i){function n(s){e.removeListener(t,r),i(s)}function r(){"function"==typeof e.removeListener&&e.removeListener("error",n),s([].slice.call(arguments))}Gs(e,t,r,{once:!0}),"error"!==t&&function(e,t,s){"function"==typeof e.on&&Gs(e,"error",t,s)}(e,n,{once:!0})})},Fs.EventEmitter=Fs,Fs.prototype._events=void 0,Fs.prototype._eventsCount=0,Fs.prototype._maxListeners=void 0;var Ps=10;function Ds(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function qs(e){return void 0===e._maxListeners?Fs.defaultMaxListeners:e._maxListeners}function Ls(e,t,s,i){var n,r,a,o;if(Ds(s),void 0===(r=e._events)?(r=e._events=Object.create(null),e._eventsCount=0):(void 0!==r.newListener&&(e.emit("newListener",t,s.listener?s.listener:s),r=e._events),a=r[t]),void 0===a)a=r[t]=s,++e._eventsCount;else if("function"==typeof a?a=r[t]=i?[s,a]:[a,s]:i?a.unshift(s):a.push(s),(n=qs(e))>0&&a.length>n&&!a.warned){a.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=a.length,o=c,console&&console.warn&&console.warn(o)}return e}function $s(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function js(e,t,s){var i={fired:!1,wrapFn:void 0,target:e,type:t,listener:s},n=$s.bind(i);return n.listener=s,i.wrapFn=n,n}function Hs(e,t,s){var i=e._events;if(void 0===i)return[];var n=i[t];return void 0===n?[]:"function"==typeof n?s?[n.listener||n]:[n]:s?function(e){for(var t=new Array(e.length),s=0;s{s=e,i=n,t>=0&&setTimeout(i,t,"timeout")}),s,i]}Object.defineProperty(Fs,"defaultMaxListeners",{enumerable:!0,get:function(){return Ps},set:function(e){if("number"!=typeof e||e<0||Rs(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");Ps=e}}),Fs.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},Fs.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||Rs(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},Fs.prototype.getMaxListeners=function(){return qs(this)},Fs.prototype.emit=function(e){for(var t=[],s=1;s0&&(r=t[0]),r instanceof Error)throw r;var a=new Error("Unhandled error."+(r?" ("+r.message+")":""));throw a.context=r,a}var o=n[e];if(void 0===o)return!1;if("function"==typeof o)_s(o,this,t);else{var c=o.length,l=Vs(o,c);for(s=0;s=0;r--)if(s[r]===t||s[r].listener===t){a=s[r].listener,n=r;break}if(n<0)return this;0===n?s.shift():function(e,t){for(;t+1=0;i--)this.removeListener(e,t[i]);return this},Fs.prototype.listeners=function(e){return Hs(this,e,!0)},Fs.prototype.rawListeners=function(e){return Hs(this,e,!1)},Fs.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):Ws.call(e,t)},Fs.prototype.listenerCount=Ws,Fs.prototype.eventNames=function(){return this._eventsCount>0?Cs(this._events):[]};class AsyncQueue extends Os.exports.EventEmitter{constructor(){super(),this.working=!1,this.working=!1,this.tasks=[],process.nextTick(()=>{this.emit("idle")})}async _digest(e){this.working=!0;const[t,s,i,n]=e;await t(s).then(i,n),this.tasks.length>0?await this._digest(this.tasks.shift()):(this.working=!1,this.emit("idle"))}addTask(e,{timeout:t=6e5}={}){const[s,i,n]=Us({timeout:t});return this.working?this.tasks.push([...e,i,n]):this._digest([...e,i,n]),s}}class ZeroClient{constructor(e=console){this.queue=new AsyncQueue,this.logger=e}bind(e){e&&(this.url=e),this.socket=new n.Request({sendTimeout:15e3,receiveTimeout:3e5}),this.socket.connect(this.url)}__request(e){let t=0;const s=async e=>{try{return this.socket.closed&&this.bind(),await this.socket.send(i.pack(e)).then(()=>this.socket.receive())}catch(i){if(t<2)return t++,console.log(`请求失败,${i.stack}`),console.error(`3s后重试第${t}次`),this.socket.close(),await new Promise(e=>setTimeout(e,3e3)),s(e);throw i}};return s(e)}async request(e,t=null,s=null){const[n,r]=Array.isArray(t)?[t,s]:[void 0,t],a={method:e};return n&&(a.args=n),r&&(a.kwargs=r),this.queue.addTask([async e=>{const[t]=await this.__request(e),s=i.unpack(t);return 0===s.code?s.data:Promise.reject(s.msg)},a])}}class PyProcessor extends ZeroClient{constructor(e,t={},s=console){super(s),this.retryCount=0,this.retryDelay=3e3,this.scriptPath=e,this.options=t}async bind(e){const t=e||await r.getPortPromise({port:12022,stopPort:12122}),s=o.defaultsDeep({args:[...this.options.args||[],"-p",`${t}`]},this.options);this.logger.info(`[python-shell]: starting python shell. path: ${this.scriptPath}`),this.pyShell=new a.PythonShell(this.scriptPath,s),this.pyShell.stdout.on("data",e=>this.logger.info(e)),this.pyShell.on("pythonError",e=>this.logger.error(`[python-shell]: ${this.scriptPath} pythonError:`,e)),this.pyShell.on("stderr",e=>this.logger.error(`[python-shell]: ${this.scriptPath} stderr:`,e)),this.pyShell.on("error",e=>this.logger.error(`[python-shell]: ${this.scriptPath} error:`,e)),this.pyShell.on("close",()=>{this.retryCount<5&&(this.retryCount++,this.logger.info(`[python-shell]: ${this.scriptPath} will retry ${this.retryCount}th time after 3 seconds`),setTimeout(()=>{this.bind()},this.retryDelay))}),super.bind(`tcp://127.0.0.1:${t}`)}}var zs={},Ks=function(e){return e instanceof Buffer},Ys={exports:{}},Zs={exports:{}};"function"==typeof Object.create?Zs.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:Zs.exports=function(e,t){e.super_=t;var s=function(){};s.prototype=t.prototype,e.prototype=new s,e.prototype.constructor=e};try{var Js=require("util");if("function"!=typeof Js.inherits)throw"";Ys.exports=Js.inherits}catch(e){Ys.exports=Zs.exports}!function(e){var t=Object.getOwnPropertyDescriptors||function(e){for(var t=Object.keys(e),s={},i=0;i=a)return e;switch(e){case"%s":return String(n[i++]);case"%d":return Number(n[i++]);case"%j":try{return JSON.stringify(n[i++])}catch(e){return"[Circular]"}default:return e}}),c=n[i];i=3&&(i.depth=arguments[2]),arguments.length>=4&&(i.colors=arguments[3]),m(s)?i.showHidden=s:s&&e._extend(i,s),g(i.showHidden)&&(i.showHidden=!1),g(i.depth)&&(i.depth=2),g(i.colors)&&(i.colors=!1),g(i.customInspect)&&(i.customInspect=!0),i.colors&&(i.stylize=a),c(i,t,i.depth)}function a(e,t){var s=r.styles[t];return s?"["+r.colors[s][0]+"m"+e+"["+r.colors[s][1]+"m":e}function o(e,t){return e}function c(t,s,i){if(t.customInspect&&s&&k(s.inspect)&&s.inspect!==e.inspect&&(!s.constructor||s.constructor.prototype!==s)){var n=s.inspect(i,t);return p(n)||(n=c(t,n,i)),n}var r=function(e,t){if(g(t))return e.stylize("undefined","undefined");if(p(t)){var s="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(s,"string")}if(f(t))return e.stylize(""+t,"number");if(m(t))return e.stylize(""+t,"boolean");if(d(t))return e.stylize("null","null")}(t,s);if(r)return r;var a=Object.keys(s),o=function(e){var t={};return e.forEach(function(e,s){t[e]=!0}),t}(a);if(t.showHidden&&(a=Object.getOwnPropertyNames(s)),S(s)&&(a.indexOf("message")>=0||a.indexOf("description")>=0))return l(s);if(0===a.length){if(k(s)){var v=s.name?": "+s.name:"";return t.stylize("[Function"+v+"]","special")}if(y(s))return t.stylize(RegExp.prototype.toString.call(s),"regexp");if(x(s))return t.stylize(Date.prototype.toString.call(s),"date");if(S(s))return l(s)}var b,T="",w=!1,E=["{","}"];(h(s)&&(w=!0,E=["[","]"]),k(s))&&(T=" [Function"+(s.name?": "+s.name:"")+"]");return y(s)&&(T=" "+RegExp.prototype.toString.call(s)),x(s)&&(T=" "+Date.prototype.toUTCString.call(s)),S(s)&&(T=" "+l(s)),0!==a.length||w&&0!=s.length?i<0?y(s)?t.stylize(RegExp.prototype.toString.call(s),"regexp"):t.stylize("[Object]","special"):(t.seen.push(s),b=w?function(e,t,s,i,n){for(var r=[],a=0,o=t.length;a60)return s[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+s[1];return s[0]+t+" "+e.join(", ")+" "+s[1]}(b,T,E)):E[0]+T+E[1]}function l(e){return"["+Error.prototype.toString.call(e)+"]"}function u(e,t,s,i,n,r){var a,o,l;if((l=Object.getOwnPropertyDescriptor(t,n)||{value:t[n]}).get?o=l.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):l.set&&(o=e.stylize("[Setter]","special")),M(i,n)||(a="["+n+"]"),o||(e.seen.indexOf(l.value)<0?(o=d(s)?c(e,l.value,null):c(e,l.value,s-1)).indexOf("\n")>-1&&(o=r?o.split("\n").map(function(e){return" "+e}).join("\n").substr(2):"\n"+o.split("\n").map(function(e){return" "+e}).join("\n")):o=e.stylize("[Circular]","special")),g(a)){if(r&&n.match(/^\d+$/))return o;(a=JSON.stringify(""+n)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(a=a.substr(1,a.length-2),a=e.stylize(a,"name")):(a=a.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),a=e.stylize(a,"string"))}return a+": "+o}function h(e){return Array.isArray(e)}function m(e){return"boolean"==typeof e}function d(e){return null===e}function f(e){return"number"==typeof e}function p(e){return"string"==typeof e}function g(e){return void 0===e}function y(e){return v(e)&&"[object RegExp]"===b(e)}function v(e){return"object"==typeof e&&null!==e}function x(e){return v(e)&&"[object Date]"===b(e)}function S(e){return v(e)&&("[object Error]"===b(e)||e instanceof Error)}function k(e){return"function"==typeof e}function b(e){return Object.prototype.toString.call(e)}function T(e){return e<10?"0"+e.toString(10):e.toString(10)}e.debuglog=function(t){if(g(i)&&(i=process.env.NODE_DEBUG||""),t=t.toUpperCase(),!n[t])if(new RegExp("\\b"+t+"\\b","i").test(i)){var s=process.pid;n[t]=function(){var i=e.format.apply(e,arguments);console.error("%s %d: %s",t,s,i)}}else n[t]=function(){};return n[t]},e.inspect=r,r.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},r.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},e.isArray=h,e.isBoolean=m,e.isNull=d,e.isNullOrUndefined=function(e){return null==e},e.isNumber=f,e.isString=p,e.isSymbol=function(e){return"symbol"==typeof e},e.isUndefined=g,e.isRegExp=y,e.isObject=v,e.isDate=x,e.isError=S,e.isFunction=k,e.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},e.isBuffer=Ks;var w=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function M(e,t){return Object.prototype.hasOwnProperty.call(e,t)}e.log=function(){var t,s;console.log("%s - %s",(t=new Date,s=[T(t.getHours()),T(t.getMinutes()),T(t.getSeconds())].join(":"),[t.getDate(),w[t.getMonth()],s].join(" ")),e.format.apply(e,arguments))},e.inherits=Ys.exports,e._extend=function(e,t){if(!t||!v(t))return e;for(var s=Object.keys(t),i=s.length;i--;)e[s[i]]=t[s[i]];return e};var E="undefined"!=typeof Symbol?Symbol("util.promisify.custom"):void 0;function A(e,t){if(!e){var s=new Error("Promise was rejected with a falsy value");s.reason=e,e=s}return t(e)}e.promisify=function(e){if("function"!=typeof e)throw new TypeError('The "original" argument must be of type Function');if(E&&e[E]){var s;if("function"!=typeof(s=e[E]))throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(s,E,{value:s,enumerable:!1,writable:!1,configurable:!0}),s}function s(){for(var t,s,i=new Promise(function(e,i){t=e,s=i}),n=[],r=0;r>>32-t},rotr:function(e,t){return e<<32-t|e>>>t},endian:function(e){if(e.constructor==Number)return 16711935&ei.rotl(e,8)|4278255360&ei.rotl(e,24);for(var t=0;t0;e--)t.push(Math.floor(256*Math.random()));return t},bytesToWords:function(e){for(var t=[],s=0,i=0;s>>5]|=e[s]<<24-i%32;return t},wordsToBytes:function(e){for(var t=[],s=0;s<32*e.length;s+=8)t.push(e[s>>>5]>>>24-s%32&255);return t},bytesToHex:function(e){for(var t=[],s=0;s>>4).toString(16)),t.push((15&e[s]).toString(16));return t.join("")},hexToBytes:function(e){for(var t=[],s=0;s>>6*(3-n)&63)):t.push("=");return t.join("")},base64ToBytes:function(e){e=e.replace(/[^A-Z0-9+\/]/gi,"");for(var t=[],s=0,i=0;s>>6-2*i);return t}},si.exports=ei;var ii={utf8:{stringToBytes:function(e){return ii.bin.stringToBytes(unescape(encodeURIComponent(e)))},bytesToString:function(e){return decodeURIComponent(escape(ii.bin.bytesToString(e)))}},bin:{stringToBytes:function(e){for(var t=[],s=0;s>5]|=128<<24-n%32,i[15+(n+64>>>9<<4)]=n;for(var h=0;h>>31}var x=(a<<5|a>>>27)+u+(r[y]>>>0)+(y<20?1518500249+(o&c|~o&l):y<40?1859775393+(o^c^l):y<60?(o&c|o&l|c&l)-1894007588:(o^c^l)-899497514);u=l,l=c,c=o<<30|o>>>2,o=a,a=x}a+=m,o+=d,c+=f,l+=p,u+=g}return[a,o,c,l,u]}(i));return n&&n.asBytes?r:n&&n.asString?s.bytesToString(r):e.bytesToHex(r)};i._blocksize=16,i._digestsize=20,ti.exports=i}();var ri=ti.exports;const ai=({page:e,backgroundImage:t,detection:s,imageSize:i,position:n})=>{const r=(s.phi2-s.phi1)/s.interval,a=i.height/s.interval,o=e.systems[e.systems.length-1],c=n?n.y:(o?o.top+o.height:0)+4,l=n?n.x:4,u=[0,...Array(s.middleRhos.length-1).fill(0).map((e,t)=>(s.middleRhos[t]+s.middleRhos[t+1])/2/s.interval)],h=[r],m=u.map((e,t)=>new Staff({top:e,height:(u[t+1]||a)-e,staffY:s.middleRhos[t]/s.interval-e,measureBars:h})),d={x:-s.phi1/s.interval,y:0,width:i.width/s.interval,height:i.height/s.interval};return new System({staves:m,left:l,top:c,width:r,backgroundImage:t,imagePosition:d,measureBars:h})};async function oi(e,{format:t="webp",maxHeight:s=1080,quality:i=80}={}){let n=await(async e=>"string"==typeof e?/^https?:\/\//.test(e)?(await x.default(e,{responseType:"buffer",decompress:!0,https:{rejectUnauthorized:!1}})).body:/^data:image\//.test(e)?Buffer.from(e.split(",")[1],"base64"):Buffer.from(e):e)(e);const r=await new Promise(e=>{v.default(n).resize({width:s,height:s,fit:"inside",withoutEnlargement:!0}).toFormat(t,{quality:i}).toBuffer((t,s)=>{e(s)})});return{buffer:r,filename:`${y.default.ArrayBuffer.hash(r)}.${t}`}}globalThis.OffscreenCanvas=globalThis.OffscreenCanvas||c.Canvas,globalThis.Image=globalThis.Image||c.Image,globalThis.btoa=globalThis.btoa||(e=>Buffer.from(e,"binary").toString("base64"));const ci=32,li={viewportHeight:256,viewportUnit:8},ui=192,hi=8,mi={viewportHeight:192,viewportUnit:8};const di=e=>Promise.all(e.map(e=>e())),fi=async(e,t,{paddingLeft:s=0,scaling:i=1,spec:n})=>{if(!e||!e.backgroundImage)return null;const r=e.staves[t];if(!r)return null;const a=n.viewportHeight/n.viewportUnit/2,o=e.imagePosition.width*n.viewportUnit,l=e.imagePosition.height*n.viewportUnit,u=e.imagePosition.x*n.viewportUnit+s,h=(e.imagePosition.y-(r.top+r.staffY-a))*n.viewportUnit,m=new c.Canvas(Math.round(o+u)*i,n.viewportHeight*i),d=m.getContext("2d");return d.fillStyle="white",d.fillRect(0,0,m.width,m.height),d.drawImage(await c.loadImage(e.backgroundImage),u*i,h*i,o*i,l*i),m};async function pi({system:e,staff:t,staffIndex:s}){const i=await fi(e,s,{paddingLeft:ci,spec:mi});t.backgroundImage=i.toBufferSync("png"),t.imagePosition={x:-32/mi.viewportUnit,y:t.staffY-mi.viewportHeight/2/mi.viewportUnit,width:i.width/mi.viewportUnit,height:i.height/mi.viewportUnit}}async function gi({system:e,staff:t,staffIndex:s,gaugeImage:i,pyClients:n}){const r=(await fi(e,s,{paddingLeft:ci,spec:li,scaling:2})).toBufferSync("png"),a=(e.middleY-(t.top+t.staffY))*li.viewportUnit+li.viewportHeight/2,{buffer:o,size:c}=await n.predictScoreImages("gaugeRenderer",[r,i,a]);t.backgroundImage=o,t.imagePosition={x:-32/li.viewportUnit,y:t.staffY-c.height/2/li.viewportUnit,width:c.width/li.viewportUnit,height:c.height/li.viewportUnit},t.maskImage=null}async function yi({staff:e,staffIndex:t,maskImage:s}){const i=await c.loadImage(s);e.maskImage=s,e.imagePosition={x:-32/hi,y:e.staffY-ui/2/hi,width:i.width/hi,height:i.height/hi}}async function vi({score:e,staffIndex:t,system:s,staff:i,graph:n}){n.offset(-32/mi.viewportUnit,0),s.assignSemantics(t,n),i.assignSemantics(n),i.clearPredictedTokens(),e.assembleSystem(s,e.settings?.semanticConfidenceThreshold||1)}function xi(e,t){[[e.source,"url"],...e.systems.map(e=>[[e,"backgroundImage"],...e.staves.map(e=>[[e,"backgroundImage"],[e,"maskImage"]]).flat()]).flat()].map(([e,s])=>{e[s]=t(e[s])})}class OMRProgress{constructor(e){this.state={},this.onChange=e}setTotal(e,t){this.state[e]=this.state[e]||{total:t,finished:0}}increase(e,t=1){(this.state[e]||{finished:0}).finished+=t,this.onChange(this.state)}}const Si=new l.WeakLRUCache,ki={get:async e=>Si.getValue(e),async set(e,t){Si.setValue(e,t)}},bi=async e=>{if(e instanceof Buffer||"string"==typeof e&&(/^https?:\/\//.test(e)||/^data:image\//.test(e))){return`data:image/webp;base64,${(await oi(e)).buffer.toString("base64")}`}return e},Ti=e=>{const t=Math.random();let s=0;for(let i=0;it)return i;return e.length-1},wi=(e,t=.9)=>{const s=e.map(e=>Math.log(e)*t).map(Math.exp),i=s.reduce((e,t)=>e+t,0);return s.map(e=>e/i)},Mi=e=>{if(!e.predisposition?.divisionVector&&!e.predisposition?.dotsVector)return e;const t=e.predisposition?.divisionVector?wi(e.predisposition.divisionVector):null,s=e.predisposition?.dotsVector?wi(e.predisposition.dotsVector):null;return new EventTerm({...e,predisposition:{...e.predisposition,divisionVector:t,dotsVector:s}})};class MeasureRectification{constructor(e){Object.assign(this,e)}toString(){return this.events.map(e=>{if(!e)return"";const{division:t="",dots:s=""}=e;return`${t}|${s}`}).join(",")}static default(e){return new MeasureRectification({events:e.map(e=>{if(!e.predisposition?.divisionVector&&!e.predisposition?.dotsVector)return null;const t=e.predisposition.divisionVector?e.division:void 0,s=e.predisposition.dotsVector?e.dots:void 0;return{id:e.id,division:t,dots:s}})})}static roll(e){return new MeasureRectification({events:e.map(e=>{if(!e.predisposition?.divisionVector&&!e.predisposition?.dotsVector)return null;let t,s;return e.predisposition.divisionVector&&(t=Ti(e.predisposition.divisionVector)),e.predisposition.dotsVector&&(s=Ti(e.predisposition.dotsVector)),{id:e.id,division:t,dots:s}})})}}const Ei=new l.WeakLRUCache,Ai={get:async e=>Ei.getValue(e),async set(e,t){Ei.setValue(e,t)},batchGet:async e=>e.map(e=>Ei.getValue(e))};var Ni;!function(e){e[e.ErrorOnly=0]="ErrorOnly",e[e.NotFine=1]="NotFine",e[e.Imperfect=2]="Imperfect"}(Ni||(Ni={}));const Ii=async(e,t,s,i,n=Ni.NotFine,r=0,a)=>{const o=e.filter(({evaluation:e})=>!e||((e,t)=>{switch(t){case Ni.ErrorOnly:return e.error;case Ni.Imperfect:return!e.perfect}return!e.fine})(e,n));s?.write(".".repeat(o.length)),s?.write("\b".repeat(o.length));const c=o.length;let l=0;for(const e of o){const s=e.current.deepCopy();s.staffGroups=e.current.staffGroups;const n=await Ts(s,{picker:e.picker,...i});s.applySolution(n);const o=qe(s),u=!e.evaluation||o.fine>e.evaluation.fine||o.qualityScore>e.evaluation.qualityScore&&o.fine===e.evaluation.fine;u&&(e.evaluation=o,Object.assign(e.current,s)),t(e.current,o,u),l++,a?.(e.current,o,u,{pass:r,remaining:c-l,total:c})}return o.length&&s?.write("\n"),o.length};globalThis.btoa=globalThis.btoa||(e=>Buffer.from(e,"binary").toString("base64"));const Ci=parseInt(process.env.RECTIFICATION_SEARCH_ITERATIONS||"30"),Oi=parseInt(process.env.BASE_QUOTA_FACTOR||"40"),Bi=parseInt(process.env.RECTIFICATION_QUOTA_FACTOR||"80"),_i=(e,t,s)=>Math.min(Math.ceil((e+1)*t*Math.log(e+2)),Math.ceil(s*Math.min(1,(24/(e+1))**2)));async function Ri(e,{solver:t,quotaMax:s=1e3,quotaFactor:i=Oi,solutionStore:n=Ai,ignoreCache:r=!1,logger:a}={}){let o=0,c=0;return a?.info(`[solveMeasures] begin, measure total: ${e.length}.`),await Promise.all(e.map(async l=>{if(!r){const e=await n.get(l.regulationHash);if(e)return l.applySolution(e),void++o}const u=_i(l.events.length,i,s);await l.regulate({policy:"equations",quota:u,solver:t});const h=qe(l);h.error||n.set(l.regulationHash0,{...l.asSolution(),priority:-l?.solutionStat?.loss}),h.perfect&&++c,a?.info(`[solveMeasures] measure[${l.measureIndex}/${e.length}] regulated: ${h.perfect?"solved":h.error?"error":"issue"}, ${l.regulationHash}`)})),a?.info(`[solveMeasures] ${o}/${e.length} cache hit, ${c} solved.`),{cached:o,computed:e.length-o,solved:c}}const Fi=async(e,{solver:t,quotaMax:s=4e3})=>{let i=qe(e),n=e.asSolution();const r=_i(e.events.length,Bi,s);let a=0;for(const s of function*(e){const t=new Set,s=MeasureRectification.default(e.events);t.add(s.toString()),yield s;let i=0,n=e.events;for(;i<100;){i&&i%10==0&&(n=n.map(Mi));const e=MeasureRectification.roll(n),s=e.toString();t.has(s)?++i:(i=0,t.add(s),yield e)}}(e)){const o=await Re.regulateMeasureWithRectification(e,s,{solver:t,quota:r}),c=e.deepCopy();c.applySolution(o);const l=qe(c);if((l.perfect>i.perfect||l.error=i.perfect&&o.priority>n.priority)&&(i=l,n=o),l.perfect)break;if(++a,a>Ci)break}return n};const Pi=async(e,{solver:t,solutionStore:s=Ai,logger:i,quotaMax:n=240,quotaFactor:r=16})=>{e.assemble();const a=e.spartito||e.makeSpartito(),o=a.measures.filter(e=>!e.regulated);await Ri(o,{solver:t,quotaMax:n,quotaFactor:r,solutionStore:s,logger:i}),console.assert(e.spartito?.regulated,"doSimpleRegulate: regulation incomplete:",a.measures.filter(e=>!e.regulated).length)};console.info("%cstarry-omr%c v1.0.0 2026-07-24T11:51:51.947Z","color:#fff; background-color: #555;padding: 5px;border-radius: 3px 0 0 3px;","color: #fff; background-color: #007dc6;padding: 5px;border-radius: 0 3px 3px 0;"),exports.DefaultSolutionStore=Ai,exports.PyClients=class PyClients{constructor(e,t=console){this.options=e,this.logger=t,this.clients=new Map}async getClient(e){if(this.clients.has(e))return this.clients.get(e);const[t,s,i]=Us(),n=this.options[e];if(!n)throw new Error(`no config for client \`${e}\` found`);try{if("string"==typeof n){const e=new ZeroClient;e.bind(n),s(e)}else{const{scriptPath:e,...t}=n,i=new PyProcessor(e,t,this.logger);await i.bind(`${await Xs()}`),s(i)}this.logger.info(`PyClients: ${e} started`)}catch(t){this.logger.error(`PyClients: ${e} start fail: ${JSON.stringify(t)}`),i(t)}return this.clients.set(e,t),t}async checkHost(e){return(await this.getClient(e)).request("checkHost")}async warmup(){const e=Object.keys(this.options);await Promise.all(e.map(e=>this.getClient(e)))}async predictScoreImages(e,...t){const s=e.split("$")[0],i=await this.getClient(s);let n=null;this.logger.info(`[predictor]: ${e} py start..`);const r=Date.now();switch(e){case"layout":n=await i.request("predictDetection",t);break;case"layout$reinforce":n=await i.request("predictReinforce",t);break;case"gauge":case"mask":n=await i.request("predict",t,{by_buffer:!0});break;case"semantic":case"textLoc":n=await i.request("predict",t);break;case"textOcr":case"brackets":case"topo":case"gaugeRenderer":case"jianpu":n=await i.request("predict",...t);break;default:this.logger.error(`[predictor]: no predictor ${e}`)}return this.logger.info(`[predictor]: ${e} py duration: ${Date.now()-r}ms`),n}},exports.abstractOMRStats=e=>{const{costTotal:t,pagesCostTotal:s,pagesTotal:i}=e.reduce((e,t)=>({costTotal:e.costTotal+t.cost,pagesCostTotal:e.pagesCostTotal+t.pagesCost,pagesTotal:e.pagesTotal+t.pages}),{costTotal:0,pagesCostTotal:0,pagesTotal:0});return{costTotal:t,costPerPage:i?t/i:null,pagesTotal:i,scoreN:e.length}},exports.abstractRegulationBeadStats=e=>{const{totalCost:t,pickerCost:s,measureN:i,timeN:n}=e.reduce((e,t)=>({totalCost:e.totalCost+t.totalCost,pickerCost:e.pickerCost+t.pickerCost,measureN:e.measureN+t.measures.computed,timeN:e.timeN+t.measures.tryTimes}),{totalCost:0,pickerCost:0,measureN:0,timeN:0}),r=i>0?t/i:null,a=n>0?t/n:null,{cached:o,simple:c,computed:l,tryTimes:u,solved:h,issue:m,fatal:d}=e.reduce((e,t)=>({cached:e.cached+t.measures.cached,simple:e.simple+t.measures.simple,computed:e.computed+t.measures.computed,tryTimes:e.tryTimes+t.measures.tryTimes,solved:e.solved+t.measures.solved,issue:e.issue+t.measures.issue,fatal:e.fatal+t.measures.fatal}),{cached:0,simple:0,computed:0,tryTimes:0,solved:0,issue:0,fatal:0});return{scoreN:e.length,totalCost:t,pickerCost:s,costPerMeasure:r,costPerTime:a,cached:o,simple:c,computed:l,tryTimes:u,solved:h,issue:m,fatal:d}},exports.abstractRegulationStats=e=>{const{baseCostTotal:t,topoCostTotal:s,baseMeasures:i,topoMeasures:n}=e.reduce((e,t)=>({baseCostTotal:e.baseCostTotal+t.baseCost,topoCostTotal:e.topoCostTotal+t.topoCost,baseMeasures:e.baseMeasures+t.baseMeasures.computed,topoMeasures:e.topoMeasures+(t.topoMeasures.solved+t.topoMeasures.issue+t.topoMeasures.fatal)}),{baseCostTotal:0,topoCostTotal:0,baseMeasures:0,topoMeasures:0}),r=i>0?t/i:null,a=n>0?s/n:null,{cached:o,baseComputed:c,baseSolved:l,topoSolved:u,topoIssue:h,topoFatal:m}=e.reduce((e,t)=>({cached:e.cached+t.baseMeasures.cached,baseComputed:e.baseComputed+t.baseMeasures.computed,baseSolved:e.baseSolved+t.baseMeasures.solved,topoSolved:e.topoSolved+t.topoMeasures.solved,topoIssue:e.topoIssue+t.topoMeasures.issue,topoFatal:e.topoFatal+t.topoMeasures.fatal}),{cached:0,baseComputed:0,baseSolved:0,topoSolved:0,topoIssue:0,topoFatal:0});return{scoreN:e.length,baseCostTotal:t,topoCostTotal:s,baseCostPerMeasure:r,topoCostPerMeasure:a,cached:o,baseComputed:c,baseSolved:l,topoSolved:u,topoIssue:h,topoFatal:m}},exports.constructSystem=ai,exports.convertImage=oi,exports.doRegulate=async(e,{pyClients:t,solver:s,solutionStore:i=Ai,onSaveIssueMeasure:n})=>{t?.logger?.info(`[doRegulate] score: ${e.title}`),e.spartito=void 0,e.assemble();const r=e.makeSpartito();r.measures.forEach(t=>e.assignBackgroundForMeasure(t));const a=Date.now(),o=await Ri(r.measures,{solver:s,quotaMax:1e3,solutionStore:i,logger:t?.logger}),c=Date.now(),l=t?await async function(e,{pyClients:t,solver:s,solutionStore:i=Ai,onSaveIssueMeasure:n}){t.logger.info(`[RegulateWithTopo] regulate score: ${e.title}, measures: ${e.spartito.measures.length}`);const r=e.spartito.measures.filter(e=>!qe(e).perfect);if(t.logger.info(`[RegulateWithTopo] basic issues: ${r.length}`),0===r.length)return{solved:0,issue:0,fatal:0};const a=[].concat(...r.map(e=>e.createClusters())),o=await t.predictScoreImages("topo",{clusters:a});console.assert(o.length===a.length,"prediction number mismatch:",a.length,o.length),a.forEach((e,t)=>{const s=o[t];console.assert(s,"no result for cluster:",e.index),e.assignPrediction(s)}),r.forEach(e=>{const t=a.filter(t=>t.index===e.measureIndex);e.applyClusters(t);const{matrixH:s}=Re.estiamteMeasure(e);s.forEach((t,s)=>t.forEach((t,i)=>{e.matrixH[s][i]=.9*e.matrixH[s][i]+t*(1-.9)}))});const c=[],l=[];await Promise.all(r.map(async e=>{const r=e.regulationHash0,a=await Fi(e,{solver:s});a&&(e.applySolution(a),i.set(r,a),i.set(e.regulationHash,e.asSolution()),t.logger.info(`[RegulateWithTopo] solutionStore set: ${e.measureIndex}, ${r}, ${e.regulationHash}`));const o=qe(e);n?.({measureIndex:e.measureIndex,measure:new EditableMeasure(e),status:o.error?2:1}),o.perfect?c.push(e.measureIndex):o.error&&l.push(e.measureIndex)}));const u=r.length-c.length-l.length;return t.logger.info(`[RegulateWithTopo] score: ${e.title}, solved/issue/fatal: ${c.length}/${u}/${l.length}`),c.length&&t.logger.info(`[RegulateWithTopo] solved measures: ${c.join(", ")}`),l.length&&t.logger.info(`[RegulateWithTopo] error measures: ${l.join(", ")}`),{solved:c.length,issue:u,fatal:l.length}}(e,{pyClients:t,solver:s,solutionStore:i,onSaveIssueMeasure:n}):void 0;return{baseCost:c-a,topoCost:Date.now()-c,baseMeasures:o,topoMeasures:l,qualityScore:r.qualityScore}},exports.doSimpleRegulate=Pi,exports.encodeFindResource=function(e){const t=e.spartito.perform(),s=e.systems.map(e=>e.staves.map(e=>e?.maskImage)).flat(),i=s.filter(Boolean).length>s.length/2,n={},r=new Map,a=new Map,o=new Map;n.unitSize=e.unitSize,n.title={title:e.title};const c=e.pages[0].tokens;if(Array.isArray(c)&&c.length>0){const[t,...s]=c.filter(e=>e.type===Z.Text&&"Title"===e.textType).sort((e,t)=>t.fontSize-e.fontSize);t&&(n.title.title=t.text,n.title.t={size:t.fontSize}),s?.length>0&&(s.sort((e,t)=>e.y-t.y),n.title.subtitle=s.map(e=>e.text).join("\n"),n.title.s={size:s.reduce((e,t)=>e+t.fontSize,0)/s.length});const i=c.filter(t=>t.type===Z.Text&&"Author"===t.textType&&t.x>e.pages[0].width/2);i.length>0&&(n.title.composer=i.map(e=>e.text).join("\n"),n.title.c={size:i.reduce((e,t)=>e+t.fontSize,0)/i.length})}if(n.page={w:e.pages[0].width,h:e.pages[0].height},n.pages=e.pages.map(t=>{const s=t.source.dimensions.width/t.source.interval,i=t.source.dimensions.height/t.source.interval,[n,r,a,o]=t.source.matrix;return{src:t.source.url,w:s,h:i,x:0,y:0,l1:e.systems.indexOf(t.systems[0]),ls:t.systems.length,matrix:[n,r,a,o,-.5*n*s+-.5*i*a+.5*t.width||0,-.5*r*s+-.5*i*o+.5*t.height||0]}}),n.parts=[],n.lines=[],i){const t=e.staffLayout.partGroups.map(e=>e.range[0]===e.range[1]?[e.range[0]]:e.range),s=e.getTokenMap(),i=[];for(const[c,l]of t.entries()){const u=t.slice(0,c).flat().length,h={measures:[]};e.systems.forEach((n,m)=>{const d=n.staves.slice(),f=t.flat().map(e=>1<m+1&&(p[m+1]=p[m]);continue}const g=[];for(const e of l){const t=f[e];t&&g.push(...t.measures[m].getChords().map(t=>({chord:t,staffIndexInPart:e-u})))}let y=0;const v=p[m],x=[];g.forEach(({staffIndexInPart:l,chord:u})=>{const h=[];let f=u.tip?u.tip.x:u.right-u.left/2;u.noteIds.forEach((e,i)=>{const n=s.get(e),m=`n_${t.length>1?c+"_":""}${d}_${y}`;y++,r.set(n.id,m),a.set(n.id,(n.left+n.right)/2-v),o.set(n.id,l+1),h.push({line:2*-u.ys[i],id:m,staff:l+1,x:(n.left+n.right)/2-f})}),i[d]=i[d]||[],i[d].push(f-v);const p=e.spartito.measures[n.headMeasureIndex+m].events.filter(e=>e.noteIds.some(e=>u.noteIds.includes(e)));x.push({elems:h,x:f-v,type:2**u.division,...p.some(e=>e.grace)?{grace:{}}:{}})}),h.measures[d]={w:p[m+1]-p[m],staves:l.length,notes:x}}});let m=null;e.spartito.measures.forEach((s,i)=>{const n=e.spartito.measureIndexMapping[i],r=s.contexts.flat().filter(e=>Ns.includes(e.tokenType)&&l.includes(e.staff)).map(e=>{const s=t.find(t=>t.includes(e.staff));return{x:e.x,clef:Is(e),staff:s.indexOf(e.staff)+1,tick:e.tick}});r.length>0&&h.measures[n]&&(h.measures[n].clefs=r);const a=s.basics.filter((e,t)=>1<0&&(n.parts[c]=h)}e.systems.forEach((s,i)=>{const r=[],a=s.staves[0],o=s.staves[s.staves.length-1],c=a.top+a.staffY-2,l=o.top+o.staffY-2,u=s.staves.slice(),h=t.flat().map(e=>!(1<h.find(t=>t?.index===e)||null),a=t.map((e,t)=>[t,!e]).filter(e=>e[1]);let o=null;a.length>0&&(o=Object.fromEntries(a.map(e=>[e[0]+1,{hide:e[1]}])));let l=0,u=0;const d=t.filter(e=>!!e);if(d.length>0){const e=d[0],t=d[d.length-1],s=e.top+e.staffY-2,i=t.top+t.staffY-2;l=s-c,u=i-s+4}const{list:f,last:p}=t.reduce((e,t,s)=>(null===e.last||null===t?0===s&&l>0?e.list.push(l-4):e.list.push(0):e.list.push(t.top+t.staffY-(e.last.top+e.last.staffY)-4),e.last=t||e.last,e),{last:m,list:[]});m=p;const g=t.map(e=>{if(e?.maskImage){const t=e.imagePosition;return{src:e.maskImage,x:t.x,y:s.top+e.top+t.y-(s.top+e.top+e.staffY-2),w:t.width,h:t.height}}return null}),y=e.spartito.measures[s.headMeasureIndex];r.push({distances:f,imgs:g,y:l,staves:n.length,parti:i,height:u,...o?{details:o}:{},clef:Object.fromEntries(e.spartito.measures[s.headMeasureIndex]?.contexts.flat().filter(e=>Ns.includes(e.tokenType)&&n.includes(e.staff)).map(e=>[e.staff,Is(e)])),fifths:y.basics.filter((e,t)=>1<e.spartito.measureIndexMapping[s.headMeasureIndex+i]).filter(e=>Number.isFinite(e));n.lines[i]={m1:d[0],m2:d.length>0?d[d.length-1]+1:void 0,x:s.left,y:s.top+c,w:s.measureBars[s.measureBars.length-1],h:l-c+4,lineStaves:r}});const c={0:"default",1:"brace",2:"bracket",3:"square"},l=it(e.staffLayoutCode),u=l.partGroups.map(e=>({sort:e.range[0],part:e})).sort((e,t)=>e.sort-t.sort).map(e=>e.part);n.groups=l.groups.filter(e=>0!==e.group.type).map((e,t)=>({type:c[e.group.type],p1:u.findIndex(t=>t.range.includes(e.range[0])),p2:u.findIndex(t=>t.range.includes(e.range[e.range.length-1]))})).filter(e=>"default"!==e.type)}let l;if(t&&(n.measInfo=t.notation.measures.map((e,t)=>{const s=new Map;return e.notes.forEach(e=>{s.set(e.tick,[...s.get(e.tick)||[],a.get(e.id)])}),Array.from(s.entries()).sort((e,t)=>+e[0]-t[0]).reduce((e,t,s)=>{const i=t[1].find(t=>t>e.last)||t[1][0];return e.list.push(i),e.last=i,e},{last:null,list:[]}).list.filter(Number.isFinite)})),t){l={};const s=new Map;let i,n;t.notation.measures.forEach((e,t)=>{const{numerator:s,denominator:r}=e.timeSignature;l.beats||l.beatsUnit||(l.beats=s,l.beatsUnit=r,i=s,n=r),l.beatInfos=l.beatInfos||[],i===s&&n===r||(i=s,n=r,l.beatInfos.push({tick:e.tick,beats:s,beatsUnit:r})),l.tempos=l.tempos||[],e.events.forEach(t=>{"meta"===t.data.type&&"setTempo"===t.data.subtype&&l.tempos.push({tick:e.tick,tempo:t.data.microsecondsPerBeat})})}),l.measures=t.notation.measures.reduce((e,t,i)=>{const n=Array.from(new Set(t.notes.map(e=>e.tick))).sort((e,t)=>e-t);return t.notes.forEach(e=>{s.set(e.id,n.indexOf(e.tick))}),e[t.tick]={measure:i,duration:t.duration,note_ticks:n},e},{}),l.measureInfos=t.notation.measures.map((e,t)=>({number:String(t+1),fifths:e.keySignature,beats:e.timeSignature.numerator,beatUnit:e.timeSignature.denominator}));const a=t.notation.toPerformingMIDI(t.notation.measures.map((e,t)=>t+1)).tracks,{partGroups:c}=e.staffLayout;let u=a.map((t,s)=>{const i=c[s].key;let n;switch(i){case"vi":case"vi1":case"vi2":n=40;break;case"viola":n=42;break;case"vo":n=55;break;case"basso":n=71;break;default:n=0}return{program:n,channel:s,name:e.instrumentDict[i]??"Piano",track:t}});if(c.some(e=>e.group.grand)){const t=/l\.?h\.?|左手|left hand/i,s=/r\.?h\.?|右手|right hand/i,i=Object.entries(e.instrumentDict).filter(([e,i])=>t.test(i)||s.test(i)).map(([e,s])=>({key:e,hand:t.test(s)?"left":"right"}));let n,r=null;if(2===i.length&&i[0].hand!==i[1].hand){const t=i.find(e=>"left"===e.hand),s=i.find(e=>"right"===e.hand);r=[e.staffLayout.staffIds.findIndex(e=>e===s?.key),e.staffLayout.staffIds.findIndex(e=>e===t?.key)],n=c.findIndex(e=>e.range[0]<=Math.min(...r)&&e.range[1]>=Math.max(...r))}if(Number.isFinite(n)&&n>-1){const e=u[n],t=[];e.track.forEach(e=>{Number.isFinite(e.staff)&&(t[e.staff]||(t[e.staff]=[]),t[e.staff].push(e)),"meta"===e.type&&t.forEach(t=>{t.push(e)})}),u.splice(n,1,t.filter(Boolean).map(t=>({...e,track:t}))),u=u.flat(),l.rightHandTrack=r[0],l.leftHandTrack=r[1]}else u.sort((e,t)=>e===u[n]?-1:0)}l.tracks=u.map(({program:e,channel:t,name:s})=>({program:e,channel:t,name:s}));const h=u.map(({track:e})=>{const t=new Map;return e.map(e=>{if("noteOn"===e.subtype&&t.set(e.noteNumber,e),"noteOff"===e.subtype){const s=t.get(e.noteNumber);s?.noteNumber===e.noteNumber&&(s.duration=e.ticks-s.ticks)}return e})}),m=new Map(Object.entries(l.measures).map(([e,t])=>[t.measure,+e]));l.events=h.map((e,t)=>e.filter(e=>"channel"===e.type).map(e=>{e?.ids?.[0]&&(e.numId=r.get(e.ids[0]));let i=[0,0,0];switch(e.subtype){case"noteOn":i=[144|e.channel,e.noteNumber,e.velocity];break;case"noteOff":i=[128|e.channel,e.noteNumber,e.velocity?e.velocity:0];break;case"noteAftertouch":i=[160|e.channel,e.noteNumber,e.amount];break;case"controller":i=[176|e.channel,e.controllerType,e.value];break;case"programChange":i=[192|e.channel,e.programNumber,0];break;case"channelAftertouch":i=[208|e.channel,e.amount,0];break;case"pitchBend":i=[224|e.channel,255&e.value,e.value>>7&255];break;default:throw new Error("unhandled event subtype:"+e.subtype)}return{..."noteOn"===e.subtype?{id:r.get(e?.ids?.[0])}:{},tick:e.ticks,channel:e.channel,duration:e.duration,track:t,event:i,elem_ids:e?.ids.map(e=>r.get(e)),measure:e.measure-1,meas_start_tick:m.get(e.measure-1),staff:o.get(e.ids[0]),note:s.get(e.ids[0])}})).flat(1).sort((e,t)=>{for(const s of["tick","measure","track"])if(e[s]!==t[s])return e[s]-t[s];return 0})}return{scoreJson:n,midiJson:l}},exports.evaluateScoreQuality=async(e,t)=>(e.spartito?.regulated||await Pi(e,t),e.spartito.regulated?e.spartito.qualityScore:null),exports.getScoreJsonImages=e=>[...e.pages.map(e=>e?.src),...e.lines.map(e=>e.lineStaves.map(e=>e.imgs)).flat(2).map(e=>e?.src).filter(Boolean)],exports.predictPages=async(e,t,s={outputWidth:1200,pageStore:ki,onReplaceImage:bi})=>{const i=e.logger;s.outputWidth=s.outputWidth||1200,s.pageStore=s.pageStore||ki,s.onReplaceImage=s.onReplaceImage||bi,s.processes=Array.isArray(s.processes)&&s.processes.length>0?s.processes:["layout","text","gauge","mask","semantic","brackets"];const n=new OMRProgress(s.onProgress),r=Date.now();t.forEach(e=>{e.layout?.detection?e.layout.detection.areas=e.layout.detection?.areas?.filter(e=>e?.staves?.middleRhos?.length>0):delete e.layout});const a=new Score({title:s?.title,stavesCount:2,paperOptions:{raggedLast:!0,raggedLastBottom:!0},headers:{},instrumentDict:{},settings:{enabledGauge:s.processes.includes("gauge"),semanticConfidenceThreshold:1}});i.info(`[predictor]: download_source_images-${t.length}`);const o=await Promise.all(t.map(e=>c.loadImage(e.url)));i.info(`[predictor]: source_images_downloaded-${t.length}`);const l=o.map((e,s)=>function(e,t){let s=e.height/e.width*t;const i=new c.Canvas(t,s);return i.getContext("2d").drawImage(e,0,0,t,t*e.height/e.width),i}(e,t[s].layout?.sourceSize?.width??e.width));n.setTotal("layout",o.length),n.setTotal("text",o.length);const u=await Promise.all(l.map(async(s,i)=>t[i].layout?!t[i].enableGauge&&t[i]?.layout?.detection?.areas?.length?(await e.predictScoreImages("layout$reinforce",[s.toBufferSync("png")],[t[i].layout]))?.[0]:t[i].layout:(await e.predictScoreImages("layout",[s.toBufferSync("png")]))?.[0]));u.forEach(e=>{e.detection.areas=e.detection?.areas?.filter(e=>e?.staves?.middleRhos?.length>0)});const h=new Map,m=async e=>{const t=await s.onReplaceImage(e);h.set(e,t)};async function d(e,i){const{url:r,key:o,layout:u,enableGauge:h}=t[i],m=ri(JSON.stringify({key:o||r,layout:u,enableGauge:h})),d=await s.pageStore.get(m),f=!s.renew&&(d&&!t[i].renew||!e.detection.areas?.length),p=a.pages[i]=f&&d?S(d,As):new Page({source:{name:o||("string"==typeof r&&/https?:\/\//.test(r)?r:null),size:0,url:r,crop:{unit:"%",x:0,y:0,width:100,height:100},dimensions:e.sourceSize,matrix:[Math.cos(e.theta),-Math.sin(e.theta),Math.sin(e.theta),Math.cos(e.theta),0,0],interval:e.interval,needGauge:t[i].enableGauge},layout:e.detection}),g=f?null:await async function({page:e,score:t,pageCanvas:s}){if(!e?.layout?.areas?.length)return null;e.width=t.pageSize.width/t.unitSize,e.height=t.pageSize.height/t.unitSize;const i=new c.Canvas(s.width,s.height),n=i.getContext("2d");n.save();const{width:r,height:a}=i,[o,l,u,h]=e.source.matrix;n.setTransform(o,l,u,h,-.5*r+.5*o*r+.5*l*a,-.5*a+.5*u*r+.5*h*a),n.drawImage(s,0,0),n.restore();const m=e.source.interval;return e.layout.areas.map((t,i)=>{console.assert(t.staves?.middleRhos?.length,"[shootImageByDetection] empty area:",t);const r=n.getImageData(t.x,t.y,t.width,t.height),a=new c.Canvas(t.width,t.height);a.getContext("2d").putImageData(r,0,0);const o=t.staves,l={width:t.width,height:t.height},u=s.width/2/m,h=s.height/2/m,d={x:(t.x+t.staves.phi1)/m-u+e.width/2,y:t.y/m-h+e.height/2};e.systems[i]=ai({page:e,backgroundImage:a.toBufferSync("png"),detection:o,imageSize:l,position:d})}),i}({score:a,page:p,pageCanvas:l[i]});return n.increase("layout"),{page:p,omit:f,hash:m,correctCanvas:g}}!function(e,t,s){const i=t.filter(e=>e&&e.detection&&e.detection.areas?.length).map((e,t)=>{const s=Math.min(...e.detection.areas.filter(e=>e.staves?.middleRhos?.length).map(e=>e.staves.interval)),i=e.sourceSize;return{...e,index:t,vw:i.width/s,hwr:i.height/i.width}});if(!i.length)throw new Error("empty result");const n=i.sort((e,t)=>t.vw-e.vw)[0],r=Math.max(...i.map(e=>e.hwr));e.unitSize=s/n.vw,e.pageSize={width:s,height:s*r}}(a,u,s.outputWidth);const f=u.reduce((e,t)=>e+(t.detection.areas?.length??0),0),p=u.reduce((e,t)=>e+(t.detection.areas?.reduce?.((e,t)=>e+(t.staves?.middleRhos?.length??0),0)??0),0);n.setTotal("gauge",p),n.setTotal("mask",p),n.setTotal("semantic",p),n.setTotal("brackets",f);const g=[],y=[],v=Date.now();let x=0;for(const r of u.keys()){const o=[],{page:l,correctCanvas:f,omit:p,hash:v}=await d(u[r],r);if(o.push(m(l.source.url)),o.push(...l.systems.map(e=>m(e.backgroundImage))),i.info(`[predictor]: check_cache_pageIndex-${r} omit: ${p}`),p)y.push(r);else{const u=l.systems.map((e,t)=>e.staves.map((s,i)=>({pageIndex:r,systemIndex:t,staffIndex:i,page:l,system:e,staff:s}))).flat(1);await di([async()=>{if(!s.processes.includes("brackets"))return;const t=l.layout,a=l.source.interval,o=Date.now(),u=l.systems.map((e,s)=>{const{x:i,y:n,staves:{middleRhos:r,phi1:o}}=t.areas[s],l=r[0],u=r[r.length-1],h={x:i+o-4*a,y:n+l-4*a,width:8*a,height:u-l+8*a},m=new c.Canvas(64,h.height/a*8);return m.getContext("2d").drawImage(f,h.x,h.y,h.width,h.height,0,0,m.width,m.height),{system:e,buffer:m.toBufferSync("png")}});i.info(`[predictor]: brackets js [pageIndex-${r}] duration: ${Date.now()-o}`);const h=await e.predictScoreImages("brackets",{buffers:u.map(e=>e.buffer)});n.increase("brackets",u.length),u.forEach(({system:e},t)=>{h[t]&&(e.bracketsAppearance=h[t])})},async()=>{if(s.processes.includes("text"))try{const t=Date.now(),o=f.toBufferSync("png"),c=(await e.predictScoreImages("textLoc",[o]))[0].filter(e=>e.score>0);if(c.length>0){const[t]=await e.predictScoreImages("textOcr",{buffers:[o],location:c});l.assignTexts(t.areas,t.imageSize),l.assemble()}if(i.info(`[predictor]: text js [pageIndex-${r}] duration: ${Date.now()-t}`),n.increase("text"),!s.title){const e=a.pages[0].tokens;if(Array.isArray(e)&&e.length>0){const[t]=e.filter(e=>e.type===Z.Text&&"Title"===e.textType).sort((e,t)=>t.fontSize-e.fontSize);t&&(a.title=t.text)}}}catch(e){i.error(`[predictor]: text js [pageIndex-${r}] ${JSON.stringify(e)}`)}},async()=>{var c;await(c=async()=>{if(s.processes.includes("gauge")&&!1!==t[r].enableGauge){const t=await e.predictScoreImages("gauge",await Promise.all(u.map(async({staffIndex:e,system:t})=>{const s=Date.now(),n=await fi(t,e,{paddingLeft:ci,spec:li});return i.info(`[predictor]: gauge js shoot [page-${r}, staff-${e}] duration: ${Date.now()-s}`),n.toBufferSync("png")})));for(const[s,{system:r,staff:a,pageIndex:c,staffIndex:l}]of u.entries()){const u=Date.now();i.info(`[predictor]: gauge js [page-${c}, staff-${l}] start..`),await gi({pyClients:e,system:r,staff:a,staffIndex:l,gaugeImage:t[s].image}),i.info(`[predictor]: gauge js [page-${c}, staff-${l}] duration: ${Date.now()-u}`),n.increase("gauge"),o.push(m(a.backgroundImage))}}else for(const[e,{system:t,staff:s,staffIndex:i}]of u.entries())await pi({system:t,staff:s,staffIndex:i}),o.push(m(s.backgroundImage))},c()),await di([async()=>{if(!s.processes.includes("mask"))return;const t=await e.predictScoreImages("mask",u.map(({staff:e})=>e.backgroundImage));for(const[e,{staff:s,staffIndex:a}]of u.entries()){const c=Date.now();await yi({staff:s,staffIndex:a,maskImage:t[e].image}),i.info(`[predictor]: mask js [page-${r}, ${e}, staff-${a}] duration: ${Date.now()-c}`),n.increase("mask"),o.push(m(s.maskImage))}},async()=>{if(!s.processes.includes("semantic"))return;const t=S(await e.predictScoreImages("semantic",u.map(({staff:e})=>e.backgroundImage)),As);u.forEach(({system:e})=>e.clearTokens());for(const[e,{staffIndex:s,system:o,staff:c}]of u.entries()){const l=Date.now();await vi({score:a,system:o,staff:c,staffIndex:s,graph:t[e]}),i.info(`[predictor]: semantic js [page-${r}, system-${o.index}, staff-${c.index}] duration: ${Date.now()-l}`),n.increase("semantic")}}])}]),++x}g.push(Promise.all(o).then(()=>(xi(l,e=>h.get(e)),i.info(`[predictor]: pageStore set: [${r}]`),s.pageStore.set(v,JSON.stringify(l)))))}const k=Date.now();await Promise.all(g),i.info(`[predictor]: inferenceStaffLayout: ${a.title}, [${a.systems.length}]`),a.inferenceStaffLayout(),i.info(`[predictor]: done: ${a.title}`),a.assemble();const b=Date.now();return{score:a,omitPages:y,stat:{cost:b-r,pagesCost:k-v,pages:x}}},exports.regulateWithBeadSolver=async(e,{logger:t,pickers:s,solutionStore:i=Ai,ignoreCache:n,freshOnly:r,onSaveIssueMeasure:a,onProgress:o,onPassStart:c})=>{e.spartito=void 0,e.assemble();const l=e.makeSpartito();l.measures.forEach(t=>e.assignBackgroundForMeasure(t));const u=Date.now();t?.info(`[regulateWithBeadSolver] begin, measure total: ${l.measures.length}.`,n?"ignoreCache":"",r?"freshOnly":"");const h=l.measures.filter(e=>e.events?.length&&!e.patched).map(e=>({origin:e.deepCopy(),current:e,evaluation:void 0,baseQuality:0}));for(const e of l.measures.filter(e=>e.events?.length)){const t=s.find(t=>t.n_seq>e.events.length+1);t&&await Ms(e,t)}l.rectifyTimeSignatures(t),s.forEach(e=>e.cost=0);const m={cached:0,simple:0,computed:0,tryTimes:0,solved:0,issue:0,fatal:0};if(t?.info("[regulateWithBeadSolver] measures estimation finished."),i&&!n)for(const e of h){const t=await i.get(e.origin.regulationHash0);t&&(e.current.applySolution(t),++m.cached,e.evaluation=qe(e.current),e.baseQuality=e.evaluation.qualityScore)}t?.info("[regulateWithBeadSolver]",`${m.cached}/${h.length}`,"solutions loaded.");const d=t?null:process.stdout;m.cached&&d?.write(`${m.cached}c`),h.forEach(e=>{const i=s.find(t=>t.n_seq>e.current.events.length+1);i?e.picker=i:t?.info(`[regulateWithBeadSolver] measure[${e.current.measureIndex}] size out of range:`,e.current.events.length)});const f=h.filter(e=>e.picker&&(!e.evaluation||!e.evaluation.fine&&!r));f.forEach(e=>{const s=e.current.deepCopy();s.staffGroups=e.current.staffGroups,s.regulate({policy:"simple"});const i=qe(s);(!e.evaluation||i.qualityScore>e.evaluation.qualityScore)&&(e.evaluation=i,Object.assign(e.current,s),i.perfect&&(t?.info(`[regulateWithBeadSolver] measure[${e.current.measureIndex}] regulated by simple policy.`),++m.simple))}),m.computed=f.length-m.simple,m.simple&&d?.write(`${m.simple}s`);const p=(e,s,i)=>{t?.info(`[regulateWithBeadSolver] measure[${e.measureIndex}/${l.measures.length}] regulated${i?"+":"-"}: ${s.qualityScore.toFixed(3)}, ${s.fine?"solved":s.error?"error":"issue"}, ${e.regulationHash}`),d?.write(`[${s.fine?"32":s.error?"31":"33"}m${i?"+":"-"}`)},g=l.measures.length,y=()=>f.filter(e=>!e.evaluation?.fine).length,v=o?(e,t,s,i)=>{o(e,t,s,{pass:i.pass,remaining:y(),total:g})}:void 0;c?.(1,"Imperfect",y()),m.tryTimes+=await Ii(f,p,d,{stopLoss:.05,quotaMax:200,quotaFactor:3,ptFactor:1},Ni.Imperfect,1,v),c?.(2,"NotFine",y()),m.tryTimes+=await Ii(f,p,d,{stopLoss:.08,quotaMax:1e3,quotaFactor:20,ptFactor:1.6},Ni.NotFine,2,v),c?.(3,"ErrorOnly",y()),m.tryTimes+=await Ii(f,p,d,{stopLoss:.08,quotaMax:1e3,quotaFactor:40,ptFactor:3},Ni.ErrorOnly,3,v),f.forEach(({evaluation:e,baseQuality:t,current:s,origin:n})=>{e.fine?++m.solved:e.error?++m.fatal:++m.issue,(e.qualityScore>t||!t)&&(i.set(n.regulationHash0,{...s.asSolution(n),priority:-s?.solutionStat?.loss}),s.regulationHash!==n.regulationHash0&&i.set(s.regulationHash,{...s.asSolution(),priority:-s?.solutionStat?.loss})),e.fine||a?.({measureIndex:s.measureIndex,measure:new EditableMeasure(s),status:e.error?2:1})});const x=Date.now(),S=s.reduce((e,t)=>e+t.cost,0),k=l.qualityScore,b=x-u;return t?.info("[regulateWithBeadSolver] done in ",b,"ms, qualityScore:",k),r&&(m.cached=0),{totalCost:x-u,pickerCost:S,measures:m,qualityScore:k}},exports.replaceScoreJsonImages=(e,t=e=>e)=>{const s=JSON.parse(JSON.stringify(e));return s.pages.forEach(e=>{e?.src&&(e.src=t(e?.src))}),s.lines.forEach(e=>{e.lineStaves.forEach(e=>{e.imgs.forEach(e=>{e?.src&&(e.src=t(e.src))})})}),s},exports.saveEditableMeasures=async(e,t,s,{status:i=2,solutionStore:n}={})=>{e.assemble();const r=e.spartito||e.makeSpartito(),a=t.map(e=>r.measures.find(t=>t.measureIndex===e)).filter(Boolean);if(n){const e=await n.batchGet(a.map(e=>e.regulationHash0));a.forEach((t,s)=>{const i=e[s];i&&t.applySolution(i)})}a.forEach(e=>{s({measureIndex:e.measureIndex,measure:new EditableMeasure(e),status:i})})},exports.starry=As,exports.updateScorePatches=(e,t,s={})=>{if(console.assert(t.every(e=>e.validRegulated),"[updateScorePatches] some measures not valid regulated:",t.filter(e=>!e.validRegulated)),e.patches=t.map(e=>e.createPatch()),s?.solutionStore){e.assemble();const i=e.makeSpartito();t.forEach(e=>{if(s.solutionStore.set(e.regulationHash,{...e.asSolution(),priority:1}),e.regulationHash0!==e.regulationHash){const t=i.measures.find(t=>t.measureIndex===e.measureIndex);s.solutionStore.set(e.regulationHash0,{...e.asSolution(t),priority:1})}})}}; //# sourceMappingURL=index.js.map diff --git a/backend/omr/dist/regulator.d.ts b/backend/omr/dist/regulator.d.ts index a9a7f46f463d785d6755e259b99335dbe8ce1ee9..00434ed038460e5e1d7c529fa4a8b6617c38cd37 100644 --- a/backend/omr/dist/regulator.d.ts +++ b/backend/omr/dist/regulator.d.ts @@ -994,6 +994,7 @@ declare namespace EquationSolver { unitSize: number; measureLayout?: MeasureLayout; staffLayout: StaffLayout; + staffLayoutCode: string; paperOptions?: Partial; headers: Partial; voiceStaves: VoicesStaff[]; @@ -2335,6 +2336,7 @@ declare namespace beadSolver { unitSize: number; measureLayout?: MeasureLayout; staffLayout: StaffLayout; + staffLayoutCode: string; paperOptions?: Partial; headers: Partial; voiceStaves: VoicesStaff[]; @@ -3939,6 +3941,7 @@ declare namespace starry { unitSize: number; measureLayout?: MeasureLayout; staffLayout: StaffLayout; + staffLayoutCode: string; paperOptions?: Partial; headers: Partial; voiceStaves: VoicesStaff[]; diff --git a/backend/omr/dist/regulator.js b/backend/omr/dist/regulator.js index 11643786ecfe5d19386f4e3935df8c4d7353e11b..d9fce14eb29f58766b8b77bf05ea38f5743bcb87 100644 --- a/backend/omr/dist/regulator.js +++ b/backend/omr/dist/regulator.js @@ -1,7 +1,7 @@ /** * name: backend * version: v1.0.0 - * build time: 7/24/2026, 12:03:31 PM + * build time: 7/24/2026, 7:51:51 PM * system user: camus * git user name: k.l.lambda * git user email: k.l.lambda@gmail.com @@ -13541,7 +13541,7 @@ class Score extends SimpleClass { const { lanes: lyricLanes, diagnostics: lyricDiagnostics } = this.makeLyricLanes(voiceStaves); if (lyricLanes.length) console.debug('[makeMusicSheet] lyric lanes:', lyricLanes.length, lyricDiagnostics); - const { title, pageSize, unitSize, staffLayout, paperOptions, headers, instrumentDict } = this; + const { title, pageSize, unitSize, staffLayout, staffLayoutCode, paperOptions, headers, instrumentDict } = this; const measureLayout = this.getMeasureLayout(); return { title, @@ -13549,6 +13549,7 @@ class Score extends SimpleClass { unitSize, measureLayout, staffLayout, + staffLayoutCode, paperOptions, headers, voiceStaves, @@ -13780,14 +13781,17 @@ class Score extends SimpleClass { if (bands.length > maxVerses) maxVerses = bands.length; }); - // build a lane per verse + // Build one lane per verse and target voice. A verse may move between + // regulated voices, so assigning the complete verse to its first voice + // would discard later syllables mapped to another voice during export. for (let verse = 0; verse < maxVerses; verse++) { - const syllables = []; + const byVoice = new Map(); lyrics.forEach((l, idx) => { const map = systemVerseAssignments.get(l.systemIndex); const v = map ? map.get(idx) ?? 0 : 0; if (v !== verse) return; + const syllables = byVoice.get(l.voiceIndex) || []; syllables.push({ text: l.text, sid: l.sid, @@ -13799,12 +13803,12 @@ class Score extends SimpleClass { verse, source: { pageIndex: l.pageIndex, systemIndex: l.systemIndex, x: l.x, y: l.y }, }); + byVoice.set(l.voiceIndex, syllables); + }); + byVoice.forEach((syllables, voiceIndex) => { + syllables.sort((a, b) => a.measureIndex - b.measureIndex || a.tick - b.tick); + lanes.push({ staffIndex, voiceIndex, verse, syllables }); }); - if (!syllables.length) - continue; - // monotonic ordering by measureIndex then tick - syllables.sort((a, b) => a.measureIndex - b.measureIndex || a.tick - b.tick); - lanes.push({ staffIndex, voiceIndex: verse === 0 ? lyrics[0].voiceIndex : lyrics[0].voiceIndex, verse, syllables }); } }); // detect duplicate event assignments and out-of-order within each lane @@ -15350,7 +15354,7 @@ const saveEditableMeasures = async (score, measureIndices, saveMeasure, { status }); }; -console.info(`%cstarry-omr%c v1.0.0 2026-07-24T04:03:57.370Z`, 'color:#fff; background-color: #555;padding: 5px;border-radius: 3px 0 0 3px;', 'color: #fff; background-color: #007dc6;padding: 5px;border-radius: 0 3px 3px 0;'); +console.info(`%cstarry-omr%c v1.0.0 2026-07-24T11:52:17.720Z`, 'color:#fff; background-color: #555;padding: 5px;border-radius: 3px 0 0 3px;', 'color: #fff; background-color: #007dc6;padding: 5px;border-radius: 0 3px 3px 0;'); exports.PyClients = PyClients; exports.abstractRegulationBeadStats = abstractRegulationBeadStats; diff --git a/backend/omr/dist/worker.js b/backend/omr/dist/worker.js index 4322e37ff3a39695c0e16eb250489c6912ffc806..b62821b655207e8d7adbecd9671181ddd4fbf5e3 100644 --- a/backend/omr/dist/worker.js +++ b/backend/omr/dist/worker.js @@ -7,5 +7,5 @@ * @copyright Chen, Yi-Cyuan 2014-2017 * @license MIT */ -(function(module){(function(){var root="object"==typeof window?window:{},NODE_JS=!root.JS_SHA1_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node;NODE_JS&&(root=global);var COMMON_JS=!root.JS_SHA1_NO_COMMON_JS&&module.exports,HEX_CHARS="0123456789abcdef".split(""),EXTRA=[-2147483648,8388608,32768,128],SHIFT=[24,16,8,0],OUTPUT_TYPES=["hex","array","digest","arrayBuffer"],blocks=[],createOutputMethod=function(t){return function(e){return new Sha1(!0).update(e)[t]()}},createMethod=function(){var t=createOutputMethod("hex");NODE_JS&&(t=nodeWrap(t)),t.create=function(){return new Sha1},t.update=function(e){return t.create().update(e)};for(var e=0;e>2]|=t[n]<>2]|=s<>2]|=(192|s>>6)<>2]|=(128|63&s)<=57344?(o[i>>2]|=(224|s>>12)<>2]|=(128|s>>6&63)<>2]|=(128|63&s)<>2]|=(240|s>>18)<>2]|=(128|s>>12&63)<>2]|=(128|s>>6&63)<>2]|=(128|63&s)<=64?(this.block=o[16],this.start=i-64,this.hash(),this.hashed=!0):this.start=i}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296|0,this.bytes=this.bytes%4294967296),this}},Sha1.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var t=this.blocks,e=this.lastByteIndex;t[16]=this.block,t[e>>2]|=EXTRA[3&e],this.block=t[16],e>=56&&(this.hashed||this.hash(),t[0]=this.block,t[16]=t[1]=t[2]=t[3]=t[4]=t[5]=t[6]=t[7]=t[8]=t[9]=t[10]=t[11]=t[12]=t[13]=t[14]=t[15]=0),t[14]=this.hBytes<<3|this.bytes>>>29,t[15]=this.bytes<<3,this.hash()}},Sha1.prototype.hash=function(){var t,e,s=this.h0,i=this.h1,n=this.h2,r=this.h3,o=this.h4,a=this.blocks;for(t=16;t<80;++t)e=a[t-3]^a[t-8]^a[t-14]^a[t-16],a[t]=e<<1|e>>>31;for(t=0;t<20;t+=5)s=(e=(i=(e=(n=(e=(r=(e=(o=(e=s<<5|s>>>27)+(i&n|~i&r)+o+1518500249+a[t]|0)<<5|o>>>27)+(s&(i=i<<30|i>>>2)|~s&n)+r+1518500249+a[t+1]|0)<<5|r>>>27)+(o&(s=s<<30|s>>>2)|~o&i)+n+1518500249+a[t+2]|0)<<5|n>>>27)+(r&(o=o<<30|o>>>2)|~r&s)+i+1518500249+a[t+3]|0)<<5|i>>>27)+(n&(r=r<<30|r>>>2)|~n&o)+s+1518500249+a[t+4]|0,n=n<<30|n>>>2;for(;t<40;t+=5)s=(e=(i=(e=(n=(e=(r=(e=(o=(e=s<<5|s>>>27)+(i^n^r)+o+1859775393+a[t]|0)<<5|o>>>27)+(s^(i=i<<30|i>>>2)^n)+r+1859775393+a[t+1]|0)<<5|r>>>27)+(o^(s=s<<30|s>>>2)^i)+n+1859775393+a[t+2]|0)<<5|n>>>27)+(r^(o=o<<30|o>>>2)^s)+i+1859775393+a[t+3]|0)<<5|i>>>27)+(n^(r=r<<30|r>>>2)^o)+s+1859775393+a[t+4]|0,n=n<<30|n>>>2;for(;t<60;t+=5)s=(e=(i=(e=(n=(e=(r=(e=(o=(e=s<<5|s>>>27)+(i&n|i&r|n&r)+o-1894007588+a[t]|0)<<5|o>>>27)+(s&(i=i<<30|i>>>2)|s&n|i&n)+r-1894007588+a[t+1]|0)<<5|r>>>27)+(o&(s=s<<30|s>>>2)|o&i|s&i)+n-1894007588+a[t+2]|0)<<5|n>>>27)+(r&(o=o<<30|o>>>2)|r&s|o&s)+i-1894007588+a[t+3]|0)<<5|i>>>27)+(n&(r=r<<30|r>>>2)|n&o|r&o)+s-1894007588+a[t+4]|0,n=n<<30|n>>>2;for(;t<80;t+=5)s=(e=(i=(e=(n=(e=(r=(e=(o=(e=s<<5|s>>>27)+(i^n^r)+o-899497514+a[t]|0)<<5|o>>>27)+(s^(i=i<<30|i>>>2)^n)+r-899497514+a[t+1]|0)<<5|r>>>27)+(o^(s=s<<30|s>>>2)^i)+n-899497514+a[t+2]|0)<<5|n>>>27)+(r^(o=o<<30|o>>>2)^s)+i-899497514+a[t+3]|0)<<5|i>>>27)+(n^(r=r<<30|r>>>2)^o)+s-899497514+a[t+4]|0,n=n<<30|n>>>2;this.h0=this.h0+s|0,this.h1=this.h1+i|0,this.h2=this.h2+n|0,this.h3=this.h3+r|0,this.h4=this.h4+o|0},Sha1.prototype.hex=function(){this.finalize();var t=this.h0,e=this.h1,s=this.h2,i=this.h3,n=this.h4;return HEX_CHARS[t>>28&15]+HEX_CHARS[t>>24&15]+HEX_CHARS[t>>20&15]+HEX_CHARS[t>>16&15]+HEX_CHARS[t>>12&15]+HEX_CHARS[t>>8&15]+HEX_CHARS[t>>4&15]+HEX_CHARS[15&t]+HEX_CHARS[e>>28&15]+HEX_CHARS[e>>24&15]+HEX_CHARS[e>>20&15]+HEX_CHARS[e>>16&15]+HEX_CHARS[e>>12&15]+HEX_CHARS[e>>8&15]+HEX_CHARS[e>>4&15]+HEX_CHARS[15&e]+HEX_CHARS[s>>28&15]+HEX_CHARS[s>>24&15]+HEX_CHARS[s>>20&15]+HEX_CHARS[s>>16&15]+HEX_CHARS[s>>12&15]+HEX_CHARS[s>>8&15]+HEX_CHARS[s>>4&15]+HEX_CHARS[15&s]+HEX_CHARS[i>>28&15]+HEX_CHARS[i>>24&15]+HEX_CHARS[i>>20&15]+HEX_CHARS[i>>16&15]+HEX_CHARS[i>>12&15]+HEX_CHARS[i>>8&15]+HEX_CHARS[i>>4&15]+HEX_CHARS[15&i]+HEX_CHARS[n>>28&15]+HEX_CHARS[n>>24&15]+HEX_CHARS[n>>20&15]+HEX_CHARS[n>>16&15]+HEX_CHARS[n>>12&15]+HEX_CHARS[n>>8&15]+HEX_CHARS[n>>4&15]+HEX_CHARS[15&n]},Sha1.prototype.toString=Sha1.prototype.hex,Sha1.prototype.digest=function(){this.finalize();var t=this.h0,e=this.h1,s=this.h2,i=this.h3,n=this.h4;return[t>>24&255,t>>16&255,t>>8&255,255&t,e>>24&255,e>>16&255,e>>8&255,255&e,s>>24&255,s>>16&255,s>>8&255,255&s,i>>24&255,i>>16&255,i>>8&255,255&i,n>>24&255,n>>16&255,n>>8&255,255&n]},Sha1.prototype.array=Sha1.prototype.digest,Sha1.prototype.arrayBuffer=function(){this.finalize();var t=new ArrayBuffer(20),e=new DataView(t);return e.setUint32(0,this.h0),e.setUint32(4,this.h1),e.setUint32(8,this.h2),e.setUint32(12,this.h3),e.setUint32(16,this.h4),t};var exports=createMethod();COMMON_JS?module.exports=exports:root.sha1=exports})()})(sha1),function(t){t.ClefG="ClefG",t.ClefF="ClefF",t.ClefC="ClefC",t.NoteheadS0="NoteheadS0",t.NoteheadS1="NoteheadS1",t.NoteheadS2="NoteheadS2",t.NoteheadS1stemU="NoteheadS1stemU",t.NoteheadS1stemD="NoteheadS1stemD",t.NoteheadS2stemU="NoteheadS2stemU",t.NoteheadS2stemD="NoteheadS2stemD",t.vline_Stem="vline_Stem",t.Flag3="Flag3",t.BeamLeft="BeamLeft",t.BeamContinue="BeamContinue",t.BeamRight="BeamRight",t.TremoloLeft="TremoloLeft",t.TremoloRight="TremoloRight",t.TremoloMiddle="TremoloMiddle",t.Dot="Dot",t.Rest0="Rest0",t.Rest1="Rest1",t.Rest2="Rest2",t.Rest3="Rest3",t.Rest4="Rest4",t.Rest5="Rest5",t.Rest6="Rest6",t.Rest0W="Rest0W",t.RestM1="RestM1",t.AccNatural="AccNatural",t.AccSharp="AccSharp",t.AccDoublesharp="AccDoublesharp",t.AccFlat="AccFlat",t.AccFlatflat="AccFlatflat",t.vline_VoltaLeft="vline_VoltaLeft",t.vline_VoltaRight="vline_VoltaRight",t.VoltaLeft="VoltaLeft",t.VoltaRight="VoltaRight",t.VoltaAlternativeBegin="VoltaAlternativeBegin",t.BarMeasure="BarMeasure",t.vline_BarMeasure="vline_BarMeasure",t.vline_BarTerminal="vline_BarTerminal",t.vline_BarSegment="vline_BarSegment",t.SlurBegin="SlurBegin",t.SlurEnd="SlurEnd",t.TimesigC44="TimesigC44",t.TimesigC22="TimesigC22",t.TimesigZero="TimesigZero",t.TimesigOne="TimesigOne",t.TimesigTwo="TimesigTwo",t.TimesigThree="TimesigThree",t.TimesigFour="TimesigFour",t.TimesigFive="TimesigFive",t.TimesigSix="TimesigSix",t.TimesigSeven="TimesigSeven",t.TimesigEight="TimesigEight",t.TimesigNine="TimesigNine",t.OctaveShift8va="OctaveShift8va",t.OctaveShift8vb="OctaveShift8vb",t.OctaveShift8="OctaveShift8",t.OctaveShift0="OctaveShift0",t.Zero="Zero",t.One="One",t.Two="Two",t.Three="Three",t.Four="Four",t.Five="Five",t.Six="Six",t.Seven="Seven",t.Eight="Eight",t.Nine="Nine",t.f="f",t.p="p",t.m="m",t.n="n",t.r="r",t.s="s",t.z="z",t.CrescendoBegin="CrescendoBegin",t.CrescendoEnd="CrescendoEnd",t.DecrescendoBegin="DecrescendoBegin",t.DecrescendoEnd="DecrescendoEnd",t.ScriptFermata="ScriptFermata",t.ScriptShortFermata="ScriptShortFermata",t.ScriptSforzato="ScriptSforzato",t.ScriptStaccato="ScriptStaccato",t.ScriptStaccatissimo="ScriptStaccatissimo",t.ScriptTurn="ScriptTurn",t.ScriptTrill="ScriptTrill",t.ScriptSegno="ScriptSegno",t.ScriptCoda="ScriptCoda",t.ScriptArpeggio="ScriptArpeggio",t.ScriptPrall="ScriptPrall",t.ScriptMordent="ScriptMordent",t.ScriptMarcato="ScriptMarcato",t.ScriptTenuto="ScriptTenuto",t.ScriptPortato="ScriptPortato",t.PedalStar="PedalStar",t.PedalPed="PedalPed",t.KeyAcc="KeyAcc",t.TempoNotehead="TempoNotehead",t.GraceNotehead="GraceNotehead",t.SignLined="SignLined",t.SignInterval="SignInterval",t.rect_Text="rect_Text",t.rect_Lyric="rect_Lyric"}(SemanticType||(SemanticType={})),SemanticType.BarMeasure,SemanticType.vline_BarMeasure,SemanticType.vline_BarTerminal,SemanticType.vline_BarSegment,SemanticType.vline_VoltaLeft,SemanticType.vline_VoltaRight,SemanticType.VoltaAlternativeBegin;const st=SemanticType;st.NoteheadS0,st.NoteheadS1,st.NoteheadS2,st.Zero,st.One,st.Two,st.Three,st.Four,st.Five,st.Six,st.Seven,st.Eight,st.Nine,st.ScriptStaccatissimo,st.TimesigZero,st.TimesigOne,st.TimesigTwo,st.TimesigThree,st.TimesigFour,st.TimesigFive,st.TimesigSix,st.TimesigSeven,st.TimesigEight,st.TimesigNine,st.Rest0,st.Rest1,st.Rest2,st.Rest3,st.Rest4,st.Rest5,st.Rest6,st.Rest0W,st.RestM1,st.SignInterval,st.SignLined,st.BeamLeft,st.BeamContinue,st.BeamRight,st.ClefG,st.ClefF,st.ClefC,st.NoteheadS0,st.NoteheadS1,st.NoteheadS2,st.Dot,st.Rest0,st.Rest1,st.Rest2,st.Rest3,st.Rest4,st.Rest5,st.Rest6,st.RestM1,st.AccNatural,st.AccSharp,st.AccDoublesharp,st.AccFlat,st.AccFlatflat,st.TimesigC44,st.TimesigC22,st.TimesigZero,st.TimesigOne,st.TimesigTwo,st.TimesigThree,st.TimesigFour,st.TimesigFive,st.TimesigSix,st.TimesigSeven,st.TimesigEight,st.TimesigNine,st.One,st.Two,st.Three,st.Four,st.Five,st.OctaveShift8,st.OctaveShift0,st.f,st.p,st.m,st.n,st.r,st.s,st.z,st.ScriptFermata,st.ScriptShortFermata,st.ScriptSforzato,st.ScriptStaccato,st.ScriptStaccatissimo,st.ScriptTurn,st.ScriptTrill,st.ScriptSegno,st.ScriptCoda,st.ScriptArpeggio,st.ScriptPrall,st.ScriptMordent,st.ScriptMarcato,st.ScriptTenuto,st.ScriptPortato,st.PedalStar,st.PedalPed;const roundNumber=(t,e,s=-1/0)=>Math.max(Math.round(t/e)*e,s),gcd=(t,e)=>Number.isInteger(t)&&Number.isInteger(e)?0===e?t:gcd(e,t%e):(console.error("non-integer gcd:",t,e),1),frac=(t,e)=>({numerator:t,denominator:e}),reducedFraction=(t,e)=>{t=Math.round(t),e=Math.round(e);const s=0!==t?gcd(t,e):e;return frac(t/s,e/s)},fractionMul=(t,e)=>e?t*e.numerator/e.denominator:t;class DummyLogger{debug(...t){}group(...t){}groupCollapsed(...t){}groupEnd(){}info(...t){}warn(...t){}assert(...t){}}const EOM=-1,GREAT_NUMBER=1920,DURATION_MULTIPLIER=1921920,floatToFrac=t=>{const e=Math.round(t*GREAT_NUMBER);return reducedFraction(e,GREAT_NUMBER)},floatToTimeWarp=t=>1===t?null:floatToFrac(t);var ActionType;!function(t){t[t.PLACE=0]="PLACE",t[t.VERTICAL=1]="VERTICAL",t[t.HORIZONTAL=2]="HORIZONTAL"}(ActionType||(ActionType={}));class Action{constructor(t){Object.assign(this,t)}static P(t){return new Action({type:ActionType.PLACE,e1:t})}static V(t,e,s=1){return new Action({type:ActionType.VERTICAL,e1:s>0?t:e,e2:s>0?e:t})}static H(t,e){return new Action({type:ActionType.HORIZONTAL,e1:t,e2:e})}get id(){switch(this.type){case ActionType.PLACE:return this.e1.toString();case ActionType.VERTICAL:return`${this.e1}|${this.e2}`;case ActionType.HORIZONTAL:return`${this.e1}-${this.e2>=0?this.e2:"."}`}}get events(){return[this.e1,this.e2].filter(Number.isFinite)}}class StageMatrix{static fromNode(t,e){const s=Array(t.stages.length).fill(null).map(()=>Array(t.stages.length).fill(null).map(()=>new Set));t.actions.filter(t=>t.type===ActionType.HORIZONTAL).forEach(e=>{const i=t.stages.findIndex(t=>t.events.includes(e.e1)),n=t.stages.findIndex(t=>t.events.includes(e.e2));console.assert(i>=0&&n>=0,"invalid stages for H action:",t.id,t.stages,e),s[i][n].add(e.e1)}),s[0][t.stages.length-1].add(0);const i=t.stagedEvents,n=e.matrixH[e.matrixH.length-1].filter((t,e)=>!i.has(e)),r=Math.max(0,Math.max(...n)-.01),o=t.actions.filter(t=>t.type===ActionType.HORIZONTAL),a=Object.keys(e.eventMap).map(Number).filter(t=>!o.find(e=>e.e2===t));return t.stages.forEach(i=>{i.events.forEach(n=>{if(n>0){!o.find(t=>t.e1===n)&&e.matrixH[e.matrixH.length-1][n]>=r&&(a.some(t=>e.matrixH[t][n]>0)||s[i.index][t.stages.length-1].add(n))}})}),new StageMatrix({matrix:s})}constructor(t){Object.assign(this,t)}pathOf(t,e,s,i=0){if(this.matrix[t][e].size){const n=[...this.matrix[t][e]][i];if(e===s)return[n];for(let t=e+1;t<=s;++t){const i=this.pathOf(e,t,s);if(i)return[n,...i]}}return null}findDoublePath(t,e){const s=[];for(let i=e;i>=t+1;--i)for(let n=0;ne.forEach(e=>t.forEach(t=>e.delete(t))))}toEquations(t){const e=[];for(let s=1;sr[t]=1),n.forEach(t=>r[t]=-1),e.push(r),this.reducePath(i.length>n.length?i:n)}}}return e}}class PathNode{constructor(t){Object.assign(this,t),console.assert(this.logger,"logger is null:",t)}get actions(){const t=this.parent?this.parent.actions:[];return this.action?[...t,this.action]:t}get id(){return this.actions.map(t=>t.id).sort().join(" ")}get stagedEvents(){const t=new Set;return this.stages&&this.stages.forEach(e=>e.events.forEach(e=>e>=0&&t.add(e))),t}like(t){return t.split(" ").sort().join(" ")===this.id}constructStages(t){this.stages=[{events:[EOM]}];for(const e of this.actions)switch(e.type){case ActionType.PLACE:this.stages.unshift({events:[e.e1]});break;case ActionType.VERTICAL:{const t=this.stages.find(t=>t.events.includes(e.e1)),s=this.stages.find(t=>t.events.includes(e.e2));console.assert(t||s,"invalid V action:",this.stages,e),t&&s?(t.events.push(...s.events),s.events=null,this.stages=this.stages.filter(t=>t.events)):t?s||t.events.push(e.e2):s.events.unshift(e.e1)}break;case ActionType.HORIZONTAL:{const s=this.stages.find(t=>t.events.includes(e.e1)),i=this.stages.find(t=>t.events.includes(e.e2));console.assert(s||i,"invalid H action:",this.stages,e);const n=s=>{console.assert(t.eventMap[s],"invalid event id:",e.id,s,t.eventMap);const i=t.eventMap[s].x,n=this.stages.find(e=>e.events.some(e=>e>0&&t.eventMap[e].x<=i)&&e.events.some(e=>e>0&&t.eventMap[e].x>=i));if(n)n.events.push(s);else{const e={events:[s]},n=this.stages.findIndex(e=>e.events[0]===EOM||t.eventMap[e.events[0]].x>=i);this.stages.splice(n,0,e)}};s||n(e.e1),i||n(e.e2)}}this.stages.forEach((t,e)=>t.index=e)}constructConstraints(t){const e=Object.keys(t.eventMap).length,s=StageMatrix.fromNode(this,t).toEquations(e),i=Array(e).fill(null).map((e,s)=>t.eventMap[s].duration);this.constraints=s.map(t=>t.map((t,e)=>t*i[e]))}inbalancesConstraints(t){console.assert(this.constraints,"constraints not constructed.");const e=Object.keys(t.eventMap).length,s=Array(e).fill(!0),i=Array(e).fill(!1),n=[];for(const t of this.constraints){const e=t.reduce((t,e)=>t+e,0);if(0!==e){const r=e<0?t.map(t=>-t):t;if(r[0]>0)continue;n.push(r),r.forEach((t,e)=>{i[e]=i[e]||t<0,t&&(s[e]=t<0||i[e])})}}return this.constraints.forEach(t=>{0!==t.reduce((t,e)=>t+e,0)||t[0]||t.some((t,e)=>t&&!s[e])&&(t.forEach((t,e)=>t&&(s[e]=!1)),n.push(t))}),{ones:s,inbalances:n}}solveEquations({ones:t,inbalances:e}){if(!e.length)return t.map(()=>1);const s=t.map((t,e)=>({fixed:t,i:e})).filter(({fixed:t})=>!t).map(({i:t})=>t).filter(t=>e.some(e=>0!==e[t]));if(!s.length)return t.map(()=>1);const i=s.map(t=>Math.abs(e.find(e=>0!==e[t])[t])),n=new Map;let r=!1;const o=e.map(t=>({line:t.filter((t,e)=>s.includes(e)),bias:-t.reduce((t,e,i)=>t+(s.includes(i)?0:e),0)})).filter(({line:t,bias:e})=>{if(t.every(t=>0===t))return!1;const s=t.join(",");return n.has(s)?(r=n.get(s)!==e,!1):(n.set(s,e),!0)});if(r)return null;const a=o.slice(0,s.length),c=o.slice(s.length);if(a.lengths===e?1:s===n?-1:0),bias:0,prior:(i[e]+i[n])/DURATION_MULTIPLIER};a.some(t=>t.line[e]&&t.line[n])&&(r.prior-=10),a.some(t=>1===t.line.filter(Number).length&&(t.line[e]||t.line[n]))&&(r.prior+=1),t.push(r)}t.sort((t,e)=>t.prior-e.prior),a.push(...t.slice(0,s.length-a.length))}const h=a.map(({line:t})=>t),l=a.map(({bias:t})=>t),u=matrixInverse(h);if(!u)return this.logger.warn("null invert:",h),null;const d=u.map(t=>t.reduce((t,e,s)=>t+e*l[s],0));if(c.length&&c.some(t=>Math.abs(t.line.reduce((t,e,s)=>t+e*d[s],0))>.001))return null;const f=t.map(()=>1);return s.forEach((t,e)=>f[t]=d[e]),f}optimallySolve(t){const{ones:e,inbalances:s}=this.inbalancesConstraints(t),i=e.map((e,s)=>e?-1:roundNumber(t.eventMap[s].shrinkness,.01)).reduce((t,e,s)=>(e>=0&&(t[e]=t[e]||[],t[e].push(s)),t),{}),n=Object.entries(i).sort((t,e)=>Number(e[0])-Number(t[0])).map(t=>t[1]);for(let i=1;i!r.includes(e)),a=this.solveEquations({ones:o,inbalances:s});if(a&&a.every((e,s)=>e<=1&&e>t.eventMap[s].lowWarp))return a}return this.solveEquations({ones:e,inbalances:s})}isConflicted(t){const{ones:e,inbalances:s}=this.inbalancesConstraints(t);for(const i of s){if(i.reduce((s,i,n)=>s+i*(e[n]||i<=0?1:t.eventMap[n].lowWarp),0)>=0)return i.forEach((e,s)=>{e&&(t.eventTendencies[s]+=e>0?1:-1)}),!0}if(!s.length)return!1;const i=this.solveEquations({ones:e,inbalances:s});return!i||!i.every((e,s)=>e>t.eventMap[s].lowWarp&&e<=1)}getSolution(t){const e=e=>t.eventMap[e.e2]?t.eventMap[e.e2].x+.06*Math.abs(t.eventMap[e.e2].x-t.eventMap[e.e1].x):t.eventMap[e.e1].x+1e4,s=this.actions.filter(t=>t.type===ActionType.HORIZONTAL).sort((t,s)=>e(t)-e(s)),i=s.reduce((t,e)=>({...t,[e.e1]:e.e2}),{}),n=new Set([...Object.keys(i)].map(Number));s.forEach(t=>n.delete(t.e2)),this.stages[0].events.forEach(t=>t>0&&n.add(t));let r=[...n].map(t=>{const e=[t];let s=t;for(;i[s]&&(s=i[s],!(s<0||e.includes(s)));)e.push(s);return e});const o=Object.values(t.eventMap).filter(t=>t.id>0).map(t=>({id:t.id,tick:null,endTick:null,tickGroup:null,timeWarp:null})),a=o.filter(t=>r.some(e=>e.includes(t.id))||s.some(e=>[e.e1,e.e2].includes(t.id))).reduce((t,e)=>({...t,[e.id]:e}),{});this.stages.forEach((t,e)=>t.events.forEach(t=>a[t]&&(a[t].tickGroup=e))),this.stages[0].tick=0,this.stages[0].events.forEach(t=>a[t]&&(a[t].tick=0));const c=this.optimallySolve(t);o.forEach(t=>t.timeWarp=floatToTimeWarp(c[t.id]));const h=this.stages.slice(0,this.stages.length-1),l=()=>{if(h.every(t=>Number.isFinite(t.tick)))return!1;let e=!1;return s.forEach(s=>{const i=this.stages.find(t=>t.events.includes(s.e1)),n=this.stages.find(t=>t.events.includes(s.e2));Number.isFinite(i.tick)&&!Number.isFinite(n.tick)&&(n.tick=i.tick+fractionMul(t.eventMap[s.e1].duration,a[s.e1].timeWarp),n.events.forEach(t=>a[t]&&(a[t].tick=n.tick)),e=!0)}),[...s].reverse().forEach(s=>{const i=this.stages.find(t=>t.events.includes(s.e1)),n=this.stages.find(t=>t.events.includes(s.e2));!Number.isFinite(i.tick)&&Number.isFinite(n.tick)&&(i.tick=n.tick-fractionMul(t.eventMap[s.e1].duration,a[s.e1].timeWarp),i.events.forEach(t=>a[t]&&(a[t].tick=i.tick)),e=!0)}),e};for(;l(););console.assert(h.every(t=>Number.isFinite(t.tick)),"stage ticks not all solved:",this.stages,this.id),o.filter(t=>Number.isFinite(t.tick)).forEach(e=>e.endTick=e.tick+fractionMul(t.eventMap[e.id].duration,e.timeWarp));const u=t.eventMap[0].duration;r.forEach(t=>{const e=t.findIndex(t=>a[t].endTick>u);if(e>=0){t.splice(e,t.length-e).forEach(t=>{a[t].tick=null,a[t].endTick=null})}}),r=r.filter(t=>t.length);const d=Math.max(0,...o.map(t=>t.endTick).filter(Number.isFinite));return this.logger.debug(String.fromCodePoint(127822),this.id,c),{voices:r,events:o,duration:d,actions:this.actions.map(t=>t.id).join(" ")}}deduce(t,e){this.stages||this.constructStages(t);const s=t.actionAccessing.get(this.id)||{times:0};if(++s.times,t.actionAccessing.set(this.id,s),this.constructConstraints(t),this.isConflicted(t))return s.closed=!0,this.logger.info(this.action.id,"❌"),null;if(this.logger.group(this.action&&this.action.id),e.credits>0){if(--e.credits,this.children||this.expand(t),this.children=this.children.filter(e=>!t.actionAccessing.get(e.id)||!t.actionAccessing.get(e.id).closed),this.children.length){const s=e=>e.possibility/((t.actionAccessing.get(e.id)||{times:0}).times+1);this.children.sort((t,e)=>s(e)-s(t));for(const s of this.children){const i=s.deduce(t,e);if(i)return this.logger.groupEnd(),i;if(e.credits<=0)break}}}else this.logger.debug("quota exhausted.");return this.logger.groupEnd(),s.closed=!0,this.getSolution(t)}expand(t){this.constructStages(t);const{eventMap:e,matrixV:s,matrixH:i}=t,n=this.stagedEvents,r=[],o=t=>{if(!this.actions.some(e=>e.id===t.action.id)&&!r.some(e=>e.action.id===t.action.id)){const e=this.stages.find(e=>e.events.includes(t.action.e1)),i=this.stages.find(e=>e.events.includes(t.action.e2));if(e===i||e&&i&&e.index>=i.index)return;if(e&&i)if(t.action.type===ActionType.VERTICAL){if(i.index-e.index>1)return;if(this.actions.some(t=>e.events.includes(t.e1)&&i.events.includes(t.e2)))return}else if(t.action.type===ActionType.HORIZONTAL&&e.index>i.index)return;if(t.action.type===ActionType.HORIZONTAL&&this.actions.some(e=>e.type===ActionType.HORIZONTAL&&(e.e1===t.action.e1||e.e2===t.action.e2||e.e1===t.action.e2&&e.e2===t.action.e1)))return;if(t.action.type===ActionType.VERTICAL){if(e&&(t.possibility=Math.min(t.possibility,...e.events.map(e=>s[t.action.e2][e])),t.possibility<=0))return;if(i&&(t.possibility=Math.min(t.possibility,...i.events.map(e=>s[e][t.action.e1])),t.possibility<=0))return}r.push(t)}};for(const t of n)t<0||(s[t].forEach((e,s)=>{e>0&&t!==s&&o({action:Action.V(s,t),possibility:e})}),s.forEach((e,s)=>{const i=e[t];i>0&&o({action:Action.V(t,s),possibility:i})}),i[t].forEach((e,s)=>{e>0&&o({action:Action.H(s,t),possibility:e})}),i.forEach((s,i)=>{i=i>=Object.keys(e).length?-1:i;const n=s[t];n>0&&o({action:Action.H(t,i),possibility:n})}));r.some(t=>[ActionType.HORIZONTAL,ActionType.PLACE].includes(t.action.type)||!n.has(t.action.e1)||!n.has(t.action.e2))?this.children=r.map(t=>new PathNode({logger:this.logger,parent:this,...t})):this.children=[]}}class Solver{constructor(t,{quota:e=1e3,logger:s=new DummyLogger}={}){this.quota=e,this.logger=s;const i={id:0,x:0,confidence:1,shrinkness:t.measureShrinkness,duration:t.expectedDuration,lowWarp:0};this.events=[i,...t.events.map(t=>({id:t.id,x:t.x,confidence:t.confidence,shrinkness:t.shrinkness,staff:t.staff,duration:t.duration,lowWarp:.5}))],this.eventMap=this.events.reduce((t,e)=>({...t,[e.id]:e}),{}),this.matrixH=t.matrixH,this.matrixV=t.matrixV,this.xSpan=t.endX-Math.min(t.endX-1,...t.events.map(t=>t.x)),this.actionAccessing=new Map}solve(){this.pathRoot=new PathNode({logger:this.logger,action:null}),this.pathRoot.children=this.events.slice(1).map(t=>new PathNode({logger:this.logger,parent:this.pathRoot,action:Action.P(t.id),possibility:this.matrixV[t.id].reduce((t,e)=>t+e,0)}));let t=null;this.logger.groupCollapsed("solve");const e=Array(this.events.length).fill(0),s={credits:this.quota,times:0};for(;s.credits>0;){++s.times;const i={eventMap:this.eventMap,matrixH:this.matrixH,matrixV:this.matrixV,actionAccessing:this.actionAccessing,eventTendencies:e},n=this.pathRoot.deduce(i,s);if(n.credits=this.quota-s.credits,n.times=s.times,this.evaluateSolution(n),this.logger.debug("loss:",n.loss),t=!t||n.losst/s.times)),t}evaluateSolution(t){t.loss=0;const e=t.events.reduce((t,e)=>({...t,[e.id]:{...e,...this.eventMap[e.id]}}),{}),s=t.events.filter(t=>Number.isFinite(t.tick)).map(t=>e[t.id]),i=s.reduce((t,e)=>(t[e.staff]=t[e.staff]||[],t[e.staff].push(e),t),{});Object.values(i).forEach(e=>{e.sort((t,e)=>t.x-e.x).slice(0,e.length-1).forEach((s,i)=>{e[i+1].tick{if(Number.isFinite(s.tick)&&!t.voices.every(t=>!t.includes(s.id))||(t.loss+=100*e[s.id].confidence),s.timeWarp){const{numerator:t,denominator:i}=s.timeWarp,r=e[s.id].shrinkness;n.set(t,Math.max(n.get(t)||0,1-r)),n.set(i,Math.max(n.get(i)||0,1-r))}});const r=reducedFraction(t.duration,this.eventMap[0].duration);n.set(r.numerator,Math.max(n.get(r.numerator)||0,1-this.eventMap[0].shrinkness)),n.set(r.denominator,Math.max(n.get(r.denominator)||0,1-this.eventMap[0].shrinkness));for(const[e,s]of n.entries())e>1&&(t.loss+=Math.log(e)*s);let o=0,a=0;t.voices.forEach(s=>{console.assert(e[s[0]],"invalid voice:",s,Object.keys(e));const i=Math.abs(e[s[0]].tick),n=e[s[s.length-1]].endTick;o+=Math.max(0,i+t.duration-n);let r=null;s.forEach(t=>{const s=e[t];s.staff!==r&&(null!==r&&++a,r=s.staff)})}),t.loss+=10*o/DURATION_MULTIPLIER,t.loss+=5**a-1;const c=[...s].sort((t,e)=>t.x-e.x),h=c.slice(1).map((e,s)=>{const i=c[s],n=e.x-i.x,r=e.tick-i.tick;if(!r)return n/this.xSpan;return(4*Math.atan2(r/t.duration,n/this.xSpan)/Math.PI-1)**2}),l=Math.max(...h,0);t.loss+=l**2,console.assert(t.loss>=0,"Invalid solution loss!!!",t.loss,n,o,a),t.loss<0&&(t.loss=1/0)}}const solveStaffGroup=(t,e)=>{if(!t.events.length)return{events:[],voices:[],duration:0};return new Solver(t,e).solve()};self.onmessage=t=>{const{id:e,args:s}=t.data;try{const t=solveStaffGroup(s[0],s[1]);self.postMessage({id:e,result:t})}catch(t){self.postMessage({id:e,error:t.message})}},console.info("%cstarry-omr%c v1.0.0 2026-07-24T04:03:52.887Z","color:#fff; background-color: #555;padding: 5px;border-radius: 3px 0 0 3px;","color: #fff; background-color: #007dc6;padding: 5px;border-radius: 0 3px 3px 0;")})(); +(function(module){(function(){var root="object"==typeof window?window:{},NODE_JS=!root.JS_SHA1_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node;NODE_JS&&(root=global);var COMMON_JS=!root.JS_SHA1_NO_COMMON_JS&&module.exports,HEX_CHARS="0123456789abcdef".split(""),EXTRA=[-2147483648,8388608,32768,128],SHIFT=[24,16,8,0],OUTPUT_TYPES=["hex","array","digest","arrayBuffer"],blocks=[],createOutputMethod=function(t){return function(e){return new Sha1(!0).update(e)[t]()}},createMethod=function(){var t=createOutputMethod("hex");NODE_JS&&(t=nodeWrap(t)),t.create=function(){return new Sha1},t.update=function(e){return t.create().update(e)};for(var e=0;e>2]|=t[n]<>2]|=s<>2]|=(192|s>>6)<>2]|=(128|63&s)<=57344?(o[i>>2]|=(224|s>>12)<>2]|=(128|s>>6&63)<>2]|=(128|63&s)<>2]|=(240|s>>18)<>2]|=(128|s>>12&63)<>2]|=(128|s>>6&63)<>2]|=(128|63&s)<=64?(this.block=o[16],this.start=i-64,this.hash(),this.hashed=!0):this.start=i}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296|0,this.bytes=this.bytes%4294967296),this}},Sha1.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var t=this.blocks,e=this.lastByteIndex;t[16]=this.block,t[e>>2]|=EXTRA[3&e],this.block=t[16],e>=56&&(this.hashed||this.hash(),t[0]=this.block,t[16]=t[1]=t[2]=t[3]=t[4]=t[5]=t[6]=t[7]=t[8]=t[9]=t[10]=t[11]=t[12]=t[13]=t[14]=t[15]=0),t[14]=this.hBytes<<3|this.bytes>>>29,t[15]=this.bytes<<3,this.hash()}},Sha1.prototype.hash=function(){var t,e,s=this.h0,i=this.h1,n=this.h2,r=this.h3,o=this.h4,a=this.blocks;for(t=16;t<80;++t)e=a[t-3]^a[t-8]^a[t-14]^a[t-16],a[t]=e<<1|e>>>31;for(t=0;t<20;t+=5)s=(e=(i=(e=(n=(e=(r=(e=(o=(e=s<<5|s>>>27)+(i&n|~i&r)+o+1518500249+a[t]|0)<<5|o>>>27)+(s&(i=i<<30|i>>>2)|~s&n)+r+1518500249+a[t+1]|0)<<5|r>>>27)+(o&(s=s<<30|s>>>2)|~o&i)+n+1518500249+a[t+2]|0)<<5|n>>>27)+(r&(o=o<<30|o>>>2)|~r&s)+i+1518500249+a[t+3]|0)<<5|i>>>27)+(n&(r=r<<30|r>>>2)|~n&o)+s+1518500249+a[t+4]|0,n=n<<30|n>>>2;for(;t<40;t+=5)s=(e=(i=(e=(n=(e=(r=(e=(o=(e=s<<5|s>>>27)+(i^n^r)+o+1859775393+a[t]|0)<<5|o>>>27)+(s^(i=i<<30|i>>>2)^n)+r+1859775393+a[t+1]|0)<<5|r>>>27)+(o^(s=s<<30|s>>>2)^i)+n+1859775393+a[t+2]|0)<<5|n>>>27)+(r^(o=o<<30|o>>>2)^s)+i+1859775393+a[t+3]|0)<<5|i>>>27)+(n^(r=r<<30|r>>>2)^o)+s+1859775393+a[t+4]|0,n=n<<30|n>>>2;for(;t<60;t+=5)s=(e=(i=(e=(n=(e=(r=(e=(o=(e=s<<5|s>>>27)+(i&n|i&r|n&r)+o-1894007588+a[t]|0)<<5|o>>>27)+(s&(i=i<<30|i>>>2)|s&n|i&n)+r-1894007588+a[t+1]|0)<<5|r>>>27)+(o&(s=s<<30|s>>>2)|o&i|s&i)+n-1894007588+a[t+2]|0)<<5|n>>>27)+(r&(o=o<<30|o>>>2)|r&s|o&s)+i-1894007588+a[t+3]|0)<<5|i>>>27)+(n&(r=r<<30|r>>>2)|n&o|r&o)+s-1894007588+a[t+4]|0,n=n<<30|n>>>2;for(;t<80;t+=5)s=(e=(i=(e=(n=(e=(r=(e=(o=(e=s<<5|s>>>27)+(i^n^r)+o-899497514+a[t]|0)<<5|o>>>27)+(s^(i=i<<30|i>>>2)^n)+r-899497514+a[t+1]|0)<<5|r>>>27)+(o^(s=s<<30|s>>>2)^i)+n-899497514+a[t+2]|0)<<5|n>>>27)+(r^(o=o<<30|o>>>2)^s)+i-899497514+a[t+3]|0)<<5|i>>>27)+(n^(r=r<<30|r>>>2)^o)+s-899497514+a[t+4]|0,n=n<<30|n>>>2;this.h0=this.h0+s|0,this.h1=this.h1+i|0,this.h2=this.h2+n|0,this.h3=this.h3+r|0,this.h4=this.h4+o|0},Sha1.prototype.hex=function(){this.finalize();var t=this.h0,e=this.h1,s=this.h2,i=this.h3,n=this.h4;return HEX_CHARS[t>>28&15]+HEX_CHARS[t>>24&15]+HEX_CHARS[t>>20&15]+HEX_CHARS[t>>16&15]+HEX_CHARS[t>>12&15]+HEX_CHARS[t>>8&15]+HEX_CHARS[t>>4&15]+HEX_CHARS[15&t]+HEX_CHARS[e>>28&15]+HEX_CHARS[e>>24&15]+HEX_CHARS[e>>20&15]+HEX_CHARS[e>>16&15]+HEX_CHARS[e>>12&15]+HEX_CHARS[e>>8&15]+HEX_CHARS[e>>4&15]+HEX_CHARS[15&e]+HEX_CHARS[s>>28&15]+HEX_CHARS[s>>24&15]+HEX_CHARS[s>>20&15]+HEX_CHARS[s>>16&15]+HEX_CHARS[s>>12&15]+HEX_CHARS[s>>8&15]+HEX_CHARS[s>>4&15]+HEX_CHARS[15&s]+HEX_CHARS[i>>28&15]+HEX_CHARS[i>>24&15]+HEX_CHARS[i>>20&15]+HEX_CHARS[i>>16&15]+HEX_CHARS[i>>12&15]+HEX_CHARS[i>>8&15]+HEX_CHARS[i>>4&15]+HEX_CHARS[15&i]+HEX_CHARS[n>>28&15]+HEX_CHARS[n>>24&15]+HEX_CHARS[n>>20&15]+HEX_CHARS[n>>16&15]+HEX_CHARS[n>>12&15]+HEX_CHARS[n>>8&15]+HEX_CHARS[n>>4&15]+HEX_CHARS[15&n]},Sha1.prototype.toString=Sha1.prototype.hex,Sha1.prototype.digest=function(){this.finalize();var t=this.h0,e=this.h1,s=this.h2,i=this.h3,n=this.h4;return[t>>24&255,t>>16&255,t>>8&255,255&t,e>>24&255,e>>16&255,e>>8&255,255&e,s>>24&255,s>>16&255,s>>8&255,255&s,i>>24&255,i>>16&255,i>>8&255,255&i,n>>24&255,n>>16&255,n>>8&255,255&n]},Sha1.prototype.array=Sha1.prototype.digest,Sha1.prototype.arrayBuffer=function(){this.finalize();var t=new ArrayBuffer(20),e=new DataView(t);return e.setUint32(0,this.h0),e.setUint32(4,this.h1),e.setUint32(8,this.h2),e.setUint32(12,this.h3),e.setUint32(16,this.h4),t};var exports=createMethod();COMMON_JS?module.exports=exports:root.sha1=exports})()})(sha1),function(t){t.ClefG="ClefG",t.ClefF="ClefF",t.ClefC="ClefC",t.NoteheadS0="NoteheadS0",t.NoteheadS1="NoteheadS1",t.NoteheadS2="NoteheadS2",t.NoteheadS1stemU="NoteheadS1stemU",t.NoteheadS1stemD="NoteheadS1stemD",t.NoteheadS2stemU="NoteheadS2stemU",t.NoteheadS2stemD="NoteheadS2stemD",t.vline_Stem="vline_Stem",t.Flag3="Flag3",t.BeamLeft="BeamLeft",t.BeamContinue="BeamContinue",t.BeamRight="BeamRight",t.TremoloLeft="TremoloLeft",t.TremoloRight="TremoloRight",t.TremoloMiddle="TremoloMiddle",t.Dot="Dot",t.Rest0="Rest0",t.Rest1="Rest1",t.Rest2="Rest2",t.Rest3="Rest3",t.Rest4="Rest4",t.Rest5="Rest5",t.Rest6="Rest6",t.Rest0W="Rest0W",t.RestM1="RestM1",t.AccNatural="AccNatural",t.AccSharp="AccSharp",t.AccDoublesharp="AccDoublesharp",t.AccFlat="AccFlat",t.AccFlatflat="AccFlatflat",t.vline_VoltaLeft="vline_VoltaLeft",t.vline_VoltaRight="vline_VoltaRight",t.VoltaLeft="VoltaLeft",t.VoltaRight="VoltaRight",t.VoltaAlternativeBegin="VoltaAlternativeBegin",t.BarMeasure="BarMeasure",t.vline_BarMeasure="vline_BarMeasure",t.vline_BarTerminal="vline_BarTerminal",t.vline_BarSegment="vline_BarSegment",t.SlurBegin="SlurBegin",t.SlurEnd="SlurEnd",t.TimesigC44="TimesigC44",t.TimesigC22="TimesigC22",t.TimesigZero="TimesigZero",t.TimesigOne="TimesigOne",t.TimesigTwo="TimesigTwo",t.TimesigThree="TimesigThree",t.TimesigFour="TimesigFour",t.TimesigFive="TimesigFive",t.TimesigSix="TimesigSix",t.TimesigSeven="TimesigSeven",t.TimesigEight="TimesigEight",t.TimesigNine="TimesigNine",t.OctaveShift8va="OctaveShift8va",t.OctaveShift8vb="OctaveShift8vb",t.OctaveShift8="OctaveShift8",t.OctaveShift0="OctaveShift0",t.Zero="Zero",t.One="One",t.Two="Two",t.Three="Three",t.Four="Four",t.Five="Five",t.Six="Six",t.Seven="Seven",t.Eight="Eight",t.Nine="Nine",t.f="f",t.p="p",t.m="m",t.n="n",t.r="r",t.s="s",t.z="z",t.CrescendoBegin="CrescendoBegin",t.CrescendoEnd="CrescendoEnd",t.DecrescendoBegin="DecrescendoBegin",t.DecrescendoEnd="DecrescendoEnd",t.ScriptFermata="ScriptFermata",t.ScriptShortFermata="ScriptShortFermata",t.ScriptSforzato="ScriptSforzato",t.ScriptStaccato="ScriptStaccato",t.ScriptStaccatissimo="ScriptStaccatissimo",t.ScriptTurn="ScriptTurn",t.ScriptTrill="ScriptTrill",t.ScriptSegno="ScriptSegno",t.ScriptCoda="ScriptCoda",t.ScriptArpeggio="ScriptArpeggio",t.ScriptPrall="ScriptPrall",t.ScriptMordent="ScriptMordent",t.ScriptMarcato="ScriptMarcato",t.ScriptTenuto="ScriptTenuto",t.ScriptPortato="ScriptPortato",t.PedalStar="PedalStar",t.PedalPed="PedalPed",t.KeyAcc="KeyAcc",t.TempoNotehead="TempoNotehead",t.GraceNotehead="GraceNotehead",t.SignLined="SignLined",t.SignInterval="SignInterval",t.rect_Text="rect_Text",t.rect_Lyric="rect_Lyric"}(SemanticType||(SemanticType={})),SemanticType.BarMeasure,SemanticType.vline_BarMeasure,SemanticType.vline_BarTerminal,SemanticType.vline_BarSegment,SemanticType.vline_VoltaLeft,SemanticType.vline_VoltaRight,SemanticType.VoltaAlternativeBegin;const st=SemanticType;st.NoteheadS0,st.NoteheadS1,st.NoteheadS2,st.Zero,st.One,st.Two,st.Three,st.Four,st.Five,st.Six,st.Seven,st.Eight,st.Nine,st.ScriptStaccatissimo,st.TimesigZero,st.TimesigOne,st.TimesigTwo,st.TimesigThree,st.TimesigFour,st.TimesigFive,st.TimesigSix,st.TimesigSeven,st.TimesigEight,st.TimesigNine,st.Rest0,st.Rest1,st.Rest2,st.Rest3,st.Rest4,st.Rest5,st.Rest6,st.Rest0W,st.RestM1,st.SignInterval,st.SignLined,st.BeamLeft,st.BeamContinue,st.BeamRight,st.ClefG,st.ClefF,st.ClefC,st.NoteheadS0,st.NoteheadS1,st.NoteheadS2,st.Dot,st.Rest0,st.Rest1,st.Rest2,st.Rest3,st.Rest4,st.Rest5,st.Rest6,st.RestM1,st.AccNatural,st.AccSharp,st.AccDoublesharp,st.AccFlat,st.AccFlatflat,st.TimesigC44,st.TimesigC22,st.TimesigZero,st.TimesigOne,st.TimesigTwo,st.TimesigThree,st.TimesigFour,st.TimesigFive,st.TimesigSix,st.TimesigSeven,st.TimesigEight,st.TimesigNine,st.One,st.Two,st.Three,st.Four,st.Five,st.OctaveShift8,st.OctaveShift0,st.f,st.p,st.m,st.n,st.r,st.s,st.z,st.ScriptFermata,st.ScriptShortFermata,st.ScriptSforzato,st.ScriptStaccato,st.ScriptStaccatissimo,st.ScriptTurn,st.ScriptTrill,st.ScriptSegno,st.ScriptCoda,st.ScriptArpeggio,st.ScriptPrall,st.ScriptMordent,st.ScriptMarcato,st.ScriptTenuto,st.ScriptPortato,st.PedalStar,st.PedalPed;const roundNumber=(t,e,s=-1/0)=>Math.max(Math.round(t/e)*e,s),gcd=(t,e)=>Number.isInteger(t)&&Number.isInteger(e)?0===e?t:gcd(e,t%e):(console.error("non-integer gcd:",t,e),1),frac=(t,e)=>({numerator:t,denominator:e}),reducedFraction=(t,e)=>{t=Math.round(t),e=Math.round(e);const s=0!==t?gcd(t,e):e;return frac(t/s,e/s)},fractionMul=(t,e)=>e?t*e.numerator/e.denominator:t;class DummyLogger{debug(...t){}group(...t){}groupCollapsed(...t){}groupEnd(){}info(...t){}warn(...t){}assert(...t){}}const EOM=-1,GREAT_NUMBER=1920,DURATION_MULTIPLIER=1921920,floatToFrac=t=>{const e=Math.round(t*GREAT_NUMBER);return reducedFraction(e,GREAT_NUMBER)},floatToTimeWarp=t=>1===t?null:floatToFrac(t);var ActionType;!function(t){t[t.PLACE=0]="PLACE",t[t.VERTICAL=1]="VERTICAL",t[t.HORIZONTAL=2]="HORIZONTAL"}(ActionType||(ActionType={}));class Action{constructor(t){Object.assign(this,t)}static P(t){return new Action({type:ActionType.PLACE,e1:t})}static V(t,e,s=1){return new Action({type:ActionType.VERTICAL,e1:s>0?t:e,e2:s>0?e:t})}static H(t,e){return new Action({type:ActionType.HORIZONTAL,e1:t,e2:e})}get id(){switch(this.type){case ActionType.PLACE:return this.e1.toString();case ActionType.VERTICAL:return`${this.e1}|${this.e2}`;case ActionType.HORIZONTAL:return`${this.e1}-${this.e2>=0?this.e2:"."}`}}get events(){return[this.e1,this.e2].filter(Number.isFinite)}}class StageMatrix{static fromNode(t,e){const s=Array(t.stages.length).fill(null).map(()=>Array(t.stages.length).fill(null).map(()=>new Set));t.actions.filter(t=>t.type===ActionType.HORIZONTAL).forEach(e=>{const i=t.stages.findIndex(t=>t.events.includes(e.e1)),n=t.stages.findIndex(t=>t.events.includes(e.e2));console.assert(i>=0&&n>=0,"invalid stages for H action:",t.id,t.stages,e),s[i][n].add(e.e1)}),s[0][t.stages.length-1].add(0);const i=t.stagedEvents,n=e.matrixH[e.matrixH.length-1].filter((t,e)=>!i.has(e)),r=Math.max(0,Math.max(...n)-.01),o=t.actions.filter(t=>t.type===ActionType.HORIZONTAL),a=Object.keys(e.eventMap).map(Number).filter(t=>!o.find(e=>e.e2===t));return t.stages.forEach(i=>{i.events.forEach(n=>{if(n>0){!o.find(t=>t.e1===n)&&e.matrixH[e.matrixH.length-1][n]>=r&&(a.some(t=>e.matrixH[t][n]>0)||s[i.index][t.stages.length-1].add(n))}})}),new StageMatrix({matrix:s})}constructor(t){Object.assign(this,t)}pathOf(t,e,s,i=0){if(this.matrix[t][e].size){const n=[...this.matrix[t][e]][i];if(e===s)return[n];for(let t=e+1;t<=s;++t){const i=this.pathOf(e,t,s);if(i)return[n,...i]}}return null}findDoublePath(t,e){const s=[];for(let i=e;i>=t+1;--i)for(let n=0;ne.forEach(e=>t.forEach(t=>e.delete(t))))}toEquations(t){const e=[];for(let s=1;sr[t]=1),n.forEach(t=>r[t]=-1),e.push(r),this.reducePath(i.length>n.length?i:n)}}}return e}}class PathNode{constructor(t){Object.assign(this,t),console.assert(this.logger,"logger is null:",t)}get actions(){const t=this.parent?this.parent.actions:[];return this.action?[...t,this.action]:t}get id(){return this.actions.map(t=>t.id).sort().join(" ")}get stagedEvents(){const t=new Set;return this.stages&&this.stages.forEach(e=>e.events.forEach(e=>e>=0&&t.add(e))),t}like(t){return t.split(" ").sort().join(" ")===this.id}constructStages(t){this.stages=[{events:[EOM]}];for(const e of this.actions)switch(e.type){case ActionType.PLACE:this.stages.unshift({events:[e.e1]});break;case ActionType.VERTICAL:{const t=this.stages.find(t=>t.events.includes(e.e1)),s=this.stages.find(t=>t.events.includes(e.e2));console.assert(t||s,"invalid V action:",this.stages,e),t&&s?(t.events.push(...s.events),s.events=null,this.stages=this.stages.filter(t=>t.events)):t?s||t.events.push(e.e2):s.events.unshift(e.e1)}break;case ActionType.HORIZONTAL:{const s=this.stages.find(t=>t.events.includes(e.e1)),i=this.stages.find(t=>t.events.includes(e.e2));console.assert(s||i,"invalid H action:",this.stages,e);const n=s=>{console.assert(t.eventMap[s],"invalid event id:",e.id,s,t.eventMap);const i=t.eventMap[s].x,n=this.stages.find(e=>e.events.some(e=>e>0&&t.eventMap[e].x<=i)&&e.events.some(e=>e>0&&t.eventMap[e].x>=i));if(n)n.events.push(s);else{const e={events:[s]},n=this.stages.findIndex(e=>e.events[0]===EOM||t.eventMap[e.events[0]].x>=i);this.stages.splice(n,0,e)}};s||n(e.e1),i||n(e.e2)}}this.stages.forEach((t,e)=>t.index=e)}constructConstraints(t){const e=Object.keys(t.eventMap).length,s=StageMatrix.fromNode(this,t).toEquations(e),i=Array(e).fill(null).map((e,s)=>t.eventMap[s].duration);this.constraints=s.map(t=>t.map((t,e)=>t*i[e]))}inbalancesConstraints(t){console.assert(this.constraints,"constraints not constructed.");const e=Object.keys(t.eventMap).length,s=Array(e).fill(!0),i=Array(e).fill(!1),n=[];for(const t of this.constraints){const e=t.reduce((t,e)=>t+e,0);if(0!==e){const r=e<0?t.map(t=>-t):t;if(r[0]>0)continue;n.push(r),r.forEach((t,e)=>{i[e]=i[e]||t<0,t&&(s[e]=t<0||i[e])})}}return this.constraints.forEach(t=>{0!==t.reduce((t,e)=>t+e,0)||t[0]||t.some((t,e)=>t&&!s[e])&&(t.forEach((t,e)=>t&&(s[e]=!1)),n.push(t))}),{ones:s,inbalances:n}}solveEquations({ones:t,inbalances:e}){if(!e.length)return t.map(()=>1);const s=t.map((t,e)=>({fixed:t,i:e})).filter(({fixed:t})=>!t).map(({i:t})=>t).filter(t=>e.some(e=>0!==e[t]));if(!s.length)return t.map(()=>1);const i=s.map(t=>Math.abs(e.find(e=>0!==e[t])[t])),n=new Map;let r=!1;const o=e.map(t=>({line:t.filter((t,e)=>s.includes(e)),bias:-t.reduce((t,e,i)=>t+(s.includes(i)?0:e),0)})).filter(({line:t,bias:e})=>{if(t.every(t=>0===t))return!1;const s=t.join(",");return n.has(s)?(r=n.get(s)!==e,!1):(n.set(s,e),!0)});if(r)return null;const a=o.slice(0,s.length),c=o.slice(s.length);if(a.lengths===e?1:s===n?-1:0),bias:0,prior:(i[e]+i[n])/DURATION_MULTIPLIER};a.some(t=>t.line[e]&&t.line[n])&&(r.prior-=10),a.some(t=>1===t.line.filter(Number).length&&(t.line[e]||t.line[n]))&&(r.prior+=1),t.push(r)}t.sort((t,e)=>t.prior-e.prior),a.push(...t.slice(0,s.length-a.length))}const h=a.map(({line:t})=>t),l=a.map(({bias:t})=>t),u=matrixInverse(h);if(!u)return this.logger.warn("null invert:",h),null;const d=u.map(t=>t.reduce((t,e,s)=>t+e*l[s],0));if(c.length&&c.some(t=>Math.abs(t.line.reduce((t,e,s)=>t+e*d[s],0))>.001))return null;const f=t.map(()=>1);return s.forEach((t,e)=>f[t]=d[e]),f}optimallySolve(t){const{ones:e,inbalances:s}=this.inbalancesConstraints(t),i=e.map((e,s)=>e?-1:roundNumber(t.eventMap[s].shrinkness,.01)).reduce((t,e,s)=>(e>=0&&(t[e]=t[e]||[],t[e].push(s)),t),{}),n=Object.entries(i).sort((t,e)=>Number(e[0])-Number(t[0])).map(t=>t[1]);for(let i=1;i!r.includes(e)),a=this.solveEquations({ones:o,inbalances:s});if(a&&a.every((e,s)=>e<=1&&e>t.eventMap[s].lowWarp))return a}return this.solveEquations({ones:e,inbalances:s})}isConflicted(t){const{ones:e,inbalances:s}=this.inbalancesConstraints(t);for(const i of s){if(i.reduce((s,i,n)=>s+i*(e[n]||i<=0?1:t.eventMap[n].lowWarp),0)>=0)return i.forEach((e,s)=>{e&&(t.eventTendencies[s]+=e>0?1:-1)}),!0}if(!s.length)return!1;const i=this.solveEquations({ones:e,inbalances:s});return!i||!i.every((e,s)=>e>t.eventMap[s].lowWarp&&e<=1)}getSolution(t){const e=e=>t.eventMap[e.e2]?t.eventMap[e.e2].x+.06*Math.abs(t.eventMap[e.e2].x-t.eventMap[e.e1].x):t.eventMap[e.e1].x+1e4,s=this.actions.filter(t=>t.type===ActionType.HORIZONTAL).sort((t,s)=>e(t)-e(s)),i=s.reduce((t,e)=>({...t,[e.e1]:e.e2}),{}),n=new Set([...Object.keys(i)].map(Number));s.forEach(t=>n.delete(t.e2)),this.stages[0].events.forEach(t=>t>0&&n.add(t));let r=[...n].map(t=>{const e=[t];let s=t;for(;i[s]&&(s=i[s],!(s<0||e.includes(s)));)e.push(s);return e});const o=Object.values(t.eventMap).filter(t=>t.id>0).map(t=>({id:t.id,tick:null,endTick:null,tickGroup:null,timeWarp:null})),a=o.filter(t=>r.some(e=>e.includes(t.id))||s.some(e=>[e.e1,e.e2].includes(t.id))).reduce((t,e)=>({...t,[e.id]:e}),{});this.stages.forEach((t,e)=>t.events.forEach(t=>a[t]&&(a[t].tickGroup=e))),this.stages[0].tick=0,this.stages[0].events.forEach(t=>a[t]&&(a[t].tick=0));const c=this.optimallySolve(t);o.forEach(t=>t.timeWarp=floatToTimeWarp(c[t.id]));const h=this.stages.slice(0,this.stages.length-1),l=()=>{if(h.every(t=>Number.isFinite(t.tick)))return!1;let e=!1;return s.forEach(s=>{const i=this.stages.find(t=>t.events.includes(s.e1)),n=this.stages.find(t=>t.events.includes(s.e2));Number.isFinite(i.tick)&&!Number.isFinite(n.tick)&&(n.tick=i.tick+fractionMul(t.eventMap[s.e1].duration,a[s.e1].timeWarp),n.events.forEach(t=>a[t]&&(a[t].tick=n.tick)),e=!0)}),[...s].reverse().forEach(s=>{const i=this.stages.find(t=>t.events.includes(s.e1)),n=this.stages.find(t=>t.events.includes(s.e2));!Number.isFinite(i.tick)&&Number.isFinite(n.tick)&&(i.tick=n.tick-fractionMul(t.eventMap[s.e1].duration,a[s.e1].timeWarp),i.events.forEach(t=>a[t]&&(a[t].tick=i.tick)),e=!0)}),e};for(;l(););console.assert(h.every(t=>Number.isFinite(t.tick)),"stage ticks not all solved:",this.stages,this.id),o.filter(t=>Number.isFinite(t.tick)).forEach(e=>e.endTick=e.tick+fractionMul(t.eventMap[e.id].duration,e.timeWarp));const u=t.eventMap[0].duration;r.forEach(t=>{const e=t.findIndex(t=>a[t].endTick>u);if(e>=0){t.splice(e,t.length-e).forEach(t=>{a[t].tick=null,a[t].endTick=null})}}),r=r.filter(t=>t.length);const d=Math.max(0,...o.map(t=>t.endTick).filter(Number.isFinite));return this.logger.debug(String.fromCodePoint(127822),this.id,c),{voices:r,events:o,duration:d,actions:this.actions.map(t=>t.id).join(" ")}}deduce(t,e){this.stages||this.constructStages(t);const s=t.actionAccessing.get(this.id)||{times:0};if(++s.times,t.actionAccessing.set(this.id,s),this.constructConstraints(t),this.isConflicted(t))return s.closed=!0,this.logger.info(this.action.id,"❌"),null;if(this.logger.group(this.action&&this.action.id),e.credits>0){if(--e.credits,this.children||this.expand(t),this.children=this.children.filter(e=>!t.actionAccessing.get(e.id)||!t.actionAccessing.get(e.id).closed),this.children.length){const s=e=>e.possibility/((t.actionAccessing.get(e.id)||{times:0}).times+1);this.children.sort((t,e)=>s(e)-s(t));for(const s of this.children){const i=s.deduce(t,e);if(i)return this.logger.groupEnd(),i;if(e.credits<=0)break}}}else this.logger.debug("quota exhausted.");return this.logger.groupEnd(),s.closed=!0,this.getSolution(t)}expand(t){this.constructStages(t);const{eventMap:e,matrixV:s,matrixH:i}=t,n=this.stagedEvents,r=[],o=t=>{if(!this.actions.some(e=>e.id===t.action.id)&&!r.some(e=>e.action.id===t.action.id)){const e=this.stages.find(e=>e.events.includes(t.action.e1)),i=this.stages.find(e=>e.events.includes(t.action.e2));if(e===i||e&&i&&e.index>=i.index)return;if(e&&i)if(t.action.type===ActionType.VERTICAL){if(i.index-e.index>1)return;if(this.actions.some(t=>e.events.includes(t.e1)&&i.events.includes(t.e2)))return}else if(t.action.type===ActionType.HORIZONTAL&&e.index>i.index)return;if(t.action.type===ActionType.HORIZONTAL&&this.actions.some(e=>e.type===ActionType.HORIZONTAL&&(e.e1===t.action.e1||e.e2===t.action.e2||e.e1===t.action.e2&&e.e2===t.action.e1)))return;if(t.action.type===ActionType.VERTICAL){if(e&&(t.possibility=Math.min(t.possibility,...e.events.map(e=>s[t.action.e2][e])),t.possibility<=0))return;if(i&&(t.possibility=Math.min(t.possibility,...i.events.map(e=>s[e][t.action.e1])),t.possibility<=0))return}r.push(t)}};for(const t of n)t<0||(s[t].forEach((e,s)=>{e>0&&t!==s&&o({action:Action.V(s,t),possibility:e})}),s.forEach((e,s)=>{const i=e[t];i>0&&o({action:Action.V(t,s),possibility:i})}),i[t].forEach((e,s)=>{e>0&&o({action:Action.H(s,t),possibility:e})}),i.forEach((s,i)=>{i=i>=Object.keys(e).length?-1:i;const n=s[t];n>0&&o({action:Action.H(t,i),possibility:n})}));r.some(t=>[ActionType.HORIZONTAL,ActionType.PLACE].includes(t.action.type)||!n.has(t.action.e1)||!n.has(t.action.e2))?this.children=r.map(t=>new PathNode({logger:this.logger,parent:this,...t})):this.children=[]}}class Solver{constructor(t,{quota:e=1e3,logger:s=new DummyLogger}={}){this.quota=e,this.logger=s;const i={id:0,x:0,confidence:1,shrinkness:t.measureShrinkness,duration:t.expectedDuration,lowWarp:0};this.events=[i,...t.events.map(t=>({id:t.id,x:t.x,confidence:t.confidence,shrinkness:t.shrinkness,staff:t.staff,duration:t.duration,lowWarp:.5}))],this.eventMap=this.events.reduce((t,e)=>({...t,[e.id]:e}),{}),this.matrixH=t.matrixH,this.matrixV=t.matrixV,this.xSpan=t.endX-Math.min(t.endX-1,...t.events.map(t=>t.x)),this.actionAccessing=new Map}solve(){this.pathRoot=new PathNode({logger:this.logger,action:null}),this.pathRoot.children=this.events.slice(1).map(t=>new PathNode({logger:this.logger,parent:this.pathRoot,action:Action.P(t.id),possibility:this.matrixV[t.id].reduce((t,e)=>t+e,0)}));let t=null;this.logger.groupCollapsed("solve");const e=Array(this.events.length).fill(0),s={credits:this.quota,times:0};for(;s.credits>0;){++s.times;const i={eventMap:this.eventMap,matrixH:this.matrixH,matrixV:this.matrixV,actionAccessing:this.actionAccessing,eventTendencies:e},n=this.pathRoot.deduce(i,s);if(n.credits=this.quota-s.credits,n.times=s.times,this.evaluateSolution(n),this.logger.debug("loss:",n.loss),t=!t||n.losst/s.times)),t}evaluateSolution(t){t.loss=0;const e=t.events.reduce((t,e)=>({...t,[e.id]:{...e,...this.eventMap[e.id]}}),{}),s=t.events.filter(t=>Number.isFinite(t.tick)).map(t=>e[t.id]),i=s.reduce((t,e)=>(t[e.staff]=t[e.staff]||[],t[e.staff].push(e),t),{});Object.values(i).forEach(e=>{e.sort((t,e)=>t.x-e.x).slice(0,e.length-1).forEach((s,i)=>{e[i+1].tick{if(Number.isFinite(s.tick)&&!t.voices.every(t=>!t.includes(s.id))||(t.loss+=100*e[s.id].confidence),s.timeWarp){const{numerator:t,denominator:i}=s.timeWarp,r=e[s.id].shrinkness;n.set(t,Math.max(n.get(t)||0,1-r)),n.set(i,Math.max(n.get(i)||0,1-r))}});const r=reducedFraction(t.duration,this.eventMap[0].duration);n.set(r.numerator,Math.max(n.get(r.numerator)||0,1-this.eventMap[0].shrinkness)),n.set(r.denominator,Math.max(n.get(r.denominator)||0,1-this.eventMap[0].shrinkness));for(const[e,s]of n.entries())e>1&&(t.loss+=Math.log(e)*s);let o=0,a=0;t.voices.forEach(s=>{console.assert(e[s[0]],"invalid voice:",s,Object.keys(e));const i=Math.abs(e[s[0]].tick),n=e[s[s.length-1]].endTick;o+=Math.max(0,i+t.duration-n);let r=null;s.forEach(t=>{const s=e[t];s.staff!==r&&(null!==r&&++a,r=s.staff)})}),t.loss+=10*o/DURATION_MULTIPLIER,t.loss+=5**a-1;const c=[...s].sort((t,e)=>t.x-e.x),h=c.slice(1).map((e,s)=>{const i=c[s],n=e.x-i.x,r=e.tick-i.tick;if(!r)return n/this.xSpan;return(4*Math.atan2(r/t.duration,n/this.xSpan)/Math.PI-1)**2}),l=Math.max(...h,0);t.loss+=l**2,console.assert(t.loss>=0,"Invalid solution loss!!!",t.loss,n,o,a),t.loss<0&&(t.loss=1/0)}}const solveStaffGroup=(t,e)=>{if(!t.events.length)return{events:[],voices:[],duration:0};return new Solver(t,e).solve()};self.onmessage=t=>{const{id:e,args:s}=t.data;try{const t=solveStaffGroup(s[0],s[1]);self.postMessage({id:e,result:t})}catch(t){self.postMessage({id:e,error:t.message})}},console.info("%cstarry-omr%c v1.0.0 2026-07-24T11:52:13.295Z","color:#fff; background-color: #555;padding: 5px;border-radius: 3px 0 0 3px;","color: #fff; background-color: #007dc6;padding: 5px;border-radius: 0 3px 3px 0;")})(); //# sourceMappingURL=worker.js.map diff --git a/dist/assets/DeleteOutlined-a511b2d4.js b/dist/assets/DeleteOutlined-e5d1e611.js similarity index 90% rename from dist/assets/DeleteOutlined-a511b2d4.js rename to dist/assets/DeleteOutlined-e5d1e611.js index 0776878754acddc0de4313bf212ecbf1a24d2c50..d138fca7cbde782be484dd3d6844c5af008bda77 100644 --- a/dist/assets/DeleteOutlined-a511b2d4.js +++ b/dist/assets/DeleteOutlined-e5d1e611.js @@ -1 +1 @@ -import{r as t,A as a,i as e}from"./umi-9940633e.js";var n={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M360 184h-8c4.4 0 8-3.6 8-8v8h304v-8c0 4.4 3.6 8 8 8h-8v72h72v-80c0-35.3-28.7-64-64-64H352c-35.3 0-64 28.7-64 64v80h72v-72zm504 72H160c-17.7 0-32 14.3-32 32v32c0 4.4 3.6 8 8 8h60.4l24.7 523c1.6 34.1 29.8 61 63.9 61h454c34.2 0 62.3-26.8 63.9-61l24.7-523H888c4.4 0 8-3.6 8-8v-32c0-17.7-14.3-32-32-32zM731.3 840H292.7l-24.2-512h487l-24.2 512z"}}]},name:"delete",theme:"outlined"};const r=n;var o=function(c,l){return t.createElement(a,e(e({},c),{},{ref:l,icon:r}))},v=t.forwardRef(o);const s=v;export{s as D}; +import{r as t,A as a,i as e}from"./umi-a12c8253.js";var n={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M360 184h-8c4.4 0 8-3.6 8-8v8h304v-8c0 4.4 3.6 8 8 8h-8v72h72v-80c0-35.3-28.7-64-64-64H352c-35.3 0-64 28.7-64 64v80h72v-72zm504 72H160c-17.7 0-32 14.3-32 32v32c0 4.4 3.6 8 8 8h60.4l24.7 523c1.6 34.1 29.8 61 63.9 61h454c34.2 0 62.3-26.8 63.9-61l24.7-523H888c4.4 0 8-3.6 8-8v-32c0-17.7-14.3-32-32-32zM731.3 840H292.7l-24.2-512h487l-24.2 512z"}}]},name:"delete",theme:"outlined"};const r=n;var o=function(c,l){return t.createElement(a,e(e({},c),{},{ref:l,icon:r}))},v=t.forwardRef(o);const s=v;export{s as D}; diff --git a/dist/assets/DownloadOutlined-0b32cbf8.js b/dist/assets/DownloadOutlined-b3f9ad21.js similarity index 89% rename from dist/assets/DownloadOutlined-0b32cbf8.js rename to dist/assets/DownloadOutlined-b3f9ad21.js index 6ebdc8736fa03552375841307fb491b35ccdacb0..d7297f0c08e31cb0803aa720a2531f513c97f751 100644 --- a/dist/assets/DownloadOutlined-0b32cbf8.js +++ b/dist/assets/DownloadOutlined-b3f9ad21.js @@ -1 +1 @@ -import{r as a,A as n,i as o}from"./umi-9940633e.js";var c={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M505.7 661a8 8 0 0012.6 0l112-141.7c4.1-5.2.4-12.9-6.3-12.9h-74.1V168c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8v338.3H400c-6.7 0-10.4 7.7-6.3 12.9l112 141.8zM878 626h-60c-4.4 0-8 3.6-8 8v154H214V634c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8v198c0 17.7 14.3 32 32 32h684c17.7 0 32-14.3 32-32V634c0-4.4-3.6-8-8-8z"}}]},name:"download",theme:"outlined"};const r=c;var d=function(t,e){return a.createElement(n,o(o({},t),{},{ref:e,icon:r}))},l=a.forwardRef(d);const u=l;export{u as D}; +import{r as a,A as n,i as o}from"./umi-a12c8253.js";var c={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M505.7 661a8 8 0 0012.6 0l112-141.7c4.1-5.2.4-12.9-6.3-12.9h-74.1V168c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8v338.3H400c-6.7 0-10.4 7.7-6.3 12.9l112 141.8zM878 626h-60c-4.4 0-8 3.6-8 8v154H214V634c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8v198c0 17.7 14.3 32 32 32h684c17.7 0 32-14.3 32-32V634c0-4.4-3.6-8-8-8z"}}]},name:"download",theme:"outlined"};const r=c;var d=function(t,e){return a.createElement(n,o(o({},t),{},{ref:e,icon:r}))},l=a.forwardRef(d);const u=l;export{u as D}; diff --git a/dist/assets/EditOutlined-fac0ac1a.js b/dist/assets/EditOutlined-d468c101.js similarity index 99% rename from dist/assets/EditOutlined-fac0ac1a.js rename to dist/assets/EditOutlined-d468c101.js index c5f96f54c1f44418456b385355d413e366e3cdeb..ac0ff65130faf6e104aaa07107246feddfd26029 100644 --- a/dist/assets/EditOutlined-fac0ac1a.js +++ b/dist/assets/EditOutlined-d468c101.js @@ -1 +1 @@ -import{r as t,A as $t,i as N,K as Y,Q as An,_ as pe,w as Re,b as w,a as F,T as Dt,d as B,aF as _n,c as oe,G as kn,U as Ln,F as $n,E as Dn,z as Tn,e as Vn,t as Fn}from"./umi-9940633e.js";import{d as Tt,i as zn,K as te,u as Xe,G as Te,c as Vt}from"./TextArea-b3aeb374.js";import{o as Ft}from"./_setToString-98c064b8.js";import{t as Un}from"./button-eaadfeb4.js";var Wn={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M176 511a56 56 0 10112 0 56 56 0 10-112 0zm280 0a56 56 0 10112 0 56 56 0 10-112 0zm280 0a56 56 0 10112 0 56 56 0 10-112 0z"}}]},name:"ellipsis",theme:"outlined"};const Hn=Wn;var jn=function(n,a){return t.createElement($t,N(N({},n),{},{ref:a,icon:Hn}))},Gn=t.forwardRef(jn);const Wr=Gn;var zt=t.createContext(null);function ft(e,n){return e===void 0?null:"".concat(e,"-").concat(n)}function Ut(e){var n=t.useContext(zt);return ft(n,e)}var qn=["children","locked"],ee=t.createContext(null);function Bn(e,n){var a=N({},e);return Object.keys(n).forEach(function(o){var r=n[o];r!==void 0&&(a[o]=r)}),a}function Ve(e){var n=e.children,a=e.locked,o=Y(e,qn),r=t.useContext(ee),l=An(function(){return Bn(r,o)},[r,o],function(i,u){return!a&&(i[0]!==u[0]||!Tt(i[1],u[1],!0))});return t.createElement(ee.Provider,{value:l},n)}var Yn=[],Wt=t.createContext(null);function et(){return t.useContext(Wt)}var Ht=t.createContext(Yn);function Fe(e){var n=t.useContext(Ht);return t.useMemo(function(){return e!==void 0?[].concat(pe(n),[e]):n},[n,e])}var jt=t.createContext(null),mt=t.createContext({});function Ot(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(zn(e)){var a=e.nodeName.toLowerCase(),o=["input","select","textarea","button"].includes(a)||e.isContentEditable||a==="a"&&!!e.getAttribute("href"),r=e.getAttribute("tabindex"),l=Number(r),i=null;return r&&!Number.isNaN(l)?i=l:o&&i===null&&(i=0),o&&e.disabled&&(i=null),i!==null&&(i>=0||n&&i<0)}return!1}function Gt(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,a=pe(e.querySelectorAll("*")).filter(function(o){return Ot(o,n)});return Ot(e,n)&&a.unshift(e),a}var ut=te.LEFT,st=te.RIGHT,ct=te.UP,Je=te.DOWN,Ze=te.ENTER,qt=te.ESC,$e=te.HOME,De=te.END,At=[ct,Je,ut,st];function Xn(e,n,a,o){var r,l,i,u,s="prev",c="next",m="children",g="parent";if(e==="inline"&&o===Ze)return{inlineTrigger:!0};var d=(r={},w(r,ct,s),w(r,Je,c),r),h=(l={},w(l,ut,a?c:s),w(l,st,a?s:c),w(l,Je,m),w(l,Ze,m),l),v=(i={},w(i,ct,s),w(i,Je,c),w(i,Ze,m),w(i,qt,g),w(i,ut,a?m:g),w(i,st,a?g:m),i),y={inline:d,horizontal:h,vertical:v,inlineSub:d,horizontalSub:v,verticalSub:v},M=(u=y["".concat(e).concat(n?"":"Sub")])===null||u===void 0?void 0:u[o];switch(M){case s:return{offset:-1,sibling:!0};case c:return{offset:1,sibling:!0};case g:return{offset:-1,sibling:!1};case m:return{offset:1,sibling:!1};default:return null}}function Jn(e){for(var n=e;n;){if(n.getAttribute("data-menu-list"))return n;n=n.parentElement}return null}function Zn(e,n){for(var a=e||document.activeElement;a;){if(n.has(a))return a;a=a.parentElement}return null}function Bt(e,n){var a=Gt(e,!0);return a.filter(function(o){return n.has(o)})}function _t(e,n,a){var o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:1;if(!e)return null;var r=Bt(e,n),l=r.length,i=r.findIndex(function(u){return a===u});return o<0?i===-1?i=l-1:i-=1:o>0&&(i+=1),i=(i+l)%l,r[i]}function Qn(e,n,a,o,r,l,i,u,s,c){var m=t.useRef(),g=t.useRef();g.current=n;var d=function(){Re.cancel(m.current)};return t.useEffect(function(){return function(){d()}},[]),function(h){var v=h.which;if([].concat(At,[Ze,qt,$e,De]).includes(v)){var y,M,S,O=function(){y=new Set,M=new Map,S=new Map;var V=l();return V.forEach(function(k){var _=document.querySelector("[data-menu-id='".concat(ft(o,k),"']"));_&&(y.add(_),S.set(_,k),M.set(k,_))}),y};O();var C=M.get(n),p=Zn(C,y),b=S.get(p),f=Xn(e,i(b,!0).length===1,a,v);if(!f&&v!==$e&&v!==De)return;(At.includes(v)||[$e,De].includes(v))&&h.preventDefault();var U=function(V){if(V){var k=V,_=V.querySelector("a");_!=null&&_.getAttribute("href")&&(k=_);var ne=S.get(V);u(ne),d(),m.current=Re(function(){g.current===ne&&k.focus()})}};if([$e,De].includes(v)||f.sibling||!p){var P;!p||e==="inline"?P=r.current:P=Jn(p);var W,T=Bt(P,y);v===$e?W=T[0]:v===De?W=T[T.length-1]:W=_t(P,y,p,f.offset),U(W)}else if(f.inlineTrigger)s(b);else if(f.offset>0)s(b,!0),d(),m.current=Re(function(){O();var D=p.getAttribute("aria-controls"),V=document.getElementById(D),k=_t(V,y);U(k)},5);else if(f.offset<0){var A=i(b,!0),$=A[A.length-2],Z=M.get($);s($,!1),U(Z)}}c==null||c(h)}}function er(e){Promise.resolve().then(e)}var pt="__RC_UTIL_PATH_SPLIT__",kt=function(n){return n.join(pt)},tr=function(n){return n.split(pt)},dt="rc-menu-more";function nr(){var e=t.useState({}),n=F(e,2),a=n[1],o=t.useRef(new Map),r=t.useRef(new Map),l=t.useState([]),i=F(l,2),u=i[0],s=i[1],c=t.useRef(0),m=t.useRef(!1),g=function(){m.current||a({})},d=t.useCallback(function(C,p){var b=kt(p);r.current.set(b,C),o.current.set(C,b),c.current+=1;var f=c.current;er(function(){f===c.current&&g()})},[]),h=t.useCallback(function(C,p){var b=kt(p);r.current.delete(b),o.current.delete(C)},[]),v=t.useCallback(function(C){s(C)},[]),y=t.useCallback(function(C,p){var b=o.current.get(C)||"",f=tr(b);return p&&u.includes(f[0])&&f.unshift(dt),f},[u]),M=t.useCallback(function(C,p){return C.some(function(b){var f=y(b,!0);return f.includes(p)})},[y]),S=function(){var p=pe(o.current.keys());return u.length&&p.push(dt),p},O=t.useCallback(function(C){var p="".concat(o.current.get(C)).concat(pt),b=new Set;return pe(r.current.keys()).forEach(function(f){f.startsWith(p)&&b.add(r.current.get(f))}),b},[]);return t.useEffect(function(){return function(){m.current=!0}},[]),{registerPath:d,unregisterPath:h,refreshOverflowKeys:v,isSubPathKey:M,getKeyPath:y,getKeys:S,getSubPathKeys:O}}function Ee(e){var n=t.useRef(e);n.current=e;var a=t.useCallback(function(){for(var o,r=arguments.length,l=new Array(r),i=0;i1&&(O.motionAppear=!1);var C=O.onVisibleChanged;return O.onVisibleChanged=function(p){return!d.current&&!p&&M(!0),C==null?void 0:C(p)},y?null:t.createElement(Ve,{mode:l,locked:!d.current},t.createElement(Vn,B({visible:S},O,{forceRender:s,removeOnLeave:!1,leavedClassName:"".concat(u,"-hidden")}),function(p){var b=p.className,f=p.style;return t.createElement(ht,{id:n,className:b,style:f},r)}))}var Ir=["style","className","title","eventKey","warnKey","disabled","internalPopupClose","children","itemIcon","expandIcon","popupClassName","popupOffset","onClick","onMouseEnter","onMouseLeave","onTitleClick","onTitleMouseEnter","onTitleMouseLeave"],Mr=["active"],Sr=function(n){var a,o=n.style,r=n.className,l=n.title,i=n.eventKey;n.warnKey;var u=n.disabled,s=n.internalPopupClose,c=n.children,m=n.itemIcon,g=n.expandIcon,d=n.popupClassName,h=n.popupOffset,v=n.onClick,y=n.onMouseEnter,M=n.onMouseLeave,S=n.onTitleClick,O=n.onTitleMouseEnter,C=n.onTitleMouseLeave,p=Y(n,Ir),b=Ut(i),f=t.useContext(ee),U=f.prefixCls,P=f.mode,W=f.openKeys,T=f.disabled,A=f.overflowDisabled,$=f.activeKey,Z=f.selectedKeys,D=f.itemIcon,V=f.expandIcon,k=f.onItemClick,_=f.onOpenChange,ne=f.onActive,le=t.useContext(mt),re=le._internalRenderSubMenuItem,Q=t.useContext(jt),L=Q.isSubPathKey,I=Fe(),R="".concat(U,"-submenu"),H=T||u,ge=t.useRef(),he=t.useRef(),de=m||D,ue=g||V,j=W.includes(i),z=!A&&j,ze=L(Z,i),Ue=Yt(i,H,O,C),Pe=Ue.active,xe=Y(Ue,Mr),we=t.useState(!1),We=F(we,2),Ne=We[0],He=We[1],je=function(J){H||He(J)},ae=function(J){je(!0),y==null||y({key:i,domEvent:J})},nt=function(J){je(!1),M==null||M({key:i,domEvent:J})},Ke=t.useMemo(function(){return Pe||(P!=="inline"?Ne||L([$],i):!1)},[P,Pe,$,Ne,i,L]),Ge=Xt(I.length),rt=function(J){H||(S==null||S({key:i,domEvent:J}),P==="inline"&&_(i,!j))},Ce=Ee(function(ie){v==null||v(Qe(ie)),k(ie)}),Oe=function(J){P!=="inline"&&_(i,J)},Ae=function(){ne(i)},_e=b&&"".concat(b,"-popup"),be=t.createElement("div",B({role:"menuitem",style:Ge,className:"".concat(R,"-title"),tabIndex:H?null:-1,ref:ge,title:typeof l=="string"?l:null,"data-menu-id":A&&b?null:b,"aria-expanded":z,"aria-haspopup":!0,"aria-controls":_e,"aria-disabled":H,onClick:rt,onFocus:Ae},xe),l,t.createElement(Jt,{icon:P!=="horizontal"?ue:null,props:N(N({},n),{},{isOpen:z,isSubMenu:!0})},t.createElement("i",{className:"".concat(R,"-arrow")}))),X=t.useRef(P);if(P!=="inline"&&I.length>1?X.current="vertical":X.current=P,!A){var ye=X.current;be=t.createElement(br,{mode:ye,prefixCls:R,visible:!s&&z&&P!=="inline",popupClassName:d,popupOffset:h,popup:t.createElement(Ve,{mode:ye==="horizontal"?"vertical":ye},t.createElement(ht,{id:_e,ref:he},c)),disabled:H,onVisibleChange:Oe},be)}var ve=t.createElement(Te.Item,B({role:"none"},p,{component:"li",style:o,className:oe(R,"".concat(R,"-").concat(P),r,(a={},w(a,"".concat(R,"-open"),z),w(a,"".concat(R,"-active"),Ke),w(a,"".concat(R,"-selected"),ze),w(a,"".concat(R,"-disabled"),H),a)),onMouseEnter:ae,onMouseLeave:nt}),be,!A&&t.createElement(yr,{id:_e,open:z,keyPath:I},c));return re&&(ve=re(ve,n,{selected:ze,active:Ke,open:z,disabled:H})),t.createElement(Ve,{onItemClick:Ce,mode:P==="horizontal"?"vertical":P,itemIcon:de,expandIcon:ue},ve)};function bt(e){var n=e.eventKey,a=e.children,o=Fe(n),r=Ct(a,o),l=et();t.useEffect(function(){if(l)return l.registerPath(n,o),function(){l.unregisterPath(n,o)}},[o]);var i;return l?i=r:i=t.createElement(Sr,e,r),t.createElement(Ht.Provider,{value:o},i)}var Er=["prefixCls","rootClassName","style","className","tabIndex","items","children","direction","id","mode","inlineCollapsed","disabled","disabledOverflow","subMenuOpenDelay","subMenuCloseDelay","forceSubMenuRender","defaultOpenKeys","openKeys","activeKey","defaultActiveFirst","selectable","multiple","defaultSelectedKeys","selectedKeys","onSelect","onDeselect","inlineIndent","motion","defaultMotions","triggerSubMenuAction","builtinPlacements","itemIcon","expandIcon","overflowedIndicator","overflowedIndicatorPopupClassName","getPopupContainer","onClick","onOpenChange","onKeyDown","openAnimation","openTransitionName","_internalRenderMenuItem","_internalRenderSubMenuItem"],Ie=[],Rr=t.forwardRef(function(e,n){var a,o,r=e,l=r.prefixCls,i=l===void 0?"rc-menu":l,u=r.rootClassName,s=r.style,c=r.className,m=r.tabIndex,g=m===void 0?0:m,d=r.items,h=r.children,v=r.direction,y=r.id,M=r.mode,S=M===void 0?"vertical":M,O=r.inlineCollapsed,C=r.disabled,p=r.disabledOverflow,b=r.subMenuOpenDelay,f=b===void 0?.1:b,U=r.subMenuCloseDelay,P=U===void 0?.1:U,W=r.forceSubMenuRender,T=r.defaultOpenKeys,A=r.openKeys,$=r.activeKey,Z=r.defaultActiveFirst,D=r.selectable,V=D===void 0?!0:D,k=r.multiple,_=k===void 0?!1:k,ne=r.defaultSelectedKeys,le=r.selectedKeys,re=r.onSelect,Q=r.onDeselect,L=r.inlineIndent,I=L===void 0?24:L,R=r.motion,H=r.defaultMotions,ge=r.triggerSubMenuAction,he=ge===void 0?"hover":ge,de=r.builtinPlacements,ue=r.itemIcon,j=r.expandIcon,z=r.overflowedIndicator,ze=z===void 0?"...":z,Ue=r.overflowedIndicatorPopupClassName,Pe=r.getPopupContainer,xe=r.onClick,we=r.onOpenChange,We=r.onKeyDown;r.openAnimation,r.openTransitionName;var Ne=r._internalRenderMenuItem,He=r._internalRenderSubMenuItem,je=Y(r,Er),ae=t.useMemo(function(){return pr(h,d,Ie)},[h,d]),nt=t.useState(!1),Ke=F(nt,2),Ge=Ke[0],rt=Ke[1],Ce=t.useRef(),Oe=ar(y),Ae=v==="rtl",_e=Xe(T,{value:A,postState:function(E){return E||Ie}}),be=F(_e,2),X=be[0],ye=be[1],ve=function(E){var x=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;function G(){ye(E),we==null||we(E)}x?Fn.flushSync(G):G()},ie=t.useState(X),J=F(ie,2),tn=J[0],nn=J[1],at=t.useRef(!1),rn=t.useMemo(function(){return(S==="inline"||S==="vertical")&&O?["vertical",O]:[S,!1]},[S,O]),yt=F(rn,2),qe=yt[0],it=yt[1],It=qe==="inline",an=t.useState(qe),Mt=F(an,2),se=Mt[0],on=Mt[1],ln=t.useState(it),St=F(ln,2),un=St[0],sn=St[1];t.useEffect(function(){on(qe),sn(it),at.current&&(It?ye(tn):ve(Ie))},[qe,it]);var cn=t.useState(0),Et=F(cn,2),Be=Et[0],dn=Et[1],ot=Be>=ae.length-1||se!=="horizontal"||p;t.useEffect(function(){It&&nn(X)},[X]),t.useEffect(function(){return at.current=!0,function(){at.current=!1}},[]);var fe=nr(),Rt=fe.registerPath,Pt=fe.unregisterPath,vn=fe.refreshOverflowKeys,xt=fe.isSubPathKey,fn=fe.getKeyPath,mn=fe.getKeys,pn=fe.getSubPathKeys,gn=t.useMemo(function(){return{registerPath:Rt,unregisterPath:Pt}},[Rt,Pt]),hn=t.useMemo(function(){return{isSubPathKey:xt}},[xt]);t.useEffect(function(){vn(ot?Ie:ae.slice(Be+1).map(function(K){return K.key}))},[Be,ot]);var Cn=Xe($||Z&&((a=ae[0])===null||a===void 0?void 0:a.key),{value:$}),wt=F(Cn,2),ke=wt[0],lt=wt[1],bn=Ee(function(K){lt(K)}),yn=Ee(function(){lt(void 0)});t.useImperativeHandle(n,function(){return{list:Ce.current,focus:function(E){var x,G=ke??((x=ae.find(function(On){return!On.props.disabled}))===null||x===void 0?void 0:x.key);if(G){var q,me,Le;(q=Ce.current)===null||q===void 0||(me=q.querySelector("li[data-menu-id='".concat(ft(Oe,G),"']")))===null||me===void 0||(Le=me.focus)===null||Le===void 0||Le.call(me,E)}}}});var In=Xe(ne||[],{value:le,postState:function(E){return Array.isArray(E)?E:E==null?Ie:[E]}}),Nt=F(In,2),Ye=Nt[0],Mn=Nt[1],Sn=function(E){if(V){var x=E.key,G=Ye.includes(x),q;_?G?q=Ye.filter(function(Le){return Le!==x}):q=[].concat(pe(Ye),[x]):q=[x],Mn(q);var me=N(N({},E),{},{selectedKeys:q});G?Q==null||Q(me):re==null||re(me)}!_&&X.length&&se!=="inline"&&ve(Ie)},En=Ee(function(K){xe==null||xe(Qe(K)),Sn(K)}),Kt=Ee(function(K,E){var x=X.filter(function(q){return q!==K});if(E)x.push(K);else if(se!=="inline"){var G=pn(K);x=x.filter(function(q){return!G.has(q)})}Tt(X,x,!0)||ve(x,!0)}),Rn=Ee(Pe),Pn=function(E,x){var G=x??!X.includes(E);Kt(E,G)},xn=Qn(se,ke,Ae,Oe,Ce,mn,fn,lt,Pn,We);t.useEffect(function(){rt(!0)},[]);var wn=t.useMemo(function(){return{_internalRenderMenuItem:Ne,_internalRenderSubMenuItem:He}},[Ne,He]),Nn=se!=="horizontal"||p?ae:ae.map(function(K,E){return t.createElement(Ve,{key:K.key,overflowDisabled:E>Be},K)}),Kn=t.createElement(Te,B({id:y,ref:Ce,prefixCls:"".concat(i,"-overflow"),component:"ul",itemComponent:gt,className:oe(i,"".concat(i,"-root"),"".concat(i,"-").concat(se),c,(o={},w(o,"".concat(i,"-inline-collapsed"),un),w(o,"".concat(i,"-rtl"),Ae),o),u),dir:v,style:s,role:"menu",tabIndex:g,data:Nn,renderRawItem:function(E){return E},renderRawRest:function(E){var x=E.length,G=x?ae.slice(-x):null;return t.createElement(bt,{eventKey:dt,title:ze,disabled:ot,internalPopupClose:x===0,popupClassName:Ue},G)},maxCount:se!=="horizontal"||p?Te.INVALIDATE:Te.RESPONSIVE,ssr:"full","data-menu-list":!0,onVisibleChange:function(E){dn(E)},onKeyDown:xn},je));return t.createElement(mt.Provider,{value:wn},t.createElement(zt.Provider,{value:Oe},t.createElement(Ve,{prefixCls:i,rootClassName:u,mode:se,openKeys:X,rtl:Ae,disabled:C,motion:Ge?R:null,defaultMotions:Ge?H:null,activeKey:ke,onActive:bn,onInactive:yn,selectedKeys:Ye,inlineIndent:I,subMenuOpenDelay:f,subMenuCloseDelay:P,forceSubMenuRender:W,builtinPlacements:de,triggerSubMenuAction:he,getPopupContainer:Rn,itemIcon:ue,expandIcon:j,onItemClick:En,onOpenChange:Kt},t.createElement(jt.Provider,{value:hn},Kn),t.createElement("div",{style:{display:"none"},"aria-hidden":!0},t.createElement(Wt.Provider,{value:gn},ae)))))}),Pr=["className","title","eventKey","children"],xr=["children"],wr=function(n){var a=n.className,o=n.title;n.eventKey;var r=n.children,l=Y(n,Pr),i=t.useContext(ee),u=i.prefixCls,s="".concat(u,"-item-group");return t.createElement("li",B({role:"presentation"},l,{onClick:function(m){return m.stopPropagation()},className:oe(s,a)}),t.createElement("div",{role:"presentation",className:"".concat(s,"-title"),title:typeof o=="string"?o:void 0},o),t.createElement("ul",{role:"group",className:"".concat(s,"-list")},r))};function Qt(e){var n=e.children,a=Y(e,xr),o=Fe(a.eventKey),r=Ct(n,o),l=et();return l?r:t.createElement(wr,Ft(a,["warnKey"]),r)}function en(e){var n=e.className,a=e.style,o=t.useContext(ee),r=o.prefixCls,l=et();return l?null:t.createElement("li",{className:oe("".concat(r,"-item-divider"),n),style:a})}var tt=Rr;tt.Item=gt;tt.SubMenu=bt;tt.ItemGroup=Qt;tt.Divider=en;var Me={adjustX:1,adjustY:1},Se=[0,0],Nr={topLeft:{points:["bl","tl"],overflow:Me,offset:[0,-4],targetOffset:Se},topCenter:{points:["bc","tc"],overflow:Me,offset:[0,-4],targetOffset:Se},topRight:{points:["br","tr"],overflow:Me,offset:[0,-4],targetOffset:Se},bottomLeft:{points:["tl","bl"],overflow:Me,offset:[0,4],targetOffset:Se},bottomCenter:{points:["tc","bc"],overflow:Me,offset:[0,4],targetOffset:Se},bottomRight:{points:["tr","br"],overflow:Me,offset:[0,4],targetOffset:Se}},Kr=te.ESC,Or=te.TAB;function Ar(e){var n=e.visible,a=e.setTriggerVisible,o=e.triggerRef,r=e.onVisibleChange,l=e.autoFocus,i=t.useRef(!1),u=function(){if(n&&o.current){var g,d,h,v;(g=o.current)===null||g===void 0||(d=g.triggerRef)===null||d===void 0||(h=d.current)===null||h===void 0||(v=h.focus)===null||v===void 0||v.call(h),a(!1),typeof r=="function"&&r(!1)}},s=function(){var g,d,h,v,y=Gt((g=o.current)===null||g===void 0||(d=g.popupRef)===null||d===void 0||(h=d.current)===null||h===void 0||(v=h.getElement)===null||v===void 0?void 0:v.call(h)),M=y[0];return M!=null&&M.focus?(M.focus(),i.current=!0,!0):!1},c=function(g){switch(g.keyCode){case Kr:u();break;case Or:{var d=!1;i.current||(d=s()),d?g.preventDefault():u();break}}};t.useEffect(function(){return n?(window.addEventListener("keydown",c),l&&Re(s,3),function(){window.removeEventListener("keydown",c),i.current=!1}):function(){i.current=!1}},[n])}var _r=["arrow","prefixCls","transitionName","animation","align","placement","placements","getPopupContainer","showAction","hideAction","overlayClassName","overlayStyle","visible","trigger","autoFocus"];function kr(e,n){var a=e.arrow,o=a===void 0?!1:a,r=e.prefixCls,l=r===void 0?"rc-dropdown":r,i=e.transitionName,u=e.animation,s=e.align,c=e.placement,m=c===void 0?"bottomLeft":c,g=e.placements,d=g===void 0?Nr:g,h=e.getPopupContainer,v=e.showAction,y=e.hideAction,M=e.overlayClassName,S=e.overlayStyle,O=e.visible,C=e.trigger,p=C===void 0?["hover"]:C,b=e.autoFocus,f=Y(e,_r),U=t.useState(),P=F(U,2),W=P[0],T=P[1],A="visible"in e?O:W,$=t.useRef(null);t.useImperativeHandle(n,function(){return $.current}),Ar({visible:A,setTriggerVisible:T,triggerRef:$,onVisibleChange:e.onVisibleChange,autoFocus:b});var Z=function(){var I=e.overlay,R;return typeof I=="function"?R=I():R=I,R},D=function(I){var R=e.onOverlayClick;T(!1),R&&R(I)},V=function(I){var R=e.onVisibleChange;T(I),typeof R=="function"&&R(I)},k=function(){var I=Z();return t.createElement(t.Fragment,null,o&&t.createElement("div",{className:"".concat(l,"-arrow")}),I)},_=function(){var I=e.overlay;return typeof I=="function"?k:k()},ne=function(){var I=e.minOverlayWidthMatchTrigger,R=e.alignPoint;return"minOverlayWidthMatchTrigger"in e?I:!R},le=function(){var I=e.openClassName;return I!==void 0?I:"".concat(l,"-open")},re=function(){var I=e.children,R=I.props?I.props:{},H=oe(R.className,le());return A&&I?t.cloneElement(I,{className:H}):I},Q=y;return!Q&&p.indexOf("contextMenu")!==-1&&(Q=["click"]),t.createElement(Vt,N(N({builtinPlacements:d},f),{},{prefixCls:l,ref:$,popupClassName:oe(M,w({},"".concat(l,"-show-arrow"),o)),popupStyle:S,action:p,showAction:v,hideAction:Q||[],popupPlacement:m,popupAlign:s,popupTransitionName:i,popupAnimation:u,popupVisible:A,stretch:ne()?"minWidth":"",popup:_(),onPopupVisibleChange:V,onPopupClick:D,getPopupContainer:h}),re())}const Hr=t.forwardRef(kr);var Lr={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M257.7 752c2 0 4-.2 6-.5L431.9 722c2-.4 3.9-1.3 5.3-2.8l423.9-423.9a9.96 9.96 0 000-14.1L694.9 114.9c-1.9-1.9-4.4-2.9-7.1-2.9s-5.2 1-7.1 2.9L256.8 538.8c-1.5 1.5-2.4 3.3-2.8 5.3l-29.5 168.2a33.5 33.5 0 009.4 29.8c6.6 6.4 14.9 9.9 23.8 9.9zm67.4-174.4L687.8 215l73.3 73.3-362.7 362.6-88.9 15.7 15.6-89zM880 836H144c-17.7 0-32 14.3-32 32v36c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-36c0-17.7-14.3-32-32-32z"}}]},name:"edit",theme:"outlined"};const $r=Lr;var Dr=function(n,a){return t.createElement($t,N(N({},n),{},{ref:a,icon:$r}))},Tr=t.forwardRef(Dr);const jr=Tr;export{en as D,jr as E,gt as M,bt as S,Qt as a,tt as b,Wr as c,Hr as d,Fe as u}; +import{r as t,A as $t,i as N,K as Y,Q as An,_ as pe,w as Re,b as w,a as F,T as Dt,d as B,aF as _n,c as oe,G as kn,U as Ln,F as $n,E as Dn,z as Tn,e as Vn,t as Fn}from"./umi-a12c8253.js";import{d as Tt,i as zn,K as te,u as Xe,G as Te,c as Vt}from"./TextArea-ec8ab387.js";import{o as Ft}from"./_setToString-ca5ad23e.js";import{t as Un}from"./button-f56a19a0.js";var Wn={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M176 511a56 56 0 10112 0 56 56 0 10-112 0zm280 0a56 56 0 10112 0 56 56 0 10-112 0zm280 0a56 56 0 10112 0 56 56 0 10-112 0z"}}]},name:"ellipsis",theme:"outlined"};const Hn=Wn;var jn=function(n,a){return t.createElement($t,N(N({},n),{},{ref:a,icon:Hn}))},Gn=t.forwardRef(jn);const Wr=Gn;var zt=t.createContext(null);function ft(e,n){return e===void 0?null:"".concat(e,"-").concat(n)}function Ut(e){var n=t.useContext(zt);return ft(n,e)}var qn=["children","locked"],ee=t.createContext(null);function Bn(e,n){var a=N({},e);return Object.keys(n).forEach(function(o){var r=n[o];r!==void 0&&(a[o]=r)}),a}function Ve(e){var n=e.children,a=e.locked,o=Y(e,qn),r=t.useContext(ee),l=An(function(){return Bn(r,o)},[r,o],function(i,u){return!a&&(i[0]!==u[0]||!Tt(i[1],u[1],!0))});return t.createElement(ee.Provider,{value:l},n)}var Yn=[],Wt=t.createContext(null);function et(){return t.useContext(Wt)}var Ht=t.createContext(Yn);function Fe(e){var n=t.useContext(Ht);return t.useMemo(function(){return e!==void 0?[].concat(pe(n),[e]):n},[n,e])}var jt=t.createContext(null),mt=t.createContext({});function Ot(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(zn(e)){var a=e.nodeName.toLowerCase(),o=["input","select","textarea","button"].includes(a)||e.isContentEditable||a==="a"&&!!e.getAttribute("href"),r=e.getAttribute("tabindex"),l=Number(r),i=null;return r&&!Number.isNaN(l)?i=l:o&&i===null&&(i=0),o&&e.disabled&&(i=null),i!==null&&(i>=0||n&&i<0)}return!1}function Gt(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,a=pe(e.querySelectorAll("*")).filter(function(o){return Ot(o,n)});return Ot(e,n)&&a.unshift(e),a}var ut=te.LEFT,st=te.RIGHT,ct=te.UP,Je=te.DOWN,Ze=te.ENTER,qt=te.ESC,$e=te.HOME,De=te.END,At=[ct,Je,ut,st];function Xn(e,n,a,o){var r,l,i,u,s="prev",c="next",m="children",g="parent";if(e==="inline"&&o===Ze)return{inlineTrigger:!0};var d=(r={},w(r,ct,s),w(r,Je,c),r),h=(l={},w(l,ut,a?c:s),w(l,st,a?s:c),w(l,Je,m),w(l,Ze,m),l),v=(i={},w(i,ct,s),w(i,Je,c),w(i,Ze,m),w(i,qt,g),w(i,ut,a?m:g),w(i,st,a?g:m),i),y={inline:d,horizontal:h,vertical:v,inlineSub:d,horizontalSub:v,verticalSub:v},M=(u=y["".concat(e).concat(n?"":"Sub")])===null||u===void 0?void 0:u[o];switch(M){case s:return{offset:-1,sibling:!0};case c:return{offset:1,sibling:!0};case g:return{offset:-1,sibling:!1};case m:return{offset:1,sibling:!1};default:return null}}function Jn(e){for(var n=e;n;){if(n.getAttribute("data-menu-list"))return n;n=n.parentElement}return null}function Zn(e,n){for(var a=e||document.activeElement;a;){if(n.has(a))return a;a=a.parentElement}return null}function Bt(e,n){var a=Gt(e,!0);return a.filter(function(o){return n.has(o)})}function _t(e,n,a){var o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:1;if(!e)return null;var r=Bt(e,n),l=r.length,i=r.findIndex(function(u){return a===u});return o<0?i===-1?i=l-1:i-=1:o>0&&(i+=1),i=(i+l)%l,r[i]}function Qn(e,n,a,o,r,l,i,u,s,c){var m=t.useRef(),g=t.useRef();g.current=n;var d=function(){Re.cancel(m.current)};return t.useEffect(function(){return function(){d()}},[]),function(h){var v=h.which;if([].concat(At,[Ze,qt,$e,De]).includes(v)){var y,M,S,O=function(){y=new Set,M=new Map,S=new Map;var V=l();return V.forEach(function(k){var _=document.querySelector("[data-menu-id='".concat(ft(o,k),"']"));_&&(y.add(_),S.set(_,k),M.set(k,_))}),y};O();var C=M.get(n),p=Zn(C,y),b=S.get(p),f=Xn(e,i(b,!0).length===1,a,v);if(!f&&v!==$e&&v!==De)return;(At.includes(v)||[$e,De].includes(v))&&h.preventDefault();var U=function(V){if(V){var k=V,_=V.querySelector("a");_!=null&&_.getAttribute("href")&&(k=_);var ne=S.get(V);u(ne),d(),m.current=Re(function(){g.current===ne&&k.focus()})}};if([$e,De].includes(v)||f.sibling||!p){var P;!p||e==="inline"?P=r.current:P=Jn(p);var W,T=Bt(P,y);v===$e?W=T[0]:v===De?W=T[T.length-1]:W=_t(P,y,p,f.offset),U(W)}else if(f.inlineTrigger)s(b);else if(f.offset>0)s(b,!0),d(),m.current=Re(function(){O();var D=p.getAttribute("aria-controls"),V=document.getElementById(D),k=_t(V,y);U(k)},5);else if(f.offset<0){var A=i(b,!0),$=A[A.length-2],Z=M.get($);s($,!1),U(Z)}}c==null||c(h)}}function er(e){Promise.resolve().then(e)}var pt="__RC_UTIL_PATH_SPLIT__",kt=function(n){return n.join(pt)},tr=function(n){return n.split(pt)},dt="rc-menu-more";function nr(){var e=t.useState({}),n=F(e,2),a=n[1],o=t.useRef(new Map),r=t.useRef(new Map),l=t.useState([]),i=F(l,2),u=i[0],s=i[1],c=t.useRef(0),m=t.useRef(!1),g=function(){m.current||a({})},d=t.useCallback(function(C,p){var b=kt(p);r.current.set(b,C),o.current.set(C,b),c.current+=1;var f=c.current;er(function(){f===c.current&&g()})},[]),h=t.useCallback(function(C,p){var b=kt(p);r.current.delete(b),o.current.delete(C)},[]),v=t.useCallback(function(C){s(C)},[]),y=t.useCallback(function(C,p){var b=o.current.get(C)||"",f=tr(b);return p&&u.includes(f[0])&&f.unshift(dt),f},[u]),M=t.useCallback(function(C,p){return C.some(function(b){var f=y(b,!0);return f.includes(p)})},[y]),S=function(){var p=pe(o.current.keys());return u.length&&p.push(dt),p},O=t.useCallback(function(C){var p="".concat(o.current.get(C)).concat(pt),b=new Set;return pe(r.current.keys()).forEach(function(f){f.startsWith(p)&&b.add(r.current.get(f))}),b},[]);return t.useEffect(function(){return function(){m.current=!0}},[]),{registerPath:d,unregisterPath:h,refreshOverflowKeys:v,isSubPathKey:M,getKeyPath:y,getKeys:S,getSubPathKeys:O}}function Ee(e){var n=t.useRef(e);n.current=e;var a=t.useCallback(function(){for(var o,r=arguments.length,l=new Array(r),i=0;i1&&(O.motionAppear=!1);var C=O.onVisibleChanged;return O.onVisibleChanged=function(p){return!d.current&&!p&&M(!0),C==null?void 0:C(p)},y?null:t.createElement(Ve,{mode:l,locked:!d.current},t.createElement(Vn,B({visible:S},O,{forceRender:s,removeOnLeave:!1,leavedClassName:"".concat(u,"-hidden")}),function(p){var b=p.className,f=p.style;return t.createElement(ht,{id:n,className:b,style:f},r)}))}var Ir=["style","className","title","eventKey","warnKey","disabled","internalPopupClose","children","itemIcon","expandIcon","popupClassName","popupOffset","onClick","onMouseEnter","onMouseLeave","onTitleClick","onTitleMouseEnter","onTitleMouseLeave"],Mr=["active"],Sr=function(n){var a,o=n.style,r=n.className,l=n.title,i=n.eventKey;n.warnKey;var u=n.disabled,s=n.internalPopupClose,c=n.children,m=n.itemIcon,g=n.expandIcon,d=n.popupClassName,h=n.popupOffset,v=n.onClick,y=n.onMouseEnter,M=n.onMouseLeave,S=n.onTitleClick,O=n.onTitleMouseEnter,C=n.onTitleMouseLeave,p=Y(n,Ir),b=Ut(i),f=t.useContext(ee),U=f.prefixCls,P=f.mode,W=f.openKeys,T=f.disabled,A=f.overflowDisabled,$=f.activeKey,Z=f.selectedKeys,D=f.itemIcon,V=f.expandIcon,k=f.onItemClick,_=f.onOpenChange,ne=f.onActive,le=t.useContext(mt),re=le._internalRenderSubMenuItem,Q=t.useContext(jt),L=Q.isSubPathKey,I=Fe(),R="".concat(U,"-submenu"),H=T||u,ge=t.useRef(),he=t.useRef(),de=m||D,ue=g||V,j=W.includes(i),z=!A&&j,ze=L(Z,i),Ue=Yt(i,H,O,C),Pe=Ue.active,xe=Y(Ue,Mr),we=t.useState(!1),We=F(we,2),Ne=We[0],He=We[1],je=function(J){H||He(J)},ae=function(J){je(!0),y==null||y({key:i,domEvent:J})},nt=function(J){je(!1),M==null||M({key:i,domEvent:J})},Ke=t.useMemo(function(){return Pe||(P!=="inline"?Ne||L([$],i):!1)},[P,Pe,$,Ne,i,L]),Ge=Xt(I.length),rt=function(J){H||(S==null||S({key:i,domEvent:J}),P==="inline"&&_(i,!j))},Ce=Ee(function(ie){v==null||v(Qe(ie)),k(ie)}),Oe=function(J){P!=="inline"&&_(i,J)},Ae=function(){ne(i)},_e=b&&"".concat(b,"-popup"),be=t.createElement("div",B({role:"menuitem",style:Ge,className:"".concat(R,"-title"),tabIndex:H?null:-1,ref:ge,title:typeof l=="string"?l:null,"data-menu-id":A&&b?null:b,"aria-expanded":z,"aria-haspopup":!0,"aria-controls":_e,"aria-disabled":H,onClick:rt,onFocus:Ae},xe),l,t.createElement(Jt,{icon:P!=="horizontal"?ue:null,props:N(N({},n),{},{isOpen:z,isSubMenu:!0})},t.createElement("i",{className:"".concat(R,"-arrow")}))),X=t.useRef(P);if(P!=="inline"&&I.length>1?X.current="vertical":X.current=P,!A){var ye=X.current;be=t.createElement(br,{mode:ye,prefixCls:R,visible:!s&&z&&P!=="inline",popupClassName:d,popupOffset:h,popup:t.createElement(Ve,{mode:ye==="horizontal"?"vertical":ye},t.createElement(ht,{id:_e,ref:he},c)),disabled:H,onVisibleChange:Oe},be)}var ve=t.createElement(Te.Item,B({role:"none"},p,{component:"li",style:o,className:oe(R,"".concat(R,"-").concat(P),r,(a={},w(a,"".concat(R,"-open"),z),w(a,"".concat(R,"-active"),Ke),w(a,"".concat(R,"-selected"),ze),w(a,"".concat(R,"-disabled"),H),a)),onMouseEnter:ae,onMouseLeave:nt}),be,!A&&t.createElement(yr,{id:_e,open:z,keyPath:I},c));return re&&(ve=re(ve,n,{selected:ze,active:Ke,open:z,disabled:H})),t.createElement(Ve,{onItemClick:Ce,mode:P==="horizontal"?"vertical":P,itemIcon:de,expandIcon:ue},ve)};function bt(e){var n=e.eventKey,a=e.children,o=Fe(n),r=Ct(a,o),l=et();t.useEffect(function(){if(l)return l.registerPath(n,o),function(){l.unregisterPath(n,o)}},[o]);var i;return l?i=r:i=t.createElement(Sr,e,r),t.createElement(Ht.Provider,{value:o},i)}var Er=["prefixCls","rootClassName","style","className","tabIndex","items","children","direction","id","mode","inlineCollapsed","disabled","disabledOverflow","subMenuOpenDelay","subMenuCloseDelay","forceSubMenuRender","defaultOpenKeys","openKeys","activeKey","defaultActiveFirst","selectable","multiple","defaultSelectedKeys","selectedKeys","onSelect","onDeselect","inlineIndent","motion","defaultMotions","triggerSubMenuAction","builtinPlacements","itemIcon","expandIcon","overflowedIndicator","overflowedIndicatorPopupClassName","getPopupContainer","onClick","onOpenChange","onKeyDown","openAnimation","openTransitionName","_internalRenderMenuItem","_internalRenderSubMenuItem"],Ie=[],Rr=t.forwardRef(function(e,n){var a,o,r=e,l=r.prefixCls,i=l===void 0?"rc-menu":l,u=r.rootClassName,s=r.style,c=r.className,m=r.tabIndex,g=m===void 0?0:m,d=r.items,h=r.children,v=r.direction,y=r.id,M=r.mode,S=M===void 0?"vertical":M,O=r.inlineCollapsed,C=r.disabled,p=r.disabledOverflow,b=r.subMenuOpenDelay,f=b===void 0?.1:b,U=r.subMenuCloseDelay,P=U===void 0?.1:U,W=r.forceSubMenuRender,T=r.defaultOpenKeys,A=r.openKeys,$=r.activeKey,Z=r.defaultActiveFirst,D=r.selectable,V=D===void 0?!0:D,k=r.multiple,_=k===void 0?!1:k,ne=r.defaultSelectedKeys,le=r.selectedKeys,re=r.onSelect,Q=r.onDeselect,L=r.inlineIndent,I=L===void 0?24:L,R=r.motion,H=r.defaultMotions,ge=r.triggerSubMenuAction,he=ge===void 0?"hover":ge,de=r.builtinPlacements,ue=r.itemIcon,j=r.expandIcon,z=r.overflowedIndicator,ze=z===void 0?"...":z,Ue=r.overflowedIndicatorPopupClassName,Pe=r.getPopupContainer,xe=r.onClick,we=r.onOpenChange,We=r.onKeyDown;r.openAnimation,r.openTransitionName;var Ne=r._internalRenderMenuItem,He=r._internalRenderSubMenuItem,je=Y(r,Er),ae=t.useMemo(function(){return pr(h,d,Ie)},[h,d]),nt=t.useState(!1),Ke=F(nt,2),Ge=Ke[0],rt=Ke[1],Ce=t.useRef(),Oe=ar(y),Ae=v==="rtl",_e=Xe(T,{value:A,postState:function(E){return E||Ie}}),be=F(_e,2),X=be[0],ye=be[1],ve=function(E){var x=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;function G(){ye(E),we==null||we(E)}x?Fn.flushSync(G):G()},ie=t.useState(X),J=F(ie,2),tn=J[0],nn=J[1],at=t.useRef(!1),rn=t.useMemo(function(){return(S==="inline"||S==="vertical")&&O?["vertical",O]:[S,!1]},[S,O]),yt=F(rn,2),qe=yt[0],it=yt[1],It=qe==="inline",an=t.useState(qe),Mt=F(an,2),se=Mt[0],on=Mt[1],ln=t.useState(it),St=F(ln,2),un=St[0],sn=St[1];t.useEffect(function(){on(qe),sn(it),at.current&&(It?ye(tn):ve(Ie))},[qe,it]);var cn=t.useState(0),Et=F(cn,2),Be=Et[0],dn=Et[1],ot=Be>=ae.length-1||se!=="horizontal"||p;t.useEffect(function(){It&&nn(X)},[X]),t.useEffect(function(){return at.current=!0,function(){at.current=!1}},[]);var fe=nr(),Rt=fe.registerPath,Pt=fe.unregisterPath,vn=fe.refreshOverflowKeys,xt=fe.isSubPathKey,fn=fe.getKeyPath,mn=fe.getKeys,pn=fe.getSubPathKeys,gn=t.useMemo(function(){return{registerPath:Rt,unregisterPath:Pt}},[Rt,Pt]),hn=t.useMemo(function(){return{isSubPathKey:xt}},[xt]);t.useEffect(function(){vn(ot?Ie:ae.slice(Be+1).map(function(K){return K.key}))},[Be,ot]);var Cn=Xe($||Z&&((a=ae[0])===null||a===void 0?void 0:a.key),{value:$}),wt=F(Cn,2),ke=wt[0],lt=wt[1],bn=Ee(function(K){lt(K)}),yn=Ee(function(){lt(void 0)});t.useImperativeHandle(n,function(){return{list:Ce.current,focus:function(E){var x,G=ke??((x=ae.find(function(On){return!On.props.disabled}))===null||x===void 0?void 0:x.key);if(G){var q,me,Le;(q=Ce.current)===null||q===void 0||(me=q.querySelector("li[data-menu-id='".concat(ft(Oe,G),"']")))===null||me===void 0||(Le=me.focus)===null||Le===void 0||Le.call(me,E)}}}});var In=Xe(ne||[],{value:le,postState:function(E){return Array.isArray(E)?E:E==null?Ie:[E]}}),Nt=F(In,2),Ye=Nt[0],Mn=Nt[1],Sn=function(E){if(V){var x=E.key,G=Ye.includes(x),q;_?G?q=Ye.filter(function(Le){return Le!==x}):q=[].concat(pe(Ye),[x]):q=[x],Mn(q);var me=N(N({},E),{},{selectedKeys:q});G?Q==null||Q(me):re==null||re(me)}!_&&X.length&&se!=="inline"&&ve(Ie)},En=Ee(function(K){xe==null||xe(Qe(K)),Sn(K)}),Kt=Ee(function(K,E){var x=X.filter(function(q){return q!==K});if(E)x.push(K);else if(se!=="inline"){var G=pn(K);x=x.filter(function(q){return!G.has(q)})}Tt(X,x,!0)||ve(x,!0)}),Rn=Ee(Pe),Pn=function(E,x){var G=x??!X.includes(E);Kt(E,G)},xn=Qn(se,ke,Ae,Oe,Ce,mn,fn,lt,Pn,We);t.useEffect(function(){rt(!0)},[]);var wn=t.useMemo(function(){return{_internalRenderMenuItem:Ne,_internalRenderSubMenuItem:He}},[Ne,He]),Nn=se!=="horizontal"||p?ae:ae.map(function(K,E){return t.createElement(Ve,{key:K.key,overflowDisabled:E>Be},K)}),Kn=t.createElement(Te,B({id:y,ref:Ce,prefixCls:"".concat(i,"-overflow"),component:"ul",itemComponent:gt,className:oe(i,"".concat(i,"-root"),"".concat(i,"-").concat(se),c,(o={},w(o,"".concat(i,"-inline-collapsed"),un),w(o,"".concat(i,"-rtl"),Ae),o),u),dir:v,style:s,role:"menu",tabIndex:g,data:Nn,renderRawItem:function(E){return E},renderRawRest:function(E){var x=E.length,G=x?ae.slice(-x):null;return t.createElement(bt,{eventKey:dt,title:ze,disabled:ot,internalPopupClose:x===0,popupClassName:Ue},G)},maxCount:se!=="horizontal"||p?Te.INVALIDATE:Te.RESPONSIVE,ssr:"full","data-menu-list":!0,onVisibleChange:function(E){dn(E)},onKeyDown:xn},je));return t.createElement(mt.Provider,{value:wn},t.createElement(zt.Provider,{value:Oe},t.createElement(Ve,{prefixCls:i,rootClassName:u,mode:se,openKeys:X,rtl:Ae,disabled:C,motion:Ge?R:null,defaultMotions:Ge?H:null,activeKey:ke,onActive:bn,onInactive:yn,selectedKeys:Ye,inlineIndent:I,subMenuOpenDelay:f,subMenuCloseDelay:P,forceSubMenuRender:W,builtinPlacements:de,triggerSubMenuAction:he,getPopupContainer:Rn,itemIcon:ue,expandIcon:j,onItemClick:En,onOpenChange:Kt},t.createElement(jt.Provider,{value:hn},Kn),t.createElement("div",{style:{display:"none"},"aria-hidden":!0},t.createElement(Wt.Provider,{value:gn},ae)))))}),Pr=["className","title","eventKey","children"],xr=["children"],wr=function(n){var a=n.className,o=n.title;n.eventKey;var r=n.children,l=Y(n,Pr),i=t.useContext(ee),u=i.prefixCls,s="".concat(u,"-item-group");return t.createElement("li",B({role:"presentation"},l,{onClick:function(m){return m.stopPropagation()},className:oe(s,a)}),t.createElement("div",{role:"presentation",className:"".concat(s,"-title"),title:typeof o=="string"?o:void 0},o),t.createElement("ul",{role:"group",className:"".concat(s,"-list")},r))};function Qt(e){var n=e.children,a=Y(e,xr),o=Fe(a.eventKey),r=Ct(n,o),l=et();return l?r:t.createElement(wr,Ft(a,["warnKey"]),r)}function en(e){var n=e.className,a=e.style,o=t.useContext(ee),r=o.prefixCls,l=et();return l?null:t.createElement("li",{className:oe("".concat(r,"-item-divider"),n),style:a})}var tt=Rr;tt.Item=gt;tt.SubMenu=bt;tt.ItemGroup=Qt;tt.Divider=en;var Me={adjustX:1,adjustY:1},Se=[0,0],Nr={topLeft:{points:["bl","tl"],overflow:Me,offset:[0,-4],targetOffset:Se},topCenter:{points:["bc","tc"],overflow:Me,offset:[0,-4],targetOffset:Se},topRight:{points:["br","tr"],overflow:Me,offset:[0,-4],targetOffset:Se},bottomLeft:{points:["tl","bl"],overflow:Me,offset:[0,4],targetOffset:Se},bottomCenter:{points:["tc","bc"],overflow:Me,offset:[0,4],targetOffset:Se},bottomRight:{points:["tr","br"],overflow:Me,offset:[0,4],targetOffset:Se}},Kr=te.ESC,Or=te.TAB;function Ar(e){var n=e.visible,a=e.setTriggerVisible,o=e.triggerRef,r=e.onVisibleChange,l=e.autoFocus,i=t.useRef(!1),u=function(){if(n&&o.current){var g,d,h,v;(g=o.current)===null||g===void 0||(d=g.triggerRef)===null||d===void 0||(h=d.current)===null||h===void 0||(v=h.focus)===null||v===void 0||v.call(h),a(!1),typeof r=="function"&&r(!1)}},s=function(){var g,d,h,v,y=Gt((g=o.current)===null||g===void 0||(d=g.popupRef)===null||d===void 0||(h=d.current)===null||h===void 0||(v=h.getElement)===null||v===void 0?void 0:v.call(h)),M=y[0];return M!=null&&M.focus?(M.focus(),i.current=!0,!0):!1},c=function(g){switch(g.keyCode){case Kr:u();break;case Or:{var d=!1;i.current||(d=s()),d?g.preventDefault():u();break}}};t.useEffect(function(){return n?(window.addEventListener("keydown",c),l&&Re(s,3),function(){window.removeEventListener("keydown",c),i.current=!1}):function(){i.current=!1}},[n])}var _r=["arrow","prefixCls","transitionName","animation","align","placement","placements","getPopupContainer","showAction","hideAction","overlayClassName","overlayStyle","visible","trigger","autoFocus"];function kr(e,n){var a=e.arrow,o=a===void 0?!1:a,r=e.prefixCls,l=r===void 0?"rc-dropdown":r,i=e.transitionName,u=e.animation,s=e.align,c=e.placement,m=c===void 0?"bottomLeft":c,g=e.placements,d=g===void 0?Nr:g,h=e.getPopupContainer,v=e.showAction,y=e.hideAction,M=e.overlayClassName,S=e.overlayStyle,O=e.visible,C=e.trigger,p=C===void 0?["hover"]:C,b=e.autoFocus,f=Y(e,_r),U=t.useState(),P=F(U,2),W=P[0],T=P[1],A="visible"in e?O:W,$=t.useRef(null);t.useImperativeHandle(n,function(){return $.current}),Ar({visible:A,setTriggerVisible:T,triggerRef:$,onVisibleChange:e.onVisibleChange,autoFocus:b});var Z=function(){var I=e.overlay,R;return typeof I=="function"?R=I():R=I,R},D=function(I){var R=e.onOverlayClick;T(!1),R&&R(I)},V=function(I){var R=e.onVisibleChange;T(I),typeof R=="function"&&R(I)},k=function(){var I=Z();return t.createElement(t.Fragment,null,o&&t.createElement("div",{className:"".concat(l,"-arrow")}),I)},_=function(){var I=e.overlay;return typeof I=="function"?k:k()},ne=function(){var I=e.minOverlayWidthMatchTrigger,R=e.alignPoint;return"minOverlayWidthMatchTrigger"in e?I:!R},le=function(){var I=e.openClassName;return I!==void 0?I:"".concat(l,"-open")},re=function(){var I=e.children,R=I.props?I.props:{},H=oe(R.className,le());return A&&I?t.cloneElement(I,{className:H}):I},Q=y;return!Q&&p.indexOf("contextMenu")!==-1&&(Q=["click"]),t.createElement(Vt,N(N({builtinPlacements:d},f),{},{prefixCls:l,ref:$,popupClassName:oe(M,w({},"".concat(l,"-show-arrow"),o)),popupStyle:S,action:p,showAction:v,hideAction:Q||[],popupPlacement:m,popupAlign:s,popupTransitionName:i,popupAnimation:u,popupVisible:A,stretch:ne()?"minWidth":"",popup:_(),onPopupVisibleChange:V,onPopupClick:D,getPopupContainer:h}),re())}const Hr=t.forwardRef(kr);var Lr={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M257.7 752c2 0 4-.2 6-.5L431.9 722c2-.4 3.9-1.3 5.3-2.8l423.9-423.9a9.96 9.96 0 000-14.1L694.9 114.9c-1.9-1.9-4.4-2.9-7.1-2.9s-5.2 1-7.1 2.9L256.8 538.8c-1.5 1.5-2.4 3.3-2.8 5.3l-29.5 168.2a33.5 33.5 0 009.4 29.8c6.6 6.4 14.9 9.9 23.8 9.9zm67.4-174.4L687.8 215l73.3 73.3-362.7 362.6-88.9 15.7 15.6-89zM880 836H144c-17.7 0-32 14.3-32 32v36c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-36c0-17.7-14.3-32-32-32z"}}]},name:"edit",theme:"outlined"};const $r=Lr;var Dr=function(n,a){return t.createElement($t,N(N({},n),{},{ref:a,icon:$r}))},Tr=t.forwardRef(Dr);const jr=Tr;export{en as D,jr as E,gt as M,bt as S,Qt as a,tt as b,Wr as c,Hr as d,Fe as u}; diff --git a/dist/assets/PlaySquareOutlined-646d1a37.js b/dist/assets/PlaySquareOutlined-1144cdf9.js similarity index 94% rename from dist/assets/PlaySquareOutlined-646d1a37.js rename to dist/assets/PlaySquareOutlined-1144cdf9.js index 6b9a2552bd44c497570fddc75ee7ba3dfaf5e102..a11b02018f0358921116437aa05b606354acc344 100644 --- a/dist/assets/PlaySquareOutlined-646d1a37.js +++ b/dist/assets/PlaySquareOutlined-1144cdf9.js @@ -1 +1 @@ -import{r as a,A as c,i as e}from"./umi-9940633e.js";var l={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372zm-88-532h-48c-4.4 0-8 3.6-8 8v304c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V360c0-4.4-3.6-8-8-8zm224 0h-48c-4.4 0-8 3.6-8 8v304c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V360c0-4.4-3.6-8-8-8z"}}]},name:"pause-circle",theme:"outlined"};const i=l;var s=function(t,r){return a.createElement(c,e(e({},t),{},{ref:r,icon:i}))},u=a.forwardRef(s);const m=u;var o={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M442.3 677.6l199.4-156.7a11.3 11.3 0 000-17.7L442.3 346.4c-7.4-5.8-18.3-.6-18.3 8.8v313.5c0 9.4 10.9 14.7 18.3 8.9z"}},{tag:"path",attrs:{d:"M880 112H144c-17.7 0-32 14.3-32 32v736c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V144c0-17.7-14.3-32-32-32zm-40 728H184V184h656v656z"}}]},name:"play-square",theme:"outlined"};const d=o;var v=function(t,r){return a.createElement(c,e(e({},t),{},{ref:r,icon:d}))},f=a.forwardRef(v);const P=f;export{P,m as a}; +import{r as a,A as c,i as e}from"./umi-a12c8253.js";var l={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372zm-88-532h-48c-4.4 0-8 3.6-8 8v304c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V360c0-4.4-3.6-8-8-8zm224 0h-48c-4.4 0-8 3.6-8 8v304c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V360c0-4.4-3.6-8-8-8z"}}]},name:"pause-circle",theme:"outlined"};const i=l;var s=function(t,r){return a.createElement(c,e(e({},t),{},{ref:r,icon:i}))},u=a.forwardRef(s);const m=u;var o={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M442.3 677.6l199.4-156.7a11.3 11.3 0 000-17.7L442.3 346.4c-7.4-5.8-18.3-.6-18.3 8.8v313.5c0 9.4 10.9 14.7 18.3 8.9z"}},{tag:"path",attrs:{d:"M880 112H144c-17.7 0-32 14.3-32 32v736c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V144c0-17.7-14.3-32-32-32zm-40 728H184V184h656v656z"}}]},name:"play-square",theme:"outlined"};const d=o;var v=function(t,r){return a.createElement(c,e(e({},t),{},{ref:r,icon:d}))},f=a.forwardRef(v);const P=f;export{P,m as a}; diff --git a/dist/assets/ScoreEncoder-5776d117.js b/dist/assets/ScoreEncoder-72da943f.js similarity index 84% rename from dist/assets/ScoreEncoder-5776d117.js rename to dist/assets/ScoreEncoder-72da943f.js index a7a63170d58fb0ce77f048e287dd78526b795f26..65c59d6481db1afc41a4871e23a93b7912cc8be2 100644 --- a/dist/assets/ScoreEncoder-5776d117.js +++ b/dist/assets/ScoreEncoder-72da943f.js @@ -1,4 +1,4 @@ -import{r as ru,ao as nu,g as iu,k as R,j as D,R as su}from"./umi-9940633e.js";import"./parser-9472c317.js";import{W as lu,a as I,b as ou,E as un,A as We}from"./index-1a249a16.js";const Ol=lu/4,uu=40;var Il={exports:{}},nr={},Cl={exports:{}},F={};/** +import{r as nu,ao as iu,g as su,k as R,j as T,R as lu}from"./umi-a12c8253.js";import"./parser-b66b074b.js";import{W as ou,a as I,b as uu,E as un,A as We}from"./index-43517c6d.js";const Ol=ou/4,au=40;var Il={exports:{}},nr={},Cl={exports:{}},F={};/** * @license React * scheduler-unstable_mock.production.min.js * @@ -6,7 +6,7 @@ import{r as ru,ao as nu,g as iu,k as R,j as D,R as su}from"./umi-9940633e.js";im * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */function ni(e,t){var r=e.length;e.push(t);e:for(;0>>1,s=e[n];if(0>>1;nvr(o,r))uvr(f,o)?(e[n]=f,e[u]=r,n=u):(e[n]=o,e[l]=r,n=l);else if(uvr(f,r))e[n]=f,e[u]=r,n=u;else break e}}return t}function vr(e,t){var r=e.sortIndex-t.sortIndex;return r!==0?r:e.id-t.id}var Pe=[],He=[],au=1,me=null,te=3,Ir=!1,pt=!1,Jt=!1,ce=0,re=null,Be=null,tt=-1,ye=null,Mt=-1,Pt=!1,he=!1,Kr=!1,ii=!1,ji=!1;function si(e){for(var t=Ee(He);t!==null;){if(t.callback===null)Or(He);else if(t.startTime<=e)Or(He),t.sortIndex=t.expirationTime,ni(Pe,t);else break;t=Ee(He)}}function ki(e){if(Jt=!1,si(e),!pt)if(Ee(Pe)!==null)pt=!0,re=Ri;else{var t=Ee(He);t!==null&&(e=t.startTime-e,Be=ki,tt=ce+e)}}function Ri(e,t){pt=!1,Jt&&(Jt=!1,Be=null,tt=-1),Ir=!0;var r=te;try{for(si(t),me=Ee(Pe);me!==null&&(!(me.expirationTime>t)||e&&!Pl());){var n=me.callback;if(typeof n=="function"){me.callback=null,te=me.priorityLevel;var s=n(me.expirationTime<=t);t=ce,typeof s=="function"?me.callback=s:me===Ee(Pe)&&Or(Pe),si(t)}else Or(Pe);me=Ee(Pe)}if(me!==null)var i=!0;else{var l=Ee(He);if(l!==null){var o=l.startTime-t;Be=ki,tt=ce+o}i=!1}return i}finally{me=null,te=r,Ir=!1}}function Pl(){return Mt===0&&ye===null||Mt!==-1&&ye!==null&&ye.length>=Mt||ii&&Kr?Pt=!0:!1}function jl(){if(he)throw Error("Already flushing work.");if(re!==null){var e=re;he=!0;try{var t=!0;do t=e(!0,ce);while(t);return t||(re=null),!0}finally{he=!1}}else return!1}F.reset=function(){if(he)throw Error("Cannot reset while already flushing work.");ce=0,Be=re=null,tt=-1,ye=null,Mt=-1,Kr=he=Pt=!1};F.unstable_IdlePriority=5;F.unstable_ImmediatePriority=1;F.unstable_LowPriority=4;F.unstable_NormalPriority=3;F.unstable_Profiling=null;F.unstable_UserBlockingPriority=2;F.unstable_advanceTime=function(e){console.log.name==="disabledLog"||ji||(ce+=e,Be!==null&&tt<=ce&&(Be(ce),tt=-1,Be=null))};F.unstable_cancelCallback=function(e){e.callback=null};F.unstable_clearYields=function(){if(ye===null)return[];var e=ye;return ye=null,e};F.unstable_continueExecution=function(){pt||Ir||(pt=!0,re=Ri)};F.unstable_flushAll=function(){if(ye!==null)throw Error("Log is not empty. Assert on the log of yielded values before flushing additional work.");if(jl(),ye!==null)throw Error("While flushing work, something yielded a value. Use an assertion helper to assert on the log of yielded values, e.g. expect(Scheduler).toFlushAndYield([...])")};F.unstable_flushAllWithoutAsserting=jl;F.unstable_flushExpired=function(){if(he)throw Error("Already flushing work.");if(re!==null){he=!0;try{re(!1,ce)||(re=null)}finally{he=!1}}};F.unstable_flushNumberOfYields=function(e){if(he)throw Error("Already flushing work.");if(re!==null){var t=re;Mt=e,he=!0;try{e=!0;do e=t(!0,ce);while(e&&!Pt);e||(re=null)}finally{Mt=-1,he=Pt=!1}}};F.unstable_flushUntilNextPaint=function(){if(he)throw Error("Already flushing work.");if(re!==null){var e=re;ii=!0,Kr=!1,he=!0;try{var t=!0;do t=e(!0,ce);while(t&&!Pt);t||(re=null)}finally{he=Pt=ii=!1}}};F.unstable_forceFrameRate=function(){};F.unstable_getCurrentPriorityLevel=function(){return te};F.unstable_getFirstCallbackNode=function(){return Ee(Pe)};F.unstable_next=function(e){switch(te){case 1:case 2:case 3:var t=3;break;default:t=te}var r=te;te=t;try{return e()}finally{te=r}};F.unstable_now=function(){return ce};F.unstable_pauseExecution=function(){};F.unstable_requestPaint=function(){Kr=!0};F.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var r=te;te=e;try{return t()}finally{te=r}};F.unstable_scheduleCallback=function(e,t,r){var n=ce;switch(typeof r=="object"&&r!==null?(r=r.delay,r=typeof r=="number"&&0n?(e.sortIndex=r,ni(He,e),Ee(Pe)===null&&e===Ee(He)&&(Jt?(Be=null,tt=-1):Jt=!0,Be=ki,tt=ce+(r-n))):(e.sortIndex=s,ni(Pe,e),pt||Ir||(pt=!0,re=Ri)),e};F.unstable_setDisableYieldValue=function(e){ji=e};F.unstable_shouldYield=Pl;F.unstable_wrapCallback=function(e){var t=te;return function(){var r=te;te=t;try{return e.apply(this,arguments)}finally{te=r}}};F.unstable_yieldValue=function(e){console.log.name==="disabledLog"||ji||(ye===null?ye=[e]:ye.push(e))};Cl.exports=F;var cu=Cl.exports;/** + */function ni(e,t){var r=e.length;e.push(t);e:for(;0>>1,s=e[n];if(0>>1;nvr(o,r))uvr(f,o)?(e[n]=f,e[u]=r,n=u):(e[n]=o,e[l]=r,n=l);else if(uvr(f,r))e[n]=f,e[u]=r,n=u;else break e}}return t}function vr(e,t){var r=e.sortIndex-t.sortIndex;return r!==0?r:e.id-t.id}var Pe=[],He=[],cu=1,me=null,te=3,Ir=!1,pt=!1,Jt=!1,ce=0,re=null,Be=null,tt=-1,ye=null,Mt=-1,Pt=!1,he=!1,Kr=!1,ii=!1,ji=!1;function si(e){for(var t=Ee(He);t!==null;){if(t.callback===null)Or(He);else if(t.startTime<=e)Or(He),t.sortIndex=t.expirationTime,ni(Pe,t);else break;t=Ee(He)}}function ki(e){if(Jt=!1,si(e),!pt)if(Ee(Pe)!==null)pt=!0,re=Ri;else{var t=Ee(He);t!==null&&(e=t.startTime-e,Be=ki,tt=ce+e)}}function Ri(e,t){pt=!1,Jt&&(Jt=!1,Be=null,tt=-1),Ir=!0;var r=te;try{for(si(t),me=Ee(Pe);me!==null&&(!(me.expirationTime>t)||e&&!Pl());){var n=me.callback;if(typeof n=="function"){me.callback=null,te=me.priorityLevel;var s=n(me.expirationTime<=t);t=ce,typeof s=="function"?me.callback=s:me===Ee(Pe)&&Or(Pe),si(t)}else Or(Pe);me=Ee(Pe)}if(me!==null)var i=!0;else{var l=Ee(He);if(l!==null){var o=l.startTime-t;Be=ki,tt=ce+o}i=!1}return i}finally{me=null,te=r,Ir=!1}}function Pl(){return Mt===0&&ye===null||Mt!==-1&&ye!==null&&ye.length>=Mt||ii&&Kr?Pt=!0:!1}function jl(){if(he)throw Error("Already flushing work.");if(re!==null){var e=re;he=!0;try{var t=!0;do t=e(!0,ce);while(t);return t||(re=null),!0}finally{he=!1}}else return!1}F.reset=function(){if(he)throw Error("Cannot reset while already flushing work.");ce=0,Be=re=null,tt=-1,ye=null,Mt=-1,Kr=he=Pt=!1};F.unstable_IdlePriority=5;F.unstable_ImmediatePriority=1;F.unstable_LowPriority=4;F.unstable_NormalPriority=3;F.unstable_Profiling=null;F.unstable_UserBlockingPriority=2;F.unstable_advanceTime=function(e){console.log.name==="disabledLog"||ji||(ce+=e,Be!==null&&tt<=ce&&(Be(ce),tt=-1,Be=null))};F.unstable_cancelCallback=function(e){e.callback=null};F.unstable_clearYields=function(){if(ye===null)return[];var e=ye;return ye=null,e};F.unstable_continueExecution=function(){pt||Ir||(pt=!0,re=Ri)};F.unstable_flushAll=function(){if(ye!==null)throw Error("Log is not empty. Assert on the log of yielded values before flushing additional work.");if(jl(),ye!==null)throw Error("While flushing work, something yielded a value. Use an assertion helper to assert on the log of yielded values, e.g. expect(Scheduler).toFlushAndYield([...])")};F.unstable_flushAllWithoutAsserting=jl;F.unstable_flushExpired=function(){if(he)throw Error("Already flushing work.");if(re!==null){he=!0;try{re(!1,ce)||(re=null)}finally{he=!1}}};F.unstable_flushNumberOfYields=function(e){if(he)throw Error("Already flushing work.");if(re!==null){var t=re;Mt=e,he=!0;try{e=!0;do e=t(!0,ce);while(e&&!Pt);e||(re=null)}finally{Mt=-1,he=Pt=!1}}};F.unstable_flushUntilNextPaint=function(){if(he)throw Error("Already flushing work.");if(re!==null){var e=re;ii=!0,Kr=!1,he=!0;try{var t=!0;do t=e(!0,ce);while(t&&!Pt);t||(re=null)}finally{he=Pt=ii=!1}}};F.unstable_forceFrameRate=function(){};F.unstable_getCurrentPriorityLevel=function(){return te};F.unstable_getFirstCallbackNode=function(){return Ee(Pe)};F.unstable_next=function(e){switch(te){case 1:case 2:case 3:var t=3;break;default:t=te}var r=te;te=t;try{return e()}finally{te=r}};F.unstable_now=function(){return ce};F.unstable_pauseExecution=function(){};F.unstable_requestPaint=function(){Kr=!0};F.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var r=te;te=e;try{return t()}finally{te=r}};F.unstable_scheduleCallback=function(e,t,r){var n=ce;switch(typeof r=="object"&&r!==null?(r=r.delay,r=typeof r=="number"&&0n?(e.sortIndex=r,ni(He,e),Ee(Pe)===null&&e===Ee(He)&&(Jt?(Be=null,tt=-1):Jt=!0,Be=ki,tt=ce+(r-n))):(e.sortIndex=s,ni(Pe,e),pt||Ir||(pt=!0,re=Ri)),e};F.unstable_setDisableYieldValue=function(e){ji=e};F.unstable_shouldYield=Pl;F.unstable_wrapCallback=function(e){var t=te;return function(){var r=te;te=t;try{return e.apply(this,arguments)}finally{te=r}}};F.unstable_yieldValue=function(e){console.log.name==="disabledLog"||ji||(ye===null?ye=[e]:ye.push(e))};Cl.exports=F;var hu=Cl.exports;/** * @license React * react-test-renderer.production.min.js * @@ -14,22 +14,22 @@ import{r as ru,ao as nu,g as iu,k as R,j as D,R as su}from"./umi-9940633e.js";im * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var kl=ru,Rl=cu,be=nu;function Ds(e,t){for(var r=0;r>>=0,e===0?32:31-(vu(e)/wu|0)|0}var ar=64,cr=4194304;function hr(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Pr(e,t){var r=e.pendingLanes;if(r===0)return 0;var n=0,s=e.suspendedLanes,i=e.pingedLanes,l=r&268435455;if(l!==0){var o=l&~s;o!==0?n=hr(o):(i&=l,i!==0&&(n=hr(i)))}else l=r&~s,l!==0?n=hr(l):i!==0&&(n=hr(i));if(n===0)return 0;if(t!==0&&t!==n&&!(t&s)&&(s=n&-n,i=t&-t,s>=i||s===16&&(i&4194240)!==0))return t;if(n&4&&(n|=r&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=n;0r;r++)t.push(e);return t}function Zr(e,t,r){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-vt(t),e[t]=r}function Tu(e,t){var r=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var n=e.eventTimes;for(e=e.expirationTimes;0>>=0,e===0?32:31-(wu(e)/xu|0)|0}var ar=64,cr=4194304;function hr(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Pr(e,t){var r=e.pendingLanes;if(r===0)return 0;var n=0,s=e.suspendedLanes,i=e.pingedLanes,l=r&268435455;if(l!==0){var o=l&~s;o!==0?n=hr(o):(i&=l,i!==0&&(n=hr(i)))}else l=r&~s,l!==0?n=hr(l):i!==0&&(n=hr(i));if(n===0)return 0;if(t!==0&&t!==n&&!(t&s)&&(s=n&-n,i=t&-t,s>=i||s===16&&(i&4194240)!==0))return t;if(n&4&&(n|=r&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=n;0r;r++)t.push(e);return t}function Zr(e,t,r){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-vt(t),e[t]=r}function Du(e,t){var r=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var n=e.eventTimes;for(e=e.expirationTimes;0o||s[l]!==i[o]){var u=` -`+s[l].replace(" at new "," at ");return e.displayName&&u.includes("")&&(u=u.replace("",e.displayName)),u}while(1<=l&&0<=o);break}}}finally{hn=!1,Error.prepareStackTrace=r}return(e=e?e.displayName||e.name:"")?Qt(e):""}var Lu=Object.prototype.hasOwnProperty,fi=[],Et=-1;function it(e){return{current:e}}function B(e){0>Et||(e.current=fi[Et],fi[Et]=null,Et--)}function z(e,t){Et++,fi[Et]=e.current,e.current=t}var rt={},ne=it(rt),de=it(!1),mt=rt;function jt(e,t){var r=e.type.contextTypes;if(!r)return rt;var n=e.stateNode;if(n&&n.__reactInternalMemoizedUnmaskedChildContext===t)return n.__reactInternalMemoizedMaskedChildContext;var s={},i;for(i in r)s[i]=t[i];return n&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=s),s}function fe(e){return e=e.childContextTypes,e!=null}function kr(){B(de),B(ne)}function Os(e,t,r){if(ne.current!==rt)throw Error("Unexpected context found on stack. This error is likely caused by a bug in React. Please file an issue.");z(ne,t),z(de,r)}function Vl(e,t,r){var n=e.stateNode;if(t=t.childContextTypes,typeof n.getChildContext!="function")return r;n=n.getChildContext();for(var s in n)if(!(s in t))throw Error((du(e)||"Unknown")+'.getChildContext(): key "'+s+'" is not defined in childContextTypes.');return ct({},r,n)}function Rr(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||rt,mt=ne.current,z(ne,e),z(de,de.current),!0}function Is(e,t,r){var n=e.stateNode;if(!n)throw Error("Expected to have an instance by this point. This error is likely caused by a bug in React. Please file an issue.");r?(e=Vl(e,t,mt),n.__reactInternalMemoizedMergedChildContext=e,B(de),B(ne),z(ne,e)):B(de),z(de,r)}function Mu(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Le=typeof Object.is=="function"?Object.is:Mu,ge=null,Gr=!1,fn=!1;function wt(){if(!fn&&ge!==null){fn=!0;var e=0,t=K;try{var r=ge;for(K=1;e")&&(u=u.replace("",e.displayName)),u}while(1<=l&&0<=o);break}}}finally{hn=!1,Error.prepareStackTrace=r}return(e=e?e.displayName||e.name:"")?Qt(e):""}var Mu=Object.prototype.hasOwnProperty,fi=[],Et=-1;function it(e){return{current:e}}function B(e){0>Et||(e.current=fi[Et],fi[Et]=null,Et--)}function z(e,t){Et++,fi[Et]=e.current,e.current=t}var rt={},ne=it(rt),de=it(!1),mt=rt;function jt(e,t){var r=e.type.contextTypes;if(!r)return rt;var n=e.stateNode;if(n&&n.__reactInternalMemoizedUnmaskedChildContext===t)return n.__reactInternalMemoizedMaskedChildContext;var s={},i;for(i in r)s[i]=t[i];return n&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=s),s}function fe(e){return e=e.childContextTypes,e!=null}function kr(){B(de),B(ne)}function Os(e,t,r){if(ne.current!==rt)throw Error("Unexpected context found on stack. This error is likely caused by a bug in React. Please file an issue.");z(ne,t),z(de,r)}function Vl(e,t,r){var n=e.stateNode;if(t=t.childContextTypes,typeof n.getChildContext!="function")return r;n=n.getChildContext();for(var s in n)if(!(s in t))throw Error((fu(e)||"Unknown")+'.getChildContext(): key "'+s+'" is not defined in childContextTypes.');return ct({},r,n)}function Rr(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||rt,mt=ne.current,z(ne,e),z(de,de.current),!0}function Is(e,t,r){var n=e.stateNode;if(!n)throw Error("Expected to have an instance by this point. This error is likely caused by a bug in React. Please file an issue.");r?(e=Vl(e,t,mt),n.__reactInternalMemoizedMergedChildContext=e,B(de),B(ne),z(ne,e)):B(de),z(de,r)}function Ou(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Le=typeof Object.is=="function"?Object.is:Ou,ge=null,Gr=!1,fn=!1;function wt(){if(!fn&&ge!==null){fn=!0;var e=0,t=K;try{var r=ge;for(K=1;eh?(S=T,T=null):S=T.sibling;var E=x(y,T,w[h],a);if(E===null){T===null&&(T=S);break}e&&T&&E.alternate===null&&t(y,T),d=i(E,d,h),m===null?p=E:m.sibling=E,m=E,T=S}if(h===w.length)return r(y,T),p;if(T===null){for(;hh?(S=T,T=null):S=T.sibling;var O=x(y,T,E.value,a);if(O===null){T===null&&(T=S);break}e&&T&&O.alternate===null&&t(y,T),d=i(O,d,h),m===null?p=O:m.sibling=O,m=O,T=S}if(E.done)return r(y,T),p;if(T===null){for(;!E.done;h++,E=w.next())E=v(y,E.value,a),E!==null&&(d=i(E,d,h),m===null?p=E:m.sibling=E,m=E);return p}for(T=n(y,T);!E.done;h++,E=w.next())E=N(T,y,h,E.value,a),E!==null&&(e&&E.alternate!==null&&T.delete(E.key===null?h:E.key),d=i(E,d,h),m===null?p=E:m.sibling=E,m=E);return e&&T.forEach(function(C){return t(y,C)}),p}function P(y,d,w,a){if(typeof w=="object"&&w!==null&&w.type===Dt&&w.key===null&&(w=w.props.children),typeof w=="object"&&w!==null){switch(w.$$typeof){case ur:e:{for(var p=w.key,m=d;m!==null;){if(m.key===p){if(p=w.type,p===Dt){if(m.tag===7){r(y,m.sibling),d=s(m,w.props.children),d.return=y,y=d;break e}}else if(m.elementType===p||typeof p=="object"&&p!==null&&p.$$typeof===Ve&&js(p)===m.type){r(y,m.sibling),d=s(m,w.props),d.ref=bt(y,m,w),d.return=y,y=d;break e}r(y,m);break}else t(y,m);m=m.sibling}w.type===Dt?(d=ft(w.props.children,y.mode,a,w.key),d.return=y,y=d):(a=Nr(w.type,w.key,w.props,null,y.mode,a),a.ref=bt(y,d,w),a.return=y,y=a)}return l(y);case Wt:e:{for(m=w.key;d!==null;){if(d.key===m)if(d.tag===4&&d.stateNode.containerInfo===w.containerInfo&&d.stateNode.implementation===w.implementation){r(y,d.sibling),d=s(d,w.children||[]),d.return=y,y=d;break e}else{r(y,d);break}else t(y,d);d=d.sibling}d=Tn(w,y.mode,a),d.return=y,y=d}return l(y);case Ve:return m=w._init,P(y,d,m(w._payload),a)}if(Vt(w))return g(y,d,w,a);if(_t(w))return L(y,d,w,a);pr(y,w)}return typeof w=="string"&&w!==""||typeof w=="number"?(w=""+w,d!==null&&d.tag===6?(r(y,d.sibling),d=s(d,w),d.return=y,y=d):(r(y,d),d=Sn(w,y.mode,a),d.return=y,y=d),l(y)):r(y,d)}return P}var kt=Ql(!0),Cu=Ql(!1),Fr=it(null),zr=null,Nt=null,bi=null;function Ai(){bi=Nt=zr=null}function Ui(e){var t=Fr.current;B(Fr),e._currentValue2=t}function pi(e,t,r){for(;e!==null;){var n=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,n!==null&&(n.childLanes|=t)):n!==null&&(n.childLanes&t)!==t&&(n.childLanes|=t),e===r)break;e=e.return}}function Ot(e,t){zr=e,bi=Nt=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(ae=!0),e.firstContext=null)}function xe(e){var t=e._currentValue2;if(bi!==e)if(e={context:e,memoizedValue:t,next:null},Nt===null){if(zr===null)throw Error("Context can only be read while React is rendering. In classes, you can read it in the render method or getDerivedStateFromProps. In function components, you can read it directly in the function body, but not inside Hooks like useReducer() or useMemo().");Nt=e,zr.dependencies={lanes:0,firstContext:e}}else Nt=Nt.next=e;return t}var ut=null;function qi(e){ut===null?ut=[e]:ut.push(e)}function $l(e,t,r,n){var s=t.interleaved;return s===null?(r.next=r,qi(t)):(r.next=s.next,s.next=r),t.interleaved=r,Rt(e,n)}function Rt(e,t){e.lanes|=t;var r=e.alternate;for(r!==null&&(r.lanes|=t),r=e,e=e.return;e!==null;)e.childLanes|=t,r=e.alternate,r!==null&&(r.childLanes|=t),r=e,e=e.return;return r.tag===3?r.stateNode:null}var Qe=!1;function Wi(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Hl(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Ye(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function ht(e,t,r){var n=e.updateQueue;if(n===null)return null;if(n=n.shared,X&2){var s=n.pending;return s===null?t.next=t:(t.next=s.next,s.next=t),n.pending=t,Rt(e,r)}return s=n.interleaved,s===null?(t.next=t,qi(n)):(t.next=s.next,s.next=t),n.interleaved=t,Rt(e,r)}function wr(e,t,r){if(t=t.updateQueue,t!==null&&(t=t.shared,(r&4194240)!==0)){var n=t.lanes;n&=e.pendingLanes,r|=n,t.lanes=r,Al(e,r)}}function ks(e,t){var r=e.updateQueue,n=e.alternate;if(n!==null&&(n=n.updateQueue,r===n)){var s=null,i=null;if(r=r.firstBaseUpdate,r!==null){do{var l={eventTime:r.eventTime,lane:r.lane,tag:r.tag,payload:r.payload,callback:r.callback,next:null};i===null?s=i=l:i=i.next=l,r=r.next}while(r!==null);i===null?s=i=t:i=i.next=t}else s=i=t;r={baseState:n.baseState,firstBaseUpdate:s,lastBaseUpdate:i,shared:n.shared,effects:n.effects},e.updateQueue=r;return}e=r.lastBaseUpdate,e===null?r.firstBaseUpdate=t:e.next=t,r.lastBaseUpdate=t}function Br(e,t,r,n){var s=e.updateQueue;Qe=!1;var i=s.firstBaseUpdate,l=s.lastBaseUpdate,o=s.shared.pending;if(o!==null){s.shared.pending=null;var u=o,f=u.next;u.next=null,l===null?i=f:l.next=f,l=u;var c=e.alternate;c!==null&&(c=c.updateQueue,o=c.lastBaseUpdate,o!==l&&(o===null?c.firstBaseUpdate=f:o.next=f,c.lastBaseUpdate=u))}if(i!==null){var v=s.baseState;l=0,c=f=u=null,o=i;do{var x=o.lane,N=o.eventTime;if((n&x)===x){c!==null&&(c=c.next={eventTime:N,lane:0,tag:o.tag,payload:o.payload,callback:o.callback,next:null});e:{var g=e,L=o;switch(x=t,N=r,L.tag){case 1:if(g=L.payload,typeof g=="function"){v=g.call(N,v,x);break e}v=g;break e;case 3:g.flags=g.flags&-65537|128;case 0:if(g=L.payload,x=typeof g=="function"?g.call(N,v,x):g,x==null)break e;v=ct({},v,x);break e;case 2:Qe=!0}}o.callback!==null&&o.lane!==0&&(e.flags|=64,x=s.effects,x===null?s.effects=[o]:x.push(o))}else N={eventTime:N,lane:x,tag:o.tag,payload:o.payload,callback:o.callback,next:null},c===null?(f=c=N,u=v):c=c.next=N,l|=x;if(o=o.next,o===null){if(o=s.shared.pending,o===null)break;x=o,o=x.next,x.next=null,s.lastBaseUpdate=x,s.shared.pending=null}}while(1);if(c===null&&(u=v),s.baseState=u,s.firstBaseUpdate=f,s.lastBaseUpdate=c,t=s.shared.interleaved,t!==null){s=t;do l|=s.lane,s=s.next;while(s!==t)}else i===null&&(s.shared.lanes=0);yt|=l,e.lanes=l,e.memoizedState=v}}function Rs(e,t,r){if(e=t.effects,t.effects=null,e!==null)for(t=0;th?(S=D,D=null):S=D.sibling;var E=x(y,D,w[h],a);if(E===null){D===null&&(D=S);break}e&&D&&E.alternate===null&&t(y,D),d=i(E,d,h),m===null?p=E:m.sibling=E,m=E,D=S}if(h===w.length)return r(y,D),p;if(D===null){for(;hh?(S=D,D=null):S=D.sibling;var O=x(y,D,E.value,a);if(O===null){D===null&&(D=S);break}e&&D&&O.alternate===null&&t(y,D),d=i(O,d,h),m===null?p=O:m.sibling=O,m=O,D=S}if(E.done)return r(y,D),p;if(D===null){for(;!E.done;h++,E=w.next())E=v(y,E.value,a),E!==null&&(d=i(E,d,h),m===null?p=E:m.sibling=E,m=E);return p}for(D=n(y,D);!E.done;h++,E=w.next())E=N(D,y,h,E.value,a),E!==null&&(e&&E.alternate!==null&&D.delete(E.key===null?h:E.key),d=i(E,d,h),m===null?p=E:m.sibling=E,m=E);return e&&D.forEach(function(C){return t(y,C)}),p}function P(y,d,w,a){if(typeof w=="object"&&w!==null&&w.type===Dt&&w.key===null&&(w=w.props.children),typeof w=="object"&&w!==null){switch(w.$$typeof){case ur:e:{for(var p=w.key,m=d;m!==null;){if(m.key===p){if(p=w.type,p===Dt){if(m.tag===7){r(y,m.sibling),d=s(m,w.props.children),d.return=y,y=d;break e}}else if(m.elementType===p||typeof p=="object"&&p!==null&&p.$$typeof===Ve&&js(p)===m.type){r(y,m.sibling),d=s(m,w.props),d.ref=bt(y,m,w),d.return=y,y=d;break e}r(y,m);break}else t(y,m);m=m.sibling}w.type===Dt?(d=ft(w.props.children,y.mode,a,w.key),d.return=y,y=d):(a=Nr(w.type,w.key,w.props,null,y.mode,a),a.ref=bt(y,d,w),a.return=y,y=a)}return l(y);case Wt:e:{for(m=w.key;d!==null;){if(d.key===m)if(d.tag===4&&d.stateNode.containerInfo===w.containerInfo&&d.stateNode.implementation===w.implementation){r(y,d.sibling),d=s(d,w.children||[]),d.return=y,y=d;break e}else{r(y,d);break}else t(y,d);d=d.sibling}d=Tn(w,y.mode,a),d.return=y,y=d}return l(y);case Ve:return m=w._init,P(y,d,m(w._payload),a)}if(Vt(w))return g(y,d,w,a);if(_t(w))return L(y,d,w,a);pr(y,w)}return typeof w=="string"&&w!==""||typeof w=="number"?(w=""+w,d!==null&&d.tag===6?(r(y,d.sibling),d=s(d,w),d.return=y,y=d):(r(y,d),d=Sn(w,y.mode,a),d.return=y,y=d),l(y)):r(y,d)}return P}var kt=Ql(!0),Pu=Ql(!1),Fr=it(null),zr=null,Nt=null,bi=null;function Ai(){bi=Nt=zr=null}function Ui(e){var t=Fr.current;B(Fr),e._currentValue2=t}function pi(e,t,r){for(;e!==null;){var n=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,n!==null&&(n.childLanes|=t)):n!==null&&(n.childLanes&t)!==t&&(n.childLanes|=t),e===r)break;e=e.return}}function Ot(e,t){zr=e,bi=Nt=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(ae=!0),e.firstContext=null)}function xe(e){var t=e._currentValue2;if(bi!==e)if(e={context:e,memoizedValue:t,next:null},Nt===null){if(zr===null)throw Error("Context can only be read while React is rendering. In classes, you can read it in the render method or getDerivedStateFromProps. In function components, you can read it directly in the function body, but not inside Hooks like useReducer() or useMemo().");Nt=e,zr.dependencies={lanes:0,firstContext:e}}else Nt=Nt.next=e;return t}var ut=null;function qi(e){ut===null?ut=[e]:ut.push(e)}function $l(e,t,r,n){var s=t.interleaved;return s===null?(r.next=r,qi(t)):(r.next=s.next,s.next=r),t.interleaved=r,Rt(e,n)}function Rt(e,t){e.lanes|=t;var r=e.alternate;for(r!==null&&(r.lanes|=t),r=e,e=e.return;e!==null;)e.childLanes|=t,r=e.alternate,r!==null&&(r.childLanes|=t),r=e,e=e.return;return r.tag===3?r.stateNode:null}var Qe=!1;function Wi(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Hl(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Ye(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function ht(e,t,r){var n=e.updateQueue;if(n===null)return null;if(n=n.shared,X&2){var s=n.pending;return s===null?t.next=t:(t.next=s.next,s.next=t),n.pending=t,Rt(e,r)}return s=n.interleaved,s===null?(t.next=t,qi(n)):(t.next=s.next,s.next=t),n.interleaved=t,Rt(e,r)}function wr(e,t,r){if(t=t.updateQueue,t!==null&&(t=t.shared,(r&4194240)!==0)){var n=t.lanes;n&=e.pendingLanes,r|=n,t.lanes=r,Al(e,r)}}function ks(e,t){var r=e.updateQueue,n=e.alternate;if(n!==null&&(n=n.updateQueue,r===n)){var s=null,i=null;if(r=r.firstBaseUpdate,r!==null){do{var l={eventTime:r.eventTime,lane:r.lane,tag:r.tag,payload:r.payload,callback:r.callback,next:null};i===null?s=i=l:i=i.next=l,r=r.next}while(r!==null);i===null?s=i=t:i=i.next=t}else s=i=t;r={baseState:n.baseState,firstBaseUpdate:s,lastBaseUpdate:i,shared:n.shared,effects:n.effects},e.updateQueue=r;return}e=r.lastBaseUpdate,e===null?r.firstBaseUpdate=t:e.next=t,r.lastBaseUpdate=t}function Br(e,t,r,n){var s=e.updateQueue;Qe=!1;var i=s.firstBaseUpdate,l=s.lastBaseUpdate,o=s.shared.pending;if(o!==null){s.shared.pending=null;var u=o,f=u.next;u.next=null,l===null?i=f:l.next=f,l=u;var c=e.alternate;c!==null&&(c=c.updateQueue,o=c.lastBaseUpdate,o!==l&&(o===null?c.firstBaseUpdate=f:o.next=f,c.lastBaseUpdate=u))}if(i!==null){var v=s.baseState;l=0,c=f=u=null,o=i;do{var x=o.lane,N=o.eventTime;if((n&x)===x){c!==null&&(c=c.next={eventTime:N,lane:0,tag:o.tag,payload:o.payload,callback:o.callback,next:null});e:{var g=e,L=o;switch(x=t,N=r,L.tag){case 1:if(g=L.payload,typeof g=="function"){v=g.call(N,v,x);break e}v=g;break e;case 3:g.flags=g.flags&-65537|128;case 0:if(g=L.payload,x=typeof g=="function"?g.call(N,v,x):g,x==null)break e;v=ct({},v,x);break e;case 2:Qe=!0}}o.callback!==null&&o.lane!==0&&(e.flags|=64,x=s.effects,x===null?s.effects=[o]:x.push(o))}else N={eventTime:N,lane:x,tag:o.tag,payload:o.payload,callback:o.callback,next:null},c===null?(f=c=N,u=v):c=c.next=N,l|=x;if(o=o.next,o===null){if(o=s.shared.pending,o===null)break;x=o,o=x.next,x.next=null,s.lastBaseUpdate=x,s.shared.pending=null}}while(1);if(c===null&&(u=v),s.baseState=u,s.firstBaseUpdate=f,s.lastBaseUpdate=c,t=s.shared.interleaved,t!==null){s=t;do l|=s.lane,s=s.next;while(s!==t)}else i===null&&(s.shared.lanes=0);yt|=l,e.lanes=l,e.memoizedState=v}}function Rs(e,t,r){if(e=t.effects,t.effects=null,e!==null)for(t=0;tr?r:4,e(!0);var n=gn.transition;gn.transition={};try{e(!1),t()}finally{K=r,gn.transition=n}}function ho(){return Se().memoizedState}function ku(e,t,r){var n=It(e);if(r={lane:n,action:r,hasEagerState:!1,eagerState:null,next:null},fo(e))po(t,r);else if(r=$l(e,t,r,n),r!==null){var s=Ne();Ge(r,e,n,s),mo(r,t,n)}}function Ru(e,t,r){var n=It(e),s={lane:n,action:r,hasEagerState:!1,eagerState:null,next:null};if(fo(e))po(t,s);else{var i=e.alternate;if(e.lanes===0&&(i===null||i.lanes===0)&&(i=t.lastRenderedReducer,i!==null))try{var l=t.lastRenderedState,o=i(l,r);if(s.hasEagerState=!0,s.eagerState=o,Le(o,l)){var u=t.interleaved;u===null?(s.next=s,qi(t)):(s.next=u.next,u.next=s),t.interleaved=s;return}}catch{}finally{}r=$l(e,t,s,n),r!==null&&(s=Ne(),Ge(r,e,n,s),mo(r,t,n))}}function fo(e){var t=e.alternate;return e===U||t!==null&&t===U}function po(e,t){$t=br=!0;var r=e.pending;r===null?t.next=t:(t.next=r.next,r.next=t),e.pending=t}function mo(e,t,r){if(r&4194240){var n=t.lanes;n&=e.pendingLanes,r|=n,t.lanes=r,Al(e,r)}}var Ar={readContext:xe,useCallback:G,useContext:G,useEffect:G,useImperativeHandle:G,useInsertionEffect:G,useLayoutEffect:G,useMemo:G,useReducer:G,useRef:G,useState:G,useDebugValue:G,useDeferredValue:G,useTransition:G,useMutableSource:G,useSyncExternalStore:G,useId:G,unstable_isNewReconciler:!1},Xu={readContext:xe,useCallback:function(e,t){return Ce().memoizedState=[e,t===void 0?null:t],e},useContext:xe,useEffect:Fs,useImperativeHandle:function(e,t,r){return r=r!=null?r.concat([e]):null,Sr(4,4,lo.bind(null,t,e),r)},useLayoutEffect:function(e,t){return Sr(4,4,e,t)},useInsertionEffect:function(e,t){return Sr(4,2,e,t)},useMemo:function(e,t){var r=Ce();return t=t===void 0?null:t,e=e(),r.memoizedState=[e,t],e},useReducer:function(e,t,r){var n=Ce();return t=r!==void 0?r(t):t,n.memoizedState=n.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},n.queue=e,e=e.dispatch=ku.bind(null,U,e),[n.memoizedState,e]},useRef:function(e){var t=Ce();return e={current:e},t.memoizedState=e},useState:Xs,useDebugValue:Yi,useDeferredValue:function(e){return Ce().memoizedState=e},useTransition:function(){var e=Xs(!1),t=e[0];return e=ju.bind(null,e[1]),Ce().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t){var r=U,n=Ce(),s=t();if(Y===null)throw Error("Expected a work-in-progress root. This is a bug in React. Please file an issue.");gt&30||Zl(r,t,s),n.memoizedState=s;var i={value:s,getSnapshot:t};return n.queue=i,Fs(eo.bind(null,r,i,e),[e]),r.flags|=2048,er(9,Gl.bind(null,r,i,s,t),void 0,null),s},useId:function(){var e=Ce(),t=Y.identifierPrefix,r=Pu++;return t=":"+t+"r"+r.toString(32)+":",e.memoizedState=t},unstable_isNewReconciler:!1},Fu={readContext:xe,useCallback:uo,useContext:xe,useEffect:Ji,useImperativeHandle:oo,useInsertionEffect:io,useLayoutEffect:so,useMemo:ao,useReducer:yn,useRef:no,useState:function(){return yn(Gt)},useDebugValue:Yi,useDeferredValue:function(e){var t=Se();return co(t,Q.memoizedState,e)},useTransition:function(){var e=yn(Gt)[0],t=Se().memoizedState;return[e,t]},useMutableSource:Jl,useSyncExternalStore:Yl,useId:ho,unstable_isNewReconciler:!1},zu={readContext:xe,useCallback:uo,useContext:xe,useEffect:Ji,useImperativeHandle:oo,useInsertionEffect:io,useLayoutEffect:so,useMemo:ao,useReducer:vn,useRef:no,useState:function(){return vn(Gt)},useDebugValue:Yi,useDeferredValue:function(e){var t=Se();return Q===null?t.memoizedState=e:co(t,Q.memoizedState,e)},useTransition:function(){var e=vn(Gt)[0],t=Se().memoizedState;return[e,t]},useMutableSource:Jl,useSyncExternalStore:Yl,useId:ho,unstable_isNewReconciler:!1};function De(e,t){if(e&&e.defaultProps){t=ct({},t),e=e.defaultProps;for(var r in e)t[r]===void 0&&(t[r]=e[r]);return t}return t}function mi(e,t,r,n){t=e.memoizedState,r=r(n,t),r=r==null?t:ct({},t,r),e.memoizedState=r,e.lanes===0&&(e.updateQueue.baseState=r)}var tn={isMounted:function(e){return(e=e._reactInternals)?Jr(e)===e:!1},enqueueSetState:function(e,t,r){e=e._reactInternals;var n=Ne(),s=It(e),i=Ye(n,s);i.payload=t,r!=null&&(i.callback=r),t=ht(e,i,s),t!==null&&(Ge(t,e,s,n),wr(t,e,s))},enqueueReplaceState:function(e,t,r){e=e._reactInternals;var n=Ne(),s=It(e),i=Ye(n,s);i.tag=1,i.payload=t,r!=null&&(i.callback=r),t=ht(e,i,s),t!==null&&(Ge(t,e,s,n),wr(t,e,s))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var r=Ne(),n=It(e),s=Ye(r,n);s.tag=2,t!=null&&(s.callback=t),t=ht(e,s,n),t!==null&&(Ge(t,e,n,r),wr(t,e,n))}};function zs(e,t,r,n,s,i,l){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(n,i,l):t.prototype&&t.prototype.isPureReactComponent?!Xr(r,n)||!Xr(s,i):!0}function go(e,t,r){var n=!1,s=rt,i=t.contextType;return typeof i=="object"&&i!==null?i=xe(i):(s=fe(t)?mt:ne.current,n=t.contextTypes,i=(n=n!=null)?jt(e,s):rt),t=new t(r,i),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=tn,e.stateNode=t,t._reactInternals=e,n&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=s,e.__reactInternalMemoizedMaskedChildContext=i),t}function Bs(e,t,r,n){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(r,n),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(r,n),t.state!==e&&tn.enqueueReplaceState(t,t.state,null)}function gi(e,t,r,n){var s=e.stateNode;s.props=r,s.state=e.memoizedState,s.refs={},Wi(e);var i=t.contextType;typeof i=="object"&&i!==null?s.context=xe(i):(i=fe(t)?mt:ne.current,s.context=jt(e,i)),s.state=e.memoizedState,i=t.getDerivedStateFromProps,typeof i=="function"&&(mi(e,t,i,r),s.state=e.memoizedState),typeof t.getDerivedStateFromProps=="function"||typeof s.getSnapshotBeforeUpdate=="function"||typeof s.UNSAFE_componentWillMount!="function"&&typeof s.componentWillMount!="function"||(t=s.state,typeof s.componentWillMount=="function"&&s.componentWillMount(),typeof s.UNSAFE_componentWillMount=="function"&&s.UNSAFE_componentWillMount(),t!==s.state&&tn.enqueueReplaceState(s,s.state,null),Br(e,r,s,n),s.state=e.memoizedState),typeof s.componentDidMount=="function"&&(e.flags|=4)}function Zi(e,t){try{var r="",n=t;do r+=Iu(n),n=n.return;while(n);var s=r}catch(i){s=` +See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.`)}function Hi(e,t){if(t===null)return!1;for(var r=0;rr?r:4,e(!0);var n=gn.transition;gn.transition={};try{e(!1),t()}finally{K=r,gn.transition=n}}function ho(){return Se().memoizedState}function Ru(e,t,r){var n=It(e);if(r={lane:n,action:r,hasEagerState:!1,eagerState:null,next:null},fo(e))po(t,r);else if(r=$l(e,t,r,n),r!==null){var s=Ne();Ge(r,e,n,s),mo(r,t,n)}}function Xu(e,t,r){var n=It(e),s={lane:n,action:r,hasEagerState:!1,eagerState:null,next:null};if(fo(e))po(t,s);else{var i=e.alternate;if(e.lanes===0&&(i===null||i.lanes===0)&&(i=t.lastRenderedReducer,i!==null))try{var l=t.lastRenderedState,o=i(l,r);if(s.hasEagerState=!0,s.eagerState=o,Le(o,l)){var u=t.interleaved;u===null?(s.next=s,qi(t)):(s.next=u.next,u.next=s),t.interleaved=s;return}}catch{}finally{}r=$l(e,t,s,n),r!==null&&(s=Ne(),Ge(r,e,n,s),mo(r,t,n))}}function fo(e){var t=e.alternate;return e===U||t!==null&&t===U}function po(e,t){$t=br=!0;var r=e.pending;r===null?t.next=t:(t.next=r.next,r.next=t),e.pending=t}function mo(e,t,r){if(r&4194240){var n=t.lanes;n&=e.pendingLanes,r|=n,t.lanes=r,Al(e,r)}}var Ar={readContext:xe,useCallback:G,useContext:G,useEffect:G,useImperativeHandle:G,useInsertionEffect:G,useLayoutEffect:G,useMemo:G,useReducer:G,useRef:G,useState:G,useDebugValue:G,useDeferredValue:G,useTransition:G,useMutableSource:G,useSyncExternalStore:G,useId:G,unstable_isNewReconciler:!1},Fu={readContext:xe,useCallback:function(e,t){return Ce().memoizedState=[e,t===void 0?null:t],e},useContext:xe,useEffect:Fs,useImperativeHandle:function(e,t,r){return r=r!=null?r.concat([e]):null,Sr(4,4,lo.bind(null,t,e),r)},useLayoutEffect:function(e,t){return Sr(4,4,e,t)},useInsertionEffect:function(e,t){return Sr(4,2,e,t)},useMemo:function(e,t){var r=Ce();return t=t===void 0?null:t,e=e(),r.memoizedState=[e,t],e},useReducer:function(e,t,r){var n=Ce();return t=r!==void 0?r(t):t,n.memoizedState=n.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},n.queue=e,e=e.dispatch=Ru.bind(null,U,e),[n.memoizedState,e]},useRef:function(e){var t=Ce();return e={current:e},t.memoizedState=e},useState:Xs,useDebugValue:Yi,useDeferredValue:function(e){return Ce().memoizedState=e},useTransition:function(){var e=Xs(!1),t=e[0];return e=ku.bind(null,e[1]),Ce().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t){var r=U,n=Ce(),s=t();if(Y===null)throw Error("Expected a work-in-progress root. This is a bug in React. Please file an issue.");gt&30||Zl(r,t,s),n.memoizedState=s;var i={value:s,getSnapshot:t};return n.queue=i,Fs(eo.bind(null,r,i,e),[e]),r.flags|=2048,er(9,Gl.bind(null,r,i,s,t),void 0,null),s},useId:function(){var e=Ce(),t=Y.identifierPrefix,r=ju++;return t=":"+t+"r"+r.toString(32)+":",e.memoizedState=t},unstable_isNewReconciler:!1},zu={readContext:xe,useCallback:uo,useContext:xe,useEffect:Ji,useImperativeHandle:oo,useInsertionEffect:io,useLayoutEffect:so,useMemo:ao,useReducer:yn,useRef:no,useState:function(){return yn(Gt)},useDebugValue:Yi,useDeferredValue:function(e){var t=Se();return co(t,Q.memoizedState,e)},useTransition:function(){var e=yn(Gt)[0],t=Se().memoizedState;return[e,t]},useMutableSource:Jl,useSyncExternalStore:Yl,useId:ho,unstable_isNewReconciler:!1},Bu={readContext:xe,useCallback:uo,useContext:xe,useEffect:Ji,useImperativeHandle:oo,useInsertionEffect:io,useLayoutEffect:so,useMemo:ao,useReducer:vn,useRef:no,useState:function(){return vn(Gt)},useDebugValue:Yi,useDeferredValue:function(e){var t=Se();return Q===null?t.memoizedState=e:co(t,Q.memoizedState,e)},useTransition:function(){var e=vn(Gt)[0],t=Se().memoizedState;return[e,t]},useMutableSource:Jl,useSyncExternalStore:Yl,useId:ho,unstable_isNewReconciler:!1};function De(e,t){if(e&&e.defaultProps){t=ct({},t),e=e.defaultProps;for(var r in e)t[r]===void 0&&(t[r]=e[r]);return t}return t}function mi(e,t,r,n){t=e.memoizedState,r=r(n,t),r=r==null?t:ct({},t,r),e.memoizedState=r,e.lanes===0&&(e.updateQueue.baseState=r)}var tn={isMounted:function(e){return(e=e._reactInternals)?Jr(e)===e:!1},enqueueSetState:function(e,t,r){e=e._reactInternals;var n=Ne(),s=It(e),i=Ye(n,s);i.payload=t,r!=null&&(i.callback=r),t=ht(e,i,s),t!==null&&(Ge(t,e,s,n),wr(t,e,s))},enqueueReplaceState:function(e,t,r){e=e._reactInternals;var n=Ne(),s=It(e),i=Ye(n,s);i.tag=1,i.payload=t,r!=null&&(i.callback=r),t=ht(e,i,s),t!==null&&(Ge(t,e,s,n),wr(t,e,s))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var r=Ne(),n=It(e),s=Ye(r,n);s.tag=2,t!=null&&(s.callback=t),t=ht(e,s,n),t!==null&&(Ge(t,e,n,r),wr(t,e,n))}};function zs(e,t,r,n,s,i,l){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(n,i,l):t.prototype&&t.prototype.isPureReactComponent?!Xr(r,n)||!Xr(s,i):!0}function go(e,t,r){var n=!1,s=rt,i=t.contextType;return typeof i=="object"&&i!==null?i=xe(i):(s=fe(t)?mt:ne.current,n=t.contextTypes,i=(n=n!=null)?jt(e,s):rt),t=new t(r,i),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=tn,e.stateNode=t,t._reactInternals=e,n&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=s,e.__reactInternalMemoizedMaskedChildContext=i),t}function Bs(e,t,r,n){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(r,n),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(r,n),t.state!==e&&tn.enqueueReplaceState(t,t.state,null)}function gi(e,t,r,n){var s=e.stateNode;s.props=r,s.state=e.memoizedState,s.refs={},Wi(e);var i=t.contextType;typeof i=="object"&&i!==null?s.context=xe(i):(i=fe(t)?mt:ne.current,s.context=jt(e,i)),s.state=e.memoizedState,i=t.getDerivedStateFromProps,typeof i=="function"&&(mi(e,t,i,r),s.state=e.memoizedState),typeof t.getDerivedStateFromProps=="function"||typeof s.getSnapshotBeforeUpdate=="function"||typeof s.UNSAFE_componentWillMount!="function"&&typeof s.componentWillMount!="function"||(t=s.state,typeof s.componentWillMount=="function"&&s.componentWillMount(),typeof s.UNSAFE_componentWillMount=="function"&&s.UNSAFE_componentWillMount(),t!==s.state&&tn.enqueueReplaceState(s,s.state,null),Br(e,r,s,n),s.state=e.memoizedState),typeof s.componentDidMount=="function"&&(e.flags|=4)}function Zi(e,t){try{var r="",n=t;do r+=Cu(n),n=n.return;while(n);var s=r}catch(i){s=` Error generating stack: `+i.message+` -`+i.stack}return{value:e,source:t,stack:s,digest:null}}function wn(e,t,r){return{value:e,source:null,stack:r??null,digest:t??null}}function yi(e,t){try{console.error(t.value)}catch(r){setTimeout(function(){throw r})}}var Bu=typeof WeakMap=="function"?WeakMap:Map;function yo(e,t,r){r=Ye(-1,r),r.tag=3,r.payload={element:null};var n=t.value;return r.callback=function(){Vr||(Vr=!0,Li=n),yi(e,t)},r}function vo(e,t,r){r=Ye(-1,r),r.tag=3;var n=e.type.getDerivedStateFromError;if(typeof n=="function"){var s=t.value;r.payload=function(){return n(s)},r.callback=function(){yi(e,t)}}var i=e.stateNode;return i!==null&&typeof i.componentDidCatch=="function"&&(r.callback=function(){yi(e,t),typeof n!="function"&&(Ze===null?Ze=new Set([this]):Ze.add(this));var l=t.stack;this.componentDidCatch(t.value,{componentStack:l!==null?l:""})}),r}function _s(e,t,r){var n=e.pingCache;if(n===null){n=e.pingCache=new Bu;var s=new Set;n.set(t,s)}else s=n.get(t),s===void 0&&(s=new Set,n.set(t,s));s.has(r)||(s.add(r),e=Gu.bind(null,e,t,r),t.then(e,e))}var _u=nt.ReactCurrentOwner,ae=!1;function le(e,t,r,n){t.child=e===null?Cu(t,null,r,n):kt(t,e.child,r,n)}function bs(e,t,r,n,s){r=r.render;var i=t.ref;return Ot(t,s),n=Ki(e,t,r,n,i,s),e!==null&&!ae?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s,_e(e,t,s)):(t.flags|=1,le(e,t,n,s),t.child)}function As(e,t,r,n,s){if(e===null){var i=r.type;return typeof i=="function"&&!ls(i)&&i.defaultProps===void 0&&r.compare===null&&r.defaultProps===void 0?(t.tag=15,t.type=i,wo(e,t,i,n,s)):(e=Nr(r.type,null,n,t,t.mode,s),e.ref=t.ref,e.return=t,t.child=e)}if(i=e.child,!(e.lanes&s)){var l=i.memoizedProps;if(r=r.compare,r=r!==null?r:Xr,r(l,n)&&e.ref===t.ref)return _e(e,t,s)}return t.flags|=1,e=et(i,n),e.ref=t.ref,e.return=t,t.child=e}function wo(e,t,r,n,s){if(e!==null){var i=e.memoizedProps;if(Xr(i,n)&&e.ref===t.ref)if(ae=!1,t.pendingProps=n=i,(e.lanes&s)!==0)e.flags&131072&&(ae=!0);else return t.lanes=e.lanes,_e(e,t,s)}return vi(e,t,r,n,s)}function xo(e,t,r){var n=t.pendingProps,s=n.children,i=e!==null?e.memoizedState:null;if(n.mode==="hidden")if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},z(Lt,pe),pe|=r;else{if(!(r&1073741824))return e=i!==null?i.baseLanes|r:r,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,z(Lt,pe),pe|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},n=i!==null?i.baseLanes:r,z(Lt,pe),pe|=n}else i!==null?(n=i.baseLanes|r,t.memoizedState=null):n=r,z(Lt,pe),pe|=n;return le(e,t,s,r),t.child}function So(e,t){var r=t.ref;(e===null&&r!==null||e!==null&&e.ref!==r)&&(t.flags|=512)}function vi(e,t,r,n,s){var i=fe(r)?mt:ne.current;return i=jt(t,i),Ot(t,s),r=Ki(e,t,r,n,i,s),e!==null&&!ae?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s,_e(e,t,s)):(t.flags|=1,le(e,t,r,s),t.child)}function Us(e,t,r,n,s){if(fe(r)){var i=!0;Rr(t)}else i=!1;if(Ot(t,s),t.stateNode===null)Tr(e,t),go(t,r,n),gi(t,r,n,s),n=!0;else if(e===null){var l=t.stateNode,o=t.memoizedProps;l.props=o;var u=l.context,f=r.contextType;typeof f=="object"&&f!==null?f=xe(f):(f=fe(r)?mt:ne.current,f=jt(t,f));var c=r.getDerivedStateFromProps,v=typeof c=="function"||typeof l.getSnapshotBeforeUpdate=="function";v||typeof l.UNSAFE_componentWillReceiveProps!="function"&&typeof l.componentWillReceiveProps!="function"||(o!==n||u!==f)&&Bs(t,l,n,f),Qe=!1;var x=t.memoizedState;l.state=x,Br(t,n,l,s),u=t.memoizedState,o!==n||x!==u||de.current||Qe?(typeof c=="function"&&(mi(t,r,c,n),u=t.memoizedState),(o=Qe||zs(t,r,o,n,x,u,f))?(v||typeof l.UNSAFE_componentWillMount!="function"&&typeof l.componentWillMount!="function"||(typeof l.componentWillMount=="function"&&l.componentWillMount(),typeof l.UNSAFE_componentWillMount=="function"&&l.UNSAFE_componentWillMount()),typeof l.componentDidMount=="function"&&(t.flags|=4)):(typeof l.componentDidMount=="function"&&(t.flags|=4),t.memoizedProps=n,t.memoizedState=u),l.props=n,l.state=u,l.context=f,n=o):(typeof l.componentDidMount=="function"&&(t.flags|=4),n=!1)}else{l=t.stateNode,Hl(e,t),o=t.memoizedProps,f=t.type===t.elementType?o:De(t.type,o),l.props=f,v=t.pendingProps,x=l.context,u=r.contextType,typeof u=="object"&&u!==null?u=xe(u):(u=fe(r)?mt:ne.current,u=jt(t,u));var N=r.getDerivedStateFromProps;(c=typeof N=="function"||typeof l.getSnapshotBeforeUpdate=="function")||typeof l.UNSAFE_componentWillReceiveProps!="function"&&typeof l.componentWillReceiveProps!="function"||(o!==v||x!==u)&&Bs(t,l,n,u),Qe=!1,x=t.memoizedState,l.state=x,Br(t,n,l,s);var g=t.memoizedState;o!==v||x!==g||de.current||Qe?(typeof N=="function"&&(mi(t,r,N,n),g=t.memoizedState),(f=Qe||zs(t,r,f,n,x,g,u)||!1)?(c||typeof l.UNSAFE_componentWillUpdate!="function"&&typeof l.componentWillUpdate!="function"||(typeof l.componentWillUpdate=="function"&&l.componentWillUpdate(n,g,u),typeof l.UNSAFE_componentWillUpdate=="function"&&l.UNSAFE_componentWillUpdate(n,g,u)),typeof l.componentDidUpdate=="function"&&(t.flags|=4),typeof l.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof l.componentDidUpdate!="function"||o===e.memoizedProps&&x===e.memoizedState||(t.flags|=4),typeof l.getSnapshotBeforeUpdate!="function"||o===e.memoizedProps&&x===e.memoizedState||(t.flags|=1024),t.memoizedProps=n,t.memoizedState=g),l.props=n,l.state=g,l.context=u,n=f):(typeof l.componentDidUpdate!="function"||o===e.memoizedProps&&x===e.memoizedState||(t.flags|=4),typeof l.getSnapshotBeforeUpdate!="function"||o===e.memoizedProps&&x===e.memoizedState||(t.flags|=1024),n=!1)}return wi(e,t,r,n,i,s)}function wi(e,t,r,n,s,i){So(e,t);var l=(t.flags&128)!==0;if(!n&&!l)return s&&Is(t,r,!1),_e(e,t,i);n=t.stateNode,_u.current=t;var o=l&&typeof r.getDerivedStateFromError!="function"?null:n.render();return t.flags|=1,e!==null&&l?(t.child=kt(t,e.child,null,i),t.child=kt(t,null,o,i)):le(e,t,o,i),t.memoizedState=n.state,s&&Is(t,r,!0),t.child}function To(e){var t=e.stateNode;t.pendingContext?Os(e,t.pendingContext,t.pendingContext!==t.context):t.context&&Os(e,t.context,!1),Vi(e,t.containerInfo)}var xi={dehydrated:null,treeContext:null,retryLane:0};function Si(e){return{baseLanes:e,cachePool:null,transitions:null}}function Do(e,t,r){var n=t.pendingProps,s=A.current,i=!1,l=(t.flags&128)!==0,o;if((o=l)||(o=e!==null&&e.memoizedState===null?!1:(s&2)!==0),o?(i=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(s|=1),z(A,s&1),e===null)return e=t.memoizedState,e!==null&&e.dehydrated!==null?(t.mode&1?Ke()?t.lanes=8:t.lanes=1073741824:t.lanes=1,null):(l=n.children,e=n.fallback,i?(n=t.mode,i=t.child,l={mode:"hidden",children:l},!(n&1)&&i!==null?(i.childLanes=0,i.pendingProps=l):i=nn(l,n,0,null),e=ft(e,n,r,null),i.return=t,e.return=t,i.sibling=e,t.child=i,t.child.memoizedState=Si(r),t.memoizedState=xi,e):Gi(t,l));if(s=e.memoizedState,s!==null&&(o=s.dehydrated,o!==null))return bu(e,t,l,n,o,s,r);if(i){i=n.fallback,l=t.mode,s=e.child,o=s.sibling;var u={mode:"hidden",children:n.children};return!(l&1)&&t.child!==s?(n=t.child,n.childLanes=0,n.pendingProps=u,t.deletions=null):(n=et(s,u),n.subtreeFlags=s.subtreeFlags&14680064),o!==null?i=et(o,i):(i=ft(i,l,r,null),i.flags|=2),i.return=t,n.return=t,n.sibling=i,t.child=n,n=i,i=t.child,l=e.child.memoizedState,l=l===null?Si(r):{baseLanes:l.baseLanes|r,cachePool:null,transitions:l.transitions},i.memoizedState=l,i.childLanes=e.childLanes&~r,t.memoizedState=xi,n}return i=e.child,e=i.sibling,n=et(i,{mode:"visible",children:n.children}),!(t.mode&1)&&(n.lanes=r),n.return=t,n.sibling=null,e!==null&&(r=t.deletions,r===null?(t.deletions=[e],t.flags|=16):r.push(e)),t.child=n,t.memoizedState=null,n}function Gi(e,t){return t=nn({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function mr(e,t,r,n){return n!==null&&(ze===null?ze=[n]:ze.push(n)),kt(t,e.child,null,r),e=Gi(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function bu(e,t,r,n,s,i,l){if(r)return t.flags&256?(t.flags&=-257,i=wn(Error("There was an error while hydrating this Suspense boundary. Switched to client rendering.")),mr(e,t,l,i)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(i=n.fallback,r=t.mode,n=nn({mode:"visible",children:n.children},r,0,null),i=ft(i,r,l,null),i.flags|=2,n.return=t,i.return=t,n.sibling=i,t.child=n,t.mode&1&&kt(t,e.child,null,l),t.child.memoizedState=Si(l),t.memoizedState=xi,i);if(!(t.mode&1))return mr(e,t,l,null);if(Ke())return i=Ke().digest,i=wn(Error("The server could not finish this Suspense boundary, likely due to an error during server rendering. Switched to client rendering."),i,void 0),mr(e,t,l,i);if(r=(l&e.childLanes)!==0,ae||r){if(n=Y,n!==null){switch(l&-l){case 4:r=2;break;case 16:r=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:r=32;break;case 536870912:r=268435456;break;default:r=0}r=r&(n.suspendedLanes|l)?0:r,r!==0&&r!==i.retryLane&&(i.retryLane=r,Rt(e,r),Ge(n,e,r,-1))}return ss(),i=wn(Error("This Suspense boundary received an update before it finished hydrating. This caused the boundary to switch to client rendering. The usual way to fix this is to wrap the original update in startTransition.")),mr(e,t,l,i)}return Ke()?(t.flags|=128,t.child=e.child,ea.bind(null,e),Ke(),null):(e=Gi(t,n.children),e.flags|=4096,e)}function qs(e,t,r){e.lanes|=t;var n=e.alternate;n!==null&&(n.lanes|=t),pi(e.return,t,r)}function xn(e,t,r,n,s){var i=e.memoizedState;i===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:n,tail:r,tailMode:s}:(i.isBackwards=t,i.rendering=null,i.renderingStartTime=0,i.last=n,i.tail=r,i.tailMode=s)}function Eo(e,t,r){var n=t.pendingProps,s=n.revealOrder,i=n.tail;if(le(e,t,n.children,r),n=A.current,n&2)n=n&1|2,t.flags|=128;else{if(e!==null&&e.flags&128)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&qs(e,r,t);else if(e.tag===19)qs(e,r,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}n&=1}if(z(A,n),!(t.mode&1))t.memoizedState=null;else switch(s){case"forwards":for(r=t.child,s=null;r!==null;)e=r.alternate,e!==null&&_r(e)===null&&(s=r),r=r.sibling;r=s,r===null?(s=t.child,t.child=null):(s=r.sibling,r.sibling=null),xn(t,!1,s,r,i);break;case"backwards":for(r=null,s=t.child,t.child=null;s!==null;){if(e=s.alternate,e!==null&&_r(e)===null){t.child=s;break}e=s.sibling,s.sibling=r,r=s,s=e}xn(t,!0,r,null,i);break;case"together":xn(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function Tr(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function _e(e,t,r){if(e!==null&&(t.dependencies=e.dependencies),yt|=t.lanes,!(r&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error("Resuming work not yet implemented.");if(t.child!==null){for(e=t.child,r=et(e,e.pendingProps),t.child=r,r.return=t;e.sibling!==null;)e=e.sibling,r=r.sibling=et(e,e.pendingProps),r.return=t;r.sibling=null}return t.child}function Au(e,t,r){switch(t.tag){case 3:To(t);break;case 5:Kl(t);break;case 1:fe(t.type)&&Rr(t);break;case 4:Vi(t,t.stateNode.containerInfo);break;case 10:var n=t.type._context,s=t.memoizedProps.value;z(Fr,n._currentValue2),n._currentValue2=s;break;case 13:if(n=t.memoizedState,n!==null)return n.dehydrated!==null?(z(A,A.current&1),t.flags|=128,null):r&t.child.childLanes?Do(e,t,r):(z(A,A.current&1),e=_e(e,t,r),e!==null?e.sibling:null);z(A,A.current&1);break;case 19:if(n=(r&t.childLanes)!==0,e.flags&128){if(n)return Eo(e,t,r);t.flags|=128}if(s=t.memoizedState,s!==null&&(s.rendering=null,s.tail=null,s.lastEffect=null),z(A,A.current),n)break;return null;case 22:case 23:return t.lanes=0,xo(e,t,r)}return _e(e,t,r)}var No,Ti,Lo,Mo;No=function(e,t){for(var r=t.child;r!==null;){if(r.tag===5||r.tag===6){var n=e,s=r.stateNode,i=n.children.indexOf(s);i!==-1&&n.children.splice(i,1),n.children.push(s)}else if(r.tag!==4&&r.child!==null){r.child.return=r,r=r.child;continue}if(r===t)break;for(;r.sibling===null;){if(r.return===null||r.return===t)return;r=r.return}r.sibling.return=r.return,r=r.sibling}};Ti=function(){};Lo=function(e,t,r,n){e.memoizedProps!==n&&(at(Re.current),t.updateQueue=Du)&&(t.flags|=4)};Mo=function(e,t,r,n){r!==n&&(t.flags|=4)};function At(e,t){switch(e.tailMode){case"hidden":t=e.tail;for(var r=null;t!==null;)t.alternate!==null&&(r=t),t=t.sibling;r===null?e.tail=null:r.sibling=null;break;case"collapsed":r=e.tail;for(var n=null;r!==null;)r.alternate!==null&&(n=r),r=r.sibling;n===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:n.sibling=null}}function ee(e){var t=e.alternate!==null&&e.alternate.child===e.child,r=0,n=0;if(t)for(var s=e.child;s!==null;)r|=s.lanes|s.childLanes,n|=s.subtreeFlags&14680064,n|=s.flags&14680064,s.return=e,s=s.sibling;else for(s=e.child;s!==null;)r|=s.lanes|s.childLanes,n|=s.subtreeFlags,n|=s.flags,s.return=e,s=s.sibling;return e.subtreeFlags|=n,e.childLanes=r,t}function Uu(e,t,r){var n=t.pendingProps;switch(_i(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return ee(t),null;case 1:return fe(t.type)&&kr(),ee(t),null;case 3:return r=t.stateNode,Xt(),B(de),B(ne),$i(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),e!==null&&e.child!==null||e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,ze!==null&&(Ii(ze),ze=null)),Ti(e,t),ee(t),null;case 5:Qi(t),r=at(Zt.current);var s=t.type;if(e!==null&&t.stateNode!=null)Lo(e,t,s,n,r),e.ref!==t.ref&&(t.flags|=512);else{if(!n){if(t.stateNode===null)throw Error("We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue.");return ee(t),null}at(Re.current),e={type:s,props:n,isHidden:!1,children:[],internalInstanceHandle:t,rootContainerInstance:r,tag:"INSTANCE"},No(e,t,!1,!1),t.stateNode=e,t.ref!==null&&(t.flags|=512)}return ee(t),null;case 6:if(e&&t.stateNode!=null)Mo(e,t,e.memoizedProps,n);else{if(typeof n!="string"&&t.stateNode===null)throw Error("We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue.");at(Zt.current),at(Re.current),t.stateNode={text:n,isHidden:!1,tag:"TEXT"}}return ee(t),null;case 13:if(B(A),n=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(n!==null&&n.dehydrated!==null){if(e===null)throw Error("A dehydrated suspense component was completed without a hydrated node. This is probably a bug in React.");!(t.flags&128)&&(t.memoizedState=null),t.flags|=4,ee(t),s=!1}else ze!==null&&(Ii(ze),ze=null),s=!0;if(!s)return t.flags&65536?t:null}return t.flags&128?(t.lanes=r,t):(r=n!==null,r!==(e!==null&&e.memoizedState!==null)&&r&&(t.child.flags|=8192,t.mode&1&&(e===null||A.current&1?H===0&&(H=3):ss())),t.updateQueue!==null&&(t.flags|=4),ee(t),null);case 4:return Xt(),Ti(e,t),ee(t),null;case 10:return Ui(t.type._context),ee(t),null;case 17:return fe(t.type)&&kr(),ee(t),null;case 19:if(B(A),s=t.memoizedState,s===null)return ee(t),null;n=(t.flags&128)!==0;var i=s.rendering;if(i===null)if(n)At(s,!1);else{if(H!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(i=_r(e),i!==null){for(t.flags|=128,At(s,!1),e=i.updateQueue,e!==null&&(t.updateQueue=e,t.flags|=4),t.subtreeFlags=0,e=r,r=t.child;r!==null;)n=r,s=e,n.flags&=14680066,i=n.alternate,i===null?(n.childLanes=0,n.lanes=s,n.child=null,n.subtreeFlags=0,n.memoizedProps=null,n.memoizedState=null,n.updateQueue=null,n.dependencies=null,n.stateNode=null):(n.childLanes=i.childLanes,n.lanes=i.lanes,n.child=i.child,n.subtreeFlags=0,n.deletions=null,n.memoizedProps=i.memoizedProps,n.memoizedState=i.memoizedState,n.updateQueue=i.updateQueue,n.type=i.type,s=i.dependencies,n.dependencies=s===null?null:{lanes:s.lanes,firstContext:s.firstContext}),r=r.sibling;return z(A,A.current&1|2),t.child}e=e.sibling}s.tail!==null&&$()>rr&&(t.flags|=128,n=!0,At(s,!1),t.lanes=4194304)}else{if(!n)if(e=_r(i),e!==null){if(t.flags|=128,n=!0,e=e.updateQueue,e!==null&&(t.updateQueue=e,t.flags|=4),At(s,!0),s.tail===null&&s.tailMode==="hidden"&&!i.alternate)return ee(t),null}else 2*$()-s.renderingStartTime>rr&&r!==1073741824&&(t.flags|=128,n=!0,At(s,!1),t.lanes=4194304);s.isBackwards?(i.sibling=t.child,t.child=i):(e=s.last,e!==null?e.sibling=i:t.child=i,s.last=i)}return s.tail!==null?(t=s.tail,s.rendering=t,s.tail=t.sibling,s.renderingStartTime=$(),t.sibling=null,e=A.current,z(A,n?e&1|2:e&1),t):(ee(t),null);case 22:case 23:return is(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?pe&1073741824&&(ee(t),t.subtreeFlags&6&&(t.flags|=8192)):ee(t),null;case 24:return null;case 25:return null}throw Error("Unknown unit of work tag ("+t.tag+"). This error is likely caused by a bug in React. Please file an issue.")}function qu(e,t){switch(_i(t),t.tag){case 1:return fe(t.type)&&kr(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Xt(),B(de),B(ne),$i(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return Qi(t),null;case 13:if(B(A),e=t.memoizedState,e!==null&&e.dehydrated!==null&&t.alternate===null)throw Error("Threw in newly mounted dehydrated component. This is likely a bug in React. Please file an issue.");return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return B(A),null;case 4:return Xt(),null;case 10:return Ui(t.type._context),null;case 22:case 23:return is(),null;case 24:return null;default:return null}}var Wu=typeof WeakSet=="function"?WeakSet:Set,j=null;function Ur(e,t){var r=e.ref;if(r!==null)if(typeof r=="function")try{r(null)}catch(n){ue(e,t,n)}else r.current=null}function Di(e,t,r){try{r()}catch(n){ue(e,t,n)}}var Ws=!1;function Vu(e,t){for(j=t;j!==null;)if(e=j,t=e.child,(e.subtreeFlags&1028)!==0&&t!==null)t.return=e,j=t;else for(;j!==null;){e=j;try{var r=e.alternate;if(e.flags&1024)switch(e.tag){case 0:case 11:case 15:break;case 1:if(r!==null){var n=r.memoizedProps,s=r.memoizedState,i=e.stateNode,l=i.getSnapshotBeforeUpdate(e.elementType===e.type?n:De(e.type,n),s);i.__reactInternalSnapshotBeforeUpdate=l}break;case 3:e.stateNode.containerInfo.children.splice(0);break;case 5:case 6:case 4:case 17:break;default:throw Error("This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue.")}}catch(o){ue(e,e.return,o)}if(t=e.sibling,t!==null){t.return=e.return,j=t;break}j=e.return}return r=Ws,Ws=!1,r}function qr(e,t,r){var n=t.updateQueue;if(n=n!==null?n.lastEffect:null,n!==null){var s=n=n.next;do{if((s.tag&e)===e){var i=s.destroy;s.destroy=void 0,i!==void 0&&Di(t,r,i)}s=s.next}while(s!==n)}}function es(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var r=t=t.next;do{if((r.tag&e)===e){var n=r.create;r.destroy=n()}r=r.next}while(r!==t)}}function Oo(e){var t=e.alternate;t!==null&&(e.alternate=null,Oo(t)),e.child=null,e.deletions=null,e.sibling=null,e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function Io(e){return e.tag===5||e.tag===3||e.tag===4}function Vs(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Io(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Ei(e,t,r){var n=e.tag;if(n===5||n===6)e=e.stateNode,t?Wl(r,e,t):ql(r,e);else if(n!==4&&(e=e.child,e!==null))for(Ei(e,t,r),e=e.sibling;e!==null;)Ei(e,t,r),e=e.sibling}function Ni(e,t,r){var n=e.tag;if(n===5||n===6)e=e.stateNode,t?Wl(r,e,t):ql(r,e);else if(n!==4&&(e=e.child,e!==null))for(Ni(e,t,r),e=e.sibling;e!==null;)Ni(e,t,r),e=e.sibling}var se=null;function lt(e,t,r){for(r=r.child;r!==null;)Co(e,t,r),r=r.sibling}function Co(e,t,r){if(ke&&typeof ke.onCommitFiberUnmount=="function")try{ke.onCommitFiberUnmount(Yr,r)}catch{}switch(r.tag){case 5:Ur(r,t);case 6:var n=se;se=null,lt(e,t,r),se=n,se!==null&&(e=se,r=e.children.indexOf(r.stateNode),e.children.splice(r,1));break;case 18:se!==null&&Ke(se,r.stateNode);break;case 4:n=se,se=r.stateNode.containerInfo,lt(e,t,r),se=n;break;case 0:case 11:case 14:case 15:if(n=r.updateQueue,n!==null&&(n=n.lastEffect,n!==null)){var s=n=n.next;do{var i=s,l=i.destroy;i=i.tag,l!==void 0&&(i&2||i&4)&&Di(r,t,l),s=s.next}while(s!==n)}lt(e,t,r);break;case 1:if(Ur(r,t),n=r.stateNode,typeof n.componentWillUnmount=="function")try{n.props=r.memoizedProps,n.state=r.memoizedState,n.componentWillUnmount()}catch(o){ue(r,t,o)}lt(e,t,r);break;case 21:lt(e,t,r);break;case 22:lt(e,t,r);break;default:lt(e,t,r)}}function Qs(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var r=e.stateNode;r===null&&(r=e.stateNode=new Wu),t.forEach(function(n){var s=ta.bind(null,e,n);r.has(n)||(r.add(n),n.then(s,s))})}}function Oe(e,t){var r=t.deletions;if(r!==null)for(var n=0;ns&&(s=l),n&=~i}if(n=s,n=$()-n,n=(120>n?120:480>n?480:1080>n?1080:1920>n?1920:3e3>n?3e3:4320>n?4320:1960*$u(n/1960))-n,10e?16:e,Je===null)var n=!1;else{if(e=Je,Je=null,Qr=0,X&6)throw Error("Cannot flush passive effects while already rendering.");var s=X;for(X|=4,j=e.current;j!==null;){var i=j,l=i.child;if(j.flags&16){var o=i.deletions;if(o!==null){for(var u=0;u$()-ns?dt(e,0):rs|=r),we(e,t)}function zo(e,t){t===0&&(e.mode&1?(t=cr,cr<<=1,!(cr&130023424)&&(cr=4194304)):t=1);var r=Ne();e=Rt(e,t),e!==null&&(Zr(e,t,r),we(e,r))}function ea(e){var t=e.memoizedState,r=0;t!==null&&(r=t.retryLane),zo(e,r)}function ta(e,t){var r=0;switch(e.tag){case 13:var n=e.stateNode,s=e.memoizedState;s!==null&&(r=s.retryLane);break;case 19:n=e.stateNode;break;default:throw Error("Pinged unknown suspense boundary type. This is probably a bug in React.")}n!==null&&n.delete(t),zo(e,r)}var Bo;Bo=function(e,t,r){if(e!==null)if(e.memoizedProps!==t.pendingProps||de.current)ae=!0;else{if(!(e.lanes&r)&&!(t.flags&128))return ae=!1,Au(e,t,r);ae=!!(e.flags&131072)}else ae=!1;switch(t.lanes=0,t.tag){case 2:var n=t.type;Tr(e,t),e=t.pendingProps;var s=jt(t,ne.current);if(Ot(t,r),s=Ki(null,t,n,e,s,r),t.flags|=1,typeof s=="object"&&s!==null&&typeof s.render=="function"&&s.$$typeof===void 0){if(t.tag=1,t.memoizedState=null,t.updateQueue=null,fe(n)){var i=!0;Rr(t)}else i=!1;t.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,Wi(t),s.updater=tn,t.stateNode=s,s._reactInternals=t,gi(t,n,e,r),t=wi(null,t,n,!0,i,r)}else t.tag=0,le(null,t,s,r),t=t.child;return t;case 16:n=t.elementType;e:{switch(Tr(e,t),e=t.pendingProps,s=n._init,n=s(n._payload),t.type=n,s=t.tag=na(n),e=De(n,e),s){case 0:t=vi(null,t,n,e,r);break e;case 1:t=Us(null,t,n,e,r);break e;case 11:t=bs(null,t,n,e,r);break e;case 14:t=As(null,t,n,De(n.type,e),r);break e}throw Error("Element type is invalid. Received a promise that resolves to: "+n+". Lazy element type must resolve to a class or function.")}return t;case 0:return n=t.type,s=t.pendingProps,s=t.elementType===n?s:De(n,s),vi(e,t,n,s,r);case 1:return n=t.type,s=t.pendingProps,s=t.elementType===n?s:De(n,s),Us(e,t,n,s,r);case 3:if(To(t),e===null)throw Error("Should have a current fiber. This is a bug in React.");return s=t.pendingProps,n=t.memoizedState.element,Hl(e,t),Br(t,s,null,r),s=t.memoizedState.element,s===n?t=_e(e,t,r):(le(e,t,s,r),t=t.child),t;case 5:return Kl(t),n=t.pendingProps.children,So(e,t),le(e,t,n,r),t.child;case 6:return null;case 13:return Do(e,t,r);case 4:return Vi(t,t.stateNode.containerInfo),n=t.pendingProps,e===null?t.child=kt(t,null,n,r):le(e,t,n,r),t.child;case 11:return n=t.type,s=t.pendingProps,s=t.elementType===n?s:De(n,s),bs(e,t,n,s,r);case 7:return le(e,t,t.pendingProps,r),t.child;case 8:return le(e,t,t.pendingProps.children,r),t.child;case 12:return le(e,t,t.pendingProps.children,r),t.child;case 10:e:{n=t.type._context,s=t.pendingProps,i=t.memoizedProps;var l=s.value;if(z(Fr,n._currentValue2),n._currentValue2=l,i!==null)if(Le(i.value,l)){if(i.children===s.children&&!de.current){t=_e(e,t,r);break e}}else for(i=t.child,i!==null&&(i.return=t);i!==null;){var o=i.dependencies;if(o!==null){l=i.child;for(var u=o.firstContext;u!==null;){if(u.context===n){if(i.tag===1){u=Ye(-1,r&-r),u.tag=2;var f=i.updateQueue;if(f!==null){f=f.shared;var c=f.pending;c===null?u.next=u:(u.next=c.next,c.next=u),f.pending=u}}i.lanes|=r,u=i.alternate,u!==null&&(u.lanes|=r),pi(i.return,r,t),o.lanes|=r;break}u=u.next}}else if(i.tag===10)l=i.type===t.type?null:i.child;else if(i.tag===18){if(l=i.return,l===null)throw Error("We just came from a parent so we must have had a parent. This is a bug in React.");l.lanes|=r,o=l.alternate,o!==null&&(o.lanes|=r),pi(l,r,t),l=i.sibling}else l=i.child;if(l!==null)l.return=i;else for(l=i;l!==null;){if(l===t){l=null;break}if(i=l.sibling,i!==null){i.return=l.return,l=i;break}l=l.return}i=l}le(e,t,s.children,r),t=t.child}return t;case 9:return s=t.type,n=t.pendingProps.children,Ot(t,r),s=xe(s),n=n(s),t.flags|=1,le(e,t,n,r),t.child;case 14:return n=t.type,s=De(n,t.pendingProps),s=De(n.type,s),As(e,t,n,s,r);case 15:return wo(e,t,t.type,t.pendingProps,r);case 17:return n=t.type,s=t.pendingProps,s=t.elementType===n?s:De(n,s),Tr(e,t),t.tag=1,fe(n)?(e=!0,Rr(t)):e=!1,Ot(t,r),go(t,n,s),gi(t,n,s,r),wi(null,t,n,!0,e,r);case 19:return Eo(e,t,r);case 22:return xo(e,t,r)}throw Error("Unknown unit of work tag ("+t.tag+"). This error is likely caused by a bug in React. Please file an issue.")};function _o(e,t){return Bi(e,t)}function ra(e,t,r,n){this.tag=e,this.key=r,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=n,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function je(e,t,r,n){return new ra(e,t,r,n)}function ls(e){return e=e.prototype,!(!e||!e.isReactComponent)}function na(e){if(typeof e=="function")return ls(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Fi)return 11;if(e===zi)return 14}return 2}function et(e,t){var r=e.alternate;return r===null?(r=je(e.tag,t,e.key,e.mode),r.elementType=e.elementType,r.type=e.type,r.stateNode=e.stateNode,r.alternate=e,e.alternate=r):(r.pendingProps=t,r.type=e.type,r.flags=0,r.subtreeFlags=0,r.deletions=null),r.flags=e.flags&14680064,r.childLanes=e.childLanes,r.lanes=e.lanes,r.child=e.child,r.memoizedProps=e.memoizedProps,r.memoizedState=e.memoizedState,r.updateQueue=e.updateQueue,t=e.dependencies,r.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},r.sibling=e.sibling,r.index=e.index,r.ref=e.ref,r}function Nr(e,t,r,n,s,i){var l=2;if(n=e,typeof e=="function")ls(e)&&(l=1);else if(typeof e=="string")l=5;else e:switch(e){case Dt:return ft(r.children,s,i,t);case Xi:l=8,s|=8;break;case li:return e=je(12,r,t,s|2),e.elementType=li,e.lanes=i,e;case oi:return e=je(13,r,t,s),e.elementType=oi,e.lanes=i,e;case ui:return e=je(19,r,t,s),e.elementType=ui,e.lanes=i,e;case zl:return nn(r,s,i,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case Xl:l=10;break e;case Fl:l=9;break e;case Fi:l=11;break e;case zi:l=14;break e;case Ve:l=16,n=null;break e}throw Error("Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: "+((e==null?e:typeof e)+"."))}return t=je(l,r,t,s),t.elementType=e,t.type=n,t.lanes=i,t}function ft(e,t,r,n){return e=je(7,e,n,t),e.lanes=r,e}function nn(e,t,r,n){return e=je(22,e,n,t),e.elementType=zl,e.lanes=r,e.stateNode={isHidden:!1},e}function Sn(e,t,r){return e=je(6,e,null,t),e.lanes=r,e}function Tn(e,t,r){return t=je(4,e.children!==null?e.children:[],e.key,t),t.lanes=r,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function ia(e,t,r,n,s){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=an(0),this.expirationTimes=an(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=an(0),this.identifierPrefix=n,this.onRecoverableError=s}function sa(e,t,r,n,s,i,l){return e=new ia(e,t,!1,i,l),t===1?(t=1,n===!0&&(t|=8)):t=0,n=je(3,null,null,t),e.current=n,n.stateNode=e,n.memoizedState={element:null,isDehydrated:!1,cache:null,transitions:null,pendingSuspenseBoundaries:null},Wi(n),e}function Dn(e,t,r,n){var s=t.current,i=Ne(),l=It(s);e:if(r){r=r._reactInternals;t:{if(Jr(r)!==r||r.tag!==1)throw Error("Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue.");var o=r;do{switch(o.tag){case 3:o=o.stateNode.context;break t;case 1:if(fe(o.type)){o=o.stateNode.__reactInternalMemoizedMergedChildContext;break t}}o=o.return}while(o!==null);throw Error("Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue.")}if(r.tag===1){var u=r.type;if(fe(u)){r=Vl(r,u,o);break e}}r=o}else r=rt;return t.context===null?t.context=r:t.pendingContext=r,t=Ye(i,l),t.payload={element:e},n=n===void 0?null:n,n!==null&&(t.callback=n),e=ht(s,t,l),e!==null&&(Ge(e,s,l,i),wr(e,s,l)),l}function la(){return null}var oa=kl.unstable_act,ua={createNodeMock:function(){return null}};function Lr(e){if(e.isHidden)return null;switch(e.tag){case"TEXT":return e.text;case"INSTANCE":var t=e.props,r=["children"];if(t==null)t={};else{var n={},s=Object.keys(t),i;for(i=0;iPi(r).length)break;return os(r)}r=r.return}return null}},{key:"children",get:function(){return Pi(this._currentFiber())}}]),e}();function Mr(e,t,r){var n=r?r.deep:!0,s=[];return t(e)&&(s.push(e),!n)||e.children.forEach(function(i){typeof i!="string"&&s.push.apply(s,Mr(i,t,r))}),s}function En(e,t){if(e.length===1)return e[0];throw Error((e.length===0?"No instances found ":"Expected 1 but found "+e.length+" instances ")+t)}function ca(e){console.error(e)}var Nn=new WeakMap;function os(e){var t=Nn.get(e);return t===void 0&&e.alternate!==null&&(t=Nn.get(e.alternate)),t===void 0&&(t=new aa(e),Nn.set(e,t)),t}var qt={findFiberByHostInstance:function(){throw Error("TestRenderer does not support findFiberByHostInstance()")},bundleType:0,version:"18.3.1",rendererPackageName:"react-test-renderer"},ha={bundleType:qt.bundleType,version:qt.version,rendererPackageName:qt.rendererPackageName,rendererConfig:qt.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:nt.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=Bl(e),e=e!==null?_l(e):null,e===null?null:e.stateNode},findFiberByHostInstance:qt.findFiberByHostInstance||la,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var yr=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!yr.isDisabled&&yr.supportsFiber)try{Yr=yr.inject(ha),ke=yr}catch{}}nr._Scheduler=Rl;nr.act=oa;nr.create=function(e,t){var r=ua.createNodeMock,n=!1,s=!1;typeof t=="object"&&t!==null&&(typeof t.createNodeMock=="function"&&(r=t.createNodeMock),t.unstable_isConcurrent===!0&&(n=!0),t.unstable_strictMode===!0&&(s=!0));var i={children:[],createNodeMock:r,tag:"CONTAINER"},l=sa(i,n?1:0,null,s,null,"",ca);if(l==null)throw Error("something went wrong");return Dn(e,l,null,null),e={_Scheduler:Rl,root:void 0,toJSON:function(){if(l==null||l.current==null||i==null||i.children.length===0)return null;if(i.children.length===1)return Lr(i.children[0]);if(i.children.length===2&&i.children[0].isHidden===!0&&i.children[1].isHidden===!1)return Lr(i.children[1]);var o=null;if(i.children&&i.children.length)for(var u=0;u":"attribute: {"+n+"}, parent: <"+this.parent.name+">"}isEqualNode(n){return!(n.namespaceURI!==this.namespaceURI||n.prefix!==this.prefix||n.localName!==this.localName||n.value!==this.value)}}return Object.defineProperty(t.prototype,"nodeType",{get:function(){return this.type}}),Object.defineProperty(t.prototype,"ownerElement",{get:function(){return this.parent}}),Object.defineProperty(t.prototype,"textContent",{get:function(){return this.value},set:function(r){return this.value=r||""}}),Object.defineProperty(t.prototype,"namespaceURI",{get:function(){return""}}),Object.defineProperty(t.prototype,"prefix",{get:function(){return""}}),Object.defineProperty(t.prototype,"localName",{get:function(){return this.name}}),Object.defineProperty(t.prototype,"specified",{get:function(){return!0}}),t}.call(this)}.call(R)),Rn.exports}var Xn={exports:{}},rl;function us(){return rl||(rl=1,function(){Xn.exports=function(){class e{constructor(r){this.nodes=r}clone(){return this.nodes=null}getNamedItem(r){return this.nodes[r]}setNamedItem(r){var n;return n=this.nodes[r.nodeName],this.nodes[r.nodeName]=r,n||null}removeNamedItem(r){var n;return n=this.nodes[r],delete this.nodes[r],n||null}item(r){return this.nodes[Object.keys(this.nodes)[r]]||null}getNamedItemNS(r,n){throw new Error("This DOM method is not implemented.")}setNamedItemNS(r){throw new Error("This DOM method is not implemented.")}removeNamedItemNS(r,n){throw new Error("This DOM method is not implemented.")}}return Object.defineProperty(e.prototype,"length",{get:function(){return Object.keys(this.nodes).length||0}}),e}.call(this)}.call(R)),Xn.exports}var nl;function as(){return nl||(nl=1,function(){var e,t,r,n,s,i,l,o={}.hasOwnProperty;({isObject:l,isFunction:i,getValue:s}=Ae()),n=Te(),e=V(),t=qo(),r=us(),jn.exports=function(){class u extends n{constructor(c,v,x){var N,g,L,P;if(super(c),v==null)throw new Error("Missing element name. "+this.debugInfo());if(this.name=this.stringify.name(v),this.type=e.Element,this.attribs={},this.schemaTypeInfo=null,x!=null&&this.attribute(x),c.type===e.Document&&(this.isRoot=!0,this.documentObject=c,c.rootObject=this,c.children)){for(P=c.children,g=0,L=P.length;g=N;v=0<=N?++x:--x)if(!this.attribs[v].isEqualNode(c.attribs[v]))return!1;return!0}}return Object.defineProperty(u.prototype,"tagName",{get:function(){return this.name}}),Object.defineProperty(u.prototype,"namespaceURI",{get:function(){return""}}),Object.defineProperty(u.prototype,"prefix",{get:function(){return""}}),Object.defineProperty(u.prototype,"localName",{get:function(){return this.name}}),Object.defineProperty(u.prototype,"id",{get:function(){throw new Error("This DOM method is not implemented."+this.debugInfo())}}),Object.defineProperty(u.prototype,"className",{get:function(){throw new Error("This DOM method is not implemented."+this.debugInfo())}}),Object.defineProperty(u.prototype,"classList",{get:function(){throw new Error("This DOM method is not implemented."+this.debugInfo())}}),Object.defineProperty(u.prototype,"attributes",{get:function(){return(!this.attributeMap||!this.attributeMap.nodes)&&(this.attributeMap=new r(this.attribs)),this.attributeMap}}),u}.call(this)}.call(R)),jn.exports}var Fn={exports:{}},zn={exports:{}},il;function sn(){return il||(il=1,function(){var e;e=Te(),zn.exports=function(){class t extends e{constructor(n){super(n),this.value=""}clone(){return Object.create(this)}substringData(n,s){throw new Error("This DOM method is not implemented."+this.debugInfo())}appendData(n){throw new Error("This DOM method is not implemented."+this.debugInfo())}insertData(n,s){throw new Error("This DOM method is not implemented."+this.debugInfo())}deleteData(n,s){throw new Error("This DOM method is not implemented."+this.debugInfo())}replaceData(n,s,i){throw new Error("This DOM method is not implemented."+this.debugInfo())}isEqualNode(n){return!(!super.isEqualNode(n)||n.data!==this.data)}}return Object.defineProperty(t.prototype,"data",{get:function(){return this.value},set:function(r){return this.value=r||""}}),Object.defineProperty(t.prototype,"length",{get:function(){return this.value.length}}),Object.defineProperty(t.prototype,"textContent",{get:function(){return this.value},set:function(r){return this.value=r||""}}),t}.call(this)}.call(R)),zn.exports}var sl;function cs(){return sl||(sl=1,function(){var e,t;e=V(),t=sn(),Fn.exports=class extends t{constructor(n,s){if(super(n),s==null)throw new Error("Missing CDATA text. "+this.debugInfo());this.name="#cdata-section",this.type=e.CData,this.value=this.stringify.cdata(s)}clone(){return Object.create(this)}toString(n){return this.options.writer.cdata(this,this.options.writer.filterOptions(n))}}}.call(R)),Fn.exports}var Bn={exports:{}},ll;function hs(){return ll||(ll=1,function(){var e,t;e=V(),t=sn(),Bn.exports=class extends t{constructor(n,s){if(super(n),s==null)throw new Error("Missing comment text. "+this.debugInfo());this.name="#comment",this.type=e.Comment,this.value=this.stringify.comment(s)}clone(){return Object.create(this)}toString(n){return this.options.writer.comment(this,this.options.writer.filterOptions(n))}}}.call(R)),Bn.exports}var _n={exports:{}},ol;function ds(){return ol||(ol=1,function(){var e,t,r;({isObject:r}=Ae()),t=Te(),e=V(),_n.exports=class extends t{constructor(s,i,l,o){super(s),r(i)&&({version:i,encoding:l,standalone:o}=i),i||(i="1.0"),this.type=e.Declaration,this.version=this.stringify.xmlVersion(i),l!=null&&(this.encoding=this.stringify.xmlEncoding(l)),o!=null&&(this.standalone=this.stringify.xmlStandalone(o))}toString(s){return this.options.writer.declaration(this,this.options.writer.filterOptions(s))}}}.call(R)),_n.exports}var bn={exports:{}},An={exports:{}},ul;function fs(){return ul||(ul=1,function(){var e,t;t=Te(),e=V(),An.exports=class extends t{constructor(n,s,i,l,o,u){if(super(n),s==null)throw new Error("Missing DTD element name. "+this.debugInfo());if(i==null)throw new Error("Missing DTD attribute name. "+this.debugInfo(s));if(!l)throw new Error("Missing DTD attribute type. "+this.debugInfo(s));if(!o)throw new Error("Missing DTD attribute default. "+this.debugInfo(s));if(o.indexOf("#")!==0&&(o="#"+o),!o.match(/^(#REQUIRED|#IMPLIED|#FIXED|#DEFAULT)$/))throw new Error("Invalid default value type; expected: #REQUIRED, #IMPLIED, #FIXED or #DEFAULT. "+this.debugInfo(s));if(u&&!o.match(/^(#FIXED|#DEFAULT)$/))throw new Error("Default value only applies to #FIXED or #DEFAULT. "+this.debugInfo(s));this.elementName=this.stringify.name(s),this.type=e.AttributeDeclaration,this.attributeName=this.stringify.name(i),this.attributeType=this.stringify.dtdAttType(l),u&&(this.defaultValue=this.stringify.dtdAttDefault(u)),this.defaultValueType=o}toString(n){return this.options.writer.dtdAttList(this,this.options.writer.filterOptions(n))}}}.call(R)),An.exports}var Un={exports:{}},al;function ps(){return al||(al=1,function(){var e,t,r;({isObject:r}=Ae()),t=Te(),e=V(),Un.exports=function(){class n extends t{constructor(i,l,o,u){if(super(i),o==null)throw new Error("Missing DTD entity name. "+this.debugInfo(o));if(u==null)throw new Error("Missing DTD entity value. "+this.debugInfo(o));if(this.pe=!!l,this.name=this.stringify.name(o),this.type=e.EntityDeclaration,!r(u))this.value=this.stringify.dtdEntityValue(u),this.internal=!0;else{if(!u.pubID&&!u.sysID)throw new Error("Public and/or system identifiers are required for an external entity. "+this.debugInfo(o));if(u.pubID&&!u.sysID)throw new Error("System identifier is required for a public external entity. "+this.debugInfo(o));if(this.internal=!1,u.pubID!=null&&(this.pubID=this.stringify.dtdPubID(u.pubID)),u.sysID!=null&&(this.sysID=this.stringify.dtdSysID(u.sysID)),u.nData!=null&&(this.nData=this.stringify.dtdNData(u.nData)),this.pe&&this.nData)throw new Error("Notation declaration is not allowed in a parameter entity. "+this.debugInfo(o))}}toString(i){return this.options.writer.dtdEntity(this,this.options.writer.filterOptions(i))}}return Object.defineProperty(n.prototype,"publicId",{get:function(){return this.pubID}}),Object.defineProperty(n.prototype,"systemId",{get:function(){return this.sysID}}),Object.defineProperty(n.prototype,"notationName",{get:function(){return this.nData||null}}),Object.defineProperty(n.prototype,"inputEncoding",{get:function(){return null}}),Object.defineProperty(n.prototype,"xmlEncoding",{get:function(){return null}}),Object.defineProperty(n.prototype,"xmlVersion",{get:function(){return null}}),n}.call(this)}.call(R)),Un.exports}var qn={exports:{}},cl;function ms(){return cl||(cl=1,function(){var e,t;t=Te(),e=V(),qn.exports=class extends t{constructor(n,s,i){if(super(n),s==null)throw new Error("Missing DTD element name. "+this.debugInfo());i||(i="(#PCDATA)"),Array.isArray(i)&&(i="("+i.join(",")+")"),this.name=this.stringify.name(s),this.type=e.ElementDeclaration,this.value=this.stringify.dtdElementValue(i)}toString(n){return this.options.writer.dtdElement(this,this.options.writer.filterOptions(n))}}}.call(R)),qn.exports}var Wn={exports:{}},hl;function gs(){return hl||(hl=1,function(){var e,t;t=Te(),e=V(),Wn.exports=function(){class r extends t{constructor(s,i,l){if(super(s),i==null)throw new Error("Missing DTD notation name. "+this.debugInfo(i));if(!l.pubID&&!l.sysID)throw new Error("Public or system identifiers are required for an external entity. "+this.debugInfo(i));this.name=this.stringify.name(i),this.type=e.NotationDeclaration,l.pubID!=null&&(this.pubID=this.stringify.dtdPubID(l.pubID)),l.sysID!=null&&(this.sysID=this.stringify.dtdSysID(l.sysID))}toString(s){return this.options.writer.dtdNotation(this,this.options.writer.filterOptions(s))}}return Object.defineProperty(r.prototype,"publicId",{get:function(){return this.pubID}}),Object.defineProperty(r.prototype,"systemId",{get:function(){return this.sysID}}),r}.call(this)}.call(R)),Wn.exports}var dl;function ys(){return dl||(dl=1,function(){var e,t,r,n,s,i,l,o;({isObject:o}=Ae()),l=Te(),e=V(),t=fs(),n=ps(),r=ms(),s=gs(),i=us(),bn.exports=function(){class u extends l{constructor(c,v,x){var N,g,L,P;if(super(c),this.type=e.DocType,c.children){for(P=c.children,g=0,L=P.length;g":(m=this.parent)!=null&&m.name?"node: <"+a+">, parent: <"+this.parent.name+">":"node: <"+a+">"}ele(a,p,m){return this.element(a,p,m)}nod(a,p,m){return this.node(a,p,m)}txt(a){return this.text(a)}dat(a){return this.cdata(a)}com(a){return this.comment(a)}ins(a,p){return this.instruction(a,p)}doc(){return this.document()}dec(a,p,m){return this.declaration(a,p,m)}e(a,p,m){return this.element(a,p,m)}n(a,p,m){return this.node(a,p,m)}t(a){return this.text(a)}d(a){return this.cdata(a)}c(a){return this.comment(a)}r(a){return this.raw(a)}i(a,p){return this.instruction(a,p)}u(){return this.up()}importXMLBuilder(a){return this.importDocument(a)}attribute(a,p){throw new Error("attribute() applies to element nodes only.")}att(a,p){return this.attribute(a,p)}a(a,p){return this.attribute(a,p)}removeAttribute(a){throw new Error("attribute() applies to element nodes only.")}replaceChild(a,p){throw new Error("This DOM method is not implemented."+this.debugInfo())}removeChild(a){throw new Error("This DOM method is not implemented."+this.debugInfo())}appendChild(a){throw new Error("This DOM method is not implemented."+this.debugInfo())}hasChildNodes(){return this.children.length!==0}cloneNode(a){throw new Error("This DOM method is not implemented."+this.debugInfo())}normalize(){throw new Error("This DOM method is not implemented."+this.debugInfo())}isSupported(a,p){return!0}hasAttributes(){return this.attribs.length!==0}compareDocumentPosition(a){var p,m;return p=this,p===a?0:this.document()!==a.document()?(m=e.Disconnected|e.ImplementationSpecific,Math.random()<.5?m|=e.Preceding:m|=e.Following,m):p.isAncestor(a)?e.Contains|e.Preceding:p.isDescendant(a)?e.Contains|e.Following:p.isPreceding(a)?e.Preceding:e.Following}isSameNode(a){throw new Error("This DOM method is not implemented."+this.debugInfo())}lookupPrefix(a){throw new Error("This DOM method is not implemented."+this.debugInfo())}isDefaultNamespace(a){throw new Error("This DOM method is not implemented."+this.debugInfo())}lookupNamespaceURI(a){throw new Error("This DOM method is not implemented."+this.debugInfo())}isEqualNode(a){var p,m,T;if(a.nodeType!==this.nodeType||a.children.length!==this.children.length)return!1;for(p=m=0,T=this.children.length-1;0<=T?m<=T:m>=T;p=0<=T?++m:--m)if(!this.children[p].isEqualNode(a.children[p]))return!1;return!0}getFeature(a,p){throw new Error("This DOM method is not implemented."+this.debugInfo())}setUserData(a,p,m){throw new Error("This DOM method is not implemented."+this.debugInfo())}getUserData(a){throw new Error("This DOM method is not implemented."+this.debugInfo())}contains(a){return a?a===this||this.isDescendant(a):!1}isDescendant(a){var p,m,T,h,S;for(S=this.children,T=0,h=S.length;Tm}treePosition(a){var p,m;return m=0,p=!1,this.foreachTreeNode(this.document(),function(T){if(m++,!p&&T===a)return p=!0}),p?m:-1}foreachTreeNode(a,p){var m,T,h,S,E;for(a||(a=this.document()),S=a.children,T=0,h=S.length;T","]]]]>"),this.assertLegalChar(n))}comment(n){if(this.options.noValidation)return n;if(n=""+n||"",n.match(/--/))throw new Error("Comment text cannot contain double-hypen: "+n);return this.assertLegalChar(n)}raw(n){return this.options.noValidation?n:""+n||""}attValue(n){return this.options.noValidation?n:this.assertLegalChar(this.attEscape(n=""+n||""))}insTarget(n){return this.options.noValidation?n:this.assertLegalChar(""+n||"")}insValue(n){if(this.options.noValidation)return n;if(n=""+n||"",n.match(/\?>/))throw new Error("Invalid processing instruction value: "+n);return this.assertLegalChar(n)}xmlVersion(n){if(this.options.noValidation)return n;if(n=""+n||"",!n.match(/1\.[0-9]+/))throw new Error("Invalid version number: "+n);return n}xmlEncoding(n){if(this.options.noValidation)return n;if(n=""+n||"",!n.match(/^[A-Za-z](?:[A-Za-z0-9._-])*$/))throw new Error("Invalid encoding: "+n);return this.assertLegalChar(n)}xmlStandalone(n){return this.options.noValidation?n:n?"yes":"no"}dtdPubID(n){return this.options.noValidation?n:this.assertLegalChar(""+n||"")}dtdSysID(n){return this.options.noValidation?n:this.assertLegalChar(""+n||"")}dtdElementValue(n){return this.options.noValidation?n:this.assertLegalChar(""+n||"")}dtdAttType(n){return this.options.noValidation?n:this.assertLegalChar(""+n||"")}dtdAttDefault(n){return this.options.noValidation?n:this.assertLegalChar(""+n||"")}dtdEntityValue(n){return this.options.noValidation?n:this.assertLegalChar(""+n||"")}dtdNData(n){return this.options.noValidation?n:this.assertLegalChar(""+n||"")}assertLegalChar(n){var s,i;if(this.options.noValidation)return n;if(this.options.version==="1.0"){if(s=/[\0-\x08\x0B\f\x0E-\x1F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/g,this.options.invalidCharReplacement!==void 0)n=n.replace(s,this.options.invalidCharReplacement);else if(i=n.match(s))throw new Error(`Invalid character in string: ${n} at index ${i.index}`)}else if(this.options.version==="1.1"){if(s=/[\0\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/g,this.options.invalidCharReplacement!==void 0)n=n.replace(s,this.options.invalidCharReplacement);else if(i=n.match(s))throw new Error(`Invalid character in string: ${n} at index ${i.index}`)}return n}assertLegalName(n){var s;if(this.options.noValidation)return n;if(n=this.assertLegalChar(n),s=/^([:A-Z_a-z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])([\x2D\.0-:A-Z_a-z\xB7\xC0-\xD6\xD8-\xF6\xF8-\u037D\u037F-\u1FFF\u200C\u200D\u203F\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])*$/,!n.match(s))throw new Error(`Invalid character in name: ${n}`);return n}textEscape(n){var s;return this.options.noValidation?n:(s=this.options.noDoubleEncoding?/(?!&(lt|gt|amp|apos|quot);)&/g:/&/g,n.replace(s,"&").replace(//g,">").replace(/\r/g," "))}attEscape(n){var s;return this.options.noValidation?n:(s=this.options.noDoubleEncoding?/(?!&(lt|gt|amp|apos|quot);)&/g:/&/g,n.replace(s,"&").replace(/0)?new Array(u).join(l.indent):""}endline(i,l,o){return!l.pretty||l.suppressPrettyCount?"":l.newline}attribute(i,l,o){var u;return this.openAttribute(i,l,o),l.pretty&&l.width>0?u=i.name+'="'+i.value+'"':u=" "+i.name+'="'+i.value+'"',this.closeAttribute(i,l,o),u}cdata(i,l,o){var u;return this.openNode(i,l,o),l.state=t.OpenTag,u=this.indent(i,l,o)+""+this.endline(i,l,o),l.state=t.None,this.closeNode(i,l,o),u}comment(i,l,o){var u;return this.openNode(i,l,o),l.state=t.OpenTag,u=this.indent(i,l,o)+""+this.endline(i,l,o),l.state=t.None,this.closeNode(i,l,o),u}declaration(i,l,o){var u;return this.openNode(i,l,o),l.state=t.OpenTag,u=this.indent(i,l,o)+"",u+=this.endline(i,l,o),l.state=t.None,this.closeNode(i,l,o),u}docType(i,l,o){var u,f,c,v,x;if(o||(o=0),this.openNode(i,l,o),l.state=t.OpenTag,v=this.indent(i,l,o),v+="0){for(v+=" [",v+=this.endline(i,l,o),l.state=t.InsideTag,x=i.children,f=0,c=x.length;f",v+=this.endline(i,l,o),l.state=t.None,this.closeNode(i,l,o),v}element(i,l,o){var u,f,c,v,x,N,g,L,P,y,d,w,a,p,m,T,h,S,E;if(o||(o=0),w=!1,this.openNode(i,l,o),l.state=t.OpenTag,a=this.indent(i,l,o)+"<"+i.name,l.pretty&&l.width>0){L=a.length,m=i.attribs;for(d in m)n.call(m,d)&&(u=m[d],p=this.attribute(u,l,o),f=p.length,L+f>l.width?(E=this.indent(i,l,o+1)+p,a+=this.endline(i,l,o)+E,L=E.length):(E=" "+p,a+=E,L+=E.length))}else{T=i.attribs;for(d in T)n.call(T,d)&&(u=T[d],a+=this.attribute(u,l,o))}if(v=i.children.length,x=v===0?null:i.children[0],v===0||i.children.every(function(O){return(O.type===e.Text||O.type===e.Raw||O.type===e.CData)&&O.value===""}))l.allowEmpty?(a+=">",l.state=t.CloseTag,a+=""+this.endline(i,l,o)):(l.state=t.CloseTag,a+=l.spaceBeforeSlash+"/>"+this.endline(i,l,o));else if(l.pretty&&v===1&&(x.type===e.Text||x.type===e.Raw||x.type===e.CData)&&x.value!=null)a+=">",l.state=t.InsideTag,l.suppressPrettyCount++,w=!0,a+=this.writeChildNode(x,l,o+1),l.suppressPrettyCount--,w=!1,l.state=t.CloseTag,a+=""+this.endline(i,l,o);else{if(l.dontPrettyTextNodes){for(h=i.children,N=0,P=h.length;N"+this.endline(i,l,o),l.state=t.InsideTag,S=i.children,g=0,y=S.length;g",w&&l.suppressPrettyCount--,a+=this.endline(i,l,o),l.state=t.None}return this.closeNode(i,l,o),a}writeChildNode(i,l,o){switch(i.type){case e.CData:return this.cdata(i,l,o);case e.Comment:return this.comment(i,l,o);case e.Element:return this.element(i,l,o);case e.Raw:return this.raw(i,l,o);case e.Text:return this.text(i,l,o);case e.ProcessingInstruction:return this.processingInstruction(i,l,o);case e.Dummy:return"";case e.Declaration:return this.declaration(i,l,o);case e.DocType:return this.docType(i,l,o);case e.AttributeDeclaration:return this.dtdAttList(i,l,o);case e.ElementDeclaration:return this.dtdElement(i,l,o);case e.EntityDeclaration:return this.dtdEntity(i,l,o);case e.NotationDeclaration:return this.dtdNotation(i,l,o);default:throw new Error("Unknown XML node type: "+i.constructor.name)}}processingInstruction(i,l,o){var u;return this.openNode(i,l,o),l.state=t.OpenTag,u=this.indent(i,l,o)+"",u+=this.endline(i,l,o),l.state=t.None,this.closeNode(i,l,o),u}raw(i,l,o){var u;return this.openNode(i,l,o),l.state=t.OpenTag,u=this.indent(i,l,o),l.state=t.InsideTag,u+=i.value,l.state=t.CloseTag,u+=this.endline(i,l,o),l.state=t.None,this.closeNode(i,l,o),u}text(i,l,o){var u;return this.openNode(i,l,o),l.state=t.OpenTag,u=this.indent(i,l,o),l.state=t.InsideTag,u+=i.value,l.state=t.CloseTag,u+=this.endline(i,l,o),l.state=t.None,this.closeNode(i,l,o),u}dtdAttList(i,l,o){var u;return this.openNode(i,l,o),l.state=t.OpenTag,u=this.indent(i,l,o)+""+this.endline(i,l,o),l.state=t.None,this.closeNode(i,l,o),u}dtdElement(i,l,o){var u;return this.openNode(i,l,o),l.state=t.OpenTag,u=this.indent(i,l,o)+""+this.endline(i,l,o),l.state=t.None,this.closeNode(i,l,o),u}dtdEntity(i,l,o){var u;return this.openNode(i,l,o),l.state=t.OpenTag,u=this.indent(i,l,o)+""+this.endline(i,l,o),l.state=t.None,this.closeNode(i,l,o),u}dtdNotation(i,l,o){var u;return this.openNode(i,l,o),l.state=t.OpenTag,u=this.indent(i,l,o)+""+this.endline(i,l,o),l.state=t.None,this.closeNode(i,l,o),u}openNode(i,l,o){}closeNode(i,l,o){}openAttribute(i,l,o){}closeAttribute(i,l,o){}}}.call(R)),Gn.exports}var Dl;function Ss(){return Dl||(Dl=1,function(){var e;e=Qo(),Zn.exports=class extends e{constructor(r){super(r)}document(r,n){var s,i,l,o,u;for(n=this.filterOptions(n),o="",u=r.children,i=0,l=u.length;i=0;)this.up();return this.onEnd()}openCurrent(){if(this.currentNode)return this.currentNode.children=!0,this.openNode(this.currentNode)}openNode(h){var S,E,O,C;if(!h.isOpen){if(!this.root&&this.currentLevel===0&&h.type===e.Element&&(this.root=h),E="",h.type===e.Element){this.writerOptions.state=t.OpenTag,E=this.writer.indent(h,this.writerOptions,this.currentLevel)+"<"+h.name,C=h.attribs;for(O in C)m.call(C,O)&&(S=C[O],E+=this.writer.attribute(S,this.writerOptions,this.currentLevel));E+=(h.children?">":"/>")+this.writer.endline(h,this.writerOptions,this.currentLevel),this.writerOptions.state=t.InsideTag}else this.writerOptions.state=t.OpenTag,E=this.writer.indent(h,this.writerOptions,this.currentLevel)+""),E+=this.writer.endline(h,this.writerOptions,this.currentLevel);return this.onData(E,this.currentLevel),h.isOpen=!0}}closeNode(h){var S;if(!h.isClosed)return S="",this.writerOptions.state=t.CloseTag,h.type===e.Element?S=this.writer.indent(h,this.writerOptions,this.currentLevel)+""+this.writer.endline(h,this.writerOptions,this.currentLevel):S=this.writer.indent(h,this.writerOptions,this.currentLevel)+"]>"+this.writer.endline(h,this.writerOptions,this.currentLevel),this.writerOptions.state=t.None,this.onData(S,this.currentLevel),h.isClosed=!0}onData(h,S){return this.documentStarted=!0,this.onDataCallback(h,S+1)}onEnd(){return this.documentCompleted=!0,this.onEndCallback()}debugInfo(h){return h==null?"":"node: <"+h+">"}ele(){return this.element(...arguments)}nod(h,S,E){return this.node(h,S,E)}txt(h){return this.text(h)}dat(h){return this.cdata(h)}com(h){return this.comment(h)}ins(h,S){return this.instruction(h,S)}dec(h,S,E){return this.declaration(h,S,E)}dtd(h,S,E){return this.doctype(h,S,E)}e(h,S,E){return this.element(h,S,E)}n(h,S,E){return this.node(h,S,E)}t(h){return this.text(h)}d(h){return this.cdata(h)}c(h){return this.comment(h)}r(h){return this.raw(h)}i(h,S){return this.instruction(h,S)}att(){return this.currentNode&&this.currentNode.type===e.DocType?this.attList(...arguments):this.attribute(...arguments)}a(){return this.currentNode&&this.currentNode.type===e.DocType?this.attList(...arguments):this.attribute(...arguments)}ent(h,S){return this.entity(h,S)}pent(h,S){return this.pEntity(h,S)}not(h,S){return this.notation(h,S)}}}.call(R)),ti.exports}var ri={exports:{}},Ll;function xa(){return Ll||(Ll=1,function(){var e,t,r,n={}.hasOwnProperty;e=V(),r=Qo(),t=ln(),ri.exports=class extends r{constructor(i,l){super(l),this.stream=i}endline(i,l,o){return i.isLastRootNode&&l.state===t.CloseTag?"":super.endline(i,l,o)}document(i,l){var o,u,f,c,v,x,N,g,L;for(N=i.children,u=f=0,v=N.length;f0){for(this.stream.write(" ["),this.stream.write(this.endline(i,l,o)),l.state=t.InsideTag,v=i.children,f=0,c=v.length;f"),this.stream.write(this.endline(i,l,o)),l.state=t.None,this.closeNode(i,l,o)}element(i,l,o){var u,f,c,v,x,N,g,L,P,y,d,w,a,p,m;if(o||(o=0),this.openNode(i,l,o),l.state=t.OpenTag,y=this.indent(i,l,o)+"<"+i.name,l.pretty&&l.width>0){g=y.length,w=i.attribs;for(P in w)n.call(w,P)&&(u=w[P],d=this.attribute(u,l,o),f=d.length,g+f>l.width?(m=this.indent(i,l,o+1)+d,y+=this.endline(i,l,o)+m,g=m.length):(m=" "+d,y+=m,g+=m.length))}else{a=i.attribs;for(P in a)n.call(a,P)&&(u=a[P],y+=this.attribute(u,l,o))}if(this.stream.write(y),v=i.children.length,x=v===0?null:i.children[0],v===0||i.children.every(function(T){return(T.type===e.Text||T.type===e.Raw||T.type===e.CData)&&T.value===""}))l.allowEmpty?(this.stream.write(">"),l.state=t.CloseTag,this.stream.write("")):(l.state=t.CloseTag,this.stream.write(l.spaceBeforeSlash+"/>"));else if(l.pretty&&v===1&&(x.type===e.Text||x.type===e.Raw||x.type===e.CData)&&x.value!=null)this.stream.write(">"),l.state=t.InsideTag,l.suppressPrettyCount++,this.writeChildNode(x,l,o+1),l.suppressPrettyCount--,l.state=t.CloseTag,this.stream.write("");else{for(this.stream.write(">"+this.endline(i,l,o)),l.state=t.InsideTag,p=i.children,N=0,L=p.length;N")}return this.stream.write(this.endline(i,l,o)),l.state=t.None,this.closeNode(i,l,o)}processingInstruction(i,l,o){return this.stream.write(super.processingInstruction(i,l,o))}raw(i,l,o){return this.stream.write(super.raw(i,l,o))}text(i,l,o){return this.stream.write(super.text(i,l,o))}dtdAttList(i,l,o){return this.stream.write(super.dtdAttList(i,l,o))}dtdElement(i,l,o){return this.stream.write(super.dtdElement(i,l,o))}dtdEntity(i,l,o){return this.stream.write(super.dtdEntity(i,l,o))}dtdNotation(i,l,o){return this.stream.write(super.dtdNotation(i,l,o))}}}.call(R)),ri.exports}(function(){var e,t,r,n,s,i,l,o,u;({assign:o,isFunction:u}=Ae()),r=Uo(),n=$o(),s=wa(),l=Ss(),i=xa(),e=V(),t=ln(),qe.create=function(f,c,v,x){var N,g;if(f==null)throw new Error("Root element needs a name.");return x=o({},c,v,x),N=new n(x),g=N.element(f),x.headless||(N.declaration(x),(x.pubID!=null||x.sysID!=null)&&N.dtd(x)),g},qe.begin=function(f,c,v){return u(f)&&([c,v]=[f,c],f={}),c?new s(f,c,v):new n(f)},qe.stringWriter=function(f){return new l(f)},qe.streamWriter=function(f,c){return new i(f,c)},qe.implementation=new r,qe.nodeType=e,qe.writerState=t}).call(R);const Ho=(e,t,r=!1)=>{const{type:n,props:s,children:i}=t,l=i||[],o=l[0];if(l.length===1&&typeof o=="string"){e.ele(n,s,o);return}let u=null;r?Object.keys(s).map(f=>{e.att(f,s[f])}):u=e.ele(n,s),l.forEach(f=>{if(typeof f=="string")throw new Error("Invaild XML");Ho(u||e,f)})},Sa=e=>{const t=fa.create(e).toJSON();if(!t)throw new Error("Element is invalid");const r=qe.create(t.type);return Ho(r,t,!0),r.end({pretty:!0}),r.toString({pretty:!0})};function Ta(e){return{alter:e.alter,step:"CDEFGAB"[(e.note+98)%7],octave:Math.floor(e.note/7)+4}}function Da(e){const t=[I.f,I.p,I.m,I.r,I.s,I.z],r=["p","pp","ppp","pppp","ppppp","pppppp","f","ff","fff","ffff","fffff","ffffff","m","mp","mf","sf","sfp","sfpp","fp","rf","rfz","sfz","sffz","fz","n","pf","sfzp","other-dynamics"],n=e.filter(i=>t.includes(i.type)),s=n.sort((i,l)=>i.x-l.x).map(i=>i.type).join("");if(n&&n.length>0){if(r.includes(s))return{type:s,direction:{"^":"above",_:"below"}[n[0].direction]};console.error("无法识别的力度记号",s)}}function Ea(e){return{10:"1024th",9:"512th",8:"256th",7:"128th",6:"64th",5:"32nd",4:"16th",3:"eighth",2:"quarter",1:"half",0:"whole"}[e]}class Ga{title;pageSize;unitSize;staffLayout;paperOptions;headers;voiceStaves;lyricLanes;score;workTitle="";partBuilders=[];constructor(t){Object.assign(this,t);const r=this.voiceStaves;for(const[n,s]of this.partTemplate.entries()){const i=this.ensurePartBuilder(n,s);for(const l of s.map(o=>r[o]))for(const[o,u]of l.voices.entries())for(const[f,c]of u.measures.entries())i.ensureMeasureBuilder(f).addVoice({...c,voiceIndexOfStaff:o})}}get partTemplate(){return this.staffLayout.partGroups.map(t=>t.range[0]===t.range[1]?[t.range[0]]:t.range)}ensurePartBuilder(t,r){for(;this.partBuilders.length<=t;){const n=new Na({parent:this,template:r});this.partBuilders.push(n)}return this.partBuilders[t]}createPartListElement(){return D.jsx("part-list",{children:this.partBuilders.map(t=>D.jsx("score-part",{id:t.id,children:D.jsx("part-name",{"print-object":"no",children:t.name})}))})}toJSX(){const t=new Date;return`${t.getFullYear()}${String(t.getMonth()+1).padStart(2,"0")}${String(t.getDate()).padStart(2,"0")}`,D.jsxs("score-partwise",{version:"4.0",children:[D.jsx("work",{children:D.jsx("work-title",{children:this.workTitle})}),D.jsx("movement-title",{children:this.workTitle}),D.jsx("defaults",{children:D.jsxs("scaling",{children:[D.jsx("millimeters",{children:"8"}),D.jsx("tenths",{children:uu})]})}),D.jsx("part-list",{children:this.partBuilders.map(r=>D.jsx("score-part",{id:r.id,children:D.jsx("part-name",{"print-object":"no",children:"MusicXML Part"})}))}),this.partBuilders.map(r=>r.toJSX())]})}toString(){return` +`+i.stack}return{value:e,source:t,stack:s,digest:null}}function wn(e,t,r){return{value:e,source:null,stack:r??null,digest:t??null}}function yi(e,t){try{console.error(t.value)}catch(r){setTimeout(function(){throw r})}}var _u=typeof WeakMap=="function"?WeakMap:Map;function yo(e,t,r){r=Ye(-1,r),r.tag=3,r.payload={element:null};var n=t.value;return r.callback=function(){Vr||(Vr=!0,Li=n),yi(e,t)},r}function vo(e,t,r){r=Ye(-1,r),r.tag=3;var n=e.type.getDerivedStateFromError;if(typeof n=="function"){var s=t.value;r.payload=function(){return n(s)},r.callback=function(){yi(e,t)}}var i=e.stateNode;return i!==null&&typeof i.componentDidCatch=="function"&&(r.callback=function(){yi(e,t),typeof n!="function"&&(Ze===null?Ze=new Set([this]):Ze.add(this));var l=t.stack;this.componentDidCatch(t.value,{componentStack:l!==null?l:""})}),r}function _s(e,t,r){var n=e.pingCache;if(n===null){n=e.pingCache=new _u;var s=new Set;n.set(t,s)}else s=n.get(t),s===void 0&&(s=new Set,n.set(t,s));s.has(r)||(s.add(r),e=ea.bind(null,e,t,r),t.then(e,e))}var bu=nt.ReactCurrentOwner,ae=!1;function le(e,t,r,n){t.child=e===null?Pu(t,null,r,n):kt(t,e.child,r,n)}function bs(e,t,r,n,s){r=r.render;var i=t.ref;return Ot(t,s),n=Ki(e,t,r,n,i,s),e!==null&&!ae?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s,_e(e,t,s)):(t.flags|=1,le(e,t,n,s),t.child)}function As(e,t,r,n,s){if(e===null){var i=r.type;return typeof i=="function"&&!ls(i)&&i.defaultProps===void 0&&r.compare===null&&r.defaultProps===void 0?(t.tag=15,t.type=i,wo(e,t,i,n,s)):(e=Nr(r.type,null,n,t,t.mode,s),e.ref=t.ref,e.return=t,t.child=e)}if(i=e.child,!(e.lanes&s)){var l=i.memoizedProps;if(r=r.compare,r=r!==null?r:Xr,r(l,n)&&e.ref===t.ref)return _e(e,t,s)}return t.flags|=1,e=et(i,n),e.ref=t.ref,e.return=t,t.child=e}function wo(e,t,r,n,s){if(e!==null){var i=e.memoizedProps;if(Xr(i,n)&&e.ref===t.ref)if(ae=!1,t.pendingProps=n=i,(e.lanes&s)!==0)e.flags&131072&&(ae=!0);else return t.lanes=e.lanes,_e(e,t,s)}return vi(e,t,r,n,s)}function xo(e,t,r){var n=t.pendingProps,s=n.children,i=e!==null?e.memoizedState:null;if(n.mode==="hidden")if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},z(Lt,pe),pe|=r;else{if(!(r&1073741824))return e=i!==null?i.baseLanes|r:r,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,z(Lt,pe),pe|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},n=i!==null?i.baseLanes:r,z(Lt,pe),pe|=n}else i!==null?(n=i.baseLanes|r,t.memoizedState=null):n=r,z(Lt,pe),pe|=n;return le(e,t,s,r),t.child}function So(e,t){var r=t.ref;(e===null&&r!==null||e!==null&&e.ref!==r)&&(t.flags|=512)}function vi(e,t,r,n,s){var i=fe(r)?mt:ne.current;return i=jt(t,i),Ot(t,s),r=Ki(e,t,r,n,i,s),e!==null&&!ae?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s,_e(e,t,s)):(t.flags|=1,le(e,t,r,s),t.child)}function Us(e,t,r,n,s){if(fe(r)){var i=!0;Rr(t)}else i=!1;if(Ot(t,s),t.stateNode===null)Tr(e,t),go(t,r,n),gi(t,r,n,s),n=!0;else if(e===null){var l=t.stateNode,o=t.memoizedProps;l.props=o;var u=l.context,f=r.contextType;typeof f=="object"&&f!==null?f=xe(f):(f=fe(r)?mt:ne.current,f=jt(t,f));var c=r.getDerivedStateFromProps,v=typeof c=="function"||typeof l.getSnapshotBeforeUpdate=="function";v||typeof l.UNSAFE_componentWillReceiveProps!="function"&&typeof l.componentWillReceiveProps!="function"||(o!==n||u!==f)&&Bs(t,l,n,f),Qe=!1;var x=t.memoizedState;l.state=x,Br(t,n,l,s),u=t.memoizedState,o!==n||x!==u||de.current||Qe?(typeof c=="function"&&(mi(t,r,c,n),u=t.memoizedState),(o=Qe||zs(t,r,o,n,x,u,f))?(v||typeof l.UNSAFE_componentWillMount!="function"&&typeof l.componentWillMount!="function"||(typeof l.componentWillMount=="function"&&l.componentWillMount(),typeof l.UNSAFE_componentWillMount=="function"&&l.UNSAFE_componentWillMount()),typeof l.componentDidMount=="function"&&(t.flags|=4)):(typeof l.componentDidMount=="function"&&(t.flags|=4),t.memoizedProps=n,t.memoizedState=u),l.props=n,l.state=u,l.context=f,n=o):(typeof l.componentDidMount=="function"&&(t.flags|=4),n=!1)}else{l=t.stateNode,Hl(e,t),o=t.memoizedProps,f=t.type===t.elementType?o:De(t.type,o),l.props=f,v=t.pendingProps,x=l.context,u=r.contextType,typeof u=="object"&&u!==null?u=xe(u):(u=fe(r)?mt:ne.current,u=jt(t,u));var N=r.getDerivedStateFromProps;(c=typeof N=="function"||typeof l.getSnapshotBeforeUpdate=="function")||typeof l.UNSAFE_componentWillReceiveProps!="function"&&typeof l.componentWillReceiveProps!="function"||(o!==v||x!==u)&&Bs(t,l,n,u),Qe=!1,x=t.memoizedState,l.state=x,Br(t,n,l,s);var g=t.memoizedState;o!==v||x!==g||de.current||Qe?(typeof N=="function"&&(mi(t,r,N,n),g=t.memoizedState),(f=Qe||zs(t,r,f,n,x,g,u)||!1)?(c||typeof l.UNSAFE_componentWillUpdate!="function"&&typeof l.componentWillUpdate!="function"||(typeof l.componentWillUpdate=="function"&&l.componentWillUpdate(n,g,u),typeof l.UNSAFE_componentWillUpdate=="function"&&l.UNSAFE_componentWillUpdate(n,g,u)),typeof l.componentDidUpdate=="function"&&(t.flags|=4),typeof l.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof l.componentDidUpdate!="function"||o===e.memoizedProps&&x===e.memoizedState||(t.flags|=4),typeof l.getSnapshotBeforeUpdate!="function"||o===e.memoizedProps&&x===e.memoizedState||(t.flags|=1024),t.memoizedProps=n,t.memoizedState=g),l.props=n,l.state=g,l.context=u,n=f):(typeof l.componentDidUpdate!="function"||o===e.memoizedProps&&x===e.memoizedState||(t.flags|=4),typeof l.getSnapshotBeforeUpdate!="function"||o===e.memoizedProps&&x===e.memoizedState||(t.flags|=1024),n=!1)}return wi(e,t,r,n,i,s)}function wi(e,t,r,n,s,i){So(e,t);var l=(t.flags&128)!==0;if(!n&&!l)return s&&Is(t,r,!1),_e(e,t,i);n=t.stateNode,bu.current=t;var o=l&&typeof r.getDerivedStateFromError!="function"?null:n.render();return t.flags|=1,e!==null&&l?(t.child=kt(t,e.child,null,i),t.child=kt(t,null,o,i)):le(e,t,o,i),t.memoizedState=n.state,s&&Is(t,r,!0),t.child}function To(e){var t=e.stateNode;t.pendingContext?Os(e,t.pendingContext,t.pendingContext!==t.context):t.context&&Os(e,t.context,!1),Vi(e,t.containerInfo)}var xi={dehydrated:null,treeContext:null,retryLane:0};function Si(e){return{baseLanes:e,cachePool:null,transitions:null}}function Do(e,t,r){var n=t.pendingProps,s=A.current,i=!1,l=(t.flags&128)!==0,o;if((o=l)||(o=e!==null&&e.memoizedState===null?!1:(s&2)!==0),o?(i=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(s|=1),z(A,s&1),e===null)return e=t.memoizedState,e!==null&&e.dehydrated!==null?(t.mode&1?Ke()?t.lanes=8:t.lanes=1073741824:t.lanes=1,null):(l=n.children,e=n.fallback,i?(n=t.mode,i=t.child,l={mode:"hidden",children:l},!(n&1)&&i!==null?(i.childLanes=0,i.pendingProps=l):i=nn(l,n,0,null),e=ft(e,n,r,null),i.return=t,e.return=t,i.sibling=e,t.child=i,t.child.memoizedState=Si(r),t.memoizedState=xi,e):Gi(t,l));if(s=e.memoizedState,s!==null&&(o=s.dehydrated,o!==null))return Au(e,t,l,n,o,s,r);if(i){i=n.fallback,l=t.mode,s=e.child,o=s.sibling;var u={mode:"hidden",children:n.children};return!(l&1)&&t.child!==s?(n=t.child,n.childLanes=0,n.pendingProps=u,t.deletions=null):(n=et(s,u),n.subtreeFlags=s.subtreeFlags&14680064),o!==null?i=et(o,i):(i=ft(i,l,r,null),i.flags|=2),i.return=t,n.return=t,n.sibling=i,t.child=n,n=i,i=t.child,l=e.child.memoizedState,l=l===null?Si(r):{baseLanes:l.baseLanes|r,cachePool:null,transitions:l.transitions},i.memoizedState=l,i.childLanes=e.childLanes&~r,t.memoizedState=xi,n}return i=e.child,e=i.sibling,n=et(i,{mode:"visible",children:n.children}),!(t.mode&1)&&(n.lanes=r),n.return=t,n.sibling=null,e!==null&&(r=t.deletions,r===null?(t.deletions=[e],t.flags|=16):r.push(e)),t.child=n,t.memoizedState=null,n}function Gi(e,t){return t=nn({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function mr(e,t,r,n){return n!==null&&(ze===null?ze=[n]:ze.push(n)),kt(t,e.child,null,r),e=Gi(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function Au(e,t,r,n,s,i,l){if(r)return t.flags&256?(t.flags&=-257,i=wn(Error("There was an error while hydrating this Suspense boundary. Switched to client rendering.")),mr(e,t,l,i)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(i=n.fallback,r=t.mode,n=nn({mode:"visible",children:n.children},r,0,null),i=ft(i,r,l,null),i.flags|=2,n.return=t,i.return=t,n.sibling=i,t.child=n,t.mode&1&&kt(t,e.child,null,l),t.child.memoizedState=Si(l),t.memoizedState=xi,i);if(!(t.mode&1))return mr(e,t,l,null);if(Ke())return i=Ke().digest,i=wn(Error("The server could not finish this Suspense boundary, likely due to an error during server rendering. Switched to client rendering."),i,void 0),mr(e,t,l,i);if(r=(l&e.childLanes)!==0,ae||r){if(n=Y,n!==null){switch(l&-l){case 4:r=2;break;case 16:r=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:r=32;break;case 536870912:r=268435456;break;default:r=0}r=r&(n.suspendedLanes|l)?0:r,r!==0&&r!==i.retryLane&&(i.retryLane=r,Rt(e,r),Ge(n,e,r,-1))}return ss(),i=wn(Error("This Suspense boundary received an update before it finished hydrating. This caused the boundary to switch to client rendering. The usual way to fix this is to wrap the original update in startTransition.")),mr(e,t,l,i)}return Ke()?(t.flags|=128,t.child=e.child,ta.bind(null,e),Ke(),null):(e=Gi(t,n.children),e.flags|=4096,e)}function qs(e,t,r){e.lanes|=t;var n=e.alternate;n!==null&&(n.lanes|=t),pi(e.return,t,r)}function xn(e,t,r,n,s){var i=e.memoizedState;i===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:n,tail:r,tailMode:s}:(i.isBackwards=t,i.rendering=null,i.renderingStartTime=0,i.last=n,i.tail=r,i.tailMode=s)}function Eo(e,t,r){var n=t.pendingProps,s=n.revealOrder,i=n.tail;if(le(e,t,n.children,r),n=A.current,n&2)n=n&1|2,t.flags|=128;else{if(e!==null&&e.flags&128)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&qs(e,r,t);else if(e.tag===19)qs(e,r,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}n&=1}if(z(A,n),!(t.mode&1))t.memoizedState=null;else switch(s){case"forwards":for(r=t.child,s=null;r!==null;)e=r.alternate,e!==null&&_r(e)===null&&(s=r),r=r.sibling;r=s,r===null?(s=t.child,t.child=null):(s=r.sibling,r.sibling=null),xn(t,!1,s,r,i);break;case"backwards":for(r=null,s=t.child,t.child=null;s!==null;){if(e=s.alternate,e!==null&&_r(e)===null){t.child=s;break}e=s.sibling,s.sibling=r,r=s,s=e}xn(t,!0,r,null,i);break;case"together":xn(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function Tr(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function _e(e,t,r){if(e!==null&&(t.dependencies=e.dependencies),yt|=t.lanes,!(r&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error("Resuming work not yet implemented.");if(t.child!==null){for(e=t.child,r=et(e,e.pendingProps),t.child=r,r.return=t;e.sibling!==null;)e=e.sibling,r=r.sibling=et(e,e.pendingProps),r.return=t;r.sibling=null}return t.child}function Uu(e,t,r){switch(t.tag){case 3:To(t);break;case 5:Kl(t);break;case 1:fe(t.type)&&Rr(t);break;case 4:Vi(t,t.stateNode.containerInfo);break;case 10:var n=t.type._context,s=t.memoizedProps.value;z(Fr,n._currentValue2),n._currentValue2=s;break;case 13:if(n=t.memoizedState,n!==null)return n.dehydrated!==null?(z(A,A.current&1),t.flags|=128,null):r&t.child.childLanes?Do(e,t,r):(z(A,A.current&1),e=_e(e,t,r),e!==null?e.sibling:null);z(A,A.current&1);break;case 19:if(n=(r&t.childLanes)!==0,e.flags&128){if(n)return Eo(e,t,r);t.flags|=128}if(s=t.memoizedState,s!==null&&(s.rendering=null,s.tail=null,s.lastEffect=null),z(A,A.current),n)break;return null;case 22:case 23:return t.lanes=0,xo(e,t,r)}return _e(e,t,r)}var No,Ti,Lo,Mo;No=function(e,t){for(var r=t.child;r!==null;){if(r.tag===5||r.tag===6){var n=e,s=r.stateNode,i=n.children.indexOf(s);i!==-1&&n.children.splice(i,1),n.children.push(s)}else if(r.tag!==4&&r.child!==null){r.child.return=r,r=r.child;continue}if(r===t)break;for(;r.sibling===null;){if(r.return===null||r.return===t)return;r=r.return}r.sibling.return=r.return,r=r.sibling}};Ti=function(){};Lo=function(e,t,r,n){e.memoizedProps!==n&&(at(Re.current),t.updateQueue=Eu)&&(t.flags|=4)};Mo=function(e,t,r,n){r!==n&&(t.flags|=4)};function At(e,t){switch(e.tailMode){case"hidden":t=e.tail;for(var r=null;t!==null;)t.alternate!==null&&(r=t),t=t.sibling;r===null?e.tail=null:r.sibling=null;break;case"collapsed":r=e.tail;for(var n=null;r!==null;)r.alternate!==null&&(n=r),r=r.sibling;n===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:n.sibling=null}}function ee(e){var t=e.alternate!==null&&e.alternate.child===e.child,r=0,n=0;if(t)for(var s=e.child;s!==null;)r|=s.lanes|s.childLanes,n|=s.subtreeFlags&14680064,n|=s.flags&14680064,s.return=e,s=s.sibling;else for(s=e.child;s!==null;)r|=s.lanes|s.childLanes,n|=s.subtreeFlags,n|=s.flags,s.return=e,s=s.sibling;return e.subtreeFlags|=n,e.childLanes=r,t}function qu(e,t,r){var n=t.pendingProps;switch(_i(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return ee(t),null;case 1:return fe(t.type)&&kr(),ee(t),null;case 3:return r=t.stateNode,Xt(),B(de),B(ne),$i(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),e!==null&&e.child!==null||e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,ze!==null&&(Ii(ze),ze=null)),Ti(e,t),ee(t),null;case 5:Qi(t),r=at(Zt.current);var s=t.type;if(e!==null&&t.stateNode!=null)Lo(e,t,s,n,r),e.ref!==t.ref&&(t.flags|=512);else{if(!n){if(t.stateNode===null)throw Error("We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue.");return ee(t),null}at(Re.current),e={type:s,props:n,isHidden:!1,children:[],internalInstanceHandle:t,rootContainerInstance:r,tag:"INSTANCE"},No(e,t,!1,!1),t.stateNode=e,t.ref!==null&&(t.flags|=512)}return ee(t),null;case 6:if(e&&t.stateNode!=null)Mo(e,t,e.memoizedProps,n);else{if(typeof n!="string"&&t.stateNode===null)throw Error("We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue.");at(Zt.current),at(Re.current),t.stateNode={text:n,isHidden:!1,tag:"TEXT"}}return ee(t),null;case 13:if(B(A),n=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(n!==null&&n.dehydrated!==null){if(e===null)throw Error("A dehydrated suspense component was completed without a hydrated node. This is probably a bug in React.");!(t.flags&128)&&(t.memoizedState=null),t.flags|=4,ee(t),s=!1}else ze!==null&&(Ii(ze),ze=null),s=!0;if(!s)return t.flags&65536?t:null}return t.flags&128?(t.lanes=r,t):(r=n!==null,r!==(e!==null&&e.memoizedState!==null)&&r&&(t.child.flags|=8192,t.mode&1&&(e===null||A.current&1?H===0&&(H=3):ss())),t.updateQueue!==null&&(t.flags|=4),ee(t),null);case 4:return Xt(),Ti(e,t),ee(t),null;case 10:return Ui(t.type._context),ee(t),null;case 17:return fe(t.type)&&kr(),ee(t),null;case 19:if(B(A),s=t.memoizedState,s===null)return ee(t),null;n=(t.flags&128)!==0;var i=s.rendering;if(i===null)if(n)At(s,!1);else{if(H!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(i=_r(e),i!==null){for(t.flags|=128,At(s,!1),e=i.updateQueue,e!==null&&(t.updateQueue=e,t.flags|=4),t.subtreeFlags=0,e=r,r=t.child;r!==null;)n=r,s=e,n.flags&=14680066,i=n.alternate,i===null?(n.childLanes=0,n.lanes=s,n.child=null,n.subtreeFlags=0,n.memoizedProps=null,n.memoizedState=null,n.updateQueue=null,n.dependencies=null,n.stateNode=null):(n.childLanes=i.childLanes,n.lanes=i.lanes,n.child=i.child,n.subtreeFlags=0,n.deletions=null,n.memoizedProps=i.memoizedProps,n.memoizedState=i.memoizedState,n.updateQueue=i.updateQueue,n.type=i.type,s=i.dependencies,n.dependencies=s===null?null:{lanes:s.lanes,firstContext:s.firstContext}),r=r.sibling;return z(A,A.current&1|2),t.child}e=e.sibling}s.tail!==null&&$()>rr&&(t.flags|=128,n=!0,At(s,!1),t.lanes=4194304)}else{if(!n)if(e=_r(i),e!==null){if(t.flags|=128,n=!0,e=e.updateQueue,e!==null&&(t.updateQueue=e,t.flags|=4),At(s,!0),s.tail===null&&s.tailMode==="hidden"&&!i.alternate)return ee(t),null}else 2*$()-s.renderingStartTime>rr&&r!==1073741824&&(t.flags|=128,n=!0,At(s,!1),t.lanes=4194304);s.isBackwards?(i.sibling=t.child,t.child=i):(e=s.last,e!==null?e.sibling=i:t.child=i,s.last=i)}return s.tail!==null?(t=s.tail,s.rendering=t,s.tail=t.sibling,s.renderingStartTime=$(),t.sibling=null,e=A.current,z(A,n?e&1|2:e&1),t):(ee(t),null);case 22:case 23:return is(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?pe&1073741824&&(ee(t),t.subtreeFlags&6&&(t.flags|=8192)):ee(t),null;case 24:return null;case 25:return null}throw Error("Unknown unit of work tag ("+t.tag+"). This error is likely caused by a bug in React. Please file an issue.")}function Wu(e,t){switch(_i(t),t.tag){case 1:return fe(t.type)&&kr(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Xt(),B(de),B(ne),$i(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return Qi(t),null;case 13:if(B(A),e=t.memoizedState,e!==null&&e.dehydrated!==null&&t.alternate===null)throw Error("Threw in newly mounted dehydrated component. This is likely a bug in React. Please file an issue.");return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return B(A),null;case 4:return Xt(),null;case 10:return Ui(t.type._context),null;case 22:case 23:return is(),null;case 24:return null;default:return null}}var Vu=typeof WeakSet=="function"?WeakSet:Set,j=null;function Ur(e,t){var r=e.ref;if(r!==null)if(typeof r=="function")try{r(null)}catch(n){ue(e,t,n)}else r.current=null}function Di(e,t,r){try{r()}catch(n){ue(e,t,n)}}var Ws=!1;function Qu(e,t){for(j=t;j!==null;)if(e=j,t=e.child,(e.subtreeFlags&1028)!==0&&t!==null)t.return=e,j=t;else for(;j!==null;){e=j;try{var r=e.alternate;if(e.flags&1024)switch(e.tag){case 0:case 11:case 15:break;case 1:if(r!==null){var n=r.memoizedProps,s=r.memoizedState,i=e.stateNode,l=i.getSnapshotBeforeUpdate(e.elementType===e.type?n:De(e.type,n),s);i.__reactInternalSnapshotBeforeUpdate=l}break;case 3:e.stateNode.containerInfo.children.splice(0);break;case 5:case 6:case 4:case 17:break;default:throw Error("This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue.")}}catch(o){ue(e,e.return,o)}if(t=e.sibling,t!==null){t.return=e.return,j=t;break}j=e.return}return r=Ws,Ws=!1,r}function qr(e,t,r){var n=t.updateQueue;if(n=n!==null?n.lastEffect:null,n!==null){var s=n=n.next;do{if((s.tag&e)===e){var i=s.destroy;s.destroy=void 0,i!==void 0&&Di(t,r,i)}s=s.next}while(s!==n)}}function es(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var r=t=t.next;do{if((r.tag&e)===e){var n=r.create;r.destroy=n()}r=r.next}while(r!==t)}}function Oo(e){var t=e.alternate;t!==null&&(e.alternate=null,Oo(t)),e.child=null,e.deletions=null,e.sibling=null,e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function Io(e){return e.tag===5||e.tag===3||e.tag===4}function Vs(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Io(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Ei(e,t,r){var n=e.tag;if(n===5||n===6)e=e.stateNode,t?Wl(r,e,t):ql(r,e);else if(n!==4&&(e=e.child,e!==null))for(Ei(e,t,r),e=e.sibling;e!==null;)Ei(e,t,r),e=e.sibling}function Ni(e,t,r){var n=e.tag;if(n===5||n===6)e=e.stateNode,t?Wl(r,e,t):ql(r,e);else if(n!==4&&(e=e.child,e!==null))for(Ni(e,t,r),e=e.sibling;e!==null;)Ni(e,t,r),e=e.sibling}var se=null;function lt(e,t,r){for(r=r.child;r!==null;)Co(e,t,r),r=r.sibling}function Co(e,t,r){if(ke&&typeof ke.onCommitFiberUnmount=="function")try{ke.onCommitFiberUnmount(Yr,r)}catch{}switch(r.tag){case 5:Ur(r,t);case 6:var n=se;se=null,lt(e,t,r),se=n,se!==null&&(e=se,r=e.children.indexOf(r.stateNode),e.children.splice(r,1));break;case 18:se!==null&&Ke(se,r.stateNode);break;case 4:n=se,se=r.stateNode.containerInfo,lt(e,t,r),se=n;break;case 0:case 11:case 14:case 15:if(n=r.updateQueue,n!==null&&(n=n.lastEffect,n!==null)){var s=n=n.next;do{var i=s,l=i.destroy;i=i.tag,l!==void 0&&(i&2||i&4)&&Di(r,t,l),s=s.next}while(s!==n)}lt(e,t,r);break;case 1:if(Ur(r,t),n=r.stateNode,typeof n.componentWillUnmount=="function")try{n.props=r.memoizedProps,n.state=r.memoizedState,n.componentWillUnmount()}catch(o){ue(r,t,o)}lt(e,t,r);break;case 21:lt(e,t,r);break;case 22:lt(e,t,r);break;default:lt(e,t,r)}}function Qs(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var r=e.stateNode;r===null&&(r=e.stateNode=new Vu),t.forEach(function(n){var s=ra.bind(null,e,n);r.has(n)||(r.add(n),n.then(s,s))})}}function Oe(e,t){var r=t.deletions;if(r!==null)for(var n=0;ns&&(s=l),n&=~i}if(n=s,n=$()-n,n=(120>n?120:480>n?480:1080>n?1080:1920>n?1920:3e3>n?3e3:4320>n?4320:1960*Hu(n/1960))-n,10e?16:e,Je===null)var n=!1;else{if(e=Je,Je=null,Qr=0,X&6)throw Error("Cannot flush passive effects while already rendering.");var s=X;for(X|=4,j=e.current;j!==null;){var i=j,l=i.child;if(j.flags&16){var o=i.deletions;if(o!==null){for(var u=0;u$()-ns?dt(e,0):rs|=r),we(e,t)}function zo(e,t){t===0&&(e.mode&1?(t=cr,cr<<=1,!(cr&130023424)&&(cr=4194304)):t=1);var r=Ne();e=Rt(e,t),e!==null&&(Zr(e,t,r),we(e,r))}function ta(e){var t=e.memoizedState,r=0;t!==null&&(r=t.retryLane),zo(e,r)}function ra(e,t){var r=0;switch(e.tag){case 13:var n=e.stateNode,s=e.memoizedState;s!==null&&(r=s.retryLane);break;case 19:n=e.stateNode;break;default:throw Error("Pinged unknown suspense boundary type. This is probably a bug in React.")}n!==null&&n.delete(t),zo(e,r)}var Bo;Bo=function(e,t,r){if(e!==null)if(e.memoizedProps!==t.pendingProps||de.current)ae=!0;else{if(!(e.lanes&r)&&!(t.flags&128))return ae=!1,Uu(e,t,r);ae=!!(e.flags&131072)}else ae=!1;switch(t.lanes=0,t.tag){case 2:var n=t.type;Tr(e,t),e=t.pendingProps;var s=jt(t,ne.current);if(Ot(t,r),s=Ki(null,t,n,e,s,r),t.flags|=1,typeof s=="object"&&s!==null&&typeof s.render=="function"&&s.$$typeof===void 0){if(t.tag=1,t.memoizedState=null,t.updateQueue=null,fe(n)){var i=!0;Rr(t)}else i=!1;t.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,Wi(t),s.updater=tn,t.stateNode=s,s._reactInternals=t,gi(t,n,e,r),t=wi(null,t,n,!0,i,r)}else t.tag=0,le(null,t,s,r),t=t.child;return t;case 16:n=t.elementType;e:{switch(Tr(e,t),e=t.pendingProps,s=n._init,n=s(n._payload),t.type=n,s=t.tag=ia(n),e=De(n,e),s){case 0:t=vi(null,t,n,e,r);break e;case 1:t=Us(null,t,n,e,r);break e;case 11:t=bs(null,t,n,e,r);break e;case 14:t=As(null,t,n,De(n.type,e),r);break e}throw Error("Element type is invalid. Received a promise that resolves to: "+n+". Lazy element type must resolve to a class or function.")}return t;case 0:return n=t.type,s=t.pendingProps,s=t.elementType===n?s:De(n,s),vi(e,t,n,s,r);case 1:return n=t.type,s=t.pendingProps,s=t.elementType===n?s:De(n,s),Us(e,t,n,s,r);case 3:if(To(t),e===null)throw Error("Should have a current fiber. This is a bug in React.");return s=t.pendingProps,n=t.memoizedState.element,Hl(e,t),Br(t,s,null,r),s=t.memoizedState.element,s===n?t=_e(e,t,r):(le(e,t,s,r),t=t.child),t;case 5:return Kl(t),n=t.pendingProps.children,So(e,t),le(e,t,n,r),t.child;case 6:return null;case 13:return Do(e,t,r);case 4:return Vi(t,t.stateNode.containerInfo),n=t.pendingProps,e===null?t.child=kt(t,null,n,r):le(e,t,n,r),t.child;case 11:return n=t.type,s=t.pendingProps,s=t.elementType===n?s:De(n,s),bs(e,t,n,s,r);case 7:return le(e,t,t.pendingProps,r),t.child;case 8:return le(e,t,t.pendingProps.children,r),t.child;case 12:return le(e,t,t.pendingProps.children,r),t.child;case 10:e:{n=t.type._context,s=t.pendingProps,i=t.memoizedProps;var l=s.value;if(z(Fr,n._currentValue2),n._currentValue2=l,i!==null)if(Le(i.value,l)){if(i.children===s.children&&!de.current){t=_e(e,t,r);break e}}else for(i=t.child,i!==null&&(i.return=t);i!==null;){var o=i.dependencies;if(o!==null){l=i.child;for(var u=o.firstContext;u!==null;){if(u.context===n){if(i.tag===1){u=Ye(-1,r&-r),u.tag=2;var f=i.updateQueue;if(f!==null){f=f.shared;var c=f.pending;c===null?u.next=u:(u.next=c.next,c.next=u),f.pending=u}}i.lanes|=r,u=i.alternate,u!==null&&(u.lanes|=r),pi(i.return,r,t),o.lanes|=r;break}u=u.next}}else if(i.tag===10)l=i.type===t.type?null:i.child;else if(i.tag===18){if(l=i.return,l===null)throw Error("We just came from a parent so we must have had a parent. This is a bug in React.");l.lanes|=r,o=l.alternate,o!==null&&(o.lanes|=r),pi(l,r,t),l=i.sibling}else l=i.child;if(l!==null)l.return=i;else for(l=i;l!==null;){if(l===t){l=null;break}if(i=l.sibling,i!==null){i.return=l.return,l=i;break}l=l.return}i=l}le(e,t,s.children,r),t=t.child}return t;case 9:return s=t.type,n=t.pendingProps.children,Ot(t,r),s=xe(s),n=n(s),t.flags|=1,le(e,t,n,r),t.child;case 14:return n=t.type,s=De(n,t.pendingProps),s=De(n.type,s),As(e,t,n,s,r);case 15:return wo(e,t,t.type,t.pendingProps,r);case 17:return n=t.type,s=t.pendingProps,s=t.elementType===n?s:De(n,s),Tr(e,t),t.tag=1,fe(n)?(e=!0,Rr(t)):e=!1,Ot(t,r),go(t,n,s),gi(t,n,s,r),wi(null,t,n,!0,e,r);case 19:return Eo(e,t,r);case 22:return xo(e,t,r)}throw Error("Unknown unit of work tag ("+t.tag+"). This error is likely caused by a bug in React. Please file an issue.")};function _o(e,t){return Bi(e,t)}function na(e,t,r,n){this.tag=e,this.key=r,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=n,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function je(e,t,r,n){return new na(e,t,r,n)}function ls(e){return e=e.prototype,!(!e||!e.isReactComponent)}function ia(e){if(typeof e=="function")return ls(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Fi)return 11;if(e===zi)return 14}return 2}function et(e,t){var r=e.alternate;return r===null?(r=je(e.tag,t,e.key,e.mode),r.elementType=e.elementType,r.type=e.type,r.stateNode=e.stateNode,r.alternate=e,e.alternate=r):(r.pendingProps=t,r.type=e.type,r.flags=0,r.subtreeFlags=0,r.deletions=null),r.flags=e.flags&14680064,r.childLanes=e.childLanes,r.lanes=e.lanes,r.child=e.child,r.memoizedProps=e.memoizedProps,r.memoizedState=e.memoizedState,r.updateQueue=e.updateQueue,t=e.dependencies,r.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},r.sibling=e.sibling,r.index=e.index,r.ref=e.ref,r}function Nr(e,t,r,n,s,i){var l=2;if(n=e,typeof e=="function")ls(e)&&(l=1);else if(typeof e=="string")l=5;else e:switch(e){case Dt:return ft(r.children,s,i,t);case Xi:l=8,s|=8;break;case li:return e=je(12,r,t,s|2),e.elementType=li,e.lanes=i,e;case oi:return e=je(13,r,t,s),e.elementType=oi,e.lanes=i,e;case ui:return e=je(19,r,t,s),e.elementType=ui,e.lanes=i,e;case zl:return nn(r,s,i,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case Xl:l=10;break e;case Fl:l=9;break e;case Fi:l=11;break e;case zi:l=14;break e;case Ve:l=16,n=null;break e}throw Error("Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: "+((e==null?e:typeof e)+"."))}return t=je(l,r,t,s),t.elementType=e,t.type=n,t.lanes=i,t}function ft(e,t,r,n){return e=je(7,e,n,t),e.lanes=r,e}function nn(e,t,r,n){return e=je(22,e,n,t),e.elementType=zl,e.lanes=r,e.stateNode={isHidden:!1},e}function Sn(e,t,r){return e=je(6,e,null,t),e.lanes=r,e}function Tn(e,t,r){return t=je(4,e.children!==null?e.children:[],e.key,t),t.lanes=r,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function sa(e,t,r,n,s){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=an(0),this.expirationTimes=an(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=an(0),this.identifierPrefix=n,this.onRecoverableError=s}function la(e,t,r,n,s,i,l){return e=new sa(e,t,!1,i,l),t===1?(t=1,n===!0&&(t|=8)):t=0,n=je(3,null,null,t),e.current=n,n.stateNode=e,n.memoizedState={element:null,isDehydrated:!1,cache:null,transitions:null,pendingSuspenseBoundaries:null},Wi(n),e}function Dn(e,t,r,n){var s=t.current,i=Ne(),l=It(s);e:if(r){r=r._reactInternals;t:{if(Jr(r)!==r||r.tag!==1)throw Error("Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue.");var o=r;do{switch(o.tag){case 3:o=o.stateNode.context;break t;case 1:if(fe(o.type)){o=o.stateNode.__reactInternalMemoizedMergedChildContext;break t}}o=o.return}while(o!==null);throw Error("Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue.")}if(r.tag===1){var u=r.type;if(fe(u)){r=Vl(r,u,o);break e}}r=o}else r=rt;return t.context===null?t.context=r:t.pendingContext=r,t=Ye(i,l),t.payload={element:e},n=n===void 0?null:n,n!==null&&(t.callback=n),e=ht(s,t,l),e!==null&&(Ge(e,s,l,i),wr(e,s,l)),l}function oa(){return null}var ua=kl.unstable_act,aa={createNodeMock:function(){return null}};function Lr(e){if(e.isHidden)return null;switch(e.tag){case"TEXT":return e.text;case"INSTANCE":var t=e.props,r=["children"];if(t==null)t={};else{var n={},s=Object.keys(t),i;for(i=0;iPi(r).length)break;return os(r)}r=r.return}return null}},{key:"children",get:function(){return Pi(this._currentFiber())}}]),e}();function Mr(e,t,r){var n=r?r.deep:!0,s=[];return t(e)&&(s.push(e),!n)||e.children.forEach(function(i){typeof i!="string"&&s.push.apply(s,Mr(i,t,r))}),s}function En(e,t){if(e.length===1)return e[0];throw Error((e.length===0?"No instances found ":"Expected 1 but found "+e.length+" instances ")+t)}function ha(e){console.error(e)}var Nn=new WeakMap;function os(e){var t=Nn.get(e);return t===void 0&&e.alternate!==null&&(t=Nn.get(e.alternate)),t===void 0&&(t=new ca(e),Nn.set(e,t)),t}var qt={findFiberByHostInstance:function(){throw Error("TestRenderer does not support findFiberByHostInstance()")},bundleType:0,version:"18.3.1",rendererPackageName:"react-test-renderer"},da={bundleType:qt.bundleType,version:qt.version,rendererPackageName:qt.rendererPackageName,rendererConfig:qt.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:nt.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=Bl(e),e=e!==null?_l(e):null,e===null?null:e.stateNode},findFiberByHostInstance:qt.findFiberByHostInstance||oa,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var yr=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!yr.isDisabled&&yr.supportsFiber)try{Yr=yr.inject(da),ke=yr}catch{}}nr._Scheduler=Rl;nr.act=ua;nr.create=function(e,t){var r=aa.createNodeMock,n=!1,s=!1;typeof t=="object"&&t!==null&&(typeof t.createNodeMock=="function"&&(r=t.createNodeMock),t.unstable_isConcurrent===!0&&(n=!0),t.unstable_strictMode===!0&&(s=!0));var i={children:[],createNodeMock:r,tag:"CONTAINER"},l=la(i,n?1:0,null,s,null,"",ha);if(l==null)throw Error("something went wrong");return Dn(e,l,null,null),e={_Scheduler:Rl,root:void 0,toJSON:function(){if(l==null||l.current==null||i==null||i.children.length===0)return null;if(i.children.length===1)return Lr(i.children[0]);if(i.children.length===2&&i.children[0].isHidden===!0&&i.children[1].isHidden===!1)return Lr(i.children[1]);var o=null;if(i.children&&i.children.length)for(var u=0;u":"attribute: {"+n+"}, parent: <"+this.parent.name+">"}isEqualNode(n){return!(n.namespaceURI!==this.namespaceURI||n.prefix!==this.prefix||n.localName!==this.localName||n.value!==this.value)}}return Object.defineProperty(t.prototype,"nodeType",{get:function(){return this.type}}),Object.defineProperty(t.prototype,"ownerElement",{get:function(){return this.parent}}),Object.defineProperty(t.prototype,"textContent",{get:function(){return this.value},set:function(r){return this.value=r||""}}),Object.defineProperty(t.prototype,"namespaceURI",{get:function(){return""}}),Object.defineProperty(t.prototype,"prefix",{get:function(){return""}}),Object.defineProperty(t.prototype,"localName",{get:function(){return this.name}}),Object.defineProperty(t.prototype,"specified",{get:function(){return!0}}),t}.call(this)}.call(R)),Rn.exports}var Xn={exports:{}},rl;function us(){return rl||(rl=1,function(){Xn.exports=function(){class e{constructor(r){this.nodes=r}clone(){return this.nodes=null}getNamedItem(r){return this.nodes[r]}setNamedItem(r){var n;return n=this.nodes[r.nodeName],this.nodes[r.nodeName]=r,n||null}removeNamedItem(r){var n;return n=this.nodes[r],delete this.nodes[r],n||null}item(r){return this.nodes[Object.keys(this.nodes)[r]]||null}getNamedItemNS(r,n){throw new Error("This DOM method is not implemented.")}setNamedItemNS(r){throw new Error("This DOM method is not implemented.")}removeNamedItemNS(r,n){throw new Error("This DOM method is not implemented.")}}return Object.defineProperty(e.prototype,"length",{get:function(){return Object.keys(this.nodes).length||0}}),e}.call(this)}.call(R)),Xn.exports}var nl;function as(){return nl||(nl=1,function(){var e,t,r,n,s,i,l,o={}.hasOwnProperty;({isObject:l,isFunction:i,getValue:s}=Ae()),n=Te(),e=V(),t=qo(),r=us(),jn.exports=function(){class u extends n{constructor(c,v,x){var N,g,L,P;if(super(c),v==null)throw new Error("Missing element name. "+this.debugInfo());if(this.name=this.stringify.name(v),this.type=e.Element,this.attribs={},this.schemaTypeInfo=null,x!=null&&this.attribute(x),c.type===e.Document&&(this.isRoot=!0,this.documentObject=c,c.rootObject=this,c.children)){for(P=c.children,g=0,L=P.length;g=N;v=0<=N?++x:--x)if(!this.attribs[v].isEqualNode(c.attribs[v]))return!1;return!0}}return Object.defineProperty(u.prototype,"tagName",{get:function(){return this.name}}),Object.defineProperty(u.prototype,"namespaceURI",{get:function(){return""}}),Object.defineProperty(u.prototype,"prefix",{get:function(){return""}}),Object.defineProperty(u.prototype,"localName",{get:function(){return this.name}}),Object.defineProperty(u.prototype,"id",{get:function(){throw new Error("This DOM method is not implemented."+this.debugInfo())}}),Object.defineProperty(u.prototype,"className",{get:function(){throw new Error("This DOM method is not implemented."+this.debugInfo())}}),Object.defineProperty(u.prototype,"classList",{get:function(){throw new Error("This DOM method is not implemented."+this.debugInfo())}}),Object.defineProperty(u.prototype,"attributes",{get:function(){return(!this.attributeMap||!this.attributeMap.nodes)&&(this.attributeMap=new r(this.attribs)),this.attributeMap}}),u}.call(this)}.call(R)),jn.exports}var Fn={exports:{}},zn={exports:{}},il;function sn(){return il||(il=1,function(){var e;e=Te(),zn.exports=function(){class t extends e{constructor(n){super(n),this.value=""}clone(){return Object.create(this)}substringData(n,s){throw new Error("This DOM method is not implemented."+this.debugInfo())}appendData(n){throw new Error("This DOM method is not implemented."+this.debugInfo())}insertData(n,s){throw new Error("This DOM method is not implemented."+this.debugInfo())}deleteData(n,s){throw new Error("This DOM method is not implemented."+this.debugInfo())}replaceData(n,s,i){throw new Error("This DOM method is not implemented."+this.debugInfo())}isEqualNode(n){return!(!super.isEqualNode(n)||n.data!==this.data)}}return Object.defineProperty(t.prototype,"data",{get:function(){return this.value},set:function(r){return this.value=r||""}}),Object.defineProperty(t.prototype,"length",{get:function(){return this.value.length}}),Object.defineProperty(t.prototype,"textContent",{get:function(){return this.value},set:function(r){return this.value=r||""}}),t}.call(this)}.call(R)),zn.exports}var sl;function cs(){return sl||(sl=1,function(){var e,t;e=V(),t=sn(),Fn.exports=class extends t{constructor(n,s){if(super(n),s==null)throw new Error("Missing CDATA text. "+this.debugInfo());this.name="#cdata-section",this.type=e.CData,this.value=this.stringify.cdata(s)}clone(){return Object.create(this)}toString(n){return this.options.writer.cdata(this,this.options.writer.filterOptions(n))}}}.call(R)),Fn.exports}var Bn={exports:{}},ll;function hs(){return ll||(ll=1,function(){var e,t;e=V(),t=sn(),Bn.exports=class extends t{constructor(n,s){if(super(n),s==null)throw new Error("Missing comment text. "+this.debugInfo());this.name="#comment",this.type=e.Comment,this.value=this.stringify.comment(s)}clone(){return Object.create(this)}toString(n){return this.options.writer.comment(this,this.options.writer.filterOptions(n))}}}.call(R)),Bn.exports}var _n={exports:{}},ol;function ds(){return ol||(ol=1,function(){var e,t,r;({isObject:r}=Ae()),t=Te(),e=V(),_n.exports=class extends t{constructor(s,i,l,o){super(s),r(i)&&({version:i,encoding:l,standalone:o}=i),i||(i="1.0"),this.type=e.Declaration,this.version=this.stringify.xmlVersion(i),l!=null&&(this.encoding=this.stringify.xmlEncoding(l)),o!=null&&(this.standalone=this.stringify.xmlStandalone(o))}toString(s){return this.options.writer.declaration(this,this.options.writer.filterOptions(s))}}}.call(R)),_n.exports}var bn={exports:{}},An={exports:{}},ul;function fs(){return ul||(ul=1,function(){var e,t;t=Te(),e=V(),An.exports=class extends t{constructor(n,s,i,l,o,u){if(super(n),s==null)throw new Error("Missing DTD element name. "+this.debugInfo());if(i==null)throw new Error("Missing DTD attribute name. "+this.debugInfo(s));if(!l)throw new Error("Missing DTD attribute type. "+this.debugInfo(s));if(!o)throw new Error("Missing DTD attribute default. "+this.debugInfo(s));if(o.indexOf("#")!==0&&(o="#"+o),!o.match(/^(#REQUIRED|#IMPLIED|#FIXED|#DEFAULT)$/))throw new Error("Invalid default value type; expected: #REQUIRED, #IMPLIED, #FIXED or #DEFAULT. "+this.debugInfo(s));if(u&&!o.match(/^(#FIXED|#DEFAULT)$/))throw new Error("Default value only applies to #FIXED or #DEFAULT. "+this.debugInfo(s));this.elementName=this.stringify.name(s),this.type=e.AttributeDeclaration,this.attributeName=this.stringify.name(i),this.attributeType=this.stringify.dtdAttType(l),u&&(this.defaultValue=this.stringify.dtdAttDefault(u)),this.defaultValueType=o}toString(n){return this.options.writer.dtdAttList(this,this.options.writer.filterOptions(n))}}}.call(R)),An.exports}var Un={exports:{}},al;function ps(){return al||(al=1,function(){var e,t,r;({isObject:r}=Ae()),t=Te(),e=V(),Un.exports=function(){class n extends t{constructor(i,l,o,u){if(super(i),o==null)throw new Error("Missing DTD entity name. "+this.debugInfo(o));if(u==null)throw new Error("Missing DTD entity value. "+this.debugInfo(o));if(this.pe=!!l,this.name=this.stringify.name(o),this.type=e.EntityDeclaration,!r(u))this.value=this.stringify.dtdEntityValue(u),this.internal=!0;else{if(!u.pubID&&!u.sysID)throw new Error("Public and/or system identifiers are required for an external entity. "+this.debugInfo(o));if(u.pubID&&!u.sysID)throw new Error("System identifier is required for a public external entity. "+this.debugInfo(o));if(this.internal=!1,u.pubID!=null&&(this.pubID=this.stringify.dtdPubID(u.pubID)),u.sysID!=null&&(this.sysID=this.stringify.dtdSysID(u.sysID)),u.nData!=null&&(this.nData=this.stringify.dtdNData(u.nData)),this.pe&&this.nData)throw new Error("Notation declaration is not allowed in a parameter entity. "+this.debugInfo(o))}}toString(i){return this.options.writer.dtdEntity(this,this.options.writer.filterOptions(i))}}return Object.defineProperty(n.prototype,"publicId",{get:function(){return this.pubID}}),Object.defineProperty(n.prototype,"systemId",{get:function(){return this.sysID}}),Object.defineProperty(n.prototype,"notationName",{get:function(){return this.nData||null}}),Object.defineProperty(n.prototype,"inputEncoding",{get:function(){return null}}),Object.defineProperty(n.prototype,"xmlEncoding",{get:function(){return null}}),Object.defineProperty(n.prototype,"xmlVersion",{get:function(){return null}}),n}.call(this)}.call(R)),Un.exports}var qn={exports:{}},cl;function ms(){return cl||(cl=1,function(){var e,t;t=Te(),e=V(),qn.exports=class extends t{constructor(n,s,i){if(super(n),s==null)throw new Error("Missing DTD element name. "+this.debugInfo());i||(i="(#PCDATA)"),Array.isArray(i)&&(i="("+i.join(",")+")"),this.name=this.stringify.name(s),this.type=e.ElementDeclaration,this.value=this.stringify.dtdElementValue(i)}toString(n){return this.options.writer.dtdElement(this,this.options.writer.filterOptions(n))}}}.call(R)),qn.exports}var Wn={exports:{}},hl;function gs(){return hl||(hl=1,function(){var e,t;t=Te(),e=V(),Wn.exports=function(){class r extends t{constructor(s,i,l){if(super(s),i==null)throw new Error("Missing DTD notation name. "+this.debugInfo(i));if(!l.pubID&&!l.sysID)throw new Error("Public or system identifiers are required for an external entity. "+this.debugInfo(i));this.name=this.stringify.name(i),this.type=e.NotationDeclaration,l.pubID!=null&&(this.pubID=this.stringify.dtdPubID(l.pubID)),l.sysID!=null&&(this.sysID=this.stringify.dtdSysID(l.sysID))}toString(s){return this.options.writer.dtdNotation(this,this.options.writer.filterOptions(s))}}return Object.defineProperty(r.prototype,"publicId",{get:function(){return this.pubID}}),Object.defineProperty(r.prototype,"systemId",{get:function(){return this.sysID}}),r}.call(this)}.call(R)),Wn.exports}var dl;function ys(){return dl||(dl=1,function(){var e,t,r,n,s,i,l,o;({isObject:o}=Ae()),l=Te(),e=V(),t=fs(),n=ps(),r=ms(),s=gs(),i=us(),bn.exports=function(){class u extends l{constructor(c,v,x){var N,g,L,P;if(super(c),this.type=e.DocType,c.children){for(P=c.children,g=0,L=P.length;g":(m=this.parent)!=null&&m.name?"node: <"+a+">, parent: <"+this.parent.name+">":"node: <"+a+">"}ele(a,p,m){return this.element(a,p,m)}nod(a,p,m){return this.node(a,p,m)}txt(a){return this.text(a)}dat(a){return this.cdata(a)}com(a){return this.comment(a)}ins(a,p){return this.instruction(a,p)}doc(){return this.document()}dec(a,p,m){return this.declaration(a,p,m)}e(a,p,m){return this.element(a,p,m)}n(a,p,m){return this.node(a,p,m)}t(a){return this.text(a)}d(a){return this.cdata(a)}c(a){return this.comment(a)}r(a){return this.raw(a)}i(a,p){return this.instruction(a,p)}u(){return this.up()}importXMLBuilder(a){return this.importDocument(a)}attribute(a,p){throw new Error("attribute() applies to element nodes only.")}att(a,p){return this.attribute(a,p)}a(a,p){return this.attribute(a,p)}removeAttribute(a){throw new Error("attribute() applies to element nodes only.")}replaceChild(a,p){throw new Error("This DOM method is not implemented."+this.debugInfo())}removeChild(a){throw new Error("This DOM method is not implemented."+this.debugInfo())}appendChild(a){throw new Error("This DOM method is not implemented."+this.debugInfo())}hasChildNodes(){return this.children.length!==0}cloneNode(a){throw new Error("This DOM method is not implemented."+this.debugInfo())}normalize(){throw new Error("This DOM method is not implemented."+this.debugInfo())}isSupported(a,p){return!0}hasAttributes(){return this.attribs.length!==0}compareDocumentPosition(a){var p,m;return p=this,p===a?0:this.document()!==a.document()?(m=e.Disconnected|e.ImplementationSpecific,Math.random()<.5?m|=e.Preceding:m|=e.Following,m):p.isAncestor(a)?e.Contains|e.Preceding:p.isDescendant(a)?e.Contains|e.Following:p.isPreceding(a)?e.Preceding:e.Following}isSameNode(a){throw new Error("This DOM method is not implemented."+this.debugInfo())}lookupPrefix(a){throw new Error("This DOM method is not implemented."+this.debugInfo())}isDefaultNamespace(a){throw new Error("This DOM method is not implemented."+this.debugInfo())}lookupNamespaceURI(a){throw new Error("This DOM method is not implemented."+this.debugInfo())}isEqualNode(a){var p,m,D;if(a.nodeType!==this.nodeType||a.children.length!==this.children.length)return!1;for(p=m=0,D=this.children.length-1;0<=D?m<=D:m>=D;p=0<=D?++m:--m)if(!this.children[p].isEqualNode(a.children[p]))return!1;return!0}getFeature(a,p){throw new Error("This DOM method is not implemented."+this.debugInfo())}setUserData(a,p,m){throw new Error("This DOM method is not implemented."+this.debugInfo())}getUserData(a){throw new Error("This DOM method is not implemented."+this.debugInfo())}contains(a){return a?a===this||this.isDescendant(a):!1}isDescendant(a){var p,m,D,h,S;for(S=this.children,D=0,h=S.length;Dm}treePosition(a){var p,m;return m=0,p=!1,this.foreachTreeNode(this.document(),function(D){if(m++,!p&&D===a)return p=!0}),p?m:-1}foreachTreeNode(a,p){var m,D,h,S,E;for(a||(a=this.document()),S=a.children,D=0,h=S.length;D","]]]]>"),this.assertLegalChar(n))}comment(n){if(this.options.noValidation)return n;if(n=""+n||"",n.match(/--/))throw new Error("Comment text cannot contain double-hypen: "+n);return this.assertLegalChar(n)}raw(n){return this.options.noValidation?n:""+n||""}attValue(n){return this.options.noValidation?n:this.assertLegalChar(this.attEscape(n=""+n||""))}insTarget(n){return this.options.noValidation?n:this.assertLegalChar(""+n||"")}insValue(n){if(this.options.noValidation)return n;if(n=""+n||"",n.match(/\?>/))throw new Error("Invalid processing instruction value: "+n);return this.assertLegalChar(n)}xmlVersion(n){if(this.options.noValidation)return n;if(n=""+n||"",!n.match(/1\.[0-9]+/))throw new Error("Invalid version number: "+n);return n}xmlEncoding(n){if(this.options.noValidation)return n;if(n=""+n||"",!n.match(/^[A-Za-z](?:[A-Za-z0-9._-])*$/))throw new Error("Invalid encoding: "+n);return this.assertLegalChar(n)}xmlStandalone(n){return this.options.noValidation?n:n?"yes":"no"}dtdPubID(n){return this.options.noValidation?n:this.assertLegalChar(""+n||"")}dtdSysID(n){return this.options.noValidation?n:this.assertLegalChar(""+n||"")}dtdElementValue(n){return this.options.noValidation?n:this.assertLegalChar(""+n||"")}dtdAttType(n){return this.options.noValidation?n:this.assertLegalChar(""+n||"")}dtdAttDefault(n){return this.options.noValidation?n:this.assertLegalChar(""+n||"")}dtdEntityValue(n){return this.options.noValidation?n:this.assertLegalChar(""+n||"")}dtdNData(n){return this.options.noValidation?n:this.assertLegalChar(""+n||"")}assertLegalChar(n){var s,i;if(this.options.noValidation)return n;if(this.options.version==="1.0"){if(s=/[\0-\x08\x0B\f\x0E-\x1F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/g,this.options.invalidCharReplacement!==void 0)n=n.replace(s,this.options.invalidCharReplacement);else if(i=n.match(s))throw new Error(`Invalid character in string: ${n} at index ${i.index}`)}else if(this.options.version==="1.1"){if(s=/[\0\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/g,this.options.invalidCharReplacement!==void 0)n=n.replace(s,this.options.invalidCharReplacement);else if(i=n.match(s))throw new Error(`Invalid character in string: ${n} at index ${i.index}`)}return n}assertLegalName(n){var s;if(this.options.noValidation)return n;if(n=this.assertLegalChar(n),s=/^([:A-Z_a-z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])([\x2D\.0-:A-Z_a-z\xB7\xC0-\xD6\xD8-\xF6\xF8-\u037D\u037F-\u1FFF\u200C\u200D\u203F\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])*$/,!n.match(s))throw new Error(`Invalid character in name: ${n}`);return n}textEscape(n){var s;return this.options.noValidation?n:(s=this.options.noDoubleEncoding?/(?!&(lt|gt|amp|apos|quot);)&/g:/&/g,n.replace(s,"&").replace(//g,">").replace(/\r/g," "))}attEscape(n){var s;return this.options.noValidation?n:(s=this.options.noDoubleEncoding?/(?!&(lt|gt|amp|apos|quot);)&/g:/&/g,n.replace(s,"&").replace(/0)?new Array(u).join(l.indent):""}endline(i,l,o){return!l.pretty||l.suppressPrettyCount?"":l.newline}attribute(i,l,o){var u;return this.openAttribute(i,l,o),l.pretty&&l.width>0?u=i.name+'="'+i.value+'"':u=" "+i.name+'="'+i.value+'"',this.closeAttribute(i,l,o),u}cdata(i,l,o){var u;return this.openNode(i,l,o),l.state=t.OpenTag,u=this.indent(i,l,o)+""+this.endline(i,l,o),l.state=t.None,this.closeNode(i,l,o),u}comment(i,l,o){var u;return this.openNode(i,l,o),l.state=t.OpenTag,u=this.indent(i,l,o)+""+this.endline(i,l,o),l.state=t.None,this.closeNode(i,l,o),u}declaration(i,l,o){var u;return this.openNode(i,l,o),l.state=t.OpenTag,u=this.indent(i,l,o)+"",u+=this.endline(i,l,o),l.state=t.None,this.closeNode(i,l,o),u}docType(i,l,o){var u,f,c,v,x;if(o||(o=0),this.openNode(i,l,o),l.state=t.OpenTag,v=this.indent(i,l,o),v+="0){for(v+=" [",v+=this.endline(i,l,o),l.state=t.InsideTag,x=i.children,f=0,c=x.length;f",v+=this.endline(i,l,o),l.state=t.None,this.closeNode(i,l,o),v}element(i,l,o){var u,f,c,v,x,N,g,L,P,y,d,w,a,p,m,D,h,S,E;if(o||(o=0),w=!1,this.openNode(i,l,o),l.state=t.OpenTag,a=this.indent(i,l,o)+"<"+i.name,l.pretty&&l.width>0){L=a.length,m=i.attribs;for(d in m)n.call(m,d)&&(u=m[d],p=this.attribute(u,l,o),f=p.length,L+f>l.width?(E=this.indent(i,l,o+1)+p,a+=this.endline(i,l,o)+E,L=E.length):(E=" "+p,a+=E,L+=E.length))}else{D=i.attribs;for(d in D)n.call(D,d)&&(u=D[d],a+=this.attribute(u,l,o))}if(v=i.children.length,x=v===0?null:i.children[0],v===0||i.children.every(function(O){return(O.type===e.Text||O.type===e.Raw||O.type===e.CData)&&O.value===""}))l.allowEmpty?(a+=">",l.state=t.CloseTag,a+=""+this.endline(i,l,o)):(l.state=t.CloseTag,a+=l.spaceBeforeSlash+"/>"+this.endline(i,l,o));else if(l.pretty&&v===1&&(x.type===e.Text||x.type===e.Raw||x.type===e.CData)&&x.value!=null)a+=">",l.state=t.InsideTag,l.suppressPrettyCount++,w=!0,a+=this.writeChildNode(x,l,o+1),l.suppressPrettyCount--,w=!1,l.state=t.CloseTag,a+=""+this.endline(i,l,o);else{if(l.dontPrettyTextNodes){for(h=i.children,N=0,P=h.length;N"+this.endline(i,l,o),l.state=t.InsideTag,S=i.children,g=0,y=S.length;g",w&&l.suppressPrettyCount--,a+=this.endline(i,l,o),l.state=t.None}return this.closeNode(i,l,o),a}writeChildNode(i,l,o){switch(i.type){case e.CData:return this.cdata(i,l,o);case e.Comment:return this.comment(i,l,o);case e.Element:return this.element(i,l,o);case e.Raw:return this.raw(i,l,o);case e.Text:return this.text(i,l,o);case e.ProcessingInstruction:return this.processingInstruction(i,l,o);case e.Dummy:return"";case e.Declaration:return this.declaration(i,l,o);case e.DocType:return this.docType(i,l,o);case e.AttributeDeclaration:return this.dtdAttList(i,l,o);case e.ElementDeclaration:return this.dtdElement(i,l,o);case e.EntityDeclaration:return this.dtdEntity(i,l,o);case e.NotationDeclaration:return this.dtdNotation(i,l,o);default:throw new Error("Unknown XML node type: "+i.constructor.name)}}processingInstruction(i,l,o){var u;return this.openNode(i,l,o),l.state=t.OpenTag,u=this.indent(i,l,o)+"",u+=this.endline(i,l,o),l.state=t.None,this.closeNode(i,l,o),u}raw(i,l,o){var u;return this.openNode(i,l,o),l.state=t.OpenTag,u=this.indent(i,l,o),l.state=t.InsideTag,u+=i.value,l.state=t.CloseTag,u+=this.endline(i,l,o),l.state=t.None,this.closeNode(i,l,o),u}text(i,l,o){var u;return this.openNode(i,l,o),l.state=t.OpenTag,u=this.indent(i,l,o),l.state=t.InsideTag,u+=i.value,l.state=t.CloseTag,u+=this.endline(i,l,o),l.state=t.None,this.closeNode(i,l,o),u}dtdAttList(i,l,o){var u;return this.openNode(i,l,o),l.state=t.OpenTag,u=this.indent(i,l,o)+""+this.endline(i,l,o),l.state=t.None,this.closeNode(i,l,o),u}dtdElement(i,l,o){var u;return this.openNode(i,l,o),l.state=t.OpenTag,u=this.indent(i,l,o)+""+this.endline(i,l,o),l.state=t.None,this.closeNode(i,l,o),u}dtdEntity(i,l,o){var u;return this.openNode(i,l,o),l.state=t.OpenTag,u=this.indent(i,l,o)+""+this.endline(i,l,o),l.state=t.None,this.closeNode(i,l,o),u}dtdNotation(i,l,o){var u;return this.openNode(i,l,o),l.state=t.OpenTag,u=this.indent(i,l,o)+""+this.endline(i,l,o),l.state=t.None,this.closeNode(i,l,o),u}openNode(i,l,o){}closeNode(i,l,o){}openAttribute(i,l,o){}closeAttribute(i,l,o){}}}.call(R)),Gn.exports}var Dl;function Ss(){return Dl||(Dl=1,function(){var e;e=Qo(),Zn.exports=class extends e{constructor(r){super(r)}document(r,n){var s,i,l,o,u;for(n=this.filterOptions(n),o="",u=r.children,i=0,l=u.length;i=0;)this.up();return this.onEnd()}openCurrent(){if(this.currentNode)return this.currentNode.children=!0,this.openNode(this.currentNode)}openNode(h){var S,E,O,C;if(!h.isOpen){if(!this.root&&this.currentLevel===0&&h.type===e.Element&&(this.root=h),E="",h.type===e.Element){this.writerOptions.state=t.OpenTag,E=this.writer.indent(h,this.writerOptions,this.currentLevel)+"<"+h.name,C=h.attribs;for(O in C)m.call(C,O)&&(S=C[O],E+=this.writer.attribute(S,this.writerOptions,this.currentLevel));E+=(h.children?">":"/>")+this.writer.endline(h,this.writerOptions,this.currentLevel),this.writerOptions.state=t.InsideTag}else this.writerOptions.state=t.OpenTag,E=this.writer.indent(h,this.writerOptions,this.currentLevel)+""),E+=this.writer.endline(h,this.writerOptions,this.currentLevel);return this.onData(E,this.currentLevel),h.isOpen=!0}}closeNode(h){var S;if(!h.isClosed)return S="",this.writerOptions.state=t.CloseTag,h.type===e.Element?S=this.writer.indent(h,this.writerOptions,this.currentLevel)+""+this.writer.endline(h,this.writerOptions,this.currentLevel):S=this.writer.indent(h,this.writerOptions,this.currentLevel)+"]>"+this.writer.endline(h,this.writerOptions,this.currentLevel),this.writerOptions.state=t.None,this.onData(S,this.currentLevel),h.isClosed=!0}onData(h,S){return this.documentStarted=!0,this.onDataCallback(h,S+1)}onEnd(){return this.documentCompleted=!0,this.onEndCallback()}debugInfo(h){return h==null?"":"node: <"+h+">"}ele(){return this.element(...arguments)}nod(h,S,E){return this.node(h,S,E)}txt(h){return this.text(h)}dat(h){return this.cdata(h)}com(h){return this.comment(h)}ins(h,S){return this.instruction(h,S)}dec(h,S,E){return this.declaration(h,S,E)}dtd(h,S,E){return this.doctype(h,S,E)}e(h,S,E){return this.element(h,S,E)}n(h,S,E){return this.node(h,S,E)}t(h){return this.text(h)}d(h){return this.cdata(h)}c(h){return this.comment(h)}r(h){return this.raw(h)}i(h,S){return this.instruction(h,S)}att(){return this.currentNode&&this.currentNode.type===e.DocType?this.attList(...arguments):this.attribute(...arguments)}a(){return this.currentNode&&this.currentNode.type===e.DocType?this.attList(...arguments):this.attribute(...arguments)}ent(h,S){return this.entity(h,S)}pent(h,S){return this.pEntity(h,S)}not(h,S){return this.notation(h,S)}}}.call(R)),ti.exports}var ri={exports:{}},Ll;function Sa(){return Ll||(Ll=1,function(){var e,t,r,n={}.hasOwnProperty;e=V(),r=Qo(),t=ln(),ri.exports=class extends r{constructor(i,l){super(l),this.stream=i}endline(i,l,o){return i.isLastRootNode&&l.state===t.CloseTag?"":super.endline(i,l,o)}document(i,l){var o,u,f,c,v,x,N,g,L;for(N=i.children,u=f=0,v=N.length;f0){for(this.stream.write(" ["),this.stream.write(this.endline(i,l,o)),l.state=t.InsideTag,v=i.children,f=0,c=v.length;f"),this.stream.write(this.endline(i,l,o)),l.state=t.None,this.closeNode(i,l,o)}element(i,l,o){var u,f,c,v,x,N,g,L,P,y,d,w,a,p,m;if(o||(o=0),this.openNode(i,l,o),l.state=t.OpenTag,y=this.indent(i,l,o)+"<"+i.name,l.pretty&&l.width>0){g=y.length,w=i.attribs;for(P in w)n.call(w,P)&&(u=w[P],d=this.attribute(u,l,o),f=d.length,g+f>l.width?(m=this.indent(i,l,o+1)+d,y+=this.endline(i,l,o)+m,g=m.length):(m=" "+d,y+=m,g+=m.length))}else{a=i.attribs;for(P in a)n.call(a,P)&&(u=a[P],y+=this.attribute(u,l,o))}if(this.stream.write(y),v=i.children.length,x=v===0?null:i.children[0],v===0||i.children.every(function(D){return(D.type===e.Text||D.type===e.Raw||D.type===e.CData)&&D.value===""}))l.allowEmpty?(this.stream.write(">"),l.state=t.CloseTag,this.stream.write("")):(l.state=t.CloseTag,this.stream.write(l.spaceBeforeSlash+"/>"));else if(l.pretty&&v===1&&(x.type===e.Text||x.type===e.Raw||x.type===e.CData)&&x.value!=null)this.stream.write(">"),l.state=t.InsideTag,l.suppressPrettyCount++,this.writeChildNode(x,l,o+1),l.suppressPrettyCount--,l.state=t.CloseTag,this.stream.write("");else{for(this.stream.write(">"+this.endline(i,l,o)),l.state=t.InsideTag,p=i.children,N=0,L=p.length;N")}return this.stream.write(this.endline(i,l,o)),l.state=t.None,this.closeNode(i,l,o)}processingInstruction(i,l,o){return this.stream.write(super.processingInstruction(i,l,o))}raw(i,l,o){return this.stream.write(super.raw(i,l,o))}text(i,l,o){return this.stream.write(super.text(i,l,o))}dtdAttList(i,l,o){return this.stream.write(super.dtdAttList(i,l,o))}dtdElement(i,l,o){return this.stream.write(super.dtdElement(i,l,o))}dtdEntity(i,l,o){return this.stream.write(super.dtdEntity(i,l,o))}dtdNotation(i,l,o){return this.stream.write(super.dtdNotation(i,l,o))}}}.call(R)),ri.exports}(function(){var e,t,r,n,s,i,l,o,u;({assign:o,isFunction:u}=Ae()),r=Uo(),n=$o(),s=xa(),l=Ss(),i=Sa(),e=V(),t=ln(),qe.create=function(f,c,v,x){var N,g;if(f==null)throw new Error("Root element needs a name.");return x=o({},c,v,x),N=new n(x),g=N.element(f),x.headless||(N.declaration(x),(x.pubID!=null||x.sysID!=null)&&N.dtd(x)),g},qe.begin=function(f,c,v){return u(f)&&([c,v]=[f,c],f={}),c?new s(f,c,v):new n(f)},qe.stringWriter=function(f){return new l(f)},qe.streamWriter=function(f,c){return new i(f,c)},qe.implementation=new r,qe.nodeType=e,qe.writerState=t}).call(R);const Ho=(e,t,r=!1)=>{const{type:n,props:s,children:i}=t,l=i||[],o=l[0];if(l.length===1&&typeof o=="string"){e.ele(n,s,o);return}let u=null;r?Object.keys(s).map(f=>{e.att(f,s[f])}):u=e.ele(n,s),l.forEach(f=>{if(typeof f=="string")throw new Error("Invaild XML");Ho(u||e,f)})},Ta=e=>{const t=pa.create(e).toJSON();if(!t)throw new Error("Element is invalid");const r=qe.create(t.type);return Ho(r,t,!0),r.end({pretty:!0}),r.toString({pretty:!0})};function Da(e){return{alter:e.alter,step:"CDEFGAB"[(e.note+98)%7],octave:Math.floor(e.note/7)+4}}function Ea(e){const t=[I.f,I.p,I.m,I.r,I.s,I.z],r=["p","pp","ppp","pppp","ppppp","pppppp","f","ff","fff","ffff","fffff","ffffff","m","mp","mf","sf","sfp","sfpp","fp","rf","rfz","sfz","sffz","fz","n","pf","sfzp","other-dynamics"],n=e.filter(i=>t.includes(i.type)),s=n.sort((i,l)=>i.x-l.x).map(i=>i.type).join("");if(n&&n.length>0){if(r.includes(s))return{type:s,direction:{"^":"above",_:"below"}[n[0].direction]};console.error("无法识别的力度记号",s)}}function Na(e){return{10:"1024th",9:"512th",8:"256th",7:"128th",6:"64th",5:"32nd",4:"16th",3:"eighth",2:"quarter",1:"half",0:"whole"}[e]}class ec{title;pageSize;unitSize;staffLayout;paperOptions;headers;voiceStaves;lyricLanes;score;workTitle="";partBuilders=[];constructor(t){Object.assign(this,t);const r=this.voiceStaves;for(const[n,s]of this.partTemplate.entries()){const i=this.ensurePartBuilder(n,s);for(const l of s.map(o=>r[o]))for(const[o,u]of l.voices.entries())for(const[f,c]of u.measures.entries())i.ensureMeasureBuilder(f).addVoice({...c,voiceIndexOfStaff:o})}}get partTemplate(){return this.staffLayout.partGroups.map(t=>t.range[0]===t.range[1]?[t.range[0]]:t.range)}ensurePartBuilder(t,r){for(;this.partBuilders.length<=t;){const n=new La({parent:this,template:r});this.partBuilders.push(n)}return this.partBuilders[t]}createPartListElement(){return T.jsx("part-list",{children:this.partBuilders.map(t=>T.jsx("score-part",{id:t.id,children:T.jsx("part-name",{"print-object":"no",children:t.name})}))})}toJSX(){const t=new Date;return`${t.getFullYear()}${String(t.getMonth()+1).padStart(2,"0")}${String(t.getDate()).padStart(2,"0")}`,T.jsxs("score-partwise",{version:"4.0",children:[T.jsx("work",{children:T.jsx("work-title",{children:this.workTitle})}),T.jsx("movement-title",{children:this.workTitle}),T.jsx("identification",{children:T.jsx("miscellaneous",{children:T.jsx("miscellaneous-field",{name:"lilylet-staves",children:this.score.staffLayoutCode})})}),T.jsx("defaults",{children:T.jsxs("scaling",{children:[T.jsx("millimeters",{children:"8"}),T.jsx("tenths",{children:au})]})}),T.jsx("part-list",{children:this.partBuilders.map(r=>T.jsx("score-part",{id:r.id,children:T.jsx("part-name",{"print-object":"no",children:"MusicXML Part"})}))}),this.partBuilders.map(r=>r.toJSX())]})}toString(){return` -${Sa(this.toJSX())} -`}}class Na{parent;name;measureBuilders=[];staffContexts=[];template;get id(){return`P${this.parent.partBuilders.indexOf(this)+1}`}get stavesCount(){return this.template.length}constructor(t){Object.assign(this,t)}ensureStaffContext(t){for(;this.staffContexts.length<=t;){const r=new Oa({parent:this,index:t});this.staffContexts.push(r)}return this.staffContexts[t]}ensureMeasureBuilder(t){for(;this.measureBuilders.length<=t;){const r=new La({parent:this});this.measureBuilders.push(r)}return this.measureBuilders[t]}toJSX(){return D.jsx("part",{id:this.id,children:this.measureBuilders.map((t,r)=>t.toJSX())})}}class La{parent;voiceBuilders=[];beamCount=0;beamState;get index(){return this.parent.measureBuilders.indexOf(this)}get score(){return this.parent.parent.score}constructor(t){Object.assign(this,t)}addVoice(t){const r=new Ma({parent:this,voice:t});this.voiceBuilders.push(r),t.contextedTerms.filter(i=>i.type===ou.Clef).forEach(i=>{const l={[I.ClefC]:"C",[I.ClefF]:"F",[I.ClefG]:"G"}[i.tokenType];l||console.error("unknown Clef",i.tokenType);const o=this.parent.ensureStaffContext(i.staff);o.addClef(new Ko({parent:o,measureIndex:this.index,tick:i.tick,number:i.staff-this.parent.template[0],sign:l,line:3-i.y})),o.addKey(new Jo({parent:o,measureIndex:this.index,fifths:t.keySignature})),o.addTime(new Yo({parent:o,measureIndex:this.index,beats:t.timeSignature.numerator,beatType:t.timeSignature.denominator,timeSigNumeric:t.timeSigNumeric}))});const n={[I.OctaveShift8va]:8,[I.OctaveShift8vb]:-8,[I.OctaveShift0]:0},s=Object.keys(n);t.contextedTerms.forEach(i=>{s.includes(i.tokenType)&&this.parent.ensureStaffContext(i.staff).addOctaveShiftTerm(i,this.index)})}toJSX(){const t=this.score.pages.reduce((r,n)=>[...r,...n.systems.reduce((s,i)=>[...s,...i.measureBars],[])],[]);return this.beamCount=0,D.jsxs("measure",{number:this.index+1,width:Math.round(t[this.index]*10),children:[this.index===0&&D.jsx(D.Fragment,{children:this.parent.staffContexts.map(r=>{var n;return r.clefBuilders.length>0?D.jsx("attributes",{children:(n=r.clefBuilders)==null?void 0:n[0].toJSX()}):null})}),this.voiceBuilders.reduce((r,n,s)=>{var i,l;return r.push(...n.toJSX()),(l=(i=this.voiceBuilders[s+1])==null?void 0:i.toJSX)!=null&&l.call(i)&&r.push(D.jsx("backup",{children:D.jsx("duration",{children:n.voice.duration})})),r},[])]})}}class Ma{parent;voice;get index(){return this.parent.voiceBuilders.indexOf(this)}constructor(t){Object.assign(this,t)}toJSX(){var v,x;const t=[],r=new Map;for(const N of this.parent.parent.parent.lyricLanes||[])for(const g of N.syllables){const L=`${g.staffIndex}:${g.voiceIndex}:${g.measureIndex}:${g.tick}`,P=r.get(L)||[];P.push(g),r.set(L,P)}const n=new Map;for(const N of this.voice.marks||[])if(((v=N.constructor)==null?void 0:v.className)==="TempoTerm"&&((x=N.isValid)!=null&&x.call(N))){const g=n.get(N.tick)||[];g.push(N),n.set(N.tick,g)}const s={[I.AccNatural]:0,[I.AccSharp]:1,[I.AccDoublesharp]:2,[I.AccFlat]:-1,[I.AccFlatflat]:-1,[I.KeyNatural]:0,[I.KeySharp]:1,[I.KeyFlat]:-1},i=Object.keys(s),l=this.voice.contextedTerms.reduce((N,g)=>{if(i.includes(g.tokenType)){const L=N.findIndex(P=>P.x===g.x&&P.y===g.y);L>-1?N.splice(L,1):N.push(g)}return N},[]),o=Object.entries(this.voice.tickMap).map(([N,g])=>{var L;return[Number(((L=N.match(/-?\d+/))==null?void 0:L[0])??NaN),g]}).sort(([N],[g])=>N-g);o.forEach(([N,g])=>{const L=l.filter(P=>P.tick===N);L.length>0&&L.forEach(P=>{var d;const y=(d=g.ys)==null?void 0:d.findIndex(w=>w===P.y);y>-1&&(g.pitches[y].accidental=s[P.tokenType])})});const u=new Set,f=new Set;let c=!1;return o.forEach(([N,g],L)=>{const P=g instanceof un&&!!g.timeWarp,y=L{var y,d,w,a,p;const P=this.parent.parent.ensureStaffContext(g.staff||0);if(g instanceof un){const m=P.lookupDivisions(this.parent.index),T=P.lookupStaves(this.parent.index),h=P.lookupClef(this.parent.index,+N),S=P.lookupKey(this.parent.index),E=P.lookupTime(this.parent.index),O=[m,S,E,T,h].filter(Boolean).map(M=>M.toJSX());L===0&&this.index===0&&O.length>0&&t.push(D.jsx("attributes",{children:O}));const C=[],b=[];b.push(...new Pa(g.accessories).toJSX()||[]),b.length>0&&C.push(D.jsx("technical",{children:b}));const _=[];g.accessories.some(M=>M.type===I.ScriptStaccato)&&_.push(D.jsx("staccato",{})),g.accessories.some(M=>M.type===I.ScriptSforzato)&&_.push(D.jsx("accent",{})),g.accessories.some(M=>M.type===I.ScriptStaccatissimo)&&_.push(D.jsx("spiccato",{})),g.accessories.some(M=>M.type===I.ScriptMarcato)&&_.push(D.jsx("strong-accent",{})),g.accessories.some(M=>M.type===I.ScriptTenuto)&&_.push(D.jsx("tenuto",{})),g.accessories.some(M=>M.type===I.ScriptPortato)&&_.push(D.jsx("detached-legato",{})),_.length>0&&C.push(D.jsx("articulations",{children:_}));const k=g.accessories.find(M=>M.type===I.ScriptFermata);k&&C.push(D.jsx("fermata",{type:{[We.Up]:"upright",[We.Down]:"inverted"}[k.direction]})),g.accessories.some(M=>M.type===I.SlurBegin)&&g.accessories.filter(M=>M.type===I.SlurBegin).forEach(M=>{C.push(D.jsx("slur",{"default-x":(g.x+M.x).toFixed(2),number:"1",placement:{[We.Up]:"above",[We.Down]:"below"}[M.direction],type:"start"}))}),g.accessories.some(M=>M.type===I.SlurEnd)&&g.accessories.filter(M=>M.type===I.SlurEnd).forEach(M=>{C.push(D.jsx("slur",{"default-x":(g.x+M.x).toFixed(2),number:"1",placement:{[We.Up]:"above",[We.Down]:"below"}[M.direction],type:"stop"}))}),g.accessories.some(M=>M.type===I.TieBegin)&&g.accessories.filter(M=>M.type===I.TieBegin).forEach(M=>{C.push(D.jsx("tied",{type:"start"}))}),g.accessories.some(M=>M.type===I.TieEnd)&&g.accessories.filter(M=>M.type===I.TieEnd).forEach(M=>{C.push(D.jsx("tied",{type:"stop"}))});const ie=[];g.accessories.some(M=>M.type===I.ScriptTurn)&&ie.push(D.jsx("turn",{})),g.accessories.some(M=>M.type===I.ScriptTrill)&&ie.push(D.jsx("trill-mark",{})),g.accessories.some(M=>M.type===I.ScriptMordent)&&ie.push(D.jsx("mordent",{})),g.accessories.some(M=>M.type===I.ScriptPrall)&&ie.push(D.jsx("inverted-mordent",{})),Number.isFinite(g.tremolo)&&ie.push(D.jsx("tremolo",{type:"single",children:g.tremolo})),ie.length>0&&C.push(D.jsx("ornaments",{children:ie})),u.has(g.tick)&&C.push(D.jsx("tuplet",{type:"start"})),f.has(g.tick)&&C.push(D.jsx("tuplet",{type:"stop"})),(g.accessories.some(M=>M.type===I.ScriptArpeggio)||g.arpeggioStyle)&&C.push(D.jsx("arpeggiate",{})),g.glissando&&C.push(D.jsx("glissando",{type:"start",number:"1"}));const Zo=Ea(g.division);if(this.index===0){const M=g.staff-this.parent.parent.template[0]+1;(n.get(g.tick)||[]).forEach(q=>{var or;const xt=(q.duration||"").match(/^(\d+)(\.)?$/),lr=xt?{1:"whole",2:"half",4:"quarter",8:"eighth",16:"16th"}[xt[1]]:"quarter",St=Number(((or=(q.beats||"").match(/\d+/))==null?void 0:or[0])||q.bpm||90);t.push(D.jsxs("direction",{placement:"above",children:[D.jsx("direction-type",{children:D.jsxs("metronome",{children:[D.jsx("beat-unit",{children:lr}),xt&&xt[2]&&D.jsx("beat-unit-dot",{}),D.jsx("per-minute",{children:Math.round(St)})]})}),D.jsx("sound",{tempo:Math.round(q.bpm)})]}))});const st=Da(g.accessories);if(st){const q=st.type;t.push(D.jsxs("direction",{placement:st.direction??"below",children:[D.jsx("direction-type",{children:D.jsx("dynamics",{children:su.createElement(q)})}),D.jsx("staff",{children:M})]}))}const sr=g.accessories.find(q=>q.type===I.WedgeCrescendo),Ft=g.accessories.find(q=>q.type===I.WedgeDiminuendo),zt=g.accessories.find(q=>q.type===I.WedgeClose);sr&&t.push(D.jsxs("direction",{placement:"below",children:[D.jsx("direction-type",{children:D.jsx("wedge",{type:"crescendo"})}),D.jsx("staff",{children:M})]})),Ft&&t.push(D.jsxs("direction",{placement:"below",children:[D.jsx("direction-type",{children:D.jsx("wedge",{type:"diminuendo"})}),D.jsx("staff",{children:M})]})),zt&&t.push(D.jsxs("direction",{children:[D.jsx("direction-type",{children:D.jsx("wedge",{type:"stop"})}),D.jsx("staff",{children:M})]})),g.accessories.some(q=>q.type===I.PedalPed)&&t.push(D.jsxs("direction",{children:[D.jsx("direction-type",{children:D.jsx("pedal",{type:"start",sign:"yes"})}),D.jsx("staff",{children:M})]})),g.accessories.some(q=>q.type===I.PedalStar)&&t.push(D.jsxs("direction",{children:[D.jsx("direction-type",{children:D.jsx("pedal",{type:"stop",sign:"yes"})}),D.jsx("staff",{children:M})]}));const Bt=(d=(y=P.lookupOctaveShift(this.parent.index))==null?void 0:y.getJSX)==null?void 0:d.call(y,g.tick);Bt&&t.push(Bt)}if(g.pitches){const M=g.pitches.length>1;(w=g.pitches)==null||w.forEach((Ue,st)=>{const{alter:sr,step:Ft,octave:zt}=Ta(Ue),Bt={u:"up",d:"down"}[g.stemDirection];if(!this.voice.empty){let q=null;switch(g.beam){case"Open":q=D.jsx("beam",{number:"1",children:"begin"}),this.parent.beamState=g.beam;break;case"Close":q=D.jsx("beam",{number:"1",children:"end"}),this.parent.beamCount+=1,this.parent.beamState=g.beam;break;default:this.parent.beamState==="Open"&&(q=D.jsx("beam",{number:"1",children:"continue"}));break}const xt=g.staff-this.parent.parent.template[0]+1,on=!g.rest&&(M?!!Ue.tying:!!g.tying||g.accessories.some(Me=>Me.type===I.TieBegin)),lr=!g.rest&&(M?!!Ue.tied:!!g.tied||g.accessories.some(Me=>Me.type===I.TieEnd)),St=(st===0?C:[]).slice();on&&St.push(D.jsx("tied",{type:"start"})),lr&&St.push(D.jsx("tied",{type:"stop"}));const or=`${g.staff}:${this.voice.voiceIndexOfStaff}:${this.parent.index}:${g.tick}`,eu=st===0&&!g.rest&&!g.grace?(r.get(or)||[]).slice().sort((Me,tu)=>Me.verse-tu.verse).map(Me=>D.jsxs("lyric",{number:Me.verse+1,children:[D.jsx("syllabic",{children:Me.syllabic||"single"}),D.jsx("text",{children:Me.text}),Me.extend?D.jsx("extend",{}):null]})):[];t.push(D.jsxs("note",{children:[g.grace&&D.jsx("grace",{"steal-time-following":g.duration}),M&&st!==0&&D.jsx("chord",{}),!g.rest&&D.jsxs("pitch",{children:[D.jsx("step",{children:Ft}),sr!==0&&D.jsx("alter",{children:sr}),D.jsx("octave",{children:zt})]}),g.rest==="r"&&D.jsxs("rest",{children:[D.jsx("display-step",{children:Ft}),D.jsx("display-octave",{children:zt})]}),g.rest==="R"&&D.jsxs("rest",{measure:"yes",children:[D.jsx("display-step",{children:Ft}),D.jsx("display-octave",{children:zt})]}),on&&D.jsx("tie",{type:"start"}),lr&&D.jsx("tie",{type:"stop"}),g.grace?null:D.jsx("duration",{children:g.duration}),D.jsx("voice",{children:this.index+1}),D.jsx("type",{children:Zo}),Array(g.dots).fill(null).map(()=>D.jsx("dot",{})),new Ra(Ue.accidental).toJSX(),g.timeWarp&&new ja(g.timeWarp).toJSX(),Bt?D.jsx("stem",{children:Bt}):null,D.jsx("staff",{children:xt}),q,St.length>0&&D.jsx("notations",{children:St}),eu]}))}})}if(this.index===0&&L===o.length-1){const M=P.getCurrentTime(this.parent.index);if(M){const Ue=(p=(a=P.lookupOctaveShift(this.parent.index))==null?void 0:a.getJSX)==null?void 0:p.call(a,Ol*M.beatType/4*M.beats);Ue&&t.push(Ue)}}const Ts=Math.max(...P.clefBuilders.map(M=>M.tick)),Go=Math.max(...Object.keys(this.voice.tickMap).map(M=>+M));if(Ts>=Go){const M=P.lookupClef(this.parent.index,Ts);M&&t.push(D.jsx("attributes",{children:M.toJSX()}))}}}),t}}class Oa{parent;index;divisionsBuilder=new Ia({value:Ol});clefBuilders=[];keyBuilders=[];timeBuilders=[];octave;tied;beamCount=0;octaveShiftBuilders=[];constructor(t){Object.assign(this,t)}lookupDivisions(t){return t===0?this.divisionsBuilder:null}lookupStaves(t){return t===0?new Ca({value:this.parent.stavesCount}):null}addClef(t){this.lookupClef(t.measureIndex,t.tick)||this.clefBuilders.length>0&&Ko.equals(this.clefBuilders[this.clefBuilders.length-1],t)||this.clefBuilders.push(t)}lookupClef(t,r){const n=this.clefBuilders.filter(s=>s.measureIndex===t&&s.tick===r);return n.length>0?n[0]:null}addKey(t){this.lookupKey(t.measureIndex)||this.keyBuilders.length>0&&Jo.equals(this.keyBuilders[this.keyBuilders.length-1],t)||this.keyBuilders.push(t)}lookupKey(t){const r=this.keyBuilders.filter(n=>n.measureIndex===t);return r.length>0?r[0]:null}addTime(t){this.lookupTime(t.measureIndex)||this.timeBuilders.length>0&&Yo.equals(this.timeBuilders[this.timeBuilders.length-1],t)||this.timeBuilders.push(t)}lookupTime(t){const r=this.timeBuilders.filter(n=>n.measureIndex===t);return r.length>0?r[0]:null}getCurrentTime(t){const r=this.timeBuilders.filter(n=>n.measureIndex<=t);return r.sort((n,s)=>n.measureIndex-s.measureIndex),r[r.length-1]}addOctaveShiftTerm(t,r){let n=this.octaveShiftBuilders.find(s=>s.measureIndex===r);n||(n=new Xa({parent:this,measureIndex:r}),this.octaveShiftBuilders.push(n)),n.addTerm(t)}lookupOctaveShift(t){const r=this.octaveShiftBuilders.filter(n=>n.measureIndex===t);return r.length>0?r[0]:null}}class Ko{parent;measureIndex;tick;number;sign;line;size="full";afterBarline=!0;additional=!1;constructor(t){Object.assign(this,t)}static equals(t,r){return t&&r&&t.number===r.number&&t.sign===r.sign&&t.line===r.line&&t.size===r.size}toJSX(){return D.jsxs("clef",{number:this.number+1,size:this.size,additional:this.additional?"yes":"no","after-barline":this.afterBarline?"yes":"no",children:[D.jsx("sign",{children:this.sign}),D.jsx("line",{children:this.line})]})}}class Jo{parent;measureIndex;fifths;mode;constructor(t){Object.assign(this,t)}static equals(t,r){return t&&r&&t.fifths===r.fifths&&t.mode===r.mode}toJSX(){return D.jsxs("key",{children:[D.jsx("fifths",{children:this.fifths}),this.mode?D.jsx("mode",{children:this.mode}):null]})}}class Yo{parent;measureIndex;beats;beatType;timeSigNumeric;constructor(t){Object.assign(this,t)}static equals(t,r){return t&&r&&t.beats===r.beats&&t.beatType===r.beatType}toJSX(){const t={};return this.beats===2&&this.beatType===2&&(t.symbol="cut"),this.beats===4&&this.beatType===4&&(t.symbol="common"),D.jsxs("time",{...t,children:[D.jsx("beats",{children:this.beats}),D.jsx("beat-type",{children:this.beatType})]})}}class Ia{value;constructor(t){Object.assign(this,t)}toJSX(){return D.jsx("divisions",{children:this.value})}}class Ca{value;constructor(t){Object.assign(this,t)}toJSX(){return D.jsx("staves",{children:this.value})}}const Ml={[I.Zero]:0,[I.One]:1,[I.Two]:2,[I.Three]:3,[I.Four]:4,[I.Five]:5,[I.Six]:6,[I.Seven]:7,[I.Eight]:8,[I.Nine]:9};class Pa{value;placement;data;constructor(t){this.data=t}toJSX(){const t=Object.keys(Ml),r=this.data.filter(n=>t.includes(n.type));return r.length>0?r.map(n=>D.jsx("fingering",{placement:{[We.Up]:"above",[We.Down]:"below"}[n.direction],children:Ml[n.type]})):null}}class ja{timeWarp;constructor(t){this.timeWarp=t}toJSX(){return D.jsxs("time-modification",{children:[D.jsx("actual-notes",{children:this.timeWarp.denominator}),D.jsx("normal-notes",{children:this.timeWarp.numerator})]})}}const ka={"-2":"flat-flat","-1":"flat",0:"natural",1:"sharp",2:"double-sharp"};class Ra{alter;constructor(t){this.alter=t}toJSX(){return typeof this.alter=="number"?D.jsx("accidental",{children:ka[this.alter]}):null}}class Xa{parent;measureIndex;number;terms=[];constructor(t){Object.assign(this,t)}addTerm(t){this.terms.find(r=>r.tick===t.tick)||this.terms.push(t)}getJSX(t){const r=this.terms.find(s=>s.tick===t);if(!r)return null;let n="up";switch(r.tokenType){case I.OctaveShift8vb:n="up";break;case I.OctaveShift8va:n="down";break;case I.OctaveShift0:n="stop";break}return D.jsxs("direction",{children:[D.jsx("direction-type",{children:D.jsx("octave-shift",{size:"8",type:n,number:"1"})}),D.jsx("staff",{children:this.parent.parent.template.indexOf(this.parent.index)+1})]})}validate(){if(this.terms.length===0)return!0;this.terms.sort((n,s)=>n.tick-s.tick);const t=[],r=[];for(let n of this.terms)[I.OctaveShift8va,I.OctaveShift8vb].includes(n.tokenType)&&r.push(n),I.OctaveShift0===n.tokenType&&(r.push(n),t.push([...r]),r.length=0);return t.some(n=>n.length!==2)||r.length===1?(console.error("八度记号配对错误"),!1):!0}toJSX(){}}export{Ga as S}; +${Ta(this.toJSX())} +`}}class La{parent;name;measureBuilders=[];staffContexts=[];template;get id(){return`P${this.parent.partBuilders.indexOf(this)+1}`}get stavesCount(){return this.template.length}constructor(t){Object.assign(this,t)}ensureStaffContext(t){for(;this.staffContexts.length<=t;){const r=new Ia({parent:this,index:t});this.staffContexts.push(r)}return this.staffContexts[t]}ensureMeasureBuilder(t){for(;this.measureBuilders.length<=t;){const r=new Ma({parent:this});this.measureBuilders.push(r)}return this.measureBuilders[t]}toJSX(){return T.jsx("part",{id:this.id,children:this.measureBuilders.map((t,r)=>t.toJSX())})}}class Ma{parent;voiceBuilders=[];beamCount=0;beamState;get index(){return this.parent.measureBuilders.indexOf(this)}get score(){return this.parent.parent.score}constructor(t){Object.assign(this,t)}addVoice(t){const r=new Oa({parent:this,voice:t});this.voiceBuilders.push(r),t.contextedTerms.filter(i=>i.type===uu.Clef).forEach(i=>{const l={[I.ClefC]:"C",[I.ClefF]:"F",[I.ClefG]:"G"}[i.tokenType];l||console.error("unknown Clef",i.tokenType);const o=this.parent.ensureStaffContext(i.staff);o.addClef(new Ko({parent:o,measureIndex:this.index,tick:i.tick,number:i.staff-this.parent.template[0],sign:l,line:3-i.y})),o.addKey(new Jo({parent:o,measureIndex:this.index,fifths:t.keySignature})),o.addTime(new Yo({parent:o,measureIndex:this.index,beats:t.timeSignature.numerator,beatType:t.timeSignature.denominator,timeSigNumeric:t.timeSigNumeric}))});const n={[I.OctaveShift8va]:8,[I.OctaveShift8vb]:-8,[I.OctaveShift0]:0},s=Object.keys(n);t.contextedTerms.forEach(i=>{s.includes(i.tokenType)&&this.parent.ensureStaffContext(i.staff).addOctaveShiftTerm(i,this.index)})}toJSX(){const t=this.score.pages.reduce((s,i)=>[...s,...i.systems.reduce((l,o)=>[...l,...o.measureBars],[])],[]);this.beamCount=0;const r=this.voiceBuilders.map(s=>s.voice.bar).find(Boolean),n=r==="|."?"light-heavy":r==="||"?"light-light":void 0;return T.jsxs("measure",{number:this.index+1,width:Math.round(t[this.index]*10),children:[this.index===0&&T.jsx(T.Fragment,{children:this.parent.staffContexts.map(s=>{var i;return s.clefBuilders.length>0?T.jsx("attributes",{children:(i=s.clefBuilders)==null?void 0:i[0].toJSX()}):null})}),this.voiceBuilders.reduce((s,i,l)=>{var o,u;return s.push(...i.toJSX()),(u=(o=this.voiceBuilders[l+1])==null?void 0:o.toJSX)!=null&&u.call(o)&&s.push(T.jsx("backup",{children:T.jsx("duration",{children:i.voice.duration})})),s},[]),n&&T.jsx("barline",{location:"right",children:T.jsx("bar-style",{children:n})})]})}}class Oa{parent;voice;get index(){return this.parent.voiceBuilders.indexOf(this)}constructor(t){Object.assign(this,t)}toJSX(){var v,x;const t=[],r=new Map;for(const N of this.parent.parent.parent.lyricLanes||[])for(const g of N.syllables){const L=`${g.staffIndex}:${g.voiceIndex}:${g.measureIndex}:${g.tick}`,P=r.get(L)||[];P.push(g),r.set(L,P)}const n=new Map;for(const N of this.voice.marks||[])if(((v=N.constructor)==null?void 0:v.className)==="TempoTerm"&&((x=N.isValid)!=null&&x.call(N))){const g=n.get(N.tick)||[];g.push(N),n.set(N.tick,g)}const s={[I.AccNatural]:0,[I.AccSharp]:1,[I.AccDoublesharp]:2,[I.AccFlat]:-1,[I.AccFlatflat]:-1,[I.KeyNatural]:0,[I.KeySharp]:1,[I.KeyFlat]:-1},i=Object.keys(s),l=this.voice.contextedTerms.reduce((N,g)=>{if(i.includes(g.tokenType)){const L=N.findIndex(P=>P.x===g.x&&P.y===g.y);L>-1?N.splice(L,1):N.push(g)}return N},[]),o=Object.entries(this.voice.tickMap).map(([N,g])=>{var L;return[Number(((L=N.match(/-?\d+/))==null?void 0:L[0])??NaN),g]}).sort(([N],[g])=>N-g);o.forEach(([N,g])=>{const L=l.filter(P=>P.tick===N);L.length>0&&L.forEach(P=>{var d;const y=(d=g.ys)==null?void 0:d.findIndex(w=>w===P.y);y>-1&&(g.pitches[y].accidental=s[P.tokenType])})});const u=new Set,f=new Set;let c=!1;return o.forEach(([N,g],L)=>{const P=g instanceof un&&!!g.timeWarp,y=L{var y,d,w,a,p;const P=this.parent.parent.ensureStaffContext(g.staff||0);if(g instanceof un){const m=P.lookupDivisions(this.parent.index),D=P.lookupStaves(this.parent.index),h=P.lookupClef(this.parent.index,+N),S=P.lookupKey(this.parent.index),E=P.lookupTime(this.parent.index),O=[m,S,E,D,h].filter(Boolean).map(M=>M.toJSX());L===0&&this.index===0&&O.length>0&&t.push(T.jsx("attributes",{children:O}));const C=[],b=[];b.push(...new ja(g.accessories).toJSX()||[]),b.length>0&&C.push(T.jsx("technical",{children:b}));const _=[];g.accessories.some(M=>M.type===I.ScriptStaccato)&&_.push(T.jsx("staccato",{})),g.accessories.some(M=>M.type===I.ScriptSforzato)&&_.push(T.jsx("accent",{})),g.accessories.some(M=>M.type===I.ScriptStaccatissimo)&&_.push(T.jsx("spiccato",{})),g.accessories.some(M=>M.type===I.ScriptMarcato)&&_.push(T.jsx("strong-accent",{})),g.accessories.some(M=>M.type===I.ScriptTenuto)&&_.push(T.jsx("tenuto",{})),g.accessories.some(M=>M.type===I.ScriptPortato)&&_.push(T.jsx("detached-legato",{})),_.length>0&&C.push(T.jsx("articulations",{children:_}));const k=g.accessories.find(M=>M.type===I.ScriptFermata);k&&C.push(T.jsx("fermata",{type:{[We.Up]:"upright",[We.Down]:"inverted"}[k.direction]})),g.accessories.some(M=>M.type===I.SlurBegin)&&g.accessories.filter(M=>M.type===I.SlurBegin).forEach(M=>{C.push(T.jsx("slur",{"default-x":(g.x+M.x).toFixed(2),number:"1",placement:{[We.Up]:"above",[We.Down]:"below"}[M.direction],type:"start"}))}),g.accessories.some(M=>M.type===I.SlurEnd)&&g.accessories.filter(M=>M.type===I.SlurEnd).forEach(M=>{C.push(T.jsx("slur",{"default-x":(g.x+M.x).toFixed(2),number:"1",placement:{[We.Up]:"above",[We.Down]:"below"}[M.direction],type:"stop"}))}),g.accessories.some(M=>M.type===I.TieBegin)&&g.accessories.filter(M=>M.type===I.TieBegin).forEach(M=>{C.push(T.jsx("tied",{type:"start"}))}),g.accessories.some(M=>M.type===I.TieEnd)&&g.accessories.filter(M=>M.type===I.TieEnd).forEach(M=>{C.push(T.jsx("tied",{type:"stop"}))});const ie=[];g.accessories.some(M=>M.type===I.ScriptTurn)&&ie.push(T.jsx("turn",{})),g.accessories.some(M=>M.type===I.ScriptTrill)&&ie.push(T.jsx("trill-mark",{})),g.accessories.some(M=>M.type===I.ScriptMordent)&&ie.push(T.jsx("mordent",{})),g.accessories.some(M=>M.type===I.ScriptPrall)&&ie.push(T.jsx("inverted-mordent",{})),Number.isFinite(g.tremolo)&&ie.push(T.jsx("tremolo",{type:"single",children:g.tremolo})),ie.length>0&&C.push(T.jsx("ornaments",{children:ie})),u.has(g.tick)&&C.push(T.jsx("tuplet",{type:"start"})),f.has(g.tick)&&C.push(T.jsx("tuplet",{type:"stop"}));const Zo=g.accessories.filter(M=>M.type===I.ScriptArpeggio).length+(g.arpeggioStyle?1:0);for(let M=0;M{var or;const xt=(q.duration||"").match(/^(\d+)(\.)?$/),lr=xt?{1:"whole",2:"half",4:"quarter",8:"eighth",16:"16th"}[xt[1]]:"quarter",St=Number(((or=(q.beats||"").match(/\d+/))==null?void 0:or[0])||q.bpm||90);t.push(T.jsxs("direction",{placement:"above",children:[T.jsx("direction-type",{children:T.jsxs("metronome",{children:[T.jsx("beat-unit",{children:lr}),xt&&xt[2]&&T.jsx("beat-unit-dot",{}),T.jsx("per-minute",{children:Math.round(St)})]})}),T.jsx("sound",{tempo:Math.round(q.bpm)})]}))});const st=Ea(g.accessories);if(st){const q=st.type;t.push(T.jsxs("direction",{placement:st.direction??"below",children:[T.jsx("direction-type",{children:T.jsx("dynamics",{children:lu.createElement(q)})}),T.jsx("staff",{children:M})]}))}const sr=g.accessories.find(q=>q.type===I.WedgeCrescendo),Ft=g.accessories.find(q=>q.type===I.WedgeDiminuendo),zt=g.accessories.find(q=>q.type===I.WedgeClose);sr&&t.push(T.jsxs("direction",{placement:"below",children:[T.jsx("direction-type",{children:T.jsx("wedge",{type:"crescendo"})}),T.jsx("staff",{children:M})]})),Ft&&t.push(T.jsxs("direction",{placement:"below",children:[T.jsx("direction-type",{children:T.jsx("wedge",{type:"diminuendo"})}),T.jsx("staff",{children:M})]})),zt&&t.push(T.jsxs("direction",{children:[T.jsx("direction-type",{children:T.jsx("wedge",{type:"stop"})}),T.jsx("staff",{children:M})]})),g.accessories.some(q=>q.type===I.PedalPed)&&t.push(T.jsxs("direction",{children:[T.jsx("direction-type",{children:T.jsx("pedal",{type:"start",sign:"yes"})}),T.jsx("staff",{children:M})]})),g.accessories.some(q=>q.type===I.PedalStar)&&t.push(T.jsxs("direction",{children:[T.jsx("direction-type",{children:T.jsx("pedal",{type:"stop",sign:"yes"})}),T.jsx("staff",{children:M})]}));const Bt=(d=(y=P.lookupOctaveShift(this.parent.index))==null?void 0:y.getJSX)==null?void 0:d.call(y,g.tick);Bt&&t.push(Bt)}if(g.pitches){const M=g.pitches.length>1;(w=g.pitches)==null||w.forEach((Ue,st)=>{const{alter:sr,step:Ft,octave:zt}=Da(Ue),Bt={u:"up",d:"down"}[g.stemDirection];if(!this.voice.empty){let q=null;switch(g.beam){case"Open":q=T.jsx("beam",{number:"1",children:"begin"}),this.parent.beamState=g.beam;break;case"Close":q=T.jsx("beam",{number:"1",children:"end"}),this.parent.beamCount+=1,this.parent.beamState=g.beam;break;default:this.parent.beamState==="Open"&&(q=T.jsx("beam",{number:"1",children:"continue"}));break}const xt=g.staff-this.parent.parent.template[0]+1,on=!g.rest&&(M?!!Ue.tying:!!g.tying||g.accessories.some(Me=>Me.type===I.TieBegin)),lr=!g.rest&&(M?!!Ue.tied:!!g.tied||g.accessories.some(Me=>Me.type===I.TieEnd)),St=(st===0?C:[]).slice();on&&St.push(T.jsx("tied",{type:"start"})),lr&&St.push(T.jsx("tied",{type:"stop"}));const or=`${g.staff}:${this.voice.voiceIndexOfStaff}:${this.parent.index}:${g.tick}`,tu=st===0&&!g.rest&&!g.grace?(r.get(or)||[]).slice().sort((Me,ru)=>Me.verse-ru.verse).map(Me=>T.jsxs("lyric",{number:Me.verse+1,children:[T.jsx("syllabic",{children:Me.syllabic||"single"}),T.jsx("text",{children:Me.text}),Me.extend?T.jsx("extend",{}):null]})):[];t.push(T.jsxs("note",{children:[g.grace&&T.jsx("grace",{"steal-time-following":g.duration}),M&&st!==0&&T.jsx("chord",{}),!g.rest&&T.jsxs("pitch",{children:[T.jsx("step",{children:Ft}),sr!==0&&T.jsx("alter",{children:sr}),T.jsx("octave",{children:zt})]}),g.rest==="r"&&T.jsxs("rest",{children:[T.jsx("display-step",{children:Ft}),T.jsx("display-octave",{children:zt})]}),g.rest==="R"&&T.jsxs("rest",{measure:"yes",children:[T.jsx("display-step",{children:Ft}),T.jsx("display-octave",{children:zt})]}),on&&T.jsx("tie",{type:"start"}),lr&&T.jsx("tie",{type:"stop"}),g.grace?null:T.jsx("duration",{children:g.duration}),T.jsx("voice",{children:this.index+1}),T.jsx("type",{children:Go}),Array(g.dots).fill(null).map(()=>T.jsx("dot",{})),new Xa(Ue.accidental).toJSX(),g.timeWarp&&new ka(g.timeWarp).toJSX(),Bt?T.jsx("stem",{children:Bt}):null,T.jsx("staff",{children:xt}),q,St.length>0&&T.jsx("notations",{children:St}),tu]}))}})}if(this.index===0&&L===o.length-1){const M=P.getCurrentTime(this.parent.index);if(M){const Ue=(p=(a=P.lookupOctaveShift(this.parent.index))==null?void 0:a.getJSX)==null?void 0:p.call(a,Ol*M.beatType/4*M.beats);Ue&&t.push(Ue)}}const Ts=Math.max(...P.clefBuilders.map(M=>M.tick)),eu=Math.max(...Object.keys(this.voice.tickMap).map(M=>+M));if(Ts>=eu){const M=P.lookupClef(this.parent.index,Ts);M&&t.push(T.jsx("attributes",{children:M.toJSX()}))}}}),t}}class Ia{parent;index;divisionsBuilder=new Ca({value:Ol});clefBuilders=[];keyBuilders=[];timeBuilders=[];octave;tied;beamCount=0;octaveShiftBuilders=[];constructor(t){Object.assign(this,t)}lookupDivisions(t){return t===0?this.divisionsBuilder:null}lookupStaves(t){return t===0?new Pa({value:this.parent.stavesCount}):null}addClef(t){this.lookupClef(t.measureIndex,t.tick)||this.clefBuilders.length>0&&Ko.equals(this.clefBuilders[this.clefBuilders.length-1],t)||this.clefBuilders.push(t)}lookupClef(t,r){const n=this.clefBuilders.filter(s=>s.measureIndex===t&&s.tick===r);return n.length>0?n[0]:null}addKey(t){this.lookupKey(t.measureIndex)||this.keyBuilders.length>0&&Jo.equals(this.keyBuilders[this.keyBuilders.length-1],t)||this.keyBuilders.push(t)}lookupKey(t){const r=this.keyBuilders.filter(n=>n.measureIndex===t);return r.length>0?r[0]:null}addTime(t){this.lookupTime(t.measureIndex)||this.timeBuilders.length>0&&Yo.equals(this.timeBuilders[this.timeBuilders.length-1],t)||this.timeBuilders.push(t)}lookupTime(t){const r=this.timeBuilders.filter(n=>n.measureIndex===t);return r.length>0?r[0]:null}getCurrentTime(t){const r=this.timeBuilders.filter(n=>n.measureIndex<=t);return r.sort((n,s)=>n.measureIndex-s.measureIndex),r[r.length-1]}addOctaveShiftTerm(t,r){let n=this.octaveShiftBuilders.find(s=>s.measureIndex===r);n||(n=new Fa({parent:this,measureIndex:r}),this.octaveShiftBuilders.push(n)),n.addTerm(t)}lookupOctaveShift(t){const r=this.octaveShiftBuilders.filter(n=>n.measureIndex===t);return r.length>0?r[0]:null}}class Ko{parent;measureIndex;tick;number;sign;line;size="full";afterBarline=!0;additional=!1;constructor(t){Object.assign(this,t)}static equals(t,r){return t&&r&&t.number===r.number&&t.sign===r.sign&&t.line===r.line&&t.size===r.size}toJSX(){return T.jsxs("clef",{number:this.number+1,size:this.size,additional:this.additional?"yes":"no","after-barline":this.afterBarline?"yes":"no",children:[T.jsx("sign",{children:this.sign}),T.jsx("line",{children:this.line})]})}}class Jo{parent;measureIndex;fifths;mode;constructor(t){Object.assign(this,t)}static equals(t,r){return t&&r&&t.fifths===r.fifths&&t.mode===r.mode}toJSX(){return T.jsxs("key",{children:[T.jsx("fifths",{children:this.fifths}),this.mode?T.jsx("mode",{children:this.mode}):null]})}}class Yo{parent;measureIndex;beats;beatType;timeSigNumeric;constructor(t){Object.assign(this,t)}static equals(t,r){return t&&r&&t.beats===r.beats&&t.beatType===r.beatType}toJSX(){const t={};return this.beats===2&&this.beatType===2&&(t.symbol="cut"),this.beats===4&&this.beatType===4&&(t.symbol="common"),T.jsxs("time",{...t,children:[T.jsx("beats",{children:this.beats}),T.jsx("beat-type",{children:this.beatType})]})}}class Ca{value;constructor(t){Object.assign(this,t)}toJSX(){return T.jsx("divisions",{children:this.value})}}class Pa{value;constructor(t){Object.assign(this,t)}toJSX(){return T.jsx("staves",{children:this.value})}}const Ml={[I.Zero]:0,[I.One]:1,[I.Two]:2,[I.Three]:3,[I.Four]:4,[I.Five]:5,[I.Six]:6,[I.Seven]:7,[I.Eight]:8,[I.Nine]:9};class ja{value;placement;data;constructor(t){this.data=t}toJSX(){const t=Object.keys(Ml),r=this.data.filter(n=>t.includes(n.type));return r.length>0?r.map(n=>T.jsx("fingering",{placement:{[We.Up]:"above",[We.Down]:"below"}[n.direction],children:Ml[n.type]})):null}}class ka{timeWarp;constructor(t){this.timeWarp=t}toJSX(){return T.jsxs("time-modification",{children:[T.jsx("actual-notes",{children:this.timeWarp.denominator}),T.jsx("normal-notes",{children:this.timeWarp.numerator})]})}}const Ra={"-2":"flat-flat","-1":"flat",0:"natural",1:"sharp",2:"double-sharp"};class Xa{alter;constructor(t){this.alter=t}toJSX(){return typeof this.alter=="number"?T.jsx("accidental",{children:Ra[this.alter]}):null}}class Fa{parent;measureIndex;number;terms=[];constructor(t){Object.assign(this,t)}addTerm(t){this.terms.find(r=>r.tick===t.tick)||this.terms.push(t)}getJSX(t){const r=this.terms.find(s=>s.tick===t);if(!r)return null;let n="up";switch(r.tokenType){case I.OctaveShift8vb:n="up";break;case I.OctaveShift8va:n="down";break;case I.OctaveShift0:n="stop";break}return T.jsxs("direction",{children:[T.jsx("direction-type",{children:T.jsx("octave-shift",{size:"8",type:n,number:"1"})}),T.jsx("staff",{children:this.parent.parent.template.indexOf(this.parent.index)+1})]})}validate(){if(this.terms.length===0)return!0;this.terms.sort((n,s)=>n.tick-s.tick);const t=[],r=[];for(let n of this.terms)[I.OctaveShift8va,I.OctaveShift8vb].includes(n.tokenType)&&r.push(n),I.OctaveShift0===n.tokenType&&(r.push(n),t.push([...r]),r.length=0);return t.some(n=>n.length!==2)||r.length===1?(console.error("八度记号配对错误"),!1):!0}toJSX(){}}export{ec as S}; diff --git a/dist/assets/Table-dcae5cc9.js b/dist/assets/Table-d40746fd.js similarity index 99% rename from dist/assets/Table-dcae5cc9.js rename to dist/assets/Table-d40746fd.js index 6a4cc1b448c85567ce242979bf201993e789c9cd..0bd9cc8bf6ca7e0c8cb6bc22411502b98918527d 100644 --- a/dist/assets/Table-dcae5cc9.js +++ b/dist/assets/Table-d40746fd.js @@ -1,4 +1,4 @@ -import{w as mo,r as s,a as ee,M as lp,C as Ut,z as Ve,c as pe,b as B,d as re,A as Ft,i as p,e as qs,N as Rt,O as en,_ as De,Q as Xs,T as rn,G as gn,U as yn,F as bn,E as Cn,K as Le,S as ko,V as Gi,L as Ma,W as Zs,X as Sf,Y as Qs,R as G,y as Js,Z as Jl,$ as sp,a0 as up,a1 as cp,a2 as dp,a3 as fp,J as Vn,a4 as vp,a5 as mp,a6 as hp,a7 as Yu,a8 as Jr,a9 as wf,aa as or,ab as qi,ac as ea,ad as pp,g as Na,ae as Pf,af as gp,ag as rt,j as C,ah as Ef,ai as Rf,aj as pt,ak as $e,m as $l,al as mn,am as hn,an as yp,k as di,t as kf}from"./umi-9940633e.js";import{b as Ff,R as Fo,P as bp,K as Ye,i as Mf,u as xt,c as Cp,d as Gu,F as Xi,g as Zi,e as Rr,f as Nf,h as Qi,a as tr,E as Tf,T as un,j as Ji,p as eu,k as xp,C as ha,l as Sp,S as Gt}from"./TextArea-b3aeb374.js";import{i as wp,a as Pp,T as pa,C as $f}from"./index-e846d634.js";import{T as Ep,s as tu,a as ro,F as _t,I as Xr,b as Rp,D as Df,S as Of,R as kp}from"./useDebounce-5d6283a5.js";import{d as qu,r as Fp,e as nu,f as Mo,P as Mp,D as Np,g as Xu,h as Zu,I as Pn,S as If,E as Qu,R as zn,C as qt,j as Tp}from"./util-477962f3.js";import{t as ir,u as el,B as Dn}from"./button-eaadfeb4.js";import{c as ho,o as tl,t as $p,_ as ru,a as _f,b as Lf,e as au,d as jf,f as Af,g as Kf,h as Vf,j as zf,k as nl,l as Dp,i as Ju,m as ou,n as Fr,p as Bf,q as Op,r as Hf,s as Wf,u as Uf,v as Yf,w as Ip,x as _p}from"./_setToString-98c064b8.js";import{u as rl,b as Gf,B as qf,d as iu,g as Xf,a as Mr,L as Lp,c as po,S as jp,D as Ap}from"./index-6a5b1b3e.js";import{S as kr,a as Kp,d as Vp}from"./index-1b65ca98.js";import{_ as No,D as To,a as lu,O as zp,P as Bp,M as Hp}from"./index-a694f10d.js";import{D as Zf}from"./DeleteOutlined-a511b2d4.js";import{C as Wp,P as Qf,a as Up}from"./progress-06af2db7.js";import{A as Yp}from"./index-690c95dc.js";function es(t){return t!=null&&t===t.window}function Gp(t,e){var r,n;if(typeof window>"u")return 0;var a=e?"scrollTop":"scrollLeft",o=0;return es(t)?o=t[e?"pageYOffset":"pageXOffset"]:t instanceof Document?o=t.documentElement[a]:(t instanceof HTMLElement||t)&&(o=t[a]),t&&!es(t)&&typeof o!="number"&&(o=(n=((r=t.ownerDocument)!==null&&r!==void 0?r:t).documentElement)===null||n===void 0?void 0:n[a]),o}function qp(t,e,r,n){var a=r-e;return t/=n/2,t<1?a/2*t*t*t+e:a/2*((t-=2)*t*t+2)+e}function Xp(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=e.getContainer,n=r===void 0?function(){return window}:r,a=e.callback,o=e.duration,l=o===void 0?450:o,i=n(),u=Gp(i,!0),c=Date.now(),d=function f(){var v=Date.now(),m=v-c,h=qp(m>l?l:m,u,t,l);es(i)?i.scrollTo(window.pageXOffset,h):i instanceof Document||i.constructor.name==="HTMLDocument"?i.documentElement.scrollTop=h:i.scrollTop=h,m0&&arguments[0]!==void 0?arguments[0]:!0,e=s.useRef({}),r=Ff();return s.useEffect(function(){var n=qu.subscribe(function(a){e.current=a,t&&r()});return function(){return qu.unsubscribe(n)}},[]),e.current}var ts=s.createContext("default"),ec=function(e){var r=e.children,n=e.size;return s.createElement(ts.Consumer,null,function(a){return s.createElement(ts.Provider,{value:n||a},r)})},Zp=globalThis&&globalThis.__rest||function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,n=Object.getOwnPropertySymbols(t);af?"".concat(f,"+"):c,$=O==="0"||O===0,F=c===null||$&&!E,N=(o!=null||i!=null)&&F,k=m&&!$,I=k?"":O,L=s.useMemo(function(){var ue=I==null||I==="";return(ue||$&&!E)&&!k},[I,$,E,k]),j=s.useRef(c);L||(j.current=c);var _=j.current,A=s.useRef(I);L||(A.current=I);var K=A.current,z=s.useRef(k);L||(z.current=k);var V=s.useMemo(function(){if(!b)return re({},x);var ue={marginTop:b[1]};return R==="rtl"?ue.left=parseInt(b[0],10):ue.right=-parseInt(b[0],10),re(re({},ue),x)},[R,b,x]),X=g??(typeof _=="string"||typeof _=="number"?_:void 0),W=L||!l?null:s.createElement("span",{className:"".concat(D,"-status-text")},l),Z=!_||Ve(_)!=="object"?void 0:ho(_,function(ue){return{style:re(re({},V),ue.style)}}),U=pe(B(B(B({},"".concat(D,"-status-dot"),N),"".concat(D,"-status-").concat(o),!!o),"".concat(D,"-status-").concat(i),Ja(i))),ae={};i&&!Ja(i)&&(ae.background=i);var q=pe(D,B(B(B({},"".concat(D,"-status"),N),"".concat(D,"-not-a-wrapper"),!a),"".concat(D,"-rtl"),R==="rtl"),S);if(!a&&N){var te=V.color;return s.createElement("span",re({},P,{className:q,style:V}),s.createElement("span",{className:U,style:ae}),l&&s.createElement("span",{style:{color:te},className:"".concat(D,"-status-text")},l))}return s.createElement("span",re({},P,{className:q}),a,s.createElement(qs,{visible:!L,motionName:"".concat(D,"-zoom"),motionAppear:!1,motionDeadline:1e3},function(ue){var Y=ue.className,J=M("scroll-number",n),Q=z.current,ie=pe(B(B(B(B(B(B({},"".concat(D,"-dot"),Q),"".concat(D,"-count"),!Q),"".concat(D,"-count-sm"),y==="small"),"".concat(D,"-multiple-words"),!Q&&K&&K.toString().length>1),"".concat(D,"-status-").concat(o),!!o),"".concat(D,"-status-").concat(i),Ja(i))),le=re({},V);return i&&!Ja(i)&&(le=le||{},le.background=i),s.createElement(mg,{prefixCls:J,show:!L,motionClassName:Y,className:ie,count:K,title:X,style:le,key:"scrollNumber"},Z)}),W)};tv.Ribbon=ug;const Mn=tv;var pg={getNow:function(){return Rt()},getFixedDate:function(e){return Rt(e,"YYYY-MM-DD")},getEndDate:function(e){var r=e.clone();return r.endOf("month")},getWeekDay:function(e){var r=e.clone().locale("en_US");return r.weekday()+r.localeData().firstDayOfWeek()},getYear:function(e){return e.year()},getMonth:function(e){return e.month()},getDate:function(e){return e.date()},getHour:function(e){return e.hour()},getMinute:function(e){return e.minute()},getSecond:function(e){return e.second()},addYear:function(e,r){var n=e.clone();return n.add(r,"year")},addMonth:function(e,r){var n=e.clone();return n.add(r,"month")},addDate:function(e,r){var n=e.clone();return n.add(r,"day")},setYear:function(e,r){var n=e.clone();return n.year(r)},setMonth:function(e,r){var n=e.clone();return n.month(r)},setDate:function(e,r){var n=e.clone();return n.date(r)},setHour:function(e,r){var n=e.clone();return n.hour(r)},setMinute:function(e,r){var n=e.clone();return n.minute(r)},setSecond:function(e,r){var n=e.clone();return n.second(r)},isAfter:function(e,r){return e.isAfter(r)},isValidate:function(e){return e.isValid()},locale:{getWeekFirstDay:function(e){var r=Rt().locale(e);return r.localeData().firstDayOfWeek()},getWeekFirstDate:function(e,r){var n=r.clone(),a=n.locale(e);return a.weekday(0)},getWeek:function(e,r){var n=r.clone(),a=n.locale(e);return a.week()},getShortWeekDays:function(e){var r=Rt().locale(e);return r.localeData().weekdaysMin()},getShortMonths:function(e){var r=Rt().locale(e);return r.localeData().monthsShort()},format:function(e,r,n){var a=r.clone(),o=a.locale(e);return o.format(n)},parse:function(e,r,n){for(var a=[],o=0;o1&&(l=e.addDate(l,-7)),l}function oo(t,e,r){var n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:1;switch(e){case"year":return r.addYear(t,n*10);case"quarter":case"month":return r.addYear(t,n);default:return r.addMonth(t,n)}}function Jt(t,e){var r=e.generateConfig,n=e.locale,a=e.format;return typeof a=="function"?a(t):r.locale.format(n.locale,t,a)}function uv(t,e){var r=e.generateConfig,n=e.locale,a=e.formatList;return!t||typeof a[0]=="function"?null:r.locale.parse(n.locale,t,a)}function os(t){var e=t.cellDate,r=t.mode,n=t.disabledDate,a=t.generateConfig;if(!n)return!1;var o=function(h,y,g){for(var b=y;b<=g;){var x=void 0;switch(h){case"date":{if(x=a.setDate(e,b),!n(x))return!1;break}case"month":{if(x=a.setMonth(e,b),!os({cellDate:x,mode:"month",generateConfig:a,disabledDate:n}))return!1;break}case"year":{if(x=a.setYear(e,b),!os({cellDate:x,mode:"year",generateConfig:a,disabledDate:n}))return!1;break}}b+=1}return!0};switch(r){case"date":case"week":return n(e);case"month":{var l=1,i=a.getDate(a.getEndDate(e));return o("date",l,i)}case"quarter":{var u=Math.floor(a.getMonth(e)/3)*3,c=u+2;return o("month",u,c)}case"year":return o("month",0,11);case"decade":{var d=a.getYear(e),f=Math.floor(d/Tn)*Tn,v=f+Tn-1;return o("year",f,v)}}}function Ig(t){var e=s.useContext(pn),r=e.hideHeader;if(r)return null;var n=t.prefixCls,a=t.generateConfig,o=t.locale,l=t.value,i=t.format,u="".concat(n,"-header");return s.createElement(Ta,{prefixCls:u},l?Jt(l,{locale:o,format:i,generateConfig:a}):" ")}function _g(t){var e=t.value,r=t.generateConfig,n=t.disabledMinutes,a=t.disabledSeconds,o=t.minutes,l=t.seconds,i=t.use12Hours,u=function(d,f,v,m){var h=e||r.getNow(),y=Math.max(0,f),g=Math.max(0,v),b=Math.max(0,m),x=n&&n(y);if(x!=null&&x.includes(g)){var S=o.find(function(P){return!x.includes(P.value)});if(S)g=S.value;else return null}var w=a&&a(y,g);if(w!=null&&w.includes(b)){var E=l.find(function(P){return!w.includes(P.value)});if(E)b=E.value;else return null}return h=nv(r,h,!i||!d?y:y+12,g,b),h};return u}function cv(t,e){for(var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"0",n=String(t);n.length=1?r|0:1,l=t;l<=e;l+=o)a.push({label:cv(l,2),value:l,disabled:(n||[]).includes(l)});return a}function Ag(t){var e=t.generateConfig,r=t.prefixCls,n=t.operationRef,a=t.activeColumnIndex,o=t.value,l=t.showHour,i=t.showMinute,u=t.showSecond,c=t.use12Hours,d=t.hourStep,f=d===void 0?1:d,v=t.minuteStep,m=v===void 0?1:v,h=t.secondStep,y=h===void 0?1:h,g=t.disabledHours,b=t.disabledMinutes,x=t.disabledSeconds,S=t.disabledTime,w=t.hideDisabledOptions,E=t.onSelect,P=[],T="".concat(r,"-content"),M="".concat(r,"-time-panel"),R,D=o?e.getHour(o):-1,O=D,$=o?e.getMinute(o):-1,F=o?e.getSecond(o):-1,N=e.getNow(),k=s.useMemo(function(){if(S){var Y=S(N);return[Y.disabledHours,Y.disabledMinutes,Y.disabledSeconds]}return[g,b,x]},[g,b,x,S,N]),I=ee(k,3),L=I[0],j=I[1],_=I[2],A=Dl(0,23,f,L&&L()),K=Xs(function(){return A},A,jg);c&&(R=O>=12,O%=12);var z=s.useMemo(function(){if(!c)return[!1,!1];var Y=[!0,!0];return K.forEach(function(J){var Q=J.disabled,ie=J.value;Q||(ie>=12?Y[1]=!1:Y[0]=!1)}),Y},[c,K]),V=ee(z,2),X=V[0],W=V[1],Z=s.useMemo(function(){return c?K.filter(R?function(Y){return Y.value>=12}:function(Y){return Y.value<12}).map(function(Y){var J=Y.value%12,Q=J===0?"12":cv(J,2);return p(p({},Y),{},{label:Q,value:J})}):K},[c,R,K]),U=Dl(0,59,m,j&&j(D)),ae=Dl(0,59,y,_&&_(D,$)),q=_g({value:o,generateConfig:e,disabledMinutes:j,disabledSeconds:_,minutes:U,seconds:ae,use12Hours:c});n.current={onUpDown:function(J){var Q=P[a];if(Q)for(var ie=Q.units.findIndex(function(ve){return ve.value===Q.value}),le=Q.units.length,ge=1;ge2&&arguments[2]!==void 0?arguments[2]:!1;(we===y||it)&&(fe(xe),T&&T(xe),ae&&ae(xe,qe),M&&!ga(i,xe,ce)&&!(v!=null&&v(xe))&&M(xe))},ot=function(xe){if(a0.includes(we)){var qe,it,ft=we==="date";switch(xe===Ye.PAGE_UP||xe===Ye.PAGE_DOWN?it=ft?i.addMonth:i.addYear:it=ft?i.addDate:i.addMonth,xe){case Ye.LEFT:case Ye.PAGE_UP:qe=it(he,-1);break;case Ye.RIGHT:case Ye.PAGE_DOWN:qe=it(he,1);break;case Ye.UP:case Ye.DOWN:qe=it(he,Number("".concat(xe===Ye.UP?"-":"").concat(ft?ao:cu)));break}if(qe)return!(v!=null&&v(qe))}return!0},Je=function(xe){if(le.current&&le.current.onKeyDown){var qe=!0,it=xe.which;if([Ye.LEFT,Ye.RIGHT,Ye.UP,Ye.DOWN,Ye.PAGE_UP,Ye.PAGE_DOWN,Ye.ENTER].includes(it)&&(xe.preventDefault(),it!==Ye.ENTER&&b===0&&(qe=ot(it))),qe)return le.current.onKeyDown(xe)}return rn(!1,"Panel not correct handle keyDown event. Please help to fire issue about this."),!1},Se=function(xe){le.current&&le.current.onBlur&&le.current.onBlur(xe)};Z&&J!=="right"&&(Z.current={onKeyDown:Je,onClose:function(){le.current&&le.current.onClose&&le.current.onClose()}}),s.useEffect(function(){u&&!ge.current&&be(u)},[u]),s.useEffect(function(){ge.current=!1},[]);var He,je=p(p({},t),{},{operationRef:le,prefixCls:n,viewDate:he,value:ce,onViewDateChange:ke,sourceMode:dt,onPanelChange:We,disabledDate:v});switch(delete je.onChange,delete je.onSelect,we){case"decade":He=s.createElement(Tg,re({},je,{onSelect:function(xe,qe){ke(xe),Oe(xe,qe)}}));break;case"year":He=s.createElement(r0,re({},je,{onSelect:function(xe,qe){ke(xe),Oe(xe,qe)}}));break;case"month":He=s.createElement(qg,re({},je,{onSelect:function(xe,qe){ke(xe),Oe(xe,qe)}}));break;case"quarter":He=s.createElement(e0,re({},je,{onSelect:function(xe,qe){ke(xe),Oe(xe,qe)}}));break;case"week":He=s.createElement(Wg,re({},je,{onSelect:function(xe,qe){ke(xe),Oe(xe,qe)}}));break;case"time":delete je.showTime,He=s.createElement(vv,re({},je,Ve(S)==="object"?S:null,{onSelect:function(xe,qe){ke(xe),Oe(xe,qe)}}));break;default:S?He=s.createElement(Hg,re({},je,{onSelect:function(xe,qe){ke(xe),Oe(xe,qe)}})):He=s.createElement(uu,re({},je,{onSelect:function(xe,qe){ke(xe),Oe(xe,qe)}}))}var ze,ye,de=function(){var xe=i.getNow(),qe=Cg(i.getHour(xe),i.getMinute(xe),i.getSecond(xe),z?I:1,V?j:1,X?A:1),it=nv(i,xe,qe[0],qe[1],qe[2]);Oe(it,"submit")};q||(ze=mv(n,we,E),ye=hv({prefixCls:n,components:F,needConfirmButton:K,okDisabled:!ce||v&&v(ce),locale:l,showNow:x,onNow:K&&de,onOk:function(){ce&&(Oe(ce,"submit",!0),$&&$(ce))}}));var Ce;if(w&&we==="date"&&y==="date"&&!S){var Me=i.getNow(),Be="".concat(n,"-today-btn"),nt=v&&v(Me);Ce=s.createElement("a",{className:pe(Be,nt&&"".concat(Be,"-disabled")),"aria-disabled":nt,onClick:function(){nt||Oe(Me,"mouse",!0)}},l.today)}return s.createElement(pn.Provider,{value:p(p({},W),{},{mode:we,hideHeader:"hideHeader"in t?P:W.hideHeader,hidePrevBtn:Y&&J==="right",hideNextBtn:Y&&J==="left"})},s.createElement("div",{tabIndex:b,className:pe("".concat(n,"-panel"),a,(e={},B(e,"".concat(n,"-panel-has-range"),Q&&Q[0]&&Q[1]),B(e,"".concat(n,"-panel-has-range-hover"),ie&&ie[0]&&ie[1]),B(e,"".concat(n,"-panel-rtl"),N==="rtl"),e)),style:o,onKeyDown:Je,onBlur:Se,onMouseDown:D,ref:U},He,ze||ye||Ce?s.createElement("div",{className:"".concat(n,"-footer")},ze,ye,Ce):null))}var o0={bottomLeft:{points:["tl","bl"],offset:[0,4],overflow:{adjustX:1,adjustY:1}},bottomRight:{points:["tr","br"],offset:[0,4],overflow:{adjustX:1,adjustY:1}},topLeft:{points:["bl","tl"],offset:[0,-4],overflow:{adjustX:0,adjustY:1}},topRight:{points:["br","tr"],offset:[0,-4],overflow:{adjustX:0,adjustY:1}}};function gv(t){var e,r=t.prefixCls,n=t.popupElement,a=t.popupStyle,o=t.visible,l=t.dropdownClassName,i=t.dropdownAlign,u=t.transitionName,c=t.getPopupContainer,d=t.children,f=t.range,v=t.popupPlacement,m=t.direction,h="".concat(r,"-dropdown"),y=function(){return v!==void 0?v:m==="rtl"?"bottomRight":"bottomLeft"};return s.createElement(Cp,{showAction:[],hideAction:[],popupPlacement:y(),builtinPlacements:o0,prefixCls:h,popupTransitionName:u,popup:n,popupAlign:i,popupVisible:o,popupClassName:pe(l,(e={},B(e,"".concat(h,"-range"),f),B(e,"".concat(h,"-rtl"),m==="rtl"),e)),popupStyle:a,getPopupContainer:c},d)}function ls(t){var e=t.open,r=t.value,n=t.isClickOutside,a=t.triggerOpen,o=t.forwardKeyDown,l=t.onKeyDown,i=t.blurToCancel,u=t.onSubmit,c=t.onCancel,d=t.onFocus,f=t.onBlur,v=t.currentFocusedKey,m=t.key,h=m===void 0?"start":m,y=s.useState(!1),g=ee(y,2),b=g[0],x=g[1],S=s.useState(!1),w=ee(S,2),E=w[0],P=w[1],T=s.useRef(),M=s.useRef(!1),R=s.useRef(!1),D=s.useRef(!1),O={onMouseDown:function(){x(!0),a(!0)},onKeyDown:function(F){var N=function(){D.current=!0};if(l(F,N),!D.current){switch(F.which){case Ye.ENTER:{e?u()!==!1&&x(!0):a(!0),F.preventDefault();return}case Ye.TAB:{b&&e&&!F.shiftKey?(x(!1),F.preventDefault()):!b&&e&&!o(F)&&F.shiftKey&&(x(!0),F.preventDefault());return}case Ye.ESC:{x(!0),c();return}}!e&&![Ye.SHIFT].includes(F.which)?a(!0):b||o(F)}},onFocus:function(F){x(!0),P(!0),v&&(v.current=h),clearTimeout(T.current),d&&d(F)},onBlur:function(F){if(M.current||!n(document.activeElement)){M.current=!1;return}i?setTimeout(function(){for(var N=document,k=N.activeElement;k&&k.shadowRoot;)k=k.shadowRoot.activeElement;n(k)&&c()},0):e&&(a(!1),R.current&&u()),P(!1),v?(v.current="",T.current=setTimeout(function(){v.current||f==null||f(F)},100)):f==null||f(F)}};return s.useEffect(function(){R.current=!1},[e]),s.useEffect(function(){R.current=!0},[r]),s.useEffect(function(){return Pg(function($){var F=Eg($),N=n(F);e?N?(!E||N)&&a(!1):(M.current=!0,requestAnimationFrame(function(){M.current=!1})):E&&!N&&(M.current=!0)})}),s.useEffect(function(){return function(){return clearTimeout(T.current)}},[]),[O,{focused:E,typing:b}]}function ss(t){var e=t.valueTexts,r=t.onTextChange,n=s.useState(""),a=ee(n,2),o=a[0],l=a[1],i=s.useRef([]);i.current=e;function u(d){l(d),r(d)}function c(){l(i.current[0])}return s.useEffect(function(){e.every(function(d){return d!==o})&&c()},[e.join("||")]),[o,u,c]}function Mi(t,e){var r=e.formatList,n=e.generateConfig,a=e.locale;return Xs(function(){if(!t)return[[""],""];for(var o="",l=[],i=0;i1&&arguments[1]!==void 0?arguments[1]:!1;if(cancelAnimationFrame(c.current),b){u(g);return}c.current=requestAnimationFrame(function(){u(g)})}var f=Mi(i,{formatList:r,generateConfig:n,locale:a}),v=ee(f,2),m=v[1];function h(g){d(g)}function y(){var g=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1;d(null,g)}return s.useEffect(function(){y(!0)},[t]),s.useEffect(function(){return function(){return cancelAnimationFrame(c.current)}},[]),[m,h,y]}function i0(t){var e,r=t.prefixCls,n=r===void 0?"rc-picker":r,a=t.id,o=t.tabIndex,l=t.style,i=t.className,u=t.dropdownClassName,c=t.dropdownAlign,d=t.popupStyle,f=t.transitionName,v=t.generateConfig,m=t.locale,h=t.inputReadOnly,y=t.allowClear,g=t.autoFocus,b=t.showTime,x=t.picker,S=x===void 0?"date":x,w=t.format,E=t.use12Hours,P=t.value,T=t.defaultValue,M=t.open,R=t.defaultOpen,D=t.defaultOpenValue,O=t.suffixIcon,$=t.clearIcon,F=t.disabled,N=t.disabledDate,k=t.placeholder,I=t.getPopupContainer,L=t.pickerRef,j=t.panelRender,_=t.onChange,A=t.onOpenChange,K=t.onFocus,z=t.onBlur,V=t.onMouseDown,X=t.onMouseUp,W=t.onMouseEnter,Z=t.onMouseLeave,U=t.onContextMenu,ae=t.onClick,q=t.onKeyDown,te=t.onSelect,ue=t.direction,Y=t.autoComplete,J=Y===void 0?"off":Y,Q=t.inputRender,ie=s.useRef(null),le=S==="date"&&!!b||S==="time",ge=dv(av(w,S,b,E)),Pe=s.useRef(null),ve=s.useRef(null),ce=s.useRef(null),fe=xt(null,{value:P,defaultValue:T}),oe=ee(fe,2),se=oe[0],he=oe[1],be=s.useState(se),ke=ee(be,2),Fe=ke[0],Ee=ke[1],Re=s.useRef(null),we=xt(!1,{value:M,defaultValue:R,postState:function(_e){return F?!1:_e},onChange:function(_e){A&&A(_e),!_e&&Re.current&&Re.current.onClose&&Re.current.onClose()}}),Ge=ee(we,2),Qe=Ge[0],ct=Ge[1],dt=Mi(Fe,{formatList:ge,generateConfig:v,locale:m}),mt=ee(dt,2),We=mt[0],Oe=mt[1],ot=ss({valueTexts:We,onTextChange:function(_e){var at=uv(_e,{locale:m,formatList:ge,generateConfig:v});at&&(!N||!N(at))&&Ee(at)}}),Je=ee(ot,3),Se=Je[0],He=Je[1],je=Je[2],ze=function(_e){Ee(_e),he(_e),_&&!ga(v,se,_e)&&_(_e,_e?Jt(_e,{generateConfig:v,locale:m,format:ge[0]}):"")},ye=function(_e){F&&_e||ct(_e)},de=function(_e){return Qe&&Re.current&&Re.current.onKeyDown?Re.current.onKeyDown(_e):(rn(!1,"Picker not correct forward KeyDown operation. Please help to fire issue about this."),!1)},Ce=function(){for(var _e=arguments.length,at=new Array(_e),Ot=0;Ot<_e;Ot++)at[Ot]=arguments[Ot];ae==null||ae.apply(void 0,at),ie.current&&(ie.current.focus(),ye(!0))},Me=ls({blurToCancel:le,open:Qe,value:Se,triggerOpen:ye,forwardKeyDown:de,isClickOutside:function(_e){return!iv([Pe.current,ve.current,ce.current],_e)},onSubmit:function(){return!Fe||N&&N(Fe)?!1:(ze(Fe),ye(!1),je(),!0)},onCancel:function(){ye(!1),Ee(se),je()},onKeyDown:function(_e,at){q==null||q(_e,at)},onFocus:K,onBlur:z}),Be=ee(Me,2),nt=Be[0],Ne=Be[1],xe=Ne.focused,qe=Ne.typing;s.useEffect(function(){Qe||(Ee(se),!We.length||We[0]===""?He(""):Oe!==Se&&je())},[Qe,We]),s.useEffect(function(){Qe||je()},[S]),s.useEffect(function(){Ee(se)},[se]),L&&(L.current={focus:function(){ie.current&&ie.current.focus()},blur:function(){ie.current&&ie.current.blur()}});var it=us(Se,{formatList:ge,generateConfig:v,locale:m}),ft=ee(it,3),At=ft[0],Kt=ft[1],kt=ft[2],zt=p(p({},t),{},{className:void 0,style:void 0,pickerValue:void 0,onPickerValueChange:void 0,onChange:null}),et=s.createElement(pv,re({},zt,{generateConfig:v,className:pe(B({},"".concat(n,"-panel-focused"),!qe)),value:Fe,locale:m,tabIndex:-1,onSelect:function(_e){te==null||te(_e),Ee(_e)},direction:ue,onPanelChange:function(_e,at){var Ot=t.onPanelChange;kt(!0),Ot==null||Ot(_e,at)}}));j&&(et=j(et));var tt=s.createElement("div",{className:"".concat(n,"-panel-container"),onMouseDown:function(_e){_e.preventDefault()}},et),lt;O&&(lt=s.createElement("span",{className:"".concat(n,"-suffix")},O));var ut;y&&se&&!F&&(ut=s.createElement("span",{onMouseDown:function(_e){_e.preventDefault(),_e.stopPropagation()},onMouseUp:function(_e){_e.preventDefault(),_e.stopPropagation(),ze(null),ye(!1)},className:"".concat(n,"-clear"),role:"button"},$||s.createElement("span",{className:"".concat(n,"-clear-btn")})));var wt=p(p(p({id:a,tabIndex:o,disabled:F,readOnly:h||typeof ge[0]=="function"||!qe,value:At||Se,onChange:function(_e){He(_e.target.value)},autoFocus:g,placeholder:k,ref:ie,title:Se},nt),{},{size:ov(S,ge[0],v)},fv(t)),{},{autoComplete:J}),St=Q?Q(wt):s.createElement("input",wt),Ae=function(_e,at){(at==="submit"||at!=="key"&&!le)&&(ze(_e),ye(!1))},Ue=ue==="rtl"?"bottomRight":"bottomLeft";return s.createElement(pn.Provider,{value:{operationRef:Re,hideHeader:S==="time",panelRef:Pe,onSelect:Ae,open:Qe,defaultOpenValue:D,onDateMouseEnter:Kt,onDateMouseLeave:kt}},s.createElement(gv,{visible:Qe,popupElement:tt,popupStyle:d,prefixCls:n,dropdownClassName:u,dropdownAlign:c,getPopupContainer:I,transitionName:f,popupPlacement:Ue,direction:ue},s.createElement("div",{ref:ce,className:pe(n,i,(e={},B(e,"".concat(n,"-disabled"),F),B(e,"".concat(n,"-focused"),xe),B(e,"".concat(n,"-rtl"),ue==="rtl"),e)),style:l,onMouseDown:V,onMouseUp:X,onMouseEnter:W,onMouseLeave:Z,onContextMenu:U,onClick:Ce},s.createElement("div",{className:pe("".concat(n,"-input"),B({},"".concat(n,"-input-placeholder"),!!At)),ref:ve},St,lt,ut))))}var l0=function(t){gn(r,t);var e=yn(r);function r(){var n;bn(this,r);for(var a=arguments.length,o=new Array(a),l=0;lm(d);case"month":return v(g)>v(d);case"week":return f(g)>f(d);default:return!rr(u,g,d)&&u.isAfter(g,d)}return!1},[l,i[1],d,e]),y=s.useCallback(function(g){if(l&&l(g))return!0;if(i[0]&&c)return!rr(u,g,d)&&u.isAfter(c,g);if(r&&c)switch(n){case"quarter":return m(g)0&&arguments[0]!==void 0?arguments[0]:!1,Te=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},Xe=null;Ie&&Rn&&Rn[0]&&Rn[1]&&h.isAfter(Rn[1],Rn[0])&&(Xe=Rn);var yt=P;if(P&&Ve(P)==="object"&&P.defaultValue){var Bt=P.defaultValue;yt=p(p({},P),{},{defaultValue:Ct(Bt,Se)||void 0})}var zr=null;return L&&(zr=function(Fn,Ln){return L(Fn,Ln,{range:Se?"end":"start"})}),s.createElement(Da.Provider,{value:{inRange:!0,panelPosition:vt,rangedValue:vr||ft,hoverRangedValue:Xe}},s.createElement(pv,re({},t,Te,{dateRender:zr,showTime:yt,mode:zt[Se],generateConfig:h,style:void 0,direction:se,disabledDate:Se===0?wt:St,disabledTime:function(Fn){return I?I(Fn,Se===0?"start":"end"):!1},className:pe(B({},"".concat(o,"-panel-focused"),Se===0?!Ke:!an)),value:Ct(ft,Se),locale:y,tabIndex:-1,onPanelChange:function(Fn,Ln){Se===0&&Kr(!0),Se===1&&sa(!0),tt(xn(zt,Ln,Se),xn(ft,Fn,Se));var Zn=Fn;vt==="right"&&zt[Se]===Ln&&(Zn=oo(Zn,Ln,h,-1)),xe(Zn,Se)},onOk:null,onSelect:void 0,onChange:void 0,defaultValue:Se===0?Ct(ft,1):Ct(ft,0)})))}var gr=0,Bu=0;if(Se&&Ge.current&&ct.current&&we.current){gr=Ge.current.offsetWidth+ct.current.offsetWidth;var tp=We.current.offsetLeft>gr?We.current.offsetLeft-gr:We.current.offsetLeft;we.current.offsetWidth&&We.current.offsetWidth&&gr>we.current.offsetWidth-We.current.offsetWidth-(se==="rtl"?0:tp)&&(Bu=gr)}var np=se==="rtl"?{right:gr}:{left:gr};function rp(){var vt,Te=mv(o,zt[Se],U),Xe=hv({prefixCls:o,components:fe,needConfirmButton:Fe,okDisabled:!Ct(ft,Se)||k&&k(ft[Se]),locale:y,rangeList:ep,onOk:function(){Ct(ft,Se)&&(Gn(ft,Se),ve&&ve(ft))}});if(E!=="time"&&!P){var yt=Ne(Se),Bt=oo(yt,E,h),zr=zt[Se],Xn=zr===E,Fn=Ml(Xn?"left":!1,{pickerValue:yt,onPickerValueChange:function(dn){xe(dn,Se)}}),Ln=Ml("right",{pickerValue:Bt,onPickerValueChange:function(dn){xe(oo(dn,E,h,-1),Se)}});se==="rtl"?vt=s.createElement(s.Fragment,null,Ln,Xn&&Fn):vt=s.createElement(s.Fragment,null,Fn,Xn&&Ln)}else vt=Ml();var Zn=s.createElement(s.Fragment,null,s.createElement("div",{className:"".concat(o,"-panels")},vt),(Te||Xe)&&s.createElement("div",{className:"".concat(o,"-footer")},Te,Xe));return j&&(Zn=j(Zn)),s.createElement("div",{className:"".concat(o,"-panel-container"),style:{marginLeft:Bu},ref:we,onMouseDown:function(dn){dn.preventDefault()}},Zn)}var ap=s.createElement("div",{className:pe("".concat(o,"-range-wrapper"),"".concat(o,"-").concat(E,"-range-wrapper")),style:{minWidth:sn}},s.createElement("div",{ref:We,className:"".concat(o,"-range-arrow"),style:np}),rp()),Hu;z&&(Hu=s.createElement("span",{className:"".concat(o,"-suffix")},z));var Wu;K&&(Ct(Ce,0)&&!ze[0]||Ct(Ce,1)&&!ze[1])&&(Wu=s.createElement("span",{onMouseDown:function(Te){Te.preventDefault(),Te.stopPropagation()},onMouseUp:function(Te){Te.preventDefault(),Te.stopPropagation();var Xe=Ce;ze[0]||(Xe=xn(Xe,null,0)),ze[1]||(Xe=xn(Xe,null,1)),Gn(Xe,null),In(!1,Se)},className:"".concat(o,"-clear")},V||s.createElement("span",{className:"".concat(o,"-clear-btn")})));var Uu={size:ov(E,Oe[0],h)},Nl=0,Tl=0;Ge.current&&Qe.current&&ct.current&&(Se===0?Tl=Ge.current.offsetWidth:(Nl=gr,Tl=Qe.current.offsetWidth));var op=se==="rtl"?{right:Nl}:{left:Nl},ip=function(Te,Xe){var yt=xn(ft,Te,Se);Xe==="submit"||Xe!=="key"&&!Fe?(Gn(yt,Se),Se===0?Kr():sa()):At(yt)};return s.createElement(pn.Provider,{value:{operationRef:je,hideHeader:E==="time",onDateMouseEnter:Fl,onDateMouseLeave:oi,hideRanges:!0,onSelect:ip,open:Ie}},s.createElement(gv,{visible:Ie,popupElement:ap,popupStyle:c,prefixCls:o,dropdownClassName:d,dropdownAlign:v,getPopupContainer:m,transitionName:f,range:!0,direction:se},s.createElement("div",re({ref:Re,className:pe(o,"".concat(o,"-range"),u,(e={},B(e,"".concat(o,"-disabled"),ze[0]&&ze[1]),B(e,"".concat(o,"-focused"),Se===0?me:Mt),B(e,"".concat(o,"-rtl"),se==="rtl"),e)),style:i,onClick:on,onMouseEnter:le,onMouseLeave:ge,onMouseDown:Vr,onMouseUp:ie},fv(t)),s.createElement("div",{className:pe("".concat(o,"-input"),(r={},B(r,"".concat(o,"-input-active"),Se===0),B(r,"".concat(o,"-input-placeholder"),!!ni),r)),ref:Ge},s.createElement("input",re({id:l,disabled:ze[0],readOnly:W||typeof Oe[0]=="function"||!Ke,value:ni||fr,onChange:function(Te){ia(Te.target.value)},autoFocus:b,placeholder:Ct(g,0)||"",ref:dt},H,Uu,{autoComplete:ke}))),s.createElement("div",{className:"".concat(o,"-range-separator"),ref:ct},R),s.createElement("div",{className:pe("".concat(o,"-input"),(n={},B(n,"".concat(o,"-input-active"),Se===1),B(n,"".concat(o,"-input-placeholder"),!!pr),n)),ref:Qe},s.createElement("input",re({disabled:ze[1],readOnly:W||typeof Oe[0]=="function"||!an,value:pr||ht,onChange:function(Te){Nt(Te.target.value)},placeholder:Ct(g,1)||"",ref:mt},Tt,Uu,{autoComplete:ke}))),s.createElement("div",{className:"".concat(o,"-active-bar"),style:p(p({},op),{},{width:Tl,position:"absolute"})}),Hu,Wu)))}var v0=function(t){gn(r,t);var e=yn(r);function r(){var n;bn(this,r);for(var a=arguments.length,o=new Array(a),l=0;l=0;c-=1){var d=e.get(c)||new Set;d.forEach(function(f){var v=f.parent,m=f.node;if(!(n(m)||!f.parent||u.has(f.parent.key))){if(n(f.parent.node)){u.add(v.key);return}var h=!0,y=!1;(v.children||[]).filter(function(g){return!n(g.node)}).forEach(function(g){var b=g.key,x=a.has(b);h&&!x&&(h=!1),!y&&(x||o.has(b))&&(y=!0)}),h&&a.add(v.key),y&&o.add(v.key),u.add(v.key)}})}return{checkedKeys:Array.from(a),halfCheckedKeys:Array.from(yv(o,a))}}function p0(t,e,r,n,a){for(var o=new Set(t),l=new Set(e),i=0;i<=n;i+=1){var u=r.get(i)||new Set;u.forEach(function(v){var m=v.key,h=v.node,y=v.children,g=y===void 0?[]:y;!o.has(m)&&!l.has(m)&&!a(h)&&g.filter(function(b){return!a(b.node)}).forEach(function(b){o.delete(b.key)})})}l=new Set;for(var c=new Set,d=n;d>=0;d-=1){var f=r.get(d)||new Set;f.forEach(function(v){var m=v.parent,h=v.node;if(!(a(h)||!v.parent||c.has(v.parent.key))){if(a(v.parent.node)){c.add(m.key);return}var y=!0,g=!1;(m.children||[]).filter(function(b){return!a(b.node)}).forEach(function(b){var x=b.key,S=o.has(x);y&&!S&&(y=!1),!g&&(S||l.has(x))&&(g=!0)}),y||o.delete(m.key),g&&l.add(m.key),c.add(m.key)}})}return{checkedKeys:Array.from(o),halfCheckedKeys:Array.from(yv(l,o))}}function wn(t,e,r,n){var a=[],o;n?o=n:o=m0;var l=new Set(t.filter(function(d){var f=!!vn(r,d);return f||a.push(d),f})),i=new Map,u=0;Object.keys(r).forEach(function(d){var f=r[d],v=f.level,m=i.get(v);m||(m=new Set,i.set(v,m)),m.add(f),u=Math.max(u,v)}),rn(!a.length,"Tree missing follow keys: ".concat(a.slice(0,100).map(function(d){return"'".concat(d,"'")}).join(", ")));var c;return e===!0?c=h0(l,i,u,o):c=p0(l,e.halfCheckedKeys,i,u,o),c}var Io=s.createContext(null),du="__RC_CASCADER_SPLIT__",bv="SHOW_PARENT",Cv="SHOW_CHILD";function wr(t){return t.join(du)}function da(t){return t.map(wr)}function g0(t){return t.split(du)}function y0(t){var e=t||{},r=e.label,n=e.value,a=e.children,o=n||"value";return{label:r||"label",value:o,key:o,children:a||"children"}}function eo(t,e){var r,n;return(r=t.isLeaf)!==null&&r!==void 0?r:!(!((n=t[e.children])===null||n===void 0)&&n.length)}function b0(t){var e=t.parentElement;if(e){var r=t.offsetTop-e.offsetTop;r-e.scrollTop<0?e.scrollTo({top:r}):r+t.offsetHeight-e.scrollTop>e.offsetHeight&&e.scrollTo({top:r+t.offsetHeight-e.offsetHeight})}}function lc(t,e,r){var n=new Set(t),a=e();return t.filter(function(o){var l=a[o],i=l?l.parent:null,u=l?l.children:null;return r===Cv?!(u&&u.some(function(c){return c.key&&n.has(c.key)})):!(i&&!i.node.disabled&&n.has(i.key))})}function go(t,e,r){for(var n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1,a=e,o=[],l=function(){var c,d,f,v=t[i],m=(c=a)===null||c===void 0?void 0:c.findIndex(function(y){var g=y[r.value];return n?String(g)===String(v):g===v}),h=m!==-1?(d=a)===null||d===void 0?void 0:d[m]:null;o.push({value:(f=h==null?void 0:h[r.value])!==null&&f!==void 0?f:v,index:m,option:h}),a=h==null?void 0:h[r.children]},i=0;i1&&arguments[1]!==void 0?arguments[1]:null;return d.map(function(v,m){for(var h=xv(f?f.pos:"0",m),y=_o(v[o],h),g,b=0;b1&&arguments[1]!==void 0?arguments[1]:{},r=e.initWrapper,n=e.processEntity,a=e.onProcessFinished,o=e.externalGetKey,l=e.childrenPropName,i=e.fieldNames,u=arguments.length>2?arguments[2]:void 0,c=o||u,d={},f={},v={posEntities:d,keyEntities:f};return r&&(v=r(v)||v),w0(t,function(m){var h=m.node,y=m.index,g=m.pos,b=m.key,x=m.parentPos,S=m.level,w=m.nodes,E={node:h,nodes:w,index:y,key:b,pos:g,level:S},P=_o(b,g);d[g]=E,f[P]=E,E.parent=d[x],E.parent&&(E.parent.children=E.parent.children||[],E.parent.children.push(E)),n&&n(E,v)},{externalGetKey:c,childrenPropName:l,fieldNames:i}),a&&a(v),v}function io(t,e){var r=e.expandedKeys,n=e.selectedKeys,a=e.loadedKeys,o=e.loadingKeys,l=e.checkedKeys,i=e.halfCheckedKeys,u=e.dragOverNodeKey,c=e.dropPosition,d=e.keyEntities,f=vn(d,t),v={eventKey:t,expanded:r.indexOf(t)!==-1,selected:n.indexOf(t)!==-1,loaded:a.indexOf(t)!==-1,loading:o.indexOf(t)!==-1,checked:l.indexOf(t)!==-1,halfChecked:i.indexOf(t)!==-1,pos:String(f?f.pos:""),dragOver:u===t&&c===0,dragOverGapTop:u===t&&c===-1,dragOverGapBottom:u===t&&c===1};return v}function Wt(t){var e=t.data,r=t.expanded,n=t.selected,a=t.checked,o=t.loaded,l=t.loading,i=t.halfChecked,u=t.dragOver,c=t.dragOverGapTop,d=t.dragOverGapBottom,f=t.pos,v=t.active,m=t.eventKey,h=p(p({},e),{},{expanded:r,selected:n,checked:a,loaded:o,loading:l,halfChecked:i,dragOver:u,dragOverGapTop:c,dragOverGapBottom:d,pos:f,active:v,key:m});return"props"in h||Object.defineProperty(h,"props",{get:function(){return rn(!1,"Second param return from event is node data instead of TreeNode instance. Please read value directly instead of reading from `props`."),t}}),h}const P0=function(t,e){var r=s.useRef({options:null,info:null}),n=s.useCallback(function(){return r.current.options!==t&&(r.current.options=t,r.current.info=Lo(t,{fieldNames:e,initWrapper:function(o){return p(p({},o),{},{pathKeyEntities:{}})},processEntity:function(o,l){var i=o.nodes.map(function(u){return u[e.value]}).join(du);l.pathKeyEntities[i]=o,o.key=i}})),r.current.info.pathKeyEntities},[e,t]);return n},E0=function(t,e){return s.useCallback(function(r){var n=[],a=[];return r.forEach(function(o){var l=go(o,t,e);l.every(function(i){return i.option})?a.push(o):n.push(o)}),[a,n]},[t,e])};function sc(t){var e=s.useRef();e.current=t;var r=s.useCallback(function(){return e.current.apply(e,arguments)},[]);return r}function R0(t){return s.useMemo(function(){if(!t)return[!1,{}];var e={matchInputWidth:!0,limit:50};return t&&Ve(t)==="object"&&(e=p(p({},e),t)),e.limit<=0&&delete e.limit,[!0,e]},[t])}var lo="__rc_cascader_search_mark__",k0=function(e,r,n){var a=n.label;return r.some(function(o){return String(o[a]).toLowerCase().includes(e.toLowerCase())})},F0=function(e,r,n,a){return r.map(function(o){return o[a.label]}).join(" / ")};const M0=function(t,e,r,n,a,o){var l=a.filter,i=l===void 0?k0:l,u=a.render,c=u===void 0?F0:u,d=a.limit,f=d===void 0?50:d,v=a.sort;return s.useMemo(function(){var m=[];if(!t)return[];function h(y,g){y.forEach(function(b){if(!(!v&&f>0&&m.length>=f)){var x=[].concat(De(g),[b]),S=b[r.children];if((!S||S.length===0||o)&&i(t,x,{label:r.label})){var w;m.push(p(p({},b),{},(w={},B(w,r.label,c(t,x,n,r)),B(w,lo,x),B(w,r.children,void 0),w)))}S&&h(b[r.children],x)}})}return h(e,[]),v&&m.sort(function(y,g){return v(y[lo],g[lo],t,r)}),f>0?m.slice(0,f):m},[t,e,r,n,c,o,i,v,f])};function N0(t){var e,r=t.prefixCls,n=t.checked,a=t.halfChecked,o=t.disabled,l=t.onClick,i=s.useContext(Io),u=i.checkable,c=typeof u!="boolean"?u:null;return s.createElement("span",{className:pe("".concat(r),(e={},B(e,"".concat(r,"-checked"),n),B(e,"".concat(r,"-indeterminate"),!n&&a),B(e,"".concat(r,"-disabled"),o),e)),onClick:l},c)}var wv="__cascader_fix_label__";function T0(t){var e=t.prefixCls,r=t.multiple,n=t.options,a=t.activeValue,o=t.prevValuePath,l=t.onToggleOpen,i=t.onSelect,u=t.onActive,c=t.checkedSet,d=t.halfCheckedSet,f=t.loadingKeys,v=t.isSelectable,m="".concat(e,"-menu"),h="".concat(e,"-menu-item"),y=s.useContext(Io),g=y.fieldNames,b=y.changeOnSelect,x=y.expandTrigger,S=y.expandIcon,w=y.loadingIcon,E=y.dropdownMenuColumnStyle,P=x==="hover",T=s.useMemo(function(){return n.map(function(M){var R,D=M.disabled,O=M[lo],$=(R=M[wv])!==null&&R!==void 0?R:M[g.label],F=M[g.value],N=eo(M,g),k=O?O.map(function(A){return A[g.value]}):[].concat(De(o),[F]),I=wr(k),L=f.includes(I),j=c.has(I),_=d.has(I);return{disabled:D,label:$,value:F,isLeaf:N,isLoading:L,checked:j,halfChecked:_,option:M,fullPath:k,fullPathKey:I}})},[n,c,g,d,f,o]);return s.createElement("ul",{className:m,role:"menu"},T.map(function(M){var R,D=M.disabled,O=M.label,$=M.value,F=M.isLeaf,N=M.isLoading,k=M.checked,I=M.halfChecked,L=M.option,j=M.fullPath,_=M.fullPathKey,A=function(){if(!D){var X=De(j);P&&F&&X.pop(),u(X)}},K=function(){v(L)&&i(j,F)},z;return typeof L.title=="string"?z=L.title:typeof O=="string"&&(z=O),s.createElement("li",{key:_,className:pe(h,(R={},B(R,"".concat(h,"-expand"),!F),B(R,"".concat(h,"-active"),a===$),B(R,"".concat(h,"-disabled"),D),B(R,"".concat(h,"-loading"),N),R)),style:E,role:"menuitemcheckbox",title:z,"aria-checked":k,"data-path-key":_,onClick:function(){A(),(!r||F)&&K()},onDoubleClick:function(){b&&l(!1)},onMouseEnter:function(){P&&A()},onMouseDown:function(X){X.preventDefault()}},r&&s.createElement(N0,{prefixCls:"".concat(e,"-checkbox"),checked:k,halfChecked:I,disabled:D,onClick:function(X){X.stopPropagation(),K()}}),s.createElement("div",{className:"".concat(h,"-content")},O),!N&&S&&!F&&s.createElement("div",{className:"".concat(h,"-expand-icon")},S),N&&w&&s.createElement("div",{className:"".concat(h,"-loading-icon")},w))}))}const $0=function(){var t=rl(),e=t.multiple,r=t.open,n=s.useContext(Io),a=n.values,o=s.useState([]),l=ee(o,2),i=l[0],u=l[1];return s.useEffect(function(){if(r&&!e){var c=a[0];u(c||[])}},[r]),[i,u]},D0=function(t,e,r,n,a,o){var l=rl(),i=l.direction,u=l.searchValue,c=l.toggleOpen,d=l.open,f=i==="rtl",v=s.useMemo(function(){for(var E=-1,P=e,T=[],M=[],R=n.length,D=function(I){var L=P.findIndex(function(j){return j[r.value]===n[I]});if(L===-1)return"break";E=L,T.push(E),M.push(n[I]),P=P[E][r.children]},O=0;O1){var P=h.slice(0,-1);b(P)}else c(!1)},w=function(){var P,T=((P=g[y])===null||P===void 0?void 0:P[r.children])||[],M=T.find(function(D){return!D.disabled});if(M){var R=[].concat(De(h),[M[r.value]]);b(R)}};s.useImperativeHandle(t,function(){return{onKeyDown:function(P){var T=P.which;switch(T){case Ye.UP:case Ye.DOWN:{var M=0;T===Ye.UP?M=-1:T===Ye.DOWN&&(M=1),M!==0&&x(M);break}case Ye.LEFT:{if(u)break;f?w():S();break}case Ye.RIGHT:{if(u)break;f?S():w();break}case Ye.BACKSPACE:{u||S();break}case Ye.ENTER:{if(h.length){var R=g[y],D=(R==null?void 0:R[lo])||[];D.length?o(D.map(function(O){return O[r.value]}),D[D.length-1]):o(h,g[y])}break}case Ye.ESC:c(!1),d&&P.stopPropagation()}},onKeyUp:function(){}}})};var O0=s.forwardRef(function(t,e){var r,n,a,o,l=rl(),i=l.prefixCls,u=l.multiple,c=l.searchValue,d=l.toggleOpen,f=l.notFoundContent,v=l.direction,m=s.useRef(),h=v==="rtl",y=s.useContext(Io),g=y.options,b=y.values,x=y.halfValues,S=y.fieldNames,w=y.changeOnSelect,E=y.onSelect,P=y.searchOptions,T=y.dropdownPrefixCls,M=y.loadData,R=y.expandTrigger,D=T||i,O=s.useState([]),$=ee(O,2),F=$[0],N=$[1],k=function(Q){if(!(!M||c)){var ie=go(Q,g,S),le=ie.map(function(ve){var ce=ve.option;return ce}),ge=le[le.length-1];if(ge&&!eo(ge,S)){var Pe=wr(Q);N(function(ve){return[].concat(De(ve),[Pe])}),M(le)}}};s.useEffect(function(){F.length&&F.forEach(function(J){var Q=g0(J),ie=go(Q,g,S,!0).map(function(ge){var Pe=ge.option;return Pe}),le=ie[ie.length-1];(!le||le[S.children]||eo(le,S))&&N(function(ge){return ge.filter(function(Pe){return Pe!==J})})})},[g,F,S]);var I=s.useMemo(function(){return new Set(da(b))},[b]),L=s.useMemo(function(){return new Set(da(x))},[x]),j=$0(),_=ee(j,2),A=_[0],K=_[1],z=function(Q){K(Q),k(Q)},V=function(Q){var ie=Q.disabled,le=eo(Q,S);return!ie&&(le||w||u)},X=function(Q,ie){var le=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;E(Q),!u&&(ie||w&&(R==="hover"||le))&&d(!1)},W=s.useMemo(function(){return c?P:g},[c,P,g]),Z=s.useMemo(function(){for(var J=[{options:W}],Q=W,ie=function(){var ve=A[le],ce=Q.find(function(oe){return oe[S.value]===ve}),fe=ce==null?void 0:ce[S.children];if(!(fe!=null&&fe.length))return"break";Q=fe,J.push({options:fe})},le=0;le":$,N=t.loadingIcon,k=t.children,I=t.dropdownMatchSelectWidth,L=I===void 0?!1:I,j=t.showCheckedStrategy,_=j===void 0?bv:j,A=Le(t,I0),K=Gf(r),z=!!f,V=xt(l,{value:i,postState:uc}),X=ee(V,2),W=X[0],Z=X[1],U=s.useMemo(function(){return y0(o)},[JSON.stringify(o)]),ae=s.useMemo(function(){return g||[]},[g]),q=P0(ae,U),te=s.useCallback(function(Je){var Se=q();return Je.map(function(He){var je=Se[He].nodes;return je.map(function(ze){return ze[U.value]})})},[q,U]),ue=xt("",{value:v,postState:function(Se){return Se||""}}),Y=ee(ue,2),J=Y[0],Q=Y[1],ie=function(Se,He){Q(Se),He.source!=="blur"&&m&&m(Se)},le=R0(h),ge=ee(le,2),Pe=ge[0],ve=ge[1],ce=M0(J,ae,U,b||a,ve,u),fe=E0(ae,U),oe=s.useMemo(function(){var Je=fe(W),Se=ee(Je,2),He=Se[0],je=Se[1];if(!z||!W.length)return[He,[],je];var ze=da(He),ye=q(),de=wn(ze,!0,ye),Ce=de.checkedKeys,Me=de.halfCheckedKeys;return[te(Ce),te(Me),je]},[z,W,q,te,fe]),se=ee(oe,3),he=se[0],be=se[1],ke=se[2],Fe=s.useMemo(function(){var Je=da(he),Se=lc(Je,q,_);return[].concat(De(ke),De(te(Se)))},[he,q,te,ke,_]),Ee=C0(Fe,ae,U,z,d),Re=sc(function(Je){if(Z(Je),c){var Se=uc(Je),He=Se.map(function(ye){return go(ye,ae,U).map(function(de){return de.option})}),je=z?Se:Se[0],ze=z?He:He[0];c(je,ze)}}),we=sc(function(Je){if(Q(""),!z)Re(Je);else{var Se=wr(Je),He=da(he),je=da(be),ze=He.includes(Se),ye=ke.some(function(it){return wr(it)===Se}),de=he,Ce=ke;if(ye&&!ze)Ce=ke.filter(function(it){return wr(it)!==Se});else{var Me=ze?He.filter(function(it){return it!==Se}):[].concat(De(He),[Se]),Be=q(),nt;if(ze){var Ne=wn(Me,{checked:!1,halfCheckedKeys:je},Be);nt=Ne.checkedKeys}else{var xe=wn(Me,!0,Be);nt=xe.checkedKeys}var qe=lc(nt,q,_);de=te(qe)}Re([].concat(De(Ce),De(de)))}}),Ge=function(Se,He){if(He.type==="clear"){Re([]);return}var je=He.values[0].valueCells;we(je)},Qe=w!==void 0?w:S,ct=P||E,dt=R||M,mt=function(Se){D==null||D(Se),O==null||O(Se)},We=s.useMemo(function(){return{options:ae,fieldNames:U,values:he,halfValues:be,changeOnSelect:u,onSelect:we,checkable:f,searchOptions:ce,dropdownPrefixCls:b,loadData:x,expandTrigger:y,expandIcon:F,loadingIcon:N,dropdownMenuColumnStyle:T}},[ae,U,he,be,u,we,f,ce,b,x,y,F,N,T]),Oe=!(J?ce:ae).length,ot=J&&ve.matchInputWidth||Oe?{}:{minWidth:"auto"};return s.createElement(Io.Provider,{value:We},s.createElement(qf,re({},A,{ref:e,id:K,prefixCls:a,dropdownMatchSelectWidth:L,dropdownStyle:ot,displayValues:Ee,onDisplayValuesChange:Ge,mode:z?"multiple":void 0,searchValue:J,onSearch:ie,showSearch:Pe,OptionList:O0,emptyOptions:Oe,open:Qe,dropdownClassName:ct,placement:dt,onDropdownVisibleChange:mt,getRawInputElement:function(){return k}})))});jo.SHOW_PARENT=bv;jo.SHOW_CHILD=Cv;var L0=globalThis&&globalThis.__rest||function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,n=Object.getOwnPropertySymbols(t);a2&&arguments[2]!==void 0?arguments[2]:!0,te=function(){T(function(Y){var J=new Map(Y),Q=J.delete(U);return Q?J:Y})};return T(function(ue){return new Map(ue).set(U,{url:ae,canPreview:q})}),te},W=function(U){U.stopPropagation(),k(!1),_(null)};return s.useEffect(function(){O(z)},[z]),s.useEffect(function(){!N&&A&&O(z)},[z,A,N]),s.createElement(p1,{value:{isPreviewGroup:!0,previewUrls:V,setPreviewUrls:T,current:D,setCurrent:O,setShowPreview:k,setMousePosition:_,registerImage:X}},a,s.createElement(Mv,re({"aria-hidden":!N,visible:N,prefixCls:n,onClose:W,mousePosition:j,src:V.get(D),icons:l,getContainer:h,countRender:x},S)))},Si=1,wi=50,qa=1,y1=.2,b1=function(e){var r,n=e.visible,a=e.maskTransitionName,o=e.getContainer,l=e.prefixCls,i=e.rootClassName,u=e.icons,c=e.countRender,d=e.showSwitch,f=e.showProgress,v=e.current,m=e.count,h=e.scale,y=e.onSwitchLeft,g=e.onSwitchRight,b=e.onClose,x=e.onZoomIn,S=e.onZoomOut,w=e.onRotateRight,E=e.onRotateLeft,P=u.rotateLeft,T=u.rotateRight,M=u.zoomIn,R=u.zoomOut,D=u.close,O=u.left,$=u.right,F="".concat(l,"-operations-operation"),N="".concat(l,"-operations-icon"),k=[{icon:D,onClick:b,type:"close"},{icon:M,onClick:x,type:"zoomIn",disabled:h===wi},{icon:R,onClick:S,type:"zoomOut",disabled:h===Si},{icon:T,onClick:w,type:"rotateRight"},{icon:P,onClick:E,type:"rotateLeft"}],I=s.createElement(s.Fragment,null,d&&s.createElement(s.Fragment,null,s.createElement("div",{className:pe("".concat(l,"-switch-left"),B({},"".concat(l,"-switch-left-disabled"),v===0)),onClick:y},O),s.createElement("div",{className:pe("".concat(l,"-switch-right"),B({},"".concat(l,"-switch-right-disabled"),v===m-1)),onClick:g},$)),s.createElement("ul",{className:"".concat(l,"-operations")},f&&s.createElement("li",{className:"".concat(l,"-operations-progress")},(r=c==null?void 0:c(v+1,m))!==null&&r!==void 0?r:"".concat(v+1," / ").concat(m)),k.map(function(L){var j,_=L.icon,A=L.onClick,K=L.type,z=L.disabled;return s.createElement("li",{className:pe(F,(j={},B(j,"".concat(l,"-operations-operation-").concat(K),!0),B(j,"".concat(l,"-operations-operation-disabled"),!!z),j)),onClick:A,key:K},s.isValidElement(_)?s.cloneElement(_,{className:N}):_)})));return s.createElement(qs,{visible:n,motionName:a},function(L){var j=L.className,_=L.style;return s.createElement(Mp,{open:!0,getContainer:o??document.body},s.createElement("div",{className:pe("".concat(l,"-operations-wrapper"),j,i),style:_},I))})},cc={x:0,y:0,rotate:0,scale:1};function C1(t){var e=s.useRef(null),r=s.useRef([]),n=s.useState(cc),a=ee(n,2),o=a[0],l=a[1],i=function(){l(cc)},u=function(f){e.current===null&&(r.current=[],e.current=mo(function(){l(function(v){var m=v;return r.current.forEach(function(h){m=p(p({},m),h)}),e.current=null,m})})),r.current.push(p(p({},o),f))},c=function(f,v,m){var h=t.current,y=h.width,g=h.height,b=h.offsetWidth,x=h.offsetHeight,S=h.offsetLeft,w=h.offsetTop,E=f,P=o.scale*f;P>wi?(E=wi/o.scale,P=wi):Pn){if(e>0)return B({},t,o);if(e<0&&an)return B({},t,e<0?o:-o);return{}}function x1(t,e,r,n){var a=Fv(),o=a.width,l=a.height,i=null;return t<=o&&e<=l?i={x:0,y:0}:(t>o||e>l)&&(i=p(p({},dc("x",r,t,o)),dc("y",n,e,l))),i}var S1=["prefixCls","src","alt","onClose","afterClose","visible","icons","rootClassName","getContainer","countRender","scaleStep","transitionName","maskTransitionName"],Mv=function(e){var r=e.prefixCls,n=e.src,a=e.alt,o=e.onClose;e.afterClose;var l=e.visible,i=e.icons,u=i===void 0?{}:i,c=e.rootClassName,d=e.getContainer,f=e.countRender,v=e.scaleStep,m=v===void 0?.5:v,h=e.transitionName,y=h===void 0?"zoom":h,g=e.maskTransitionName,b=g===void 0?"fade":g,x=Le(e,S1),S=s.useRef(),w=s.useRef({deltaX:0,deltaY:0,transformX:0,transformY:0}),E=s.useState(!1),P=ee(E,2),T=P[0],M=P[1],R=s.useContext(vu),D=R.previewUrls,O=R.current,$=R.isPreviewGroup,F=R.setCurrent,N=D.size,k=Array.from(D.keys()),I=k.indexOf(O),L=$?D.get(O):n,j=$&&N>1,_=$&&N>=1,A=C1(S),K=A.transform,z=A.resetTransform,V=A.updateTransform,X=A.dispatchZoonChange,W=K.rotate,Z=K.scale,U=pe(B({},"".concat(r,"-moving"),T)),ae=function(){z()},q=function(){X(qa+m)},te=function(){X(qa-m)},ue=function(){V({rotate:W+90})},Y=function(){V({rotate:W-90})},J=function(oe){oe.preventDefault(),oe.stopPropagation(),I>0&&F(k[I-1])},Q=function(oe){oe.preventDefault(),oe.stopPropagation(),I0&&(be=qa/be),X(be,oe.clientX,oe.clientY)}},ve=s.useCallback(function(fe){!l||!j||(fe.keyCode===Ye.LEFT?I>0&&F(k[I-1]):fe.keyCode===Ye.RIGHT&&I=0||i.relatedTarget.className.indexOf("".concat(f,"-item"))>=0))&&d(n.getValidValue()))},n.go=function(i){var u=n.state.goInputText;u!==""&&(i.keyCode===Br.ENTER||i.type==="click")&&(n.setState({goInputText:""}),n.props.quickGo(n.getValidValue()))},n}return Cn(r,[{key:"getValidValue",value:function(){var a=this.state.goInputText;return!a||isNaN(a)?void 0:Number(a)}},{key:"getPageSizeOptions",value:function(){var a=this.props,o=a.pageSize,l=a.pageSizeOptions;return l.some(function(i){return i.toString()===o.toString()})?l:l.concat([o.toString()]).sort(function(i,u){var c=isNaN(Number(i))?0:Number(i),d=isNaN(Number(u))?0:Number(u);return c-d})}},{key:"render",value:function(){var a=this,o=this.props,l=o.pageSize,i=o.locale,u=o.rootPrefixCls,c=o.changeSize,d=o.quickGo,f=o.goButton,v=o.selectComponentClass,m=o.buildOptionText,h=o.selectPrefixCls,y=o.disabled,g=this.state.goInputText,b="".concat(u,"-options"),x=v,S=null,w=null,E=null;if(!c&&!d)return null;var P=this.getPageSizeOptions();if(c&&x){var T=P.map(function(M,R){return G.createElement(x.Option,{key:R,value:M.toString()},(m||a.buildOptionText)(M))});S=G.createElement(x,{disabled:y,prefixCls:h,showSearch:!1,className:"".concat(b,"-size-changer"),optionLabelProp:"children",dropdownMatchSelectWidth:!1,value:(l||P[0]).toString(),onChange:this.changeSize,getPopupContainer:function(R){return R.parentNode},"aria-label":i.page_size,defaultOpen:!1},T)}return d&&(f&&(E=typeof f=="boolean"?G.createElement("button",{type:"button",onClick:this.go,onKeyUp:this.go,disabled:y,className:"".concat(b,"-quick-jumper-button")},i.jump_to_confirm):G.createElement("span",{onClick:this.go,onKeyUp:this.go},f)),w=G.createElement("div",{className:"".concat(b,"-quick-jumper")},i.jump_to,G.createElement("input",{disabled:y,type:"text",value:g,onChange:this.handleChange,onKeyUp:this.go,onBlur:this.handleBlur,"aria-label":i.page}),i.page,E)),G.createElement("li",{className:"".concat(b)},S,w)}}]),r}(G.Component);$v.defaultProps={pageSizeOptions:["10","20","50","100"]};function ds(){}function mc(t){var e=Number(t);return typeof e=="number"&&!isNaN(e)&&isFinite(e)&&Math.floor(e)===e}function oy(t,e,r){return r}function yr(t,e,r){var n=typeof t>"u"?e.pageSize:t;return Math.floor((r.total-1)/n)+1}var Dv=function(t){gn(r,t);var e=yn(r);function r(n){var a;bn(this,r),a=e.call(this,n),a.getJumpPrevPage=function(){return Math.max(1,a.state.current-(a.props.showLessItems?3:5))},a.getJumpNextPage=function(){return Math.min(yr(void 0,a.state,a.props),a.state.current+(a.props.showLessItems?3:5))},a.getItemIcon=function(c,d){var f=a.props.prefixCls,v=c||G.createElement("button",{type:"button","aria-label":d,className:"".concat(f,"-item-link")});return typeof c=="function"&&(v=G.createElement(c,p({},a.props))),v},a.savePaginationNode=function(c){a.paginationNode=c},a.isValid=function(c){var d=a.props.total;return mc(c)&&c!==a.state.current&&mc(d)&&d>0},a.shouldDisplayQuickJumper=function(){var c=a.props,d=c.showQuickJumper,f=c.total,v=a.state.pageSize;return f<=v?!1:d},a.handleKeyDown=function(c){(c.keyCode===Br.ARROW_UP||c.keyCode===Br.ARROW_DOWN)&&c.preventDefault()},a.handleKeyUp=function(c){var d=a.getValidValue(c),f=a.state.currentInputValue;d!==f&&a.setState({currentInputValue:d}),c.keyCode===Br.ENTER?a.handleChange(d):c.keyCode===Br.ARROW_UP?a.handleChange(d-1):c.keyCode===Br.ARROW_DOWN&&a.handleChange(d+1)},a.handleBlur=function(c){var d=a.getValidValue(c);a.handleChange(d)},a.changePageSize=function(c){var d=a.state.current,f=yr(c,a.state,a.props);d=d>f?f:d,f===0&&(d=a.state.current),typeof c=="number"&&("pageSize"in a.props||a.setState({pageSize:c}),"current"in a.props||a.setState({current:d,currentInputValue:d})),a.props.onShowSizeChange(d,c),"onChange"in a.props&&a.props.onChange&&a.props.onChange(d,c)},a.handleChange=function(c){var d=a.props,f=d.disabled,v=d.onChange,m=a.state,h=m.pageSize,y=m.current,g=m.currentInputValue;if(a.isValid(c)&&!f){var b=yr(void 0,a.state,a.props),x=c;return c>b?x=b:c<1&&(x=1),"current"in a.props||a.setState({current:x}),x!==g&&a.setState({currentInputValue:x}),v(x,h),x}return y},a.prev=function(){a.hasPrev()&&a.handleChange(a.state.current-1)},a.next=function(){a.hasNext()&&a.handleChange(a.state.current+1)},a.jumpPrev=function(){a.handleChange(a.getJumpPrevPage())},a.jumpNext=function(){a.handleChange(a.getJumpNextPage())},a.hasPrev=function(){return a.state.current>1},a.hasNext=function(){return a.state.current2?f-2:0),m=2;m=l?u=l:u=Number(o),u}},{key:"getShowSizeChanger",value:function(){var a=this.props,o=a.showSizeChanger,l=a.total,i=a.totalBoundaryShowSizeChanger;return typeof o<"u"?o:l>i}},{key:"renderPrev",value:function(a){var o=this.props,l=o.prevIcon,i=o.itemRender,u=i(a,"prev",this.getItemIcon(l,"prev page")),c=!this.hasPrev();return s.isValidElement(u)?s.cloneElement(u,{disabled:c}):u}},{key:"renderNext",value:function(a){var o=this.props,l=o.nextIcon,i=o.itemRender,u=i(a,"next",this.getItemIcon(l,"next page")),c=!this.hasNext();return s.isValidElement(u)?s.cloneElement(u,{disabled:c}):u}},{key:"render",value:function(){var a=this,o=this.props,l=o.prefixCls,i=o.className,u=o.style,c=o.disabled,d=o.hideOnSinglePage,f=o.total,v=o.locale,m=o.showQuickJumper,h=o.showLessItems,y=o.showTitle,g=o.showTotal,b=o.simple,x=o.itemRender,S=o.showPrevNextJumpers,w=o.jumpPrevIcon,E=o.jumpNextIcon,P=o.selectComponentClass,T=o.selectPrefixCls,M=o.pageSizeOptions,R=this.state,D=R.current,O=R.pageSize,$=R.currentInputValue;if(d===!0&&f<=O)return null;var F=yr(void 0,this.state,this.props),N=[],k=null,I=null,L=null,j=null,_=null,A=m&&m.goButton,K=h?1:2,z=D-1>0?D-1:0,V=D+1f?f:D*O]));if(b)return A&&(typeof A=="boolean"?_=G.createElement("button",{type:"button",onClick:this.handleGoTO,onKeyUp:this.handleGoTO},v.jump_to_confirm):_=G.createElement("span",{onClick:this.handleGoTO,onKeyUp:this.handleGoTO},A),_=G.createElement("li",{title:y?"".concat(v.jump_to).concat(D,"/").concat(F):null,className:"".concat(l,"-simple-pager")},_)),G.createElement("ul",re({className:pe(l,"".concat(l,"-simple"),B({},"".concat(l,"-disabled"),c),i),style:u,ref:this.savePaginationNode},X),W,G.createElement("li",{title:y?v.prev_page:null,onClick:this.prev,tabIndex:this.hasPrev()?0:null,onKeyPress:this.runIfEnterPrev,className:pe("".concat(l,"-prev"),B({},"".concat(l,"-disabled"),!this.hasPrev())),"aria-disabled":!this.hasPrev()},this.renderPrev(z)),G.createElement("li",{title:y?"".concat(D,"/").concat(F):null,className:"".concat(l,"-simple-pager")},G.createElement("input",{type:"text",value:$,disabled:c,onKeyDown:this.handleKeyDown,onKeyUp:this.handleKeyUp,onChange:this.handleKeyUp,onBlur:this.handleBlur,size:"3"}),G.createElement("span",{className:"".concat(l,"-slash")},"/"),F),G.createElement("li",{title:y?v.next_page:null,onClick:this.next,tabIndex:this.hasPrev()?0:null,onKeyPress:this.runIfEnterNext,className:pe("".concat(l,"-next"),B({},"".concat(l,"-disabled"),!this.hasNext())),"aria-disabled":!this.hasNext()},this.renderNext(V)),_);if(F<=3+K*2){var Z={locale:v,rootPrefixCls:l,onClick:this.handleChange,onKeyPress:this.runIfEnter,showTitle:y,itemRender:x};F||N.push(G.createElement(Xa,re({},Z,{key:"noPager",page:1,className:"".concat(l,"-item-disabled")})));for(var U=1;U<=F;U+=1){var ae=D===U;N.push(G.createElement(Xa,re({},Z,{key:U,page:U,active:ae})))}}else{var q=h?v.prev_3:v.prev_5,te=h?v.next_3:v.next_5;S&&(k=G.createElement("li",{title:y?q:null,key:"prev",onClick:this.jumpPrev,tabIndex:"0",onKeyPress:this.runIfEnterJumpPrev,className:pe("".concat(l,"-jump-prev"),B({},"".concat(l,"-jump-prev-custom-icon"),!!w))},x(this.getJumpPrevPage(),"jump-prev",this.getItemIcon(w,"prev page"))),I=G.createElement("li",{title:y?te:null,key:"next",tabIndex:"0",onClick:this.jumpNext,onKeyPress:this.runIfEnterJumpNext,className:pe("".concat(l,"-jump-next"),B({},"".concat(l,"-jump-next-custom-icon"),!!E))},x(this.getJumpNextPage(),"jump-next",this.getItemIcon(E,"next page")))),j=G.createElement(Xa,{locale:v,last:!0,rootPrefixCls:l,onClick:this.handleChange,onKeyPress:this.runIfEnter,key:F,page:F,active:!1,showTitle:y,itemRender:x}),L=G.createElement(Xa,{locale:v,rootPrefixCls:l,onClick:this.handleChange,onKeyPress:this.runIfEnter,key:1,page:1,active:!1,showTitle:y,itemRender:x});var ue=Math.max(1,D-K),Y=Math.min(D+K,F);D-1<=K&&(Y=1+K*2),F-D<=K&&(ue=F-K*2);for(var J=ue;J<=Y;J+=1){var Q=D===J;N.push(G.createElement(Xa,{locale:v,rootPrefixCls:l,onClick:this.handleChange,onKeyPress:this.runIfEnter,key:J,page:J,active:Q,showTitle:y,itemRender:x}))}D-1>=K*2&&D!==1+2&&(N[0]=s.cloneElement(N[0],{className:"".concat(l,"-item-after-jump-prev")}),N.unshift(k)),F-D>=K*2&&D!==F-2&&(N[N.length-1]=s.cloneElement(N[N.length-1],{className:"".concat(l,"-item-before-jump-next")}),N.push(I)),ue!==1&&N.unshift(L),Y!==F&&N.push(j)}var ie=!this.hasPrev()||!F,le=!this.hasNext()||!F;return G.createElement("ul",re({className:pe(l,i,B({},"".concat(l,"-disabled"),c)),style:u,ref:this.savePaginationNode},X),W,G.createElement("li",{title:y?v.prev_page:null,onClick:this.prev,tabIndex:ie?null:0,onKeyPress:this.runIfEnterPrev,className:pe("".concat(l,"-prev"),B({},"".concat(l,"-disabled"),ie)),"aria-disabled":ie},this.renderPrev(z)),N,G.createElement("li",{title:y?v.next_page:null,onClick:this.next,tabIndex:le?null:0,onKeyPress:this.runIfEnterNext,className:pe("".concat(l,"-next"),B({},"".concat(l,"-disabled"),le)),"aria-disabled":le},this.renderNext(V)),G.createElement($v,{disabled:c,locale:v,rootPrefixCls:l,selectComponentClass:P,selectPrefixCls:T,changeSize:this.getShowSizeChanger()?this.changePageSize:null,current:D,pageSize:O,pageSizeOptions:M,quickGo:this.shouldDisplayQuickJumper()?this.handleChange:null,goButton:A}))}}],[{key:"getDerivedStateFromProps",value:function(a,o){var l={};if("current"in a&&(l.current=a.current,a.current!==o.current&&(l.currentInputValue=l.current)),"pageSize"in a&&a.pageSize!==o.pageSize){var i=o.current,u=yr(a.pageSize,o,a);i=i>u?u:i,"current"in a||(l.current=i,l.currentInputValue=i),l.pageSize=a.pageSize}return l}}]),r}(G.Component);Dv.defaultProps={defaultCurrent:1,total:0,defaultPageSize:10,onChange:ds,className:"",selectPrefixCls:"rc-select",prefixCls:"rc-pagination",selectComponentClass:null,hideOnSinglePage:!1,showPrevNextJumpers:!0,showQuickJumper:!1,showLessItems:!1,showTitle:!0,onShowSizeChange:ds,locale:sp,style:{},itemRender:oy,totalBoundaryShowSizeChanger:50};var Ov=function(e){return s.createElement(Mr,re({},e,{size:"small"}))},Iv=function(e){return s.createElement(Mr,re({},e,{size:"middle"}))};Ov.Option=Mr.Option;Iv.Option=Mr.Option;var iy=globalThis&&globalThis.__rest||function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,n=Object.getOwnPropertySymbols(t);a=d&&iv?"true":"false","aria-posinset":v+1,"aria-setsize":m,tabIndex:u?-1:0},G.createElement("div",{className:"".concat(c,"-first")},y),G.createElement("div",{className:"".concat(c,"-second")},y)));return f&&(g=f(g,this.props)),g}}]),r}(G.Component);function hc(){}var _v=function(t){gn(r,t);var e=yn(r);function r(n){var a;bn(this,r),a=e.call(this,n),a.stars=void 0,a.rate=void 0,a.onHover=function(l,i){var u=a.props.onHoverChange,c=a.getStarValue(i,l.pageX),d=a.state.cleanedValue;c!==d&&a.setState({hoverValue:c,cleanedValue:null}),u(c)},a.onMouseLeave=function(){var l=a.props.onHoverChange;a.setState({hoverValue:void 0,cleanedValue:null}),l(void 0)},a.onClick=function(l,i){var u=a.props.allowClear,c=a.state.value,d=a.getStarValue(i,l.pageX),f=!1;u&&(f=d===c),a.onMouseLeave(),a.changeValue(f?0:d),a.setState({cleanedValue:f?d:null})},a.onFocus=function(){var l=a.props.onFocus;a.setState({focused:!0}),l&&l()},a.onBlur=function(){var l=a.props.onBlur;a.setState({focused:!1}),l&&l()},a.onKeyDown=function(l){var i=l.keyCode,u=a.props,c=u.count,d=u.allowHalf,f=u.onKeyDown,v=u.direction,m=v==="rtl",h=a.state.value;i===Ye.RIGHT&&h0&&!m||i===Ye.RIGHT&&h>0&&m?(d?h-=.5:h-=1,a.changeValue(h),l.preventDefault()):i===Ye.LEFT&&hm/2||!c&&o-v=r}function Gy(t){return t&&Ve(t)==="object"&&!Array.isArray(t)&&!s.isValidElement(t)}function qy(t){return typeof t=="string"?!0:mp(t)}var Xy=function(e){var r=e.ellipsis,n=e.rowType,a=e.children,o,l=r===!0?{showTitle:!0}:r;return l&&(l.showTitle||n==="header")&&(typeof a=="string"||typeof a=="number"?o=a.toString():s.isValidElement(a)&&typeof a.props.children=="string"&&(o=a.props.children)),o};function Zy(t,e){var r,n,a,o=t.prefixCls,l=t.className,i=t.record,u=t.index,c=t.renderIndex,d=t.dataIndex,f=t.render,v=t.children,m=t.component,h=m===void 0?"td":m,y=t.colSpan,g=t.rowSpan,b=t.fixLeft,x=t.fixRight,S=t.firstFixLeft,w=t.lastFixLeft,E=t.firstFixRight,P=t.lastFixRight,T=t.appendNode,M=t.additionalProps,R=M===void 0?{}:M,D=t.ellipsis,O=t.align,$=t.rowType,F=t.isSticky,N=t.hovering,k=t.onHover,I="".concat(o,"-cell"),L=s.useContext(Bv),j=s.useContext(Vv),_=s.useContext(ul),A=_.allColumnsFixedLeft,K=s.useMemo(function(){if(fs(v))return[v];var oe=Kv(i,d),se=oe,he=void 0;if(f){var be=f(oe,i,c);Gy(be)?(se=be.children,he=be.props,L.renderWithProps=!0):se=be}return[se,he]},[L.renderWithProps?Math.random():0,v,d,L,i,f,c]),z=ee(K,2),V=z[0],X=z[1],W=V;Ve(W)==="object"&&!Array.isArray(W)&&!s.isValidElement(W)&&(W=null),D&&(w||E)&&(W=s.createElement("span",{className:"".concat(I,"-content")},W));var Z=X||{},U=Z.colSpan,ae=Z.rowSpan,q=Z.style,te=Z.className,ue=Le(Z,Uy),Y=(r=U!==void 0?U:y)!==null&&r!==void 0?r:1,J=(n=ae!==void 0?ae:g)!==null&&n!==void 0?n:1;if(Y===0||J===0)return null;var Q={},ie=typeof b=="number"&&j,le=typeof x=="number"&&j;ie&&(Q.position="sticky",Q.left=b),le&&(Q.position="sticky",Q.right=x);var ge={};O&&(ge.textAlign=O);var Pe=function(se){var he;i&&k(u,u+J-1),R==null||(he=R.onMouseEnter)===null||he===void 0||he.call(R,se)},ve=function(se){var he;i&&k(-1,-1),R==null||(he=R.onMouseLeave)===null||he===void 0||he.call(R,se)},ce=Xy({rowType:$,ellipsis:D,children:V}),fe=p(p(p({title:ce},ue),R),{},{colSpan:Y!==1?Y:null,rowSpan:J!==1?J:null,className:pe(I,l,(a={},B(a,"".concat(I,"-fix-left"),ie&&j),B(a,"".concat(I,"-fix-left-first"),S&&j),B(a,"".concat(I,"-fix-left-last"),w&&j),B(a,"".concat(I,"-fix-left-all"),w&&A&&j),B(a,"".concat(I,"-fix-right"),le&&j),B(a,"".concat(I,"-fix-right-first"),E&&j),B(a,"".concat(I,"-fix-right-last"),P&&j),B(a,"".concat(I,"-ellipsis"),D),B(a,"".concat(I,"-with-append"),T),B(a,"".concat(I,"-fix-sticky"),(ie||le)&&F&&j),B(a,"".concat(I,"-row-hover"),!X&&N),a),R.className,te),style:p(p(p(p({},R.style),ge),Q),q),onMouseEnter:Pe,onMouseLeave:ve,ref:qy(h)?e:null});return s.createElement(h,fe,T,W)}var Hv=s.forwardRef(Zy);Hv.displayName="Cell";var Qy=["expanded","className","hovering"],Jy=s.memo(Hv,function(t,e){return e.shouldCellUpdate?Qy.every(function(r){return t[r]===e[r]})&&!e.shouldCellUpdate(e.record,t.record):tu(t,e)}),Ko=s.forwardRef(function(t,e){var r=t.index,n=t.additionalProps,a=n===void 0?{}:n,o=t.colSpan,l=t.rowSpan,i=a.colSpan,u=a.rowSpan,c=o??i,d=l??u,f=Wy(zv,function(h){var y=Yy(r,d||1,h==null?void 0:h.startRow,h==null?void 0:h.endRow);return{onHover:h==null?void 0:h.onHover,hovering:y}}),v=f.onHover,m=f.hovering;return s.createElement(Jy,re({},t,{colSpan:c,rowSpan:d,hovering:m,ref:e,onHover:v}))});Ko.displayName="WrappedCell";var Un=s.createContext(null);function mu(t,e,r,n,a){var o=r[t]||{},l=r[e]||{},i,u;o.fixed==="left"?i=n.left[t]:l.fixed==="right"&&(u=n.right[e]);var c=!1,d=!1,f=!1,v=!1,m=r[e+1],h=r[t-1];if(a==="rtl"){if(i!==void 0){var y=h&&h.fixed==="left";v=!y}else if(u!==void 0){var g=m&&m.fixed==="right";f=!g}}else if(i!==void 0){var b=m&&m.fixed==="left";c=!b}else if(u!==void 0){var x=h&&h.fixed==="right";d=!x}return{fixLeft:i,fixRight:u,lastFixLeft:c,firstFixRight:d,lastFixRight:f,firstFixLeft:v,isSticky:n.isSticky}}function Wv(t){var e=t.cells,r=t.stickyOffsets,n=t.flattenColumns,a=t.rowComponent,o=t.cellComponent,l=t.onHeaderRow,i=t.index,u=s.useContext(Un),c=u.prefixCls,d=u.direction,f;l&&(f=l(e.map(function(m){return m.column}),i));var v=sl(e.map(function(m){return m.column}));return s.createElement(a,f,e.map(function(m,h){var y=m.column,g=mu(m.colStart,m.colEnd,n,r,d),b;return y&&y.onHeaderCell&&(b=m.column.onHeaderCell(y)),s.createElement(Ko,re({},m,{ellipsis:y.ellipsis,align:y.align,component:o,prefixCls:c,key:v[h]},g,{additionalProps:b,rowType:"header"}))}))}Wv.displayName="HeaderRow";function eb(t){var e=[];function r(l,i){var u=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0;e[u]=e[u]||[];var c=i,d=l.filter(Boolean).map(function(f){var v={key:f.key,className:f.className||"",children:f.title,column:f,colStart:c},m=1,h=f.children;return h&&h.length>0&&(m=r(h,c,u+1).reduce(function(y,g){return y+g},0),v.hasSubColumns=!0),"colSpan"in f&&(m=f.colSpan),"rowSpan"in f&&(v.rowSpan=f.rowSpan),v.colSpan=m,v.colEnd=v.colStart+m-1,e[u].push(v),c+=m,m});return d}r(t,0);for(var n=e.length,a=function(i){e[i].forEach(function(u){!("rowSpan"in u)&&!u.hasSubColumns&&(u.rowSpan=n-i)})},o=0;o1?ie-1:0),ge=1;ge0?[].concat(De(e),De(vs(o).map(function(l){return p({fixed:a},l)}))):[].concat(De(e),[p(p({},r),{},{fixed:a})])},[])}function ub(t){return t.map(function(e){var r=e.fixed,n=Le(e,sb),a=r;return r==="left"?a="right":r==="right"&&(a="left"),p({fixed:a},n)})}function cb(t,e){var r=t.prefixCls,n=t.columns,a=t.children,o=t.expandable,l=t.expandedKeys,i=t.columnTitle,u=t.getRowKey,c=t.onTriggerExpand,d=t.expandIcon,f=t.rowExpandable,v=t.expandIconColumnIndex,m=t.direction,h=t.expandRowByClick,y=t.columnWidth,g=t.fixed,b=s.useMemo(function(){return n||hu(a)},[n,a]),x=s.useMemo(function(){if(o){var E,P=b.slice();if(!P.includes(Hr)){var T=v||0;T>=0&&P.splice(T,0,Hr)}var M=P.indexOf(Hr);P=P.filter(function($,F){return $!==Hr||F===M});var R=b[M],D;(g==="left"||g)&&!v?D="left":(g==="right"||g)&&v===b.length?D="right":D=R?R.fixed:null;var O=(E={},B(E,so,{className:"".concat(r,"-expand-icon-col"),columnType:"EXPAND_COLUMN"}),B(E,"title",i),B(E,"fixed",D),B(E,"className","".concat(r,"-row-expand-icon-cell")),B(E,"width",y),B(E,"render",function(F,N,k){var I=u(N,k),L=l.has(I),j=f?f(N):!0,_=d({prefixCls:r,expanded:L,expandable:j,record:N,onExpand:c});return h?s.createElement("span",{onClick:function(K){return K.stopPropagation()}},_):_}),E);return P.map(function($){return $===Hr?O:$})}return b.filter(function($){return $!==Hr})},[o,b,u,l,d,m]),S=s.useMemo(function(){var E=x;return e&&(E=e(E)),E.length||(E=[{render:function(){return null}}]),E},[e,x,m]),w=s.useMemo(function(){return m==="rtl"?ub(vs(S)):vs(S)},[S,m]);return[S,w]}function Qv(t){var e=s.useRef(t),r=s.useState({}),n=ee(r,2),a=n[1],o=s.useRef(null),l=s.useRef([]);function i(u){l.current.push(u);var c=Promise.resolve();o.current=c,c.then(function(){if(o.current===c){var d=l.current,f=e.current;l.current=[],d.forEach(function(v){e.current=v(e.current)}),o.current=null,f!==e.current&&a({})}})}return s.useEffect(function(){return function(){o.current=null}},[]),[e.current,i]}function db(t){var e=s.useRef(t||null),r=s.useRef();function n(){window.clearTimeout(r.current)}function a(l){e.current=l,n(),r.current=window.setTimeout(function(){e.current=null,r.current=void 0},100)}function o(){return e.current}return s.useEffect(function(){return n},[]),[a,o]}function fb(t,e,r){var n=s.useMemo(function(){for(var a=[],o=[],l=0,i=0,u=0;u=0;i-=1){var u=e[i],c=r&&r[i],d=c&&c[so];if(u||d||l){var f=d||{};f.columnType;var v=Le(f,vb);a.unshift(s.createElement("col",re({key:i,style:{width:u}},v))),l=!0}}return s.createElement("colgroup",null,a)}function Cc(t){var e=t.className,r=t.children;return s.createElement("div",{className:e},r)}var em=s.createContext({});function mb(t){var e=t.className,r=t.index,n=t.children,a=t.colSpan,o=a===void 0?1:a,l=t.rowSpan,i=t.align,u=s.useContext(Un),c=u.prefixCls,d=u.direction,f=s.useContext(em),v=f.scrollColumnIndex,m=f.stickyOffsets,h=f.flattenColumns,y=r+o-1,g=y+1===v?o+1:o,b=mu(r,r+g-1,h,m,d);return s.createElement(Ko,re({className:e,index:r,component:"td",prefixCls:c,record:null,dataIndex:null,align:i,colSpan:g,rowSpan:l,render:function(){return n}},b))}var hb=["children"];function pb(t){var e=t.children,r=Le(t,hb);return s.createElement("tr",r,e)}function cl(t){var e=t.children;return e}cl.Row=pb;cl.Cell=mb;function gi(t){var e=t.children,r=t.stickyOffsets,n=t.flattenColumns,a=s.useContext(Un),o=a.prefixCls,l=n.length-1,i=n[l],u=s.useMemo(function(){return{stickyOffsets:r,flattenColumns:n,scrollColumnIndex:i!=null&&i.scrollbar?l:null}},[i,n,l,r]);return s.createElement(em.Provider,{value:u},s.createElement("tfoot",{className:"".concat(o,"-summary")},e))}var tm=cl;function gb(t){var e,r=t.prefixCls,n=t.record,a=t.onExpand,o=t.expanded,l=t.expandable,i="".concat(r,"-row-expand-icon");if(!l)return s.createElement("span",{className:pe(i,"".concat(r,"-row-spaced"))});var u=function(d){a(n,d),d.stopPropagation()};return s.createElement("span",{className:pe(i,(e={},B(e,"".concat(r,"-row-expanded"),o),B(e,"".concat(r,"-row-collapsed"),!o),e)),onClick:u})}function yb(t,e,r){var n=[];function a(o){(o||[]).forEach(function(l,i){n.push(e(l,i)),a(l[r])})}return a(t),n}var bb=function(e,r){var n,a,o=e.scrollBodyRef,l=e.onScroll,i=e.offsetScroll,u=e.container,c=s.useContext(Un),d=c.prefixCls,f=((n=o.current)===null||n===void 0?void 0:n.scrollWidth)||0,v=((a=o.current)===null||a===void 0?void 0:a.clientWidth)||0,m=f&&v*(v/f),h=s.useRef(),y=Qv({scrollLeft:0,isHiddenScrollBar:!1}),g=ee(y,2),b=g[0],x=g[1],S=s.useRef({delta:0,x:0}),w=s.useState(!1),E=ee(w,2),P=E[0],T=E[1],M=function(){T(!1)},R=function(N){N.persist(),S.current.delta=N.pageX-b.scrollLeft,S.current.x=0,T(!0),N.preventDefault()},D=function(N){var k,I=N||((k=window)===null||k===void 0?void 0:k.event),L=I.buttons;if(!P||L===0){P&&T(!1);return}var j=S.current.x+N.pageX-S.current.x-S.current.delta;j<=0&&(j=0),j+m>=v&&(j=v-m),l({scrollLeft:j/v*(f+2)}),S.current.x=N.pageX},O=function(){if(o.current){var N=cs(o.current).top,k=N+o.current.offsetHeight,I=u===window?document.documentElement.scrollTop+window.innerHeight:cs(u).top+u.clientHeight;k-Xu()<=I||N>=I-i?x(function(L){return p(p({},L),{},{isHiddenScrollBar:!0})}):x(function(L){return p(p({},L),{},{isHiddenScrollBar:!1})})}},$=function(N){x(function(k){return p(p({},k),{},{scrollLeft:N/f*v||0})})};return s.useImperativeHandle(r,function(){return{setScrollLeft:$}}),s.useEffect(function(){var F=tr(document.body,"mouseup",M,!1),N=tr(document.body,"mousemove",D,!1);return O(),function(){F.remove(),N.remove()}},[m,P]),s.useEffect(function(){var F=tr(u,"scroll",O,!1),N=tr(window,"resize",O,!1);return function(){F.remove(),N.remove()}},[u]),s.useEffect(function(){b.isHiddenScrollBar||x(function(F){var N=o.current;return N?p(p({},F),{},{scrollLeft:N.scrollLeft/N.scrollWidth*N.clientWidth}):F})},[b.isHiddenScrollBar]),f<=v||!m||b.isHiddenScrollBar?null:s.createElement("div",{style:{height:Xu(),width:v,bottom:i},className:"".concat(d,"-sticky-scroll")},s.createElement("div",{onMouseDown:R,ref:h,className:pe("".concat(d,"-sticky-scroll-bar"),B({},"".concat(d,"-sticky-scroll-bar-active"),P)),style:{width:"".concat(m,"px"),transform:"translate3d(".concat(b.scrollLeft,"px, 0, 0)")}}))};const Cb=s.forwardRef(bb);var xc=hp()?window:null;function xb(t,e){var r=Ve(t)==="object"?t:{},n=r.offsetHeader,a=n===void 0?0:n,o=r.offsetSummary,l=o===void 0?0:o,i=r.offsetScroll,u=i===void 0?0:i,c=r.getContainer,d=c===void 0?function(){return xc}:c,f=d()||xc;return s.useMemo(function(){var v=!!t;return{isSticky:v,stickyClassName:v?"".concat(e,"-sticky-holder"):"",offsetHeader:a,offsetSummary:l,offsetScroll:u,container:f}},[u,a,l,e,f])}var Sb=["className","noData","columns","flattenColumns","colWidths","columCount","stickyOffsets","direction","fixHeader","stickyTopOffset","stickyBottomOffset","stickyClassName","onScroll","maxContentScroll","children"];function wb(t,e){return s.useMemo(function(){for(var r=[],n=0;n=0})},[o]),D=o[o.length-1],O={fixed:D?D.fixed:null,scrollbar:!0,onHeaderCell:function(){return{className:"".concat(S,"-cell-scrollbar")}}},$=s.useMemo(function(){return P?[].concat(De(a),[O]):a},[P,a]),F=s.useMemo(function(){return P?[].concat(De(o),[O]):o},[P,o]),N=s.useMemo(function(){var I=u.right,L=u.left;return p(p({},u),{},{left:c==="rtl"?[].concat(De(L.map(function(j){return j+P})),[0]):L,right:c==="rtl"?I:[].concat(De(I.map(function(j){return j+P})),[0]),isSticky:E})},[P,u,E]),k=wb(l,i);return s.createElement("div",{style:p({overflow:"hidden"},E?{top:f,bottom:v}:{}),ref:M,className:pe(r,B({},m,!!m))},s.createElement("table",{style:{tableLayout:"fixed",visibility:n||k?null:"hidden"}},(!n||!y||R)&&s.createElement(Jv,{colWidths:k?[].concat(De(k),[P]):[],columCount:i+1,columns:F}),g(p(p({},b),{},{stickyOffsets:N,columns:$,flattenColumns:F}))))});ms.displayName="FixedHolder";var Pb=[],Eb={},Pi="rc-table-internal-hook",Rb=s.memo(function(t){var e=t.children;return e},function(t,e){return tu(t.props,e.props)?t.pingLeft!==e.pingLeft||t.pingRight!==e.pingRight:!1});function na(t){var e,r=t.prefixCls,n=t.className,a=t.rowClassName,o=t.style,l=t.data,i=t.rowKey,u=t.scroll,c=t.tableLayout,d=t.direction,f=t.title,v=t.footer,m=t.summary,h=t.id,y=t.showHeader,g=t.components,b=t.emptyText,x=t.onRow,S=t.onHeaderRow,w=t.internalHooks,E=t.transformColumns,P=t.internalRefs,T=t.sticky,M=l||Pb,R=!!M.length,D=s.useCallback(function(st,ht){return Kv(g||{},st)||ht},[g]),O=s.useMemo(function(){return typeof i=="function"?i:function(st){var ht=st&&st[i];return ht}},[i]),$=ib(t),F=$.expandIcon,N=$.expandedRowKeys,k=$.defaultExpandedRowKeys,I=$.defaultExpandAllRows,L=$.expandedRowRender,j=$.columnTitle,_=$.onExpand,A=$.onExpandedRowsChange,K=$.expandRowByClick,z=$.rowExpandable,V=$.expandIconColumnIndex,X=$.expandedRowClassName,W=$.childrenColumnName,Z=$.indentSize,U=F||gb,ae=W||"children",q=s.useMemo(function(){return L?"row":t.expandable&&w===Pi&&t.expandable.__PARENT_RENDER_ICON__||M.some(function(st){return st&&Ve(st)==="object"&&st[ae]})?"nest":!1},[!!L,M]),te=s.useState(function(){return k||(I?yb(M,O,ae):[])}),ue=ee(te,2),Y=ue[0],J=ue[1],Q=s.useMemo(function(){return new Set(N||Y||[])},[N,Y]),ie=s.useCallback(function(st){var ht=O(st,M.indexOf(st)),Nt,Zt=Q.has(ht);Zt?(Q.delete(ht),Nt=De(Q)):Nt=[].concat(De(Q),[ht]),J(Nt),_&&_(!Zt,st),A&&A(Nt)},[O,Q,M,_,A]),le=s.useState(0),ge=ee(le,2),Pe=ge[0],ve=ge[1],ce=cb(p(p(p({},t),$),{},{expandable:!!L,columnTitle:j,expandedKeys:Q,getRowKey:O,onTriggerExpand:ie,expandIcon:U,expandIconColumnIndex:V,direction:d}),w===Pi?E:null),fe=ee(ce,2),oe=fe[0],se=fe[1],he=s.useMemo(function(){return{columns:oe,flattenColumns:se}},[oe,se]),be=s.useRef(),ke=s.useRef(),Fe=s.useRef(),Ee=s.useRef(),Re=s.useRef(),we=s.useState(!1),Ge=ee(we,2),Qe=Ge[0],ct=Ge[1],dt=s.useState(!1),mt=ee(dt,2),We=mt[0],Oe=mt[1],ot=Qv(new Map),Je=ee(ot,2),Se=Je[0],He=Je[1],je=sl(se),ze=je.map(function(st){return Se.get(st)}),ye=s.useMemo(function(){return ze},[ze.join("_")]),de=fb(ye,se.length,d),Ce=u&&fs(u.y),Me=u&&fs(u.x)||!!$.fixed,Be=Me&&se.some(function(st){var ht=st.fixed;return ht}),nt=s.useRef(),Ne=xb(T,r),xe=Ne.isSticky,qe=Ne.offsetHeader,it=Ne.offsetSummary,ft=Ne.offsetScroll,At=Ne.stickyClassName,Kt=Ne.container,kt=m==null?void 0:m(M),zt=(Ce||xe)&&s.isValidElement(kt)&&kt.type===cl&&kt.props.fixed,et,tt,lt;Ce&&(tt={overflowY:"scroll",maxHeight:u.y}),Me&&(et={overflowX:"auto"},Ce||(tt={overflowY:"hidden"}),lt={width:(u==null?void 0:u.x)===!0?"auto":u==null?void 0:u.x,minWidth:"100%"});var ut=s.useCallback(function(st,ht){Mf(be.current)&&He(function(Nt){if(Nt.get(st)!==ht){var Zt=new Map(Nt);return Zt.set(st,ht),Zt}return Nt})},[]),wt=db(null),St=ee(wt,2),Ae=St[0],Ue=St[1];function Ie(st,ht){ht&&(typeof ht=="function"?ht(st):ht.scrollLeft!==st&&(ht.scrollLeft=st))}var _e=function(ht){var Nt=ht.currentTarget,Zt=ht.scrollLeft,Ba=d==="rtl",cn=typeof Zt=="number"?Zt:Nt.scrollLeft,vr=Nt||Eb;if(!Ue()||Ue()===vr){var mr;Ae(vr),Ie(cn,ke.current),Ie(cn,Fe.current),Ie(cn,Re.current),Ie(cn,(mr=nt.current)===null||mr===void 0?void 0:mr.setScrollLeft)}if(Nt){var jr=Nt.scrollWidth,hr=Nt.clientWidth;if(jr===hr){ct(!1),Oe(!1);return}Ba?(ct(-cn0)):(ct(cn>0),Oe(cni))return!1;var c=o.get(t),d=o.get(e);if(c&&d)return c==e&&d==t;var f=-1,v=!0,m=r&CC?new pC:void 0;for(o.set(t,e),o.set(e,t);++f0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],r=t.length,n=e.length;if(Math.abs(r-n)!==1)return{add:!1,key:null};function a(o,l){var i=new Map;o.forEach(function(c){i.set(c,!0)});var u=l.filter(function(c){return!i.has(c)});return u.length===1?u[0]:null}return r ").concat(e);return e}var mm=s.forwardRef(function(t,e){var r=t.prefixCls,n=t.data;t.selectable,t.checkable;var a=t.expandedKeys,o=t.selectedKeys,l=t.checkedKeys,i=t.loadedKeys,u=t.loadingKeys,c=t.halfCheckedKeys,d=t.keyEntities,f=t.disabled,v=t.dragging,m=t.dragOverNodeKey,h=t.dropPosition,y=t.motion,g=t.height,b=t.itemHeight,x=t.virtual,S=t.focusable,w=t.activeItem,E=t.focused,P=t.tabIndex,T=t.onKeyDown,M=t.onFocus,R=t.onBlur,D=t.onActiveChange,O=t.onListChangeStart,$=t.onListChangeEnd,F=Le(t,mS),N=s.useRef(null),k=s.useRef(null);s.useImperativeHandle(e,function(){return{scrollTo:function(fe){N.current.scrollTo(fe)},getIndentWidth:function(){return k.current.offsetWidth}}});var I=s.useState(a),L=ee(I,2),j=L[0],_=L[1],A=s.useState(n),K=ee(A,2),z=K[0],V=K[1],X=s.useState(n),W=ee(X,2),Z=W[0],U=W[1],ae=s.useState([]),q=ee(ae,2),te=q[0],ue=q[1],Y=s.useState(null),J=ee(Y,2),Q=J[0],ie=J[1],le=s.useRef(n);le.current=n;function ge(){var ce=le.current;V(ce),U(ce),ue([]),ie(null),$()}Ji(function(){_(a);var ce=vS(j,a);if(ce.key!==null)if(ce.add){var fe=z.findIndex(function(Fe){var Ee=Fe.key;return Ee===ce.key}),oe=Yc(Hc(z,n,ce.key),x,g,b),se=z.slice();se.splice(fe+1,0,Uc),U(se),ue(oe),ie("show")}else{var he=n.findIndex(function(Fe){var Ee=Fe.key;return Ee===ce.key}),be=Yc(Hc(n,z,ce.key),x,g,b),ke=n.slice();ke.splice(he+1,0,Uc),U(ke),ue(be),ie("hide")}else z!==n&&(V(n),U(n))},[a,n]),s.useEffect(function(){v||ge()},[v]);var Pe=y?Z:n,ve={expandedKeys:a,selectedKeys:o,loadedKeys:i,loadingKeys:u,checkedKeys:l,halfCheckedKeys:c,dragOverNodeKey:m,dropPosition:h,keyEntities:d};return s.createElement(s.Fragment,null,E&&w&&s.createElement("span",{style:Wc,"aria-live":"assertive"},pS(w)),s.createElement("div",null,s.createElement("input",{style:Wc,disabled:S===!1||f,tabIndex:S!==!1?P:null,onKeyDown:T,onFocus:M,onBlur:R,value:"",onChange:hS,"aria-label":"for screen reader"})),s.createElement("div",{className:"".concat(r,"-treenode"),"aria-hidden":!0,style:{position:"absolute",pointerEvents:"none",visibility:"hidden",height:0,overflow:"hidden",border:0,padding:0}},s.createElement("div",{className:"".concat(r,"-indent")},s.createElement("div",{ref:k,className:"".concat(r,"-indent-unit")}))),s.createElement(Lp,re({},F,{data:Pe,itemKey:Gc,height:g,fullHeight:!1,virtual:x,itemHeight:b,prefixCls:"".concat(r,"-list"),ref:N,onVisibleChange:function(fe,oe){var se=new Set(fe),he=oe.filter(function(be){return!se.has(be)});he.some(function(be){return Gc(be)===Qr})&&ge()}}),function(ce){var fe=ce.pos,oe=re({},(dm(ce.data),ce.data)),se=ce.title,he=ce.key,be=ce.isStart,ke=ce.isEnd,Fe=_o(he,fe);delete oe.key,delete oe.children;var Ee=io(Fe,ve);return s.createElement(fS,re({},oe,Ee,{title:se,active:!!w&&he===w.key,pos:fe,data:ce.data,isStart:be,isEnd:ke,motion:y,motionNodes:he===Qr?te:null,motionType:Q,onMotionStart:O,onMotionEnd:ge,treeNodeRequiredProps:ve,onMouseMove:function(){D(null)}}))}))});mm.displayName="NodeList";function An(t,e){if(!t)return[];var r=t.slice(),n=r.indexOf(e);return n>=0&&r.splice(n,1),r}function Jn(t,e){var r=(t||[]).slice();return r.indexOf(e)===-1&&r.push(e),r}function wu(t){return t.split("-")}function gS(t,e){var r=[],n=vn(e,t);function a(){var o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];o.forEach(function(l){var i=l.key,u=l.children;r.push(i),a(u)})}return a(n.children),r}function yS(t){if(t.parent){var e=wu(t.pos);return Number(e[e.length-1])===t.parent.children.length-1}return!1}function bS(t){var e=wu(t.pos);return Number(e[e.length-1])===0}function qc(t,e,r,n,a,o,l,i,u,c){var d,f=t.clientX,v=t.clientY,m=t.target.getBoundingClientRect(),h=m.top,y=m.height,g=(c==="rtl"?-1:1)*(((a==null?void 0:a.x)||0)-f),b=(g-12)/n,x=vn(i,r.props.eventKey);if(v-1.5?o({dragNode:$,dropNode:F,dropPosition:1})?R=1:N=!1:o({dragNode:$,dropNode:F,dropPosition:0})?R=0:o({dragNode:$,dropNode:F,dropPosition:1})?R=1:N=!1:o({dragNode:$,dropNode:F,dropPosition:1})?R=1:N=!1,{dropPosition:R,dropLevelOffset:D,dropTargetKey:x.key,dropTargetPos:x.pos,dragOverNodeKey:M,dropContainerKey:R===0?null:((d=x.parent)===null||d===void 0?void 0:d.key)||null,dropAllowed:N}}function Xc(t,e){if(t){var r=e.multiple;return r?t.slice():t.length?[t[0]]:t}}function Ll(t){if(!t)return null;var e;if(Array.isArray(t))e={checkedKeys:t,halfCheckedKeys:void 0};else if(Ve(t)==="object")e={checkedKeys:t.checked||void 0,halfCheckedKeys:t.halfChecked||void 0};else return rn(!1,"`checkedKeys` is not an array or an object"),null;return e}function xs(t,e){var r=new Set;function n(a){if(!r.has(a)){var o=vn(e,a);if(o){r.add(a);var l=o.parent,i=o.node;i.disabled||l&&n(l.key)}}}return(t||[]).forEach(function(a){n(a)}),De(r)}var CS=10,pl=function(t){gn(r,t);var e=yn(r);function r(){var n;bn(this,r);for(var a=arguments.length,o=new Array(a),l=0;l2&&arguments[2]!==void 0?arguments[2]:!1,f=n.state,v=f.dragChildrenKeys,m=f.dropPosition,h=f.dropTargetKey,y=f.dropTargetPos,g=f.dropAllowed;if(g){var b=n.props.onDrop;if(n.setState({dragOverNodeKey:null}),n.cleanDragState(),h!==null){var x=p(p({},io(h,n.getTreeNodeRequiredProps())),{},{active:((c=n.getActiveItem())===null||c===void 0?void 0:c.key)===h,data:vn(n.state.keyEntities,h).node}),S=v.indexOf(h)!==-1;rn(!S,"Can not drop to dragNode's children node. This is a bug of rc-tree. Please report an issue.");var w=wu(y),E={event:i,node:Wt(x),dragNode:n.dragNode?Wt(n.dragNode.props):null,dragNodesKeys:[n.dragNode.props.eventKey].concat(v),dropToGap:m!==0,dropPosition:m+Number(w[w.length-1])};d||b==null||b(E),n.dragNode=null}}},n.cleanDragState=function(){var i=n.state.draggingNodeKey;i!==null&&n.setState({draggingNodeKey:null,dropPosition:null,dropContainerKey:null,dropTargetKey:null,dropLevelOffset:null,dropAllowed:!0,dragOverNodeKey:null}),n.dragStartMousePosition=null,n.currentMouseOverDroppableNodeKey=null},n.triggerExpandActionExpand=function(i,u){var c=n.state,d=c.expandedKeys,f=c.flattenNodes,v=u.expanded,m=u.key,h=u.isLeaf;if(!(h||i.shiftKey||i.metaKey||i.ctrlKey)){var y=f.filter(function(b){return b.key===m})[0],g=Wt(p(p({},io(m,n.getTreeNodeRequiredProps())),{},{data:y.data}));n.setExpandedKeys(v?An(d,m):Jn(d,m)),n.onNodeExpand(i,g)}},n.onNodeClick=function(i,u){var c=n.props,d=c.onClick,f=c.expandAction;f==="click"&&n.triggerExpandActionExpand(i,u),d==null||d(i,u)},n.onNodeDoubleClick=function(i,u){var c=n.props,d=c.onDoubleClick,f=c.expandAction;f==="doubleClick"&&n.triggerExpandActionExpand(i,u),d==null||d(i,u)},n.onNodeSelect=function(i,u){var c=n.state.selectedKeys,d=n.state,f=d.keyEntities,v=d.fieldNames,m=n.props,h=m.onSelect,y=m.multiple,g=u.selected,b=u[v.key],x=!g;x?y?c=Jn(c,b):c=[b]:c=An(c,b);var S=c.map(function(w){var E=vn(f,w);return E?E.node:null}).filter(function(w){return w});n.setUncontrolledState({selectedKeys:c}),h==null||h(c,{event:"select",selected:x,node:u,selectedNodes:S,nativeEvent:i.nativeEvent})},n.onNodeCheck=function(i,u,c){var d=n.state,f=d.keyEntities,v=d.checkedKeys,m=d.halfCheckedKeys,h=n.props,y=h.checkStrictly,g=h.onCheck,b=u.key,x,S={event:"check",node:u,checked:c,nativeEvent:i.nativeEvent};if(y){var w=c?Jn(v,b):An(v,b),E=An(m,b);x={checked:w,halfChecked:E},S.checkedNodes=w.map(function(O){return vn(f,O)}).filter(function(O){return O}).map(function(O){return O.node}),n.setUncontrolledState({checkedKeys:w})}else{var P=wn([].concat(De(v),[b]),!0,f),T=P.checkedKeys,M=P.halfCheckedKeys;if(!c){var R=new Set(T);R.delete(b);var D=wn(Array.from(R),{checked:!1,halfCheckedKeys:M},f);T=D.checkedKeys,M=D.halfCheckedKeys}x=T,S.checkedNodes=[],S.checkedNodesPositions=[],S.halfCheckedKeys=M,T.forEach(function(O){var $=vn(f,O);if($){var F=$.node,N=$.pos;S.checkedNodes.push(F),S.checkedNodesPositions.push({node:F,pos:N})}}),n.setUncontrolledState({checkedKeys:T},!1,{halfCheckedKeys:M})}g==null||g(x,S)},n.onNodeLoad=function(i){var u=i.key,c=new Promise(function(d,f){n.setState(function(v){var m=v.loadedKeys,h=m===void 0?[]:m,y=v.loadingKeys,g=y===void 0?[]:y,b=n.props,x=b.loadData,S=b.onLoad;if(!x||h.indexOf(u)!==-1||g.indexOf(u)!==-1)return null;var w=x(i);return w.then(function(){var E=n.state.loadedKeys,P=Jn(E,u);S==null||S(P,{event:"load",node:i}),n.setUncontrolledState({loadedKeys:P}),n.setState(function(T){return{loadingKeys:An(T.loadingKeys,u)}}),d()}).catch(function(E){if(n.setState(function(T){return{loadingKeys:An(T.loadingKeys,u)}}),n.loadingRetryTimes[u]=(n.loadingRetryTimes[u]||0)+1,n.loadingRetryTimes[u]>=CS){var P=n.state.loadedKeys;rn(!1,"Retry for `loadData` many times but still failed. No more retry."),n.setUncontrolledState({loadedKeys:Jn(P,u)}),d()}f(E)}),{loadingKeys:Jn(g,u)}})});return c.catch(function(){}),c},n.onNodeMouseEnter=function(i,u){var c=n.props.onMouseEnter;c==null||c({event:i,node:u})},n.onNodeMouseLeave=function(i,u){var c=n.props.onMouseLeave;c==null||c({event:i,node:u})},n.onNodeContextMenu=function(i,u){var c=n.props.onRightClick;c&&(i.preventDefault(),c({event:i,node:u}))},n.onFocus=function(){var i=n.props.onFocus;n.setState({focused:!0});for(var u=arguments.length,c=new Array(u),d=0;d1&&arguments[1]!==void 0?arguments[1]:!1,c=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null;if(!n.destroyed){var d=!1,f=!0,v={};Object.keys(i).forEach(function(m){if(m in n.props){f=!1;return}d=!0,v[m]=i[m]}),d&&(!u||f)&&n.setState(p(p({},v),c))}},n.scrollTo=function(i){n.listRef.current.scrollTo(i)},n}return Cn(r,[{key:"componentDidMount",value:function(){this.destroyed=!1,this.onUpdated()}},{key:"componentDidUpdate",value:function(){this.onUpdated()}},{key:"onUpdated",value:function(){var a=this.props.activeKey;a!==void 0&&a!==this.state.activeKey&&(this.setState({activeKey:a}),a!==null&&this.scrollTo({key:a}))}},{key:"componentWillUnmount",value:function(){window.removeEventListener("dragend",this.onWindowDragEnd),this.destroyed=!0}},{key:"resetDragState",value:function(){this.setState({dragOverNodeKey:null,dropPosition:null,dropLevelOffset:null,dropTargetKey:null,dropContainerKey:null,dropTargetPos:null,dropAllowed:!1})}},{key:"render",value:function(){var a,o=this.state,l=o.focused,i=o.flattenNodes,u=o.keyEntities,c=o.draggingNodeKey,d=o.activeKey,f=o.dropLevelOffset,v=o.dropContainerKey,m=o.dropTargetKey,h=o.dropPosition,y=o.dragOverNodeKey,g=o.indent,b=this.props,x=b.prefixCls,S=b.className,w=b.style,E=b.showLine,P=b.focusable,T=b.tabIndex,M=T===void 0?0:T,R=b.selectable,D=b.showIcon,O=b.icon,$=b.switcherIcon,F=b.draggable,N=b.checkable,k=b.checkStrictly,I=b.disabled,L=b.motion,j=b.loadData,_=b.filterTreeNode,A=b.height,K=b.itemHeight,z=b.virtual,V=b.titleRender,X=b.dropIndicatorRender,W=b.onContextMenu,Z=b.onScroll,U=b.direction,ae=b.rootClassName,q=b.rootStyle,te=eu(this.props,{aria:!0,data:!0}),ue;return F&&(Ve(F)==="object"?ue=F:typeof F=="function"?ue={nodeDraggable:F}:ue={}),s.createElement(Su.Provider,{value:{prefixCls:x,selectable:R,showIcon:D,icon:O,switcherIcon:$,draggable:ue,draggingNodeKey:c,checkable:N,checkStrictly:k,disabled:I,keyEntities:u,dropLevelOffset:f,dropContainerKey:v,dropTargetKey:m,dropPosition:h,dragOverNodeKey:y,indent:g,direction:U,dropIndicatorRender:X,loadData:j,filterTreeNode:_,titleRender:V,onNodeClick:this.onNodeClick,onNodeDoubleClick:this.onNodeDoubleClick,onNodeExpand:this.onNodeExpand,onNodeSelect:this.onNodeSelect,onNodeCheck:this.onNodeCheck,onNodeLoad:this.onNodeLoad,onNodeMouseEnter:this.onNodeMouseEnter,onNodeMouseLeave:this.onNodeMouseLeave,onNodeContextMenu:this.onNodeContextMenu,onNodeDragStart:this.onNodeDragStart,onNodeDragEnter:this.onNodeDragEnter,onNodeDragOver:this.onNodeDragOver,onNodeDragLeave:this.onNodeDragLeave,onNodeDragEnd:this.onNodeDragEnd,onNodeDrop:this.onNodeDrop}},s.createElement("div",{role:"tree",className:pe(x,S,ae,(a={},B(a,"".concat(x,"-show-line"),E),B(a,"".concat(x,"-focused"),l),B(a,"".concat(x,"-active-focused"),d!==null),a)),style:q},s.createElement(mm,re({ref:this.listRef,prefixCls:x,style:w,data:i,disabled:I,selectable:R,checkable:!!N,motion:L,dragging:c!==null,height:A,itemHeight:K,virtual:z,focusable:P,focused:l,tabIndex:M,activeItem:this.getActiveItem(),onFocus:this.onFocus,onBlur:this.onBlur,onKeyDown:this.onKeyDown,onActiveChange:this.onActiveChange,onListChangeStart:this.onListChangeStart,onListChangeEnd:this.onListChangeEnd,onContextMenu:W,onScroll:Z},this.getTreeNodeRequiredProps(),te))))}}],[{key:"getDerivedStateFromProps",value:function(a,o){var l=o.prevProps,i={prevProps:a};function u(P){return!l&&P in a||l&&l[P]!==a[P]}var c,d=o.fieldNames;if(u("fieldNames")&&(d=Ni(a.fieldNames),i.fieldNames=d),u("treeData")?c=a.treeData:u("children")&&(rn(!1,"`children` of Tree is deprecated. Please use `treeData` instead."),c=Sv(a.children)),c){i.treeData=c;var f=Lo(c,{fieldNames:d});i.keyEntities=p(B({},Qr,vm),f.keyEntities)}var v=i.keyEntities||o.keyEntities;if(u("expandedKeys")||l&&u("autoExpandParent"))i.expandedKeys=a.autoExpandParent||!l&&a.defaultExpandParent?xs(a.expandedKeys,v):a.expandedKeys;else if(!l&&a.defaultExpandAll){var m=p({},v);delete m[Qr],i.expandedKeys=Object.keys(m).map(function(P){return m[P].key})}else!l&&a.defaultExpandedKeys&&(i.expandedKeys=a.autoExpandParent||a.defaultExpandParent?xs(a.defaultExpandedKeys,v):a.defaultExpandedKeys);if(i.expandedKeys||delete i.expandedKeys,c||i.expandedKeys){var h=Ol(c||o.treeData,i.expandedKeys||o.expandedKeys,d);i.flattenNodes=h}if(a.selectable&&(u("selectedKeys")?i.selectedKeys=Xc(a.selectedKeys,a):!l&&a.defaultSelectedKeys&&(i.selectedKeys=Xc(a.defaultSelectedKeys,a))),a.checkable){var y;if(u("checkedKeys")?y=Ll(a.checkedKeys)||{}:!l&&a.defaultCheckedKeys?y=Ll(a.defaultCheckedKeys)||{}:c&&(y=Ll(a.checkedKeys)||{checkedKeys:o.checkedKeys,halfCheckedKeys:o.halfCheckedKeys}),y){var g=y,b=g.checkedKeys,x=b===void 0?[]:b,S=g.halfCheckedKeys,w=S===void 0?[]:S;if(!a.checkStrictly){var E=wn(x,!0,v);x=E.checkedKeys,w=E.halfCheckedKeys}i.checkedKeys=x,i.halfCheckedKeys=w}}return u("loadedKeys")&&(i.loadedKeys=a.loadedKeys),i}}]),r}(s.Component);pl.defaultProps={prefixCls:"rc-tree",showLine:!1,showIcon:!0,selectable:!0,multiple:!1,checkable:!1,disabled:!1,checkStrictly:!1,draggable:!1,defaultExpandParent:!0,autoExpandParent:!1,defaultExpandAll:!1,defaultExpandedKeys:[],defaultCheckedKeys:[],defaultSelectedKeys:[],dropIndicatorRender:aS,allowDrop:function(){return!0},expandAction:!1};pl.TreeNode=ba;var xS={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M300 276.5a56 56 0 1056-97 56 56 0 00-56 97zm0 284a56 56 0 1056-97 56 56 0 00-56 97zM640 228a56 56 0 10112 0 56 56 0 00-112 0zm0 284a56 56 0 10112 0 56 56 0 00-112 0zM300 844.5a56 56 0 1056-97 56 56 0 00-56 97zM640 796a56 56 0 10112 0 56 56 0 00-112 0z"}}]},name:"holder",theme:"outlined"};const SS=xS;var wS=function(e,r){return s.createElement(Ft,p(p({},e),{},{ref:r,icon:SS}))},PS=s.forwardRef(wS);const ES=PS;var Zc=4;function RS(t){var e=t.dropPosition,r=t.dropLevelOffset,n=t.prefixCls,a=t.indent,o=t.direction,l=o===void 0?"ltr":o,i=l==="ltr"?"left":"right",u=l==="ltr"?"right":"left",c=B(B({},i,-r*a+Zc),u,0);switch(e){case-1:c.top=-3;break;case 1:c.bottom=-3;break;default:c.bottom=-3,c[i]=a+Zc;break}return G.createElement("div",{style:c,className:"".concat(n,"-drop-indicator")})}var kS={icon:{tag:"svg",attrs:{viewBox:"0 0 1024 1024",focusable:"false"},children:[{tag:"path",attrs:{d:"M840.4 300H183.6c-19.7 0-30.7 20.8-18.5 35l328.4 380.8c9.4 10.9 27.5 10.9 37 0L858.9 335c12.2-14.2 1.2-35-18.5-35z"}}]},name:"caret-down",theme:"filled"};const FS=kS;var MS=function(e,r){return s.createElement(Ft,p(p({},e),{},{ref:r,icon:FS}))},NS=s.forwardRef(MS);const TS=NS;var $S={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M854.6 288.6L639.4 73.4c-6-6-14.1-9.4-22.6-9.4H192c-17.7 0-32 14.3-32 32v832c0 17.7 14.3 32 32 32h640c17.7 0 32-14.3 32-32V311.3c0-8.5-3.4-16.7-9.4-22.7zM790.2 326H602V137.8L790.2 326zm1.8 562H232V136h302v216a42 42 0 0042 42h216v494z"}}]},name:"file",theme:"outlined"};const DS=$S;var OS=function(e,r){return s.createElement(Ft,p(p({},e),{},{ref:r,icon:DS}))},IS=s.forwardRef(OS);const hm=IS;var _S={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M328 544h368c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8H328c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8z"}},{tag:"path",attrs:{d:"M880 112H144c-17.7 0-32 14.3-32 32v736c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V144c0-17.7-14.3-32-32-32zm-40 728H184V184h656v656z"}}]},name:"minus-square",theme:"outlined"};const LS=_S;var jS=function(e,r){return s.createElement(Ft,p(p({},e),{},{ref:r,icon:LS}))},AS=s.forwardRef(jS);const KS=AS;var VS={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M328 544h152v152c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V544h152c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8H544V328c0-4.4-3.6-8-8-8h-48c-4.4 0-8 3.6-8 8v152H328c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8z"}},{tag:"path",attrs:{d:"M880 112H144c-17.7 0-32 14.3-32 32v736c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V144c0-17.7-14.3-32-32-32zm-40 728H184V184h656v656z"}}]},name:"plus-square",theme:"outlined"};const zS=VS;var BS=function(e,r){return s.createElement(Ft,p(p({},e),{},{ref:r,icon:zS}))},HS=s.forwardRef(BS);const WS=HS;function pm(t,e,r,n){var a=n.isLeaf,o=n.expanded,l=n.loading;if(l)return s.createElement(Ma,{className:"".concat(t,"-switcher-loading-icon")});var i;if(r&&Ve(r)==="object"&&(i=r.showLeafIcon),a){if(!r)return null;if(typeof i!="boolean"&&i){var u=typeof i=="function"?i(n):i,c="".concat(t,"-switcher-line-custom-icon");return Ju(u)?ho(u,{className:pe(u.props.className||"",c)}):u}return i?s.createElement(hm,{className:"".concat(t,"-switcher-line-icon")}):s.createElement("span",{className:"".concat(t,"-switcher-leaf-line")})}var d="".concat(t,"-switcher-icon"),f=typeof e=="function"?e(n):e;return Ju(f)?ho(f,{className:pe(f.props.className||"",d)}):f||(r?o?s.createElement(KS,{className:"".concat(t,"-switcher-line-icon")}):s.createElement(WS,{className:"".concat(t,"-switcher-line-icon")}):s.createElement(TS,{className:d}))}var US=s.forwardRef(function(t,e){var r=s.useContext(Ut),n=r.getPrefixCls,a=r.direction,o=r.virtual,l=t.prefixCls,i=t.className,u=t.showIcon,c=u===void 0?!1:u,d=t.showLine,f=t.switcherIcon,v=t.blockNode,m=v===void 0?!1:v,h=t.children,y=t.checkable,g=y===void 0?!1:y,b=t.selectable,x=b===void 0?!0:b,S=t.draggable,w=t.motion,E=w===void 0?re(re({},xp),{motionAppear:!1}):w,P=n("tree",l),T=re(re({},t),{checkable:g,selectable:x,showIcon:c,motion:E,blockNode:m,showLine:!!d,dropIndicatorRender:RS}),M=s.useMemo(function(){if(!S)return!1;var R={};switch(Ve(S)){case"function":R.nodeDraggable=S;break;case"object":R=re({},S);break}return R.icon!==!1&&(R.icon=R.icon||s.createElement(ES,null)),R},[S]);return s.createElement(pl,re({itemHeight:20,ref:e,virtual:o},T,{prefixCls:P,className:pe(B(B(B(B({},"".concat(P,"-icon-hide"),!c),"".concat(P,"-block-node"),m),"".concat(P,"-unselectable"),!x),"".concat(P,"-rtl"),a==="rtl"),i),direction:a,checkable:g&&s.createElement("span",{className:"".concat(P,"-checkbox-inner")}),selectable:x,switcherIcon:function(D){return pm(P,f,d,D)},draggable:M}),h)});const gm=US;var YS={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M928 444H820V330.4c0-17.7-14.3-32-32-32H473L355.7 186.2a8.15 8.15 0 00-5.5-2.2H96c-17.7 0-32 14.3-32 32v592c0 17.7 14.3 32 32 32h698c13 0 24.8-7.9 29.7-20l134-332c1.5-3.8 2.3-7.9 2.3-12 0-17.7-14.3-32-32-32zM136 256h188.5l119.6 114.4H748V444H238c-13 0-24.8 7.9-29.7 20L136 643.2V256zm635.3 512H159l103.3-256h612.4L771.3 768z"}}]},name:"folder-open",theme:"outlined"};const GS=YS;var qS=function(e,r){return s.createElement(Ft,p(p({},e),{},{ref:r,icon:GS}))},XS=s.forwardRef(qS);const ZS=XS;var QS={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M880 298.4H521L403.7 186.2a8.15 8.15 0 00-5.5-2.2H144c-17.7 0-32 14.3-32 32v592c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V330.4c0-17.7-14.3-32-32-32zM840 768H184V256h188.5l119.6 114.4H840V768z"}}]},name:"folder",theme:"outlined"};const JS=QS;var e4=function(e,r){return s.createElement(Ft,p(p({},e),{},{ref:r,icon:JS}))},t4=s.forwardRef(e4);const n4=t4;var er;(function(t){t[t.None=0]="None",t[t.Start=1]="Start",t[t.End=2]="End"})(er||(er={}));function Pu(t,e){function r(n){var a=n.key,o=n.children;e(a,n)!==!1&&Pu(o||[],e)}t.forEach(r)}function r4(t){var e=t.treeData,r=t.expandedKeys,n=t.startKey,a=t.endKey,o=[],l=er.None;if(n&&n===a)return[n];if(!n||!a)return[];function i(u){return u===n||u===a}return Pu(e,function(u){if(l===er.End)return!1;if(i(u)){if(o.push(u),l===er.None)l=er.Start;else if(l===er.Start)return l=er.End,!1}else l===er.Start&&o.push(u);return r.includes(u)}),o}function jl(t,e){var r=De(e),n=[];return Pu(t,function(a,o){var l=r.indexOf(a);return l!==-1&&(n.push(o),r.splice(l,1)),!!r.length}),n}var Qc=globalThis&&globalThis.__rest||function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,n=Object.getOwnPropertySymbols(t);a0&&arguments[0]!==void 0?arguments[0]:{confirm:!1,closeDropdown:!1},we=Re.confirm,Ge=Re.closeDropdown;we&&ue([]),Ge&&$(!1),q(""),j(E?(P||[]).map(function(Qe){return String(Qe)}):[])},Q=function(){var Re=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{closeDropdown:!0},we=Re.closeDropdown;we&&$(!1),ue(L())},ie=function(Re){Re&&N!==void 0&&j(Al(N)),$(Re),!Re&&!a.filterDropdown&&Y()},le=pe(B({},"".concat(o,"-menu-without-submenu"),!f4(a.filters||[]))),ge=function(Re){if(Re.target.checked){var we=va(a==null?void 0:a.filters).map(function(Ge){return String(Ge)});j(we)}else j([])},Pe=function Ee(Re){var we=Re.filters;return(we||[]).map(function(Ge,Qe){var ct=String(Ge.value),dt={title:Ge.text,key:Ge.value!==void 0?ct:String(Qe)};return Ge.children&&(dt.children=Ee({filters:Ge.children})),dt})},ve=function Ee(Re){var we;return re(re({},Re),{text:Re.title,value:Re.key,children:((we=Re.children)===null||we===void 0?void 0:we.map(function(Ge){return Ee(Ge)}))||[]})},ce;if(typeof a.filterDropdown=="function")ce=a.filterDropdown({prefixCls:"".concat(o,"-custom"),setSelectedKeys:function(Re){return _({selectedKeys:Re})},selectedKeys:L(),confirm:Q,clearFilters:J,filters:a.filters,visible:F,close:function(){$(!1)}});else if(a.filterDropdown)ce=a.filterDropdown;else{var fe=L()||[],oe=function(){return(a.filters||[]).length===0?s.createElement(Qu,{image:Qu.PRESENTED_IMAGE_SIMPLE,description:h.filterEmptyText,imageStyle:{height:24},style:{margin:0,padding:"16px 0"}}):c==="tree"?s.createElement(s.Fragment,null,s.createElement(ed,{filterSearch:f,value:ae,onChange:te,tablePrefixCls:r,locale:h}),s.createElement("div",{className:"".concat(r,"-filter-dropdown-tree")},i?s.createElement(ha,{checked:fe.length===va(a.filters).length,indeterminate:fe.length>0&&fe.length0?o:t}),v=Math.ceil((o||t)/f.pageSize);f.current>v&&(f.current=v||1);var m=function(g,b){d({current:g??1,pageSize:b||f.pageSize})},h=function(g,b){var x;e&&((x=e.onChange)===null||x===void 0||x.call(e,g,b)),m(g,b),r(g,b||(f==null?void 0:f.pageSize))};return e===!1?[{},function(){}]:[re(re({},f),{onChange:h}),m]}var br={},ws="SELECT_ALL",Ps="SELECT_INVERT",Es="SELECT_NONE",rd=[];function Pm(t,e){var r=[];return(t||[]).forEach(function(n){r.push(n),n&&Ve(n)==="object"&&e in n&&(r=[].concat(De(r),De(Pm(n[e],e))))}),r}function b4(t,e){var r=t||{},n=r.preserveSelectedRowKeys,a=r.selectedRowKeys,o=r.defaultSelectedRowKeys,l=r.getCheckboxProps,i=r.onChange,u=r.onSelect,c=r.onSelectAll,d=r.onSelectInvert,f=r.onSelectNone,v=r.onSelectMultiple,m=r.columnWidth,h=r.type,y=r.selections,g=r.fixed,b=r.renderCell,x=r.hideSelectAll,S=r.checkStrictly,w=S===void 0?!0:S,E=e.prefixCls,P=e.data,T=e.pageData,M=e.getRecordByKey,R=e.getRowKey,D=e.expandType,O=e.childrenColumnName,$=e.locale,F=e.getPopupContainer,N=xt(a||o||rd,{value:a}),k=ee(N,2),I=k[0],L=k[1],j=s.useRef(new Map),_=s.useCallback(function(ve){if(n){var ce=new Map;ve.forEach(function(fe){var oe=M(fe);!oe&&j.current.has(fe)&&(oe=j.current.get(fe)),ce.set(fe,oe)}),j.current=ce}},[M,n]);s.useEffect(function(){_(I)},[I]);var A=s.useMemo(function(){return w?{keyEntities:null}:Lo(P,{externalGetKey:R,childrenPropName:O})},[P,R,w,O]),K=A.keyEntities,z=s.useMemo(function(){return Pm(T,O)},[T,O]),V=s.useMemo(function(){var ve=new Map;return z.forEach(function(ce,fe){var oe=R(ce,fe),se=(l?l(ce):null)||{};ve.set(oe,se)}),ve},[z,R,l]),X=s.useCallback(function(ve){var ce;return!!(!((ce=V.get(R(ve)))===null||ce===void 0)&&ce.disabled)},[V,R]),W=s.useMemo(function(){if(w)return[I||[],[]];var ve=wn(I,!0,K,X),ce=ve.checkedKeys,fe=ve.halfCheckedKeys;return[ce||[],fe]},[I,w,K,X]),Z=ee(W,2),U=Z[0],ae=Z[1],q=s.useMemo(function(){var ve=h==="radio"?U.slice(0,1):U;return new Set(ve)},[U,h]),te=s.useMemo(function(){return h==="radio"?new Set:new Set(ae)},[ae,h]),ue=s.useState(null),Y=ee(ue,2),J=Y[0],Q=Y[1];s.useEffect(function(){t||L(rd)},[!!t]);var ie=s.useCallback(function(ve,ce){var fe,oe;_(ve),n?(fe=ve,oe=ve.map(function(se){return j.current.get(se)})):(fe=[],oe=[],ve.forEach(function(se){var he=M(se);he!==void 0&&(fe.push(se),oe.push(he))})),L(fe),i==null||i(fe,oe,{type:ce})},[L,M,i,n]),le=s.useCallback(function(ve,ce,fe,oe){if(u){var se=fe.map(function(he){return M(he)});u(M(ve),ce,se,oe)}ie(fe,"single")},[u,M,ie]),ge=s.useMemo(function(){if(!y||x)return null;var ve=y===!0?[ws,Ps,Es]:y;return ve.map(function(ce){return ce===ws?{key:"all",text:$.selectionAll,onSelect:function(){ie(P.map(function(oe,se){return R(oe,se)}).filter(function(oe){var se=V.get(oe);return!(se!=null&&se.disabled)||q.has(oe)}),"all")}}:ce===Ps?{key:"invert",text:$.selectInvert,onSelect:function(){var oe=new Set(q);T.forEach(function(he,be){var ke=R(he,be),Fe=V.get(ke);Fe!=null&&Fe.disabled||(oe.has(ke)?oe.delete(ke):oe.add(ke))});var se=Array.from(oe);d&&d(se),ie(se,"invert")}}:ce===Es?{key:"none",text:$.selectNone,onSelect:function(){f==null||f(),ie(Array.from(q).filter(function(oe){var se=V.get(oe);return se==null?void 0:se.disabled}),"none")}}:ce}).map(function(ce){return re(re({},ce),{onSelect:function(){for(var oe,se,he=arguments.length,be=new Array(he),ke=0;ke2&&arguments[2]!==void 0?arguments[2]:!1,at=re(re({},fe),Ue);_e&&(fe.resetPagination(),at.pagination.current&&(at.pagination.current=1),c&&c.onChange&&c.onChange(1,at.pagination.pageSize)),R&&R.scrollToFirstRowOnChange!==!1&&le.body.current&&Xp(0,{getContainer:function(){return le.body.current}}),b==null||b(at.pagination,at.filters,at.sorter,{currentDataSource:nd(ks(U,at.sorterStates,Q),at.filterStates),action:Ie})},se=function(Ue,Ie){oe({sorter:Ue,sorterStates:Ie},"sort",!1)},he=T4({prefixCls:te,mergedColumns:L,onSorterChange:se,sortDirections:D||["ascend","descend"],tableLocale:Z,showSorterTooltip:F}),be=ee(he,4),ke=be[0],Fe=be[1],Ee=be[2],Re=be[3],we=s.useMemo(function(){return ks(U,Fe,Q)},[U,Fe]);fe.sorter=Re(),fe.sorterStates=Fe;var Ge=function(Ue,Ie){oe({filters:Ue,filterStates:Ie},"filter",!0)},Qe=m4({prefixCls:te,locale:Z,dropdownPrefixCls:ue,mergedColumns:L,onFilterChange:Ge,getPopupContainer:x}),ct=ee(Qe,3),dt=ct[0],mt=ct[1],We=ct[2],Oe=nd(we,mt);fe.filters=We,fe.filterStates=mt;var ot=s.useMemo(function(){var Ae={};return Object.keys(We).forEach(function(Ue){We[Ue]!==null&&(Ae[Ue]=We[Ue])}),re(re({},Ee),{filters:Ae})},[Ee,We]),Je=$4(ot),Se=ee(Je,1),He=Se[0],je=function(Ue,Ie){oe({pagination:re(re({},fe.pagination),{current:Ue,pageSize:Ie})},"paginate")},ze=y4(Oe.length,c,je),ye=ee(ze,2),de=ye[0],Ce=ye[1];fe.pagination=c===!1?{}:p4(c,de),fe.resetPagination=Ce;var Me=s.useMemo(function(){if(c===!1||!de.pageSize)return Oe;var Ae=de.current,Ue=Ae===void 0?1:Ae,Ie=de.total,_e=de.pageSize,at=_e===void 0?wm:_e;return Oe.lengthat?Oe.slice((Ue-1)*at,Ue*at):Oe:Oe.slice((Ue-1)*at,Ue*at)},[!!c,Oe,de&&de.current,de&&de.pageSize,de&&de.total]),Be=b4(d,{prefixCls:te,data:Oe,pageData:Me,getRowKey:ge,getRecordByKey:ce,expandType:ie,childrenColumnName:Q,locale:Z,getPopupContainer:x}),nt=ee(Be,2),Ne=nt[0],xe=nt[1],qe=function(Ue,Ie,_e){var at;return typeof m=="function"?at=pe(m(Ue,Ie,_e)):at=pe(m),pe(B({},"".concat(te,"-row-selected"),xe.has(ge(Ue,Ie))),at)};Y.__PARENT_RENDER_ICON__=Y.expandIcon,Y.expandIcon=Y.expandIcon||w||Mb(Z),ie==="nest"&&Y.expandIconColumnIndex===void 0?Y.expandIconColumnIndex=d?1:0:Y.expandIconColumnIndex>0&&d&&(Y.expandIconColumnIndex-=1),typeof Y.indentSize!="number"&&(Y.indentSize=typeof M=="number"?M:15);var it=s.useCallback(function(Ae){return He(Ne(dt(ke(Ae))))},[ke,dt,Ne]),ft,At;if(c!==!1&&(de!=null&&de.total)){var Kt;de.size?Kt=de.size:Kt=W==="small"||W==="middle"?"small":void 0;var kt=function(Ue){return s.createElement(sy,re({},de,{className:pe("".concat(te,"-pagination ").concat(te,"-pagination-").concat(Ue),de.className),size:Kt}))},zt=X==="rtl"?"left":"right",et=de.position;if(et!==null&&Array.isArray(et)){var tt=et.find(function(Ae){return Ae.includes("top")}),lt=et.find(function(Ae){return Ae.includes("bottom")}),ut=et.every(function(Ae){return"".concat(Ae)==="none"});!tt&&!lt&&!ut&&(At=kt(zt)),tt&&(ft=kt(tt.toLowerCase().replace("top",""))),lt&&(At=kt(lt.toLowerCase().replace("bottom","")))}else At=kt(zt)}var wt;typeof S=="boolean"?wt={spinning:S}:Ve(S)==="object"&&(wt=re({spinning:!0},S));var St=pe("".concat(te,"-wrapper"),B({},"".concat(te,"-wrapper-rtl"),X==="rtl"),n);return s.createElement("div",{ref:e,className:St,style:a},s.createElement(kr,re({spinning:!1},wt),ft,s.createElement(na,re({},j,{columns:L,direction:X,expandable:Y,prefixCls:te,className:pe(B(B(B(B({},"".concat(te,"-middle"),W==="middle"),"".concat(te,"-small"),W==="small"),"".concat(te,"-bordered"),l),"".concat(te,"-empty"),U.length===0)),data:Me,rowKey:ge,rowClassName:qe,emptyText:O&&O.emptyText||(V||iu)("Table"),internalHooks:Pi,internalRefs:le,transformColumns:it})),At))}var I4=s.forwardRef(O4),lr=I4;lr.SELECTION_COLUMN=br;lr.EXPAND_COLUMN=na.EXPAND_COLUMN;lr.SELECTION_ALL=ws;lr.SELECTION_INVERT=Ps;lr.SELECTION_NONE=Es;lr.Column=kb;lr.ColumnGroup=Fb;lr.Summary=tm;const Ca=lr;var _4=globalThis&&globalThis.__rest||function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,n=Object.getOwnPropertySymbols(t);a1&&arguments[1]!==void 0?arguments[1]:"0",v=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;return d.map(function(m,h){var y="".concat(f,"-").concat(h),g=m[o.value],b=r.includes(g),x=c(m[o.children]||[],y,b),S=s.createElement(Ru,m,x.map(function(E){return E.node}));if(e===g&&(l=S),b){var w={pos:y,node:S,children:x};return v||i.push(w),w}return null}).filter(function(m){return m})}i||(i=[],c(n),i.sort(function(d,f){var v=d.node.props.value,m=f.node.props.value,h=r.indexOf(v),y=r.indexOf(m);return h-y}))}Object.defineProperty(t,"triggerNode",{get:function(){return rn(!1,"`triggerNode` is deprecated. Please consider decoupling data with node."),u(),l}}),Object.defineProperty(t,"allCheckedNodes",{get:function(){return rn(!1,"`allCheckedNodes` is deprecated. Please consider decoupling data with node."),u(),a?i:i.map(function(d){var f=d.node;return f})}})}function Y4(t,e){var r=e.id,n=e.pId,a=e.rootPId,o={},l=[],i=t.map(function(u){var c=p({},u),d=c[r];return o[d]=c,c.key=c.key||d,c});return i.forEach(function(u){var c=u[n],d=o[c];d&&(d.children=d.children||[],d.children.push(u)),(c===a||!d&&a===null)&&l.push(u)}),l}function G4(t,e,r){return s.useMemo(function(){return t?r?Y4(t,p({id:"id",pId:"pId",rootPId:null},r!==!0?r:{})):t:Dm(e)},[e,r,t])}const q4=function(t){var e=s.useRef({valueLabels:new Map});return s.useMemo(function(){var r=e.current.valueLabels,n=new Map,a=t.map(function(o){var l,i=o.value,u=(l=o.label)!==null&&l!==void 0?l:r.get(i);return n.set(i,u),p(p({},o),{},{label:u})});return e.current.valueLabels=n,[a]},[t])};function ud(t){var e=s.useRef();e.current=t;var r=s.useCallback(function(){return e.current.apply(e,arguments)},[]);return r}const X4=function(t,e){return s.useMemo(function(){var r=Lo(t,{fieldNames:e,initWrapper:function(a){return p(p({},a),{},{valueEntities:new Map})},processEntity:function(a,o){var l=a.node[e.value];o.valueEntities.set(l,a)}});return r},[t,e])},Z4=function(t,e,r,n){return s.useMemo(function(){var a=t.map(function(u){var c=u.value;return c}),o=e.map(function(u){var c=u.value;return c}),l=a.filter(function(u){return!n[u]});if(r){var i=wn(a,!0,n);a=i.checkedKeys,o=i.halfCheckedKeys}return[Array.from(new Set([].concat(De(l),De(a)))),o]},[t,e,r,n])},Q4=function(t,e,r){var n=r.treeNodeFilterProp,a=r.filterTreeNode,o=r.fieldNames,l=o.children;return s.useMemo(function(){if(!e||a===!1)return t;var i;if(typeof a=="function")i=a;else{var u=e.toUpperCase();i=function(f,v){var m=v[n];return String(m).toUpperCase().includes(u)}}function c(d){var f=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return d.map(function(v){var m=v[l],h=f||i(e,Ms(v)),y=c(m||[],h);return h||y.length?p(p({},v),{},B({isLeaf:void 0},l,y)):null}).filter(function(v){return v})}return c(t)},[t,e,l,n,a])};var J4=["id","prefixCls","value","defaultValue","onChange","onSelect","onDeselect","searchValue","inputValue","onSearch","autoClearSearchValue","filterTreeNode","treeNodeFilterProp","showCheckedStrategy","treeNodeLabelProp","multiple","treeCheckable","treeCheckStrictly","labelInValue","fieldNames","treeDataSimpleMode","treeData","children","loadData","treeLoadedKeys","onTreeLoad","treeDefaultExpandAll","treeExpandedKeys","treeDefaultExpandedKeys","onTreeExpand","treeExpandAction","virtual","listHeight","listItemHeight","onDropdownVisibleChange","dropdownMatchSelectWidth","treeLine","treeIcon","showTreeIcon","switcherIcon","treeMotion"];function e3(t){return!t||Ve(t)!=="object"}var t3=s.forwardRef(function(t,e){var r=t.id,n=t.prefixCls,a=n===void 0?"rc-tree-select":n,o=t.value,l=t.defaultValue,i=t.onChange,u=t.onSelect,c=t.onDeselect,d=t.searchValue,f=t.inputValue,v=t.onSearch,m=t.autoClearSearchValue,h=m===void 0?!0:m,y=t.filterTreeNode,g=t.treeNodeFilterProp,b=g===void 0?"value":g,x=t.showCheckedStrategy,S=x===void 0?gl:x,w=t.treeNodeLabelProp,E=t.multiple,P=t.treeCheckable,T=t.treeCheckStrictly,M=t.labelInValue,R=t.fieldNames,D=t.treeDataSimpleMode,O=t.treeData,$=t.children,F=t.loadData,N=t.treeLoadedKeys,k=t.onTreeLoad,I=t.treeDefaultExpandAll,L=t.treeExpandedKeys,j=t.treeDefaultExpandedKeys,_=t.onTreeExpand,A=t.treeExpandAction,K=t.virtual,z=t.listHeight,V=z===void 0?200:z,X=t.listItemHeight,W=X===void 0?20:X,Z=t.onDropdownVisibleChange,U=t.dropdownMatchSelectWidth,ae=U===void 0?!0:U,q=t.treeLine,te=t.treeIcon,ue=t.showTreeIcon,Y=t.switcherIcon,J=t.treeMotion,Q=Le(t,J4),ie=Gf(r),le=P&&!T,ge=P||T,Pe=T||M,ve=ge||E,ce=xt(l,{value:o}),fe=ee(ce,2),oe=fe[0],se=fe[1],he=s.useMemo(function(){return V4(R)},[JSON.stringify(R)]),be=xt("",{value:d!==void 0?d:f,postState:function(tt){return tt||""}}),ke=ee(be,2),Fe=ke[0],Ee=ke[1],Re=function(tt){Ee(tt),v==null||v(tt)},we=G4(O,$,D),Ge=X4(we,he),Qe=Ge.keyEntities,ct=Ge.valueEntities,dt=s.useCallback(function(et){var tt=[],lt=[];return et.forEach(function(ut){ct.has(ut)?lt.push(ut):tt.push(ut)}),{missingRawValues:tt,existRawValues:lt}},[ct]),mt=Q4(we,Fe,{fieldNames:he,treeNodeFilterProp:b,filterTreeNode:y}),We=s.useCallback(function(et){if(et){if(w)return et[w];for(var tt=he._title,lt=0;lt=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(c){throw c},f:a}}throw new TypeError(`Invalid attempt to iterate non-iterable instance. +import{w as mo,r as s,a as ee,M as lp,C as Ut,z as Ve,c as pe,b as B,d as re,A as Ft,i as p,e as qs,N as Rt,O as en,_ as De,Q as Xs,T as rn,G as gn,U as yn,F as bn,E as Cn,K as Le,S as ko,V as Gi,L as Ma,W as Zs,X as Sf,Y as Qs,R as G,y as Js,Z as Jl,$ as sp,a0 as up,a1 as cp,a2 as dp,a3 as fp,J as Vn,a4 as vp,a5 as mp,a6 as hp,a7 as Yu,a8 as Jr,a9 as wf,aa as or,ab as qi,ac as ea,ad as pp,g as Na,ae as Pf,af as gp,ag as rt,j as C,ah as Ef,ai as Rf,aj as pt,ak as $e,m as $l,al as mn,am as hn,an as yp,k as di,t as kf}from"./umi-a12c8253.js";import{b as Ff,R as Fo,P as bp,K as Ye,i as Mf,u as xt,c as Cp,d as Gu,F as Xi,g as Zi,e as Rr,f as Nf,h as Qi,a as tr,E as Tf,T as un,j as Ji,p as eu,k as xp,C as ha,l as Sp,S as Gt}from"./TextArea-ec8ab387.js";import{i as wp,a as Pp,T as pa,C as $f}from"./index-dfec1b5b.js";import{T as Ep,s as tu,a as ro,F as _t,I as Xr,b as Rp,D as Df,S as Of,R as kp}from"./useDebounce-b5b4777f.js";import{d as qu,r as Fp,e as nu,f as Mo,P as Mp,D as Np,g as Xu,h as Zu,I as Pn,S as If,E as Qu,R as zn,C as qt,j as Tp}from"./util-590d1471.js";import{t as ir,u as el,B as Dn}from"./button-f56a19a0.js";import{c as ho,o as tl,t as $p,_ as ru,a as _f,b as Lf,e as au,d as jf,f as Af,g as Kf,h as Vf,j as zf,k as nl,l as Dp,i as Ju,m as ou,n as Fr,p as Bf,q as Op,r as Hf,s as Wf,u as Uf,v as Yf,w as Ip,x as _p}from"./_setToString-ca5ad23e.js";import{u as rl,b as Gf,B as qf,d as iu,g as Xf,a as Mr,L as Lp,c as po,S as jp,D as Ap}from"./index-c353c509.js";import{S as kr,a as Kp,d as Vp}from"./index-40bfaf7c.js";import{_ as No,D as To,a as lu,O as zp,P as Bp,M as Hp}from"./index-a2a53045.js";import{D as Zf}from"./DeleteOutlined-e5d1e611.js";import{C as Wp,P as Qf,a as Up}from"./progress-81ce73da.js";import{A as Yp}from"./index-868eaf8d.js";function es(t){return t!=null&&t===t.window}function Gp(t,e){var r,n;if(typeof window>"u")return 0;var a=e?"scrollTop":"scrollLeft",o=0;return es(t)?o=t[e?"pageYOffset":"pageXOffset"]:t instanceof Document?o=t.documentElement[a]:(t instanceof HTMLElement||t)&&(o=t[a]),t&&!es(t)&&typeof o!="number"&&(o=(n=((r=t.ownerDocument)!==null&&r!==void 0?r:t).documentElement)===null||n===void 0?void 0:n[a]),o}function qp(t,e,r,n){var a=r-e;return t/=n/2,t<1?a/2*t*t*t+e:a/2*((t-=2)*t*t+2)+e}function Xp(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=e.getContainer,n=r===void 0?function(){return window}:r,a=e.callback,o=e.duration,l=o===void 0?450:o,i=n(),u=Gp(i,!0),c=Date.now(),d=function f(){var v=Date.now(),m=v-c,h=qp(m>l?l:m,u,t,l);es(i)?i.scrollTo(window.pageXOffset,h):i instanceof Document||i.constructor.name==="HTMLDocument"?i.documentElement.scrollTop=h:i.scrollTop=h,m0&&arguments[0]!==void 0?arguments[0]:!0,e=s.useRef({}),r=Ff();return s.useEffect(function(){var n=qu.subscribe(function(a){e.current=a,t&&r()});return function(){return qu.unsubscribe(n)}},[]),e.current}var ts=s.createContext("default"),ec=function(e){var r=e.children,n=e.size;return s.createElement(ts.Consumer,null,function(a){return s.createElement(ts.Provider,{value:n||a},r)})},Zp=globalThis&&globalThis.__rest||function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,n=Object.getOwnPropertySymbols(t);af?"".concat(f,"+"):c,$=O==="0"||O===0,F=c===null||$&&!E,N=(o!=null||i!=null)&&F,k=m&&!$,I=k?"":O,L=s.useMemo(function(){var ue=I==null||I==="";return(ue||$&&!E)&&!k},[I,$,E,k]),j=s.useRef(c);L||(j.current=c);var _=j.current,A=s.useRef(I);L||(A.current=I);var K=A.current,z=s.useRef(k);L||(z.current=k);var V=s.useMemo(function(){if(!b)return re({},x);var ue={marginTop:b[1]};return R==="rtl"?ue.left=parseInt(b[0],10):ue.right=-parseInt(b[0],10),re(re({},ue),x)},[R,b,x]),X=g??(typeof _=="string"||typeof _=="number"?_:void 0),W=L||!l?null:s.createElement("span",{className:"".concat(D,"-status-text")},l),Z=!_||Ve(_)!=="object"?void 0:ho(_,function(ue){return{style:re(re({},V),ue.style)}}),U=pe(B(B(B({},"".concat(D,"-status-dot"),N),"".concat(D,"-status-").concat(o),!!o),"".concat(D,"-status-").concat(i),Ja(i))),ae={};i&&!Ja(i)&&(ae.background=i);var q=pe(D,B(B(B({},"".concat(D,"-status"),N),"".concat(D,"-not-a-wrapper"),!a),"".concat(D,"-rtl"),R==="rtl"),S);if(!a&&N){var te=V.color;return s.createElement("span",re({},P,{className:q,style:V}),s.createElement("span",{className:U,style:ae}),l&&s.createElement("span",{style:{color:te},className:"".concat(D,"-status-text")},l))}return s.createElement("span",re({},P,{className:q}),a,s.createElement(qs,{visible:!L,motionName:"".concat(D,"-zoom"),motionAppear:!1,motionDeadline:1e3},function(ue){var Y=ue.className,J=M("scroll-number",n),Q=z.current,ie=pe(B(B(B(B(B(B({},"".concat(D,"-dot"),Q),"".concat(D,"-count"),!Q),"".concat(D,"-count-sm"),y==="small"),"".concat(D,"-multiple-words"),!Q&&K&&K.toString().length>1),"".concat(D,"-status-").concat(o),!!o),"".concat(D,"-status-").concat(i),Ja(i))),le=re({},V);return i&&!Ja(i)&&(le=le||{},le.background=i),s.createElement(mg,{prefixCls:J,show:!L,motionClassName:Y,className:ie,count:K,title:X,style:le,key:"scrollNumber"},Z)}),W)};tv.Ribbon=ug;const Mn=tv;var pg={getNow:function(){return Rt()},getFixedDate:function(e){return Rt(e,"YYYY-MM-DD")},getEndDate:function(e){var r=e.clone();return r.endOf("month")},getWeekDay:function(e){var r=e.clone().locale("en_US");return r.weekday()+r.localeData().firstDayOfWeek()},getYear:function(e){return e.year()},getMonth:function(e){return e.month()},getDate:function(e){return e.date()},getHour:function(e){return e.hour()},getMinute:function(e){return e.minute()},getSecond:function(e){return e.second()},addYear:function(e,r){var n=e.clone();return n.add(r,"year")},addMonth:function(e,r){var n=e.clone();return n.add(r,"month")},addDate:function(e,r){var n=e.clone();return n.add(r,"day")},setYear:function(e,r){var n=e.clone();return n.year(r)},setMonth:function(e,r){var n=e.clone();return n.month(r)},setDate:function(e,r){var n=e.clone();return n.date(r)},setHour:function(e,r){var n=e.clone();return n.hour(r)},setMinute:function(e,r){var n=e.clone();return n.minute(r)},setSecond:function(e,r){var n=e.clone();return n.second(r)},isAfter:function(e,r){return e.isAfter(r)},isValidate:function(e){return e.isValid()},locale:{getWeekFirstDay:function(e){var r=Rt().locale(e);return r.localeData().firstDayOfWeek()},getWeekFirstDate:function(e,r){var n=r.clone(),a=n.locale(e);return a.weekday(0)},getWeek:function(e,r){var n=r.clone(),a=n.locale(e);return a.week()},getShortWeekDays:function(e){var r=Rt().locale(e);return r.localeData().weekdaysMin()},getShortMonths:function(e){var r=Rt().locale(e);return r.localeData().monthsShort()},format:function(e,r,n){var a=r.clone(),o=a.locale(e);return o.format(n)},parse:function(e,r,n){for(var a=[],o=0;o1&&(l=e.addDate(l,-7)),l}function oo(t,e,r){var n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:1;switch(e){case"year":return r.addYear(t,n*10);case"quarter":case"month":return r.addYear(t,n);default:return r.addMonth(t,n)}}function Jt(t,e){var r=e.generateConfig,n=e.locale,a=e.format;return typeof a=="function"?a(t):r.locale.format(n.locale,t,a)}function uv(t,e){var r=e.generateConfig,n=e.locale,a=e.formatList;return!t||typeof a[0]=="function"?null:r.locale.parse(n.locale,t,a)}function os(t){var e=t.cellDate,r=t.mode,n=t.disabledDate,a=t.generateConfig;if(!n)return!1;var o=function(h,y,g){for(var b=y;b<=g;){var x=void 0;switch(h){case"date":{if(x=a.setDate(e,b),!n(x))return!1;break}case"month":{if(x=a.setMonth(e,b),!os({cellDate:x,mode:"month",generateConfig:a,disabledDate:n}))return!1;break}case"year":{if(x=a.setYear(e,b),!os({cellDate:x,mode:"year",generateConfig:a,disabledDate:n}))return!1;break}}b+=1}return!0};switch(r){case"date":case"week":return n(e);case"month":{var l=1,i=a.getDate(a.getEndDate(e));return o("date",l,i)}case"quarter":{var u=Math.floor(a.getMonth(e)/3)*3,c=u+2;return o("month",u,c)}case"year":return o("month",0,11);case"decade":{var d=a.getYear(e),f=Math.floor(d/Tn)*Tn,v=f+Tn-1;return o("year",f,v)}}}function Ig(t){var e=s.useContext(pn),r=e.hideHeader;if(r)return null;var n=t.prefixCls,a=t.generateConfig,o=t.locale,l=t.value,i=t.format,u="".concat(n,"-header");return s.createElement(Ta,{prefixCls:u},l?Jt(l,{locale:o,format:i,generateConfig:a}):" ")}function _g(t){var e=t.value,r=t.generateConfig,n=t.disabledMinutes,a=t.disabledSeconds,o=t.minutes,l=t.seconds,i=t.use12Hours,u=function(d,f,v,m){var h=e||r.getNow(),y=Math.max(0,f),g=Math.max(0,v),b=Math.max(0,m),x=n&&n(y);if(x!=null&&x.includes(g)){var S=o.find(function(P){return!x.includes(P.value)});if(S)g=S.value;else return null}var w=a&&a(y,g);if(w!=null&&w.includes(b)){var E=l.find(function(P){return!w.includes(P.value)});if(E)b=E.value;else return null}return h=nv(r,h,!i||!d?y:y+12,g,b),h};return u}function cv(t,e){for(var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"0",n=String(t);n.length=1?r|0:1,l=t;l<=e;l+=o)a.push({label:cv(l,2),value:l,disabled:(n||[]).includes(l)});return a}function Ag(t){var e=t.generateConfig,r=t.prefixCls,n=t.operationRef,a=t.activeColumnIndex,o=t.value,l=t.showHour,i=t.showMinute,u=t.showSecond,c=t.use12Hours,d=t.hourStep,f=d===void 0?1:d,v=t.minuteStep,m=v===void 0?1:v,h=t.secondStep,y=h===void 0?1:h,g=t.disabledHours,b=t.disabledMinutes,x=t.disabledSeconds,S=t.disabledTime,w=t.hideDisabledOptions,E=t.onSelect,P=[],T="".concat(r,"-content"),M="".concat(r,"-time-panel"),R,D=o?e.getHour(o):-1,O=D,$=o?e.getMinute(o):-1,F=o?e.getSecond(o):-1,N=e.getNow(),k=s.useMemo(function(){if(S){var Y=S(N);return[Y.disabledHours,Y.disabledMinutes,Y.disabledSeconds]}return[g,b,x]},[g,b,x,S,N]),I=ee(k,3),L=I[0],j=I[1],_=I[2],A=Dl(0,23,f,L&&L()),K=Xs(function(){return A},A,jg);c&&(R=O>=12,O%=12);var z=s.useMemo(function(){if(!c)return[!1,!1];var Y=[!0,!0];return K.forEach(function(J){var Q=J.disabled,ie=J.value;Q||(ie>=12?Y[1]=!1:Y[0]=!1)}),Y},[c,K]),V=ee(z,2),X=V[0],W=V[1],Z=s.useMemo(function(){return c?K.filter(R?function(Y){return Y.value>=12}:function(Y){return Y.value<12}).map(function(Y){var J=Y.value%12,Q=J===0?"12":cv(J,2);return p(p({},Y),{},{label:Q,value:J})}):K},[c,R,K]),U=Dl(0,59,m,j&&j(D)),ae=Dl(0,59,y,_&&_(D,$)),q=_g({value:o,generateConfig:e,disabledMinutes:j,disabledSeconds:_,minutes:U,seconds:ae,use12Hours:c});n.current={onUpDown:function(J){var Q=P[a];if(Q)for(var ie=Q.units.findIndex(function(ve){return ve.value===Q.value}),le=Q.units.length,ge=1;ge2&&arguments[2]!==void 0?arguments[2]:!1;(we===y||it)&&(fe(xe),T&&T(xe),ae&&ae(xe,qe),M&&!ga(i,xe,ce)&&!(v!=null&&v(xe))&&M(xe))},ot=function(xe){if(a0.includes(we)){var qe,it,ft=we==="date";switch(xe===Ye.PAGE_UP||xe===Ye.PAGE_DOWN?it=ft?i.addMonth:i.addYear:it=ft?i.addDate:i.addMonth,xe){case Ye.LEFT:case Ye.PAGE_UP:qe=it(he,-1);break;case Ye.RIGHT:case Ye.PAGE_DOWN:qe=it(he,1);break;case Ye.UP:case Ye.DOWN:qe=it(he,Number("".concat(xe===Ye.UP?"-":"").concat(ft?ao:cu)));break}if(qe)return!(v!=null&&v(qe))}return!0},Je=function(xe){if(le.current&&le.current.onKeyDown){var qe=!0,it=xe.which;if([Ye.LEFT,Ye.RIGHT,Ye.UP,Ye.DOWN,Ye.PAGE_UP,Ye.PAGE_DOWN,Ye.ENTER].includes(it)&&(xe.preventDefault(),it!==Ye.ENTER&&b===0&&(qe=ot(it))),qe)return le.current.onKeyDown(xe)}return rn(!1,"Panel not correct handle keyDown event. Please help to fire issue about this."),!1},Se=function(xe){le.current&&le.current.onBlur&&le.current.onBlur(xe)};Z&&J!=="right"&&(Z.current={onKeyDown:Je,onClose:function(){le.current&&le.current.onClose&&le.current.onClose()}}),s.useEffect(function(){u&&!ge.current&&be(u)},[u]),s.useEffect(function(){ge.current=!1},[]);var He,je=p(p({},t),{},{operationRef:le,prefixCls:n,viewDate:he,value:ce,onViewDateChange:ke,sourceMode:dt,onPanelChange:We,disabledDate:v});switch(delete je.onChange,delete je.onSelect,we){case"decade":He=s.createElement(Tg,re({},je,{onSelect:function(xe,qe){ke(xe),Oe(xe,qe)}}));break;case"year":He=s.createElement(r0,re({},je,{onSelect:function(xe,qe){ke(xe),Oe(xe,qe)}}));break;case"month":He=s.createElement(qg,re({},je,{onSelect:function(xe,qe){ke(xe),Oe(xe,qe)}}));break;case"quarter":He=s.createElement(e0,re({},je,{onSelect:function(xe,qe){ke(xe),Oe(xe,qe)}}));break;case"week":He=s.createElement(Wg,re({},je,{onSelect:function(xe,qe){ke(xe),Oe(xe,qe)}}));break;case"time":delete je.showTime,He=s.createElement(vv,re({},je,Ve(S)==="object"?S:null,{onSelect:function(xe,qe){ke(xe),Oe(xe,qe)}}));break;default:S?He=s.createElement(Hg,re({},je,{onSelect:function(xe,qe){ke(xe),Oe(xe,qe)}})):He=s.createElement(uu,re({},je,{onSelect:function(xe,qe){ke(xe),Oe(xe,qe)}}))}var ze,ye,de=function(){var xe=i.getNow(),qe=Cg(i.getHour(xe),i.getMinute(xe),i.getSecond(xe),z?I:1,V?j:1,X?A:1),it=nv(i,xe,qe[0],qe[1],qe[2]);Oe(it,"submit")};q||(ze=mv(n,we,E),ye=hv({prefixCls:n,components:F,needConfirmButton:K,okDisabled:!ce||v&&v(ce),locale:l,showNow:x,onNow:K&&de,onOk:function(){ce&&(Oe(ce,"submit",!0),$&&$(ce))}}));var Ce;if(w&&we==="date"&&y==="date"&&!S){var Me=i.getNow(),Be="".concat(n,"-today-btn"),nt=v&&v(Me);Ce=s.createElement("a",{className:pe(Be,nt&&"".concat(Be,"-disabled")),"aria-disabled":nt,onClick:function(){nt||Oe(Me,"mouse",!0)}},l.today)}return s.createElement(pn.Provider,{value:p(p({},W),{},{mode:we,hideHeader:"hideHeader"in t?P:W.hideHeader,hidePrevBtn:Y&&J==="right",hideNextBtn:Y&&J==="left"})},s.createElement("div",{tabIndex:b,className:pe("".concat(n,"-panel"),a,(e={},B(e,"".concat(n,"-panel-has-range"),Q&&Q[0]&&Q[1]),B(e,"".concat(n,"-panel-has-range-hover"),ie&&ie[0]&&ie[1]),B(e,"".concat(n,"-panel-rtl"),N==="rtl"),e)),style:o,onKeyDown:Je,onBlur:Se,onMouseDown:D,ref:U},He,ze||ye||Ce?s.createElement("div",{className:"".concat(n,"-footer")},ze,ye,Ce):null))}var o0={bottomLeft:{points:["tl","bl"],offset:[0,4],overflow:{adjustX:1,adjustY:1}},bottomRight:{points:["tr","br"],offset:[0,4],overflow:{adjustX:1,adjustY:1}},topLeft:{points:["bl","tl"],offset:[0,-4],overflow:{adjustX:0,adjustY:1}},topRight:{points:["br","tr"],offset:[0,-4],overflow:{adjustX:0,adjustY:1}}};function gv(t){var e,r=t.prefixCls,n=t.popupElement,a=t.popupStyle,o=t.visible,l=t.dropdownClassName,i=t.dropdownAlign,u=t.transitionName,c=t.getPopupContainer,d=t.children,f=t.range,v=t.popupPlacement,m=t.direction,h="".concat(r,"-dropdown"),y=function(){return v!==void 0?v:m==="rtl"?"bottomRight":"bottomLeft"};return s.createElement(Cp,{showAction:[],hideAction:[],popupPlacement:y(),builtinPlacements:o0,prefixCls:h,popupTransitionName:u,popup:n,popupAlign:i,popupVisible:o,popupClassName:pe(l,(e={},B(e,"".concat(h,"-range"),f),B(e,"".concat(h,"-rtl"),m==="rtl"),e)),popupStyle:a,getPopupContainer:c},d)}function ls(t){var e=t.open,r=t.value,n=t.isClickOutside,a=t.triggerOpen,o=t.forwardKeyDown,l=t.onKeyDown,i=t.blurToCancel,u=t.onSubmit,c=t.onCancel,d=t.onFocus,f=t.onBlur,v=t.currentFocusedKey,m=t.key,h=m===void 0?"start":m,y=s.useState(!1),g=ee(y,2),b=g[0],x=g[1],S=s.useState(!1),w=ee(S,2),E=w[0],P=w[1],T=s.useRef(),M=s.useRef(!1),R=s.useRef(!1),D=s.useRef(!1),O={onMouseDown:function(){x(!0),a(!0)},onKeyDown:function(F){var N=function(){D.current=!0};if(l(F,N),!D.current){switch(F.which){case Ye.ENTER:{e?u()!==!1&&x(!0):a(!0),F.preventDefault();return}case Ye.TAB:{b&&e&&!F.shiftKey?(x(!1),F.preventDefault()):!b&&e&&!o(F)&&F.shiftKey&&(x(!0),F.preventDefault());return}case Ye.ESC:{x(!0),c();return}}!e&&![Ye.SHIFT].includes(F.which)?a(!0):b||o(F)}},onFocus:function(F){x(!0),P(!0),v&&(v.current=h),clearTimeout(T.current),d&&d(F)},onBlur:function(F){if(M.current||!n(document.activeElement)){M.current=!1;return}i?setTimeout(function(){for(var N=document,k=N.activeElement;k&&k.shadowRoot;)k=k.shadowRoot.activeElement;n(k)&&c()},0):e&&(a(!1),R.current&&u()),P(!1),v?(v.current="",T.current=setTimeout(function(){v.current||f==null||f(F)},100)):f==null||f(F)}};return s.useEffect(function(){R.current=!1},[e]),s.useEffect(function(){R.current=!0},[r]),s.useEffect(function(){return Pg(function($){var F=Eg($),N=n(F);e?N?(!E||N)&&a(!1):(M.current=!0,requestAnimationFrame(function(){M.current=!1})):E&&!N&&(M.current=!0)})}),s.useEffect(function(){return function(){return clearTimeout(T.current)}},[]),[O,{focused:E,typing:b}]}function ss(t){var e=t.valueTexts,r=t.onTextChange,n=s.useState(""),a=ee(n,2),o=a[0],l=a[1],i=s.useRef([]);i.current=e;function u(d){l(d),r(d)}function c(){l(i.current[0])}return s.useEffect(function(){e.every(function(d){return d!==o})&&c()},[e.join("||")]),[o,u,c]}function Mi(t,e){var r=e.formatList,n=e.generateConfig,a=e.locale;return Xs(function(){if(!t)return[[""],""];for(var o="",l=[],i=0;i1&&arguments[1]!==void 0?arguments[1]:!1;if(cancelAnimationFrame(c.current),b){u(g);return}c.current=requestAnimationFrame(function(){u(g)})}var f=Mi(i,{formatList:r,generateConfig:n,locale:a}),v=ee(f,2),m=v[1];function h(g){d(g)}function y(){var g=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1;d(null,g)}return s.useEffect(function(){y(!0)},[t]),s.useEffect(function(){return function(){return cancelAnimationFrame(c.current)}},[]),[m,h,y]}function i0(t){var e,r=t.prefixCls,n=r===void 0?"rc-picker":r,a=t.id,o=t.tabIndex,l=t.style,i=t.className,u=t.dropdownClassName,c=t.dropdownAlign,d=t.popupStyle,f=t.transitionName,v=t.generateConfig,m=t.locale,h=t.inputReadOnly,y=t.allowClear,g=t.autoFocus,b=t.showTime,x=t.picker,S=x===void 0?"date":x,w=t.format,E=t.use12Hours,P=t.value,T=t.defaultValue,M=t.open,R=t.defaultOpen,D=t.defaultOpenValue,O=t.suffixIcon,$=t.clearIcon,F=t.disabled,N=t.disabledDate,k=t.placeholder,I=t.getPopupContainer,L=t.pickerRef,j=t.panelRender,_=t.onChange,A=t.onOpenChange,K=t.onFocus,z=t.onBlur,V=t.onMouseDown,X=t.onMouseUp,W=t.onMouseEnter,Z=t.onMouseLeave,U=t.onContextMenu,ae=t.onClick,q=t.onKeyDown,te=t.onSelect,ue=t.direction,Y=t.autoComplete,J=Y===void 0?"off":Y,Q=t.inputRender,ie=s.useRef(null),le=S==="date"&&!!b||S==="time",ge=dv(av(w,S,b,E)),Pe=s.useRef(null),ve=s.useRef(null),ce=s.useRef(null),fe=xt(null,{value:P,defaultValue:T}),oe=ee(fe,2),se=oe[0],he=oe[1],be=s.useState(se),ke=ee(be,2),Fe=ke[0],Ee=ke[1],Re=s.useRef(null),we=xt(!1,{value:M,defaultValue:R,postState:function(_e){return F?!1:_e},onChange:function(_e){A&&A(_e),!_e&&Re.current&&Re.current.onClose&&Re.current.onClose()}}),Ge=ee(we,2),Qe=Ge[0],ct=Ge[1],dt=Mi(Fe,{formatList:ge,generateConfig:v,locale:m}),mt=ee(dt,2),We=mt[0],Oe=mt[1],ot=ss({valueTexts:We,onTextChange:function(_e){var at=uv(_e,{locale:m,formatList:ge,generateConfig:v});at&&(!N||!N(at))&&Ee(at)}}),Je=ee(ot,3),Se=Je[0],He=Je[1],je=Je[2],ze=function(_e){Ee(_e),he(_e),_&&!ga(v,se,_e)&&_(_e,_e?Jt(_e,{generateConfig:v,locale:m,format:ge[0]}):"")},ye=function(_e){F&&_e||ct(_e)},de=function(_e){return Qe&&Re.current&&Re.current.onKeyDown?Re.current.onKeyDown(_e):(rn(!1,"Picker not correct forward KeyDown operation. Please help to fire issue about this."),!1)},Ce=function(){for(var _e=arguments.length,at=new Array(_e),Ot=0;Ot<_e;Ot++)at[Ot]=arguments[Ot];ae==null||ae.apply(void 0,at),ie.current&&(ie.current.focus(),ye(!0))},Me=ls({blurToCancel:le,open:Qe,value:Se,triggerOpen:ye,forwardKeyDown:de,isClickOutside:function(_e){return!iv([Pe.current,ve.current,ce.current],_e)},onSubmit:function(){return!Fe||N&&N(Fe)?!1:(ze(Fe),ye(!1),je(),!0)},onCancel:function(){ye(!1),Ee(se),je()},onKeyDown:function(_e,at){q==null||q(_e,at)},onFocus:K,onBlur:z}),Be=ee(Me,2),nt=Be[0],Ne=Be[1],xe=Ne.focused,qe=Ne.typing;s.useEffect(function(){Qe||(Ee(se),!We.length||We[0]===""?He(""):Oe!==Se&&je())},[Qe,We]),s.useEffect(function(){Qe||je()},[S]),s.useEffect(function(){Ee(se)},[se]),L&&(L.current={focus:function(){ie.current&&ie.current.focus()},blur:function(){ie.current&&ie.current.blur()}});var it=us(Se,{formatList:ge,generateConfig:v,locale:m}),ft=ee(it,3),At=ft[0],Kt=ft[1],kt=ft[2],zt=p(p({},t),{},{className:void 0,style:void 0,pickerValue:void 0,onPickerValueChange:void 0,onChange:null}),et=s.createElement(pv,re({},zt,{generateConfig:v,className:pe(B({},"".concat(n,"-panel-focused"),!qe)),value:Fe,locale:m,tabIndex:-1,onSelect:function(_e){te==null||te(_e),Ee(_e)},direction:ue,onPanelChange:function(_e,at){var Ot=t.onPanelChange;kt(!0),Ot==null||Ot(_e,at)}}));j&&(et=j(et));var tt=s.createElement("div",{className:"".concat(n,"-panel-container"),onMouseDown:function(_e){_e.preventDefault()}},et),lt;O&&(lt=s.createElement("span",{className:"".concat(n,"-suffix")},O));var ut;y&&se&&!F&&(ut=s.createElement("span",{onMouseDown:function(_e){_e.preventDefault(),_e.stopPropagation()},onMouseUp:function(_e){_e.preventDefault(),_e.stopPropagation(),ze(null),ye(!1)},className:"".concat(n,"-clear"),role:"button"},$||s.createElement("span",{className:"".concat(n,"-clear-btn")})));var wt=p(p(p({id:a,tabIndex:o,disabled:F,readOnly:h||typeof ge[0]=="function"||!qe,value:At||Se,onChange:function(_e){He(_e.target.value)},autoFocus:g,placeholder:k,ref:ie,title:Se},nt),{},{size:ov(S,ge[0],v)},fv(t)),{},{autoComplete:J}),St=Q?Q(wt):s.createElement("input",wt),Ae=function(_e,at){(at==="submit"||at!=="key"&&!le)&&(ze(_e),ye(!1))},Ue=ue==="rtl"?"bottomRight":"bottomLeft";return s.createElement(pn.Provider,{value:{operationRef:Re,hideHeader:S==="time",panelRef:Pe,onSelect:Ae,open:Qe,defaultOpenValue:D,onDateMouseEnter:Kt,onDateMouseLeave:kt}},s.createElement(gv,{visible:Qe,popupElement:tt,popupStyle:d,prefixCls:n,dropdownClassName:u,dropdownAlign:c,getPopupContainer:I,transitionName:f,popupPlacement:Ue,direction:ue},s.createElement("div",{ref:ce,className:pe(n,i,(e={},B(e,"".concat(n,"-disabled"),F),B(e,"".concat(n,"-focused"),xe),B(e,"".concat(n,"-rtl"),ue==="rtl"),e)),style:l,onMouseDown:V,onMouseUp:X,onMouseEnter:W,onMouseLeave:Z,onContextMenu:U,onClick:Ce},s.createElement("div",{className:pe("".concat(n,"-input"),B({},"".concat(n,"-input-placeholder"),!!At)),ref:ve},St,lt,ut))))}var l0=function(t){gn(r,t);var e=yn(r);function r(){var n;bn(this,r);for(var a=arguments.length,o=new Array(a),l=0;lm(d);case"month":return v(g)>v(d);case"week":return f(g)>f(d);default:return!rr(u,g,d)&&u.isAfter(g,d)}return!1},[l,i[1],d,e]),y=s.useCallback(function(g){if(l&&l(g))return!0;if(i[0]&&c)return!rr(u,g,d)&&u.isAfter(c,g);if(r&&c)switch(n){case"quarter":return m(g)0&&arguments[0]!==void 0?arguments[0]:!1,Te=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},Xe=null;Ie&&Rn&&Rn[0]&&Rn[1]&&h.isAfter(Rn[1],Rn[0])&&(Xe=Rn);var yt=P;if(P&&Ve(P)==="object"&&P.defaultValue){var Bt=P.defaultValue;yt=p(p({},P),{},{defaultValue:Ct(Bt,Se)||void 0})}var zr=null;return L&&(zr=function(Fn,Ln){return L(Fn,Ln,{range:Se?"end":"start"})}),s.createElement(Da.Provider,{value:{inRange:!0,panelPosition:vt,rangedValue:vr||ft,hoverRangedValue:Xe}},s.createElement(pv,re({},t,Te,{dateRender:zr,showTime:yt,mode:zt[Se],generateConfig:h,style:void 0,direction:se,disabledDate:Se===0?wt:St,disabledTime:function(Fn){return I?I(Fn,Se===0?"start":"end"):!1},className:pe(B({},"".concat(o,"-panel-focused"),Se===0?!Ke:!an)),value:Ct(ft,Se),locale:y,tabIndex:-1,onPanelChange:function(Fn,Ln){Se===0&&Kr(!0),Se===1&&sa(!0),tt(xn(zt,Ln,Se),xn(ft,Fn,Se));var Zn=Fn;vt==="right"&&zt[Se]===Ln&&(Zn=oo(Zn,Ln,h,-1)),xe(Zn,Se)},onOk:null,onSelect:void 0,onChange:void 0,defaultValue:Se===0?Ct(ft,1):Ct(ft,0)})))}var gr=0,Bu=0;if(Se&&Ge.current&&ct.current&&we.current){gr=Ge.current.offsetWidth+ct.current.offsetWidth;var tp=We.current.offsetLeft>gr?We.current.offsetLeft-gr:We.current.offsetLeft;we.current.offsetWidth&&We.current.offsetWidth&&gr>we.current.offsetWidth-We.current.offsetWidth-(se==="rtl"?0:tp)&&(Bu=gr)}var np=se==="rtl"?{right:gr}:{left:gr};function rp(){var vt,Te=mv(o,zt[Se],U),Xe=hv({prefixCls:o,components:fe,needConfirmButton:Fe,okDisabled:!Ct(ft,Se)||k&&k(ft[Se]),locale:y,rangeList:ep,onOk:function(){Ct(ft,Se)&&(Gn(ft,Se),ve&&ve(ft))}});if(E!=="time"&&!P){var yt=Ne(Se),Bt=oo(yt,E,h),zr=zt[Se],Xn=zr===E,Fn=Ml(Xn?"left":!1,{pickerValue:yt,onPickerValueChange:function(dn){xe(dn,Se)}}),Ln=Ml("right",{pickerValue:Bt,onPickerValueChange:function(dn){xe(oo(dn,E,h,-1),Se)}});se==="rtl"?vt=s.createElement(s.Fragment,null,Ln,Xn&&Fn):vt=s.createElement(s.Fragment,null,Fn,Xn&&Ln)}else vt=Ml();var Zn=s.createElement(s.Fragment,null,s.createElement("div",{className:"".concat(o,"-panels")},vt),(Te||Xe)&&s.createElement("div",{className:"".concat(o,"-footer")},Te,Xe));return j&&(Zn=j(Zn)),s.createElement("div",{className:"".concat(o,"-panel-container"),style:{marginLeft:Bu},ref:we,onMouseDown:function(dn){dn.preventDefault()}},Zn)}var ap=s.createElement("div",{className:pe("".concat(o,"-range-wrapper"),"".concat(o,"-").concat(E,"-range-wrapper")),style:{minWidth:sn}},s.createElement("div",{ref:We,className:"".concat(o,"-range-arrow"),style:np}),rp()),Hu;z&&(Hu=s.createElement("span",{className:"".concat(o,"-suffix")},z));var Wu;K&&(Ct(Ce,0)&&!ze[0]||Ct(Ce,1)&&!ze[1])&&(Wu=s.createElement("span",{onMouseDown:function(Te){Te.preventDefault(),Te.stopPropagation()},onMouseUp:function(Te){Te.preventDefault(),Te.stopPropagation();var Xe=Ce;ze[0]||(Xe=xn(Xe,null,0)),ze[1]||(Xe=xn(Xe,null,1)),Gn(Xe,null),In(!1,Se)},className:"".concat(o,"-clear")},V||s.createElement("span",{className:"".concat(o,"-clear-btn")})));var Uu={size:ov(E,Oe[0],h)},Nl=0,Tl=0;Ge.current&&Qe.current&&ct.current&&(Se===0?Tl=Ge.current.offsetWidth:(Nl=gr,Tl=Qe.current.offsetWidth));var op=se==="rtl"?{right:Nl}:{left:Nl},ip=function(Te,Xe){var yt=xn(ft,Te,Se);Xe==="submit"||Xe!=="key"&&!Fe?(Gn(yt,Se),Se===0?Kr():sa()):At(yt)};return s.createElement(pn.Provider,{value:{operationRef:je,hideHeader:E==="time",onDateMouseEnter:Fl,onDateMouseLeave:oi,hideRanges:!0,onSelect:ip,open:Ie}},s.createElement(gv,{visible:Ie,popupElement:ap,popupStyle:c,prefixCls:o,dropdownClassName:d,dropdownAlign:v,getPopupContainer:m,transitionName:f,range:!0,direction:se},s.createElement("div",re({ref:Re,className:pe(o,"".concat(o,"-range"),u,(e={},B(e,"".concat(o,"-disabled"),ze[0]&&ze[1]),B(e,"".concat(o,"-focused"),Se===0?me:Mt),B(e,"".concat(o,"-rtl"),se==="rtl"),e)),style:i,onClick:on,onMouseEnter:le,onMouseLeave:ge,onMouseDown:Vr,onMouseUp:ie},fv(t)),s.createElement("div",{className:pe("".concat(o,"-input"),(r={},B(r,"".concat(o,"-input-active"),Se===0),B(r,"".concat(o,"-input-placeholder"),!!ni),r)),ref:Ge},s.createElement("input",re({id:l,disabled:ze[0],readOnly:W||typeof Oe[0]=="function"||!Ke,value:ni||fr,onChange:function(Te){ia(Te.target.value)},autoFocus:b,placeholder:Ct(g,0)||"",ref:dt},H,Uu,{autoComplete:ke}))),s.createElement("div",{className:"".concat(o,"-range-separator"),ref:ct},R),s.createElement("div",{className:pe("".concat(o,"-input"),(n={},B(n,"".concat(o,"-input-active"),Se===1),B(n,"".concat(o,"-input-placeholder"),!!pr),n)),ref:Qe},s.createElement("input",re({disabled:ze[1],readOnly:W||typeof Oe[0]=="function"||!an,value:pr||ht,onChange:function(Te){Nt(Te.target.value)},placeholder:Ct(g,1)||"",ref:mt},Tt,Uu,{autoComplete:ke}))),s.createElement("div",{className:"".concat(o,"-active-bar"),style:p(p({},op),{},{width:Tl,position:"absolute"})}),Hu,Wu)))}var v0=function(t){gn(r,t);var e=yn(r);function r(){var n;bn(this,r);for(var a=arguments.length,o=new Array(a),l=0;l=0;c-=1){var d=e.get(c)||new Set;d.forEach(function(f){var v=f.parent,m=f.node;if(!(n(m)||!f.parent||u.has(f.parent.key))){if(n(f.parent.node)){u.add(v.key);return}var h=!0,y=!1;(v.children||[]).filter(function(g){return!n(g.node)}).forEach(function(g){var b=g.key,x=a.has(b);h&&!x&&(h=!1),!y&&(x||o.has(b))&&(y=!0)}),h&&a.add(v.key),y&&o.add(v.key),u.add(v.key)}})}return{checkedKeys:Array.from(a),halfCheckedKeys:Array.from(yv(o,a))}}function p0(t,e,r,n,a){for(var o=new Set(t),l=new Set(e),i=0;i<=n;i+=1){var u=r.get(i)||new Set;u.forEach(function(v){var m=v.key,h=v.node,y=v.children,g=y===void 0?[]:y;!o.has(m)&&!l.has(m)&&!a(h)&&g.filter(function(b){return!a(b.node)}).forEach(function(b){o.delete(b.key)})})}l=new Set;for(var c=new Set,d=n;d>=0;d-=1){var f=r.get(d)||new Set;f.forEach(function(v){var m=v.parent,h=v.node;if(!(a(h)||!v.parent||c.has(v.parent.key))){if(a(v.parent.node)){c.add(m.key);return}var y=!0,g=!1;(m.children||[]).filter(function(b){return!a(b.node)}).forEach(function(b){var x=b.key,S=o.has(x);y&&!S&&(y=!1),!g&&(S||l.has(x))&&(g=!0)}),y||o.delete(m.key),g&&l.add(m.key),c.add(m.key)}})}return{checkedKeys:Array.from(o),halfCheckedKeys:Array.from(yv(l,o))}}function wn(t,e,r,n){var a=[],o;n?o=n:o=m0;var l=new Set(t.filter(function(d){var f=!!vn(r,d);return f||a.push(d),f})),i=new Map,u=0;Object.keys(r).forEach(function(d){var f=r[d],v=f.level,m=i.get(v);m||(m=new Set,i.set(v,m)),m.add(f),u=Math.max(u,v)}),rn(!a.length,"Tree missing follow keys: ".concat(a.slice(0,100).map(function(d){return"'".concat(d,"'")}).join(", ")));var c;return e===!0?c=h0(l,i,u,o):c=p0(l,e.halfCheckedKeys,i,u,o),c}var Io=s.createContext(null),du="__RC_CASCADER_SPLIT__",bv="SHOW_PARENT",Cv="SHOW_CHILD";function wr(t){return t.join(du)}function da(t){return t.map(wr)}function g0(t){return t.split(du)}function y0(t){var e=t||{},r=e.label,n=e.value,a=e.children,o=n||"value";return{label:r||"label",value:o,key:o,children:a||"children"}}function eo(t,e){var r,n;return(r=t.isLeaf)!==null&&r!==void 0?r:!(!((n=t[e.children])===null||n===void 0)&&n.length)}function b0(t){var e=t.parentElement;if(e){var r=t.offsetTop-e.offsetTop;r-e.scrollTop<0?e.scrollTo({top:r}):r+t.offsetHeight-e.scrollTop>e.offsetHeight&&e.scrollTo({top:r+t.offsetHeight-e.offsetHeight})}}function lc(t,e,r){var n=new Set(t),a=e();return t.filter(function(o){var l=a[o],i=l?l.parent:null,u=l?l.children:null;return r===Cv?!(u&&u.some(function(c){return c.key&&n.has(c.key)})):!(i&&!i.node.disabled&&n.has(i.key))})}function go(t,e,r){for(var n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1,a=e,o=[],l=function(){var c,d,f,v=t[i],m=(c=a)===null||c===void 0?void 0:c.findIndex(function(y){var g=y[r.value];return n?String(g)===String(v):g===v}),h=m!==-1?(d=a)===null||d===void 0?void 0:d[m]:null;o.push({value:(f=h==null?void 0:h[r.value])!==null&&f!==void 0?f:v,index:m,option:h}),a=h==null?void 0:h[r.children]},i=0;i1&&arguments[1]!==void 0?arguments[1]:null;return d.map(function(v,m){for(var h=xv(f?f.pos:"0",m),y=_o(v[o],h),g,b=0;b1&&arguments[1]!==void 0?arguments[1]:{},r=e.initWrapper,n=e.processEntity,a=e.onProcessFinished,o=e.externalGetKey,l=e.childrenPropName,i=e.fieldNames,u=arguments.length>2?arguments[2]:void 0,c=o||u,d={},f={},v={posEntities:d,keyEntities:f};return r&&(v=r(v)||v),w0(t,function(m){var h=m.node,y=m.index,g=m.pos,b=m.key,x=m.parentPos,S=m.level,w=m.nodes,E={node:h,nodes:w,index:y,key:b,pos:g,level:S},P=_o(b,g);d[g]=E,f[P]=E,E.parent=d[x],E.parent&&(E.parent.children=E.parent.children||[],E.parent.children.push(E)),n&&n(E,v)},{externalGetKey:c,childrenPropName:l,fieldNames:i}),a&&a(v),v}function io(t,e){var r=e.expandedKeys,n=e.selectedKeys,a=e.loadedKeys,o=e.loadingKeys,l=e.checkedKeys,i=e.halfCheckedKeys,u=e.dragOverNodeKey,c=e.dropPosition,d=e.keyEntities,f=vn(d,t),v={eventKey:t,expanded:r.indexOf(t)!==-1,selected:n.indexOf(t)!==-1,loaded:a.indexOf(t)!==-1,loading:o.indexOf(t)!==-1,checked:l.indexOf(t)!==-1,halfChecked:i.indexOf(t)!==-1,pos:String(f?f.pos:""),dragOver:u===t&&c===0,dragOverGapTop:u===t&&c===-1,dragOverGapBottom:u===t&&c===1};return v}function Wt(t){var e=t.data,r=t.expanded,n=t.selected,a=t.checked,o=t.loaded,l=t.loading,i=t.halfChecked,u=t.dragOver,c=t.dragOverGapTop,d=t.dragOverGapBottom,f=t.pos,v=t.active,m=t.eventKey,h=p(p({},e),{},{expanded:r,selected:n,checked:a,loaded:o,loading:l,halfChecked:i,dragOver:u,dragOverGapTop:c,dragOverGapBottom:d,pos:f,active:v,key:m});return"props"in h||Object.defineProperty(h,"props",{get:function(){return rn(!1,"Second param return from event is node data instead of TreeNode instance. Please read value directly instead of reading from `props`."),t}}),h}const P0=function(t,e){var r=s.useRef({options:null,info:null}),n=s.useCallback(function(){return r.current.options!==t&&(r.current.options=t,r.current.info=Lo(t,{fieldNames:e,initWrapper:function(o){return p(p({},o),{},{pathKeyEntities:{}})},processEntity:function(o,l){var i=o.nodes.map(function(u){return u[e.value]}).join(du);l.pathKeyEntities[i]=o,o.key=i}})),r.current.info.pathKeyEntities},[e,t]);return n},E0=function(t,e){return s.useCallback(function(r){var n=[],a=[];return r.forEach(function(o){var l=go(o,t,e);l.every(function(i){return i.option})?a.push(o):n.push(o)}),[a,n]},[t,e])};function sc(t){var e=s.useRef();e.current=t;var r=s.useCallback(function(){return e.current.apply(e,arguments)},[]);return r}function R0(t){return s.useMemo(function(){if(!t)return[!1,{}];var e={matchInputWidth:!0,limit:50};return t&&Ve(t)==="object"&&(e=p(p({},e),t)),e.limit<=0&&delete e.limit,[!0,e]},[t])}var lo="__rc_cascader_search_mark__",k0=function(e,r,n){var a=n.label;return r.some(function(o){return String(o[a]).toLowerCase().includes(e.toLowerCase())})},F0=function(e,r,n,a){return r.map(function(o){return o[a.label]}).join(" / ")};const M0=function(t,e,r,n,a,o){var l=a.filter,i=l===void 0?k0:l,u=a.render,c=u===void 0?F0:u,d=a.limit,f=d===void 0?50:d,v=a.sort;return s.useMemo(function(){var m=[];if(!t)return[];function h(y,g){y.forEach(function(b){if(!(!v&&f>0&&m.length>=f)){var x=[].concat(De(g),[b]),S=b[r.children];if((!S||S.length===0||o)&&i(t,x,{label:r.label})){var w;m.push(p(p({},b),{},(w={},B(w,r.label,c(t,x,n,r)),B(w,lo,x),B(w,r.children,void 0),w)))}S&&h(b[r.children],x)}})}return h(e,[]),v&&m.sort(function(y,g){return v(y[lo],g[lo],t,r)}),f>0?m.slice(0,f):m},[t,e,r,n,c,o,i,v,f])};function N0(t){var e,r=t.prefixCls,n=t.checked,a=t.halfChecked,o=t.disabled,l=t.onClick,i=s.useContext(Io),u=i.checkable,c=typeof u!="boolean"?u:null;return s.createElement("span",{className:pe("".concat(r),(e={},B(e,"".concat(r,"-checked"),n),B(e,"".concat(r,"-indeterminate"),!n&&a),B(e,"".concat(r,"-disabled"),o),e)),onClick:l},c)}var wv="__cascader_fix_label__";function T0(t){var e=t.prefixCls,r=t.multiple,n=t.options,a=t.activeValue,o=t.prevValuePath,l=t.onToggleOpen,i=t.onSelect,u=t.onActive,c=t.checkedSet,d=t.halfCheckedSet,f=t.loadingKeys,v=t.isSelectable,m="".concat(e,"-menu"),h="".concat(e,"-menu-item"),y=s.useContext(Io),g=y.fieldNames,b=y.changeOnSelect,x=y.expandTrigger,S=y.expandIcon,w=y.loadingIcon,E=y.dropdownMenuColumnStyle,P=x==="hover",T=s.useMemo(function(){return n.map(function(M){var R,D=M.disabled,O=M[lo],$=(R=M[wv])!==null&&R!==void 0?R:M[g.label],F=M[g.value],N=eo(M,g),k=O?O.map(function(A){return A[g.value]}):[].concat(De(o),[F]),I=wr(k),L=f.includes(I),j=c.has(I),_=d.has(I);return{disabled:D,label:$,value:F,isLeaf:N,isLoading:L,checked:j,halfChecked:_,option:M,fullPath:k,fullPathKey:I}})},[n,c,g,d,f,o]);return s.createElement("ul",{className:m,role:"menu"},T.map(function(M){var R,D=M.disabled,O=M.label,$=M.value,F=M.isLeaf,N=M.isLoading,k=M.checked,I=M.halfChecked,L=M.option,j=M.fullPath,_=M.fullPathKey,A=function(){if(!D){var X=De(j);P&&F&&X.pop(),u(X)}},K=function(){v(L)&&i(j,F)},z;return typeof L.title=="string"?z=L.title:typeof O=="string"&&(z=O),s.createElement("li",{key:_,className:pe(h,(R={},B(R,"".concat(h,"-expand"),!F),B(R,"".concat(h,"-active"),a===$),B(R,"".concat(h,"-disabled"),D),B(R,"".concat(h,"-loading"),N),R)),style:E,role:"menuitemcheckbox",title:z,"aria-checked":k,"data-path-key":_,onClick:function(){A(),(!r||F)&&K()},onDoubleClick:function(){b&&l(!1)},onMouseEnter:function(){P&&A()},onMouseDown:function(X){X.preventDefault()}},r&&s.createElement(N0,{prefixCls:"".concat(e,"-checkbox"),checked:k,halfChecked:I,disabled:D,onClick:function(X){X.stopPropagation(),K()}}),s.createElement("div",{className:"".concat(h,"-content")},O),!N&&S&&!F&&s.createElement("div",{className:"".concat(h,"-expand-icon")},S),N&&w&&s.createElement("div",{className:"".concat(h,"-loading-icon")},w))}))}const $0=function(){var t=rl(),e=t.multiple,r=t.open,n=s.useContext(Io),a=n.values,o=s.useState([]),l=ee(o,2),i=l[0],u=l[1];return s.useEffect(function(){if(r&&!e){var c=a[0];u(c||[])}},[r]),[i,u]},D0=function(t,e,r,n,a,o){var l=rl(),i=l.direction,u=l.searchValue,c=l.toggleOpen,d=l.open,f=i==="rtl",v=s.useMemo(function(){for(var E=-1,P=e,T=[],M=[],R=n.length,D=function(I){var L=P.findIndex(function(j){return j[r.value]===n[I]});if(L===-1)return"break";E=L,T.push(E),M.push(n[I]),P=P[E][r.children]},O=0;O1){var P=h.slice(0,-1);b(P)}else c(!1)},w=function(){var P,T=((P=g[y])===null||P===void 0?void 0:P[r.children])||[],M=T.find(function(D){return!D.disabled});if(M){var R=[].concat(De(h),[M[r.value]]);b(R)}};s.useImperativeHandle(t,function(){return{onKeyDown:function(P){var T=P.which;switch(T){case Ye.UP:case Ye.DOWN:{var M=0;T===Ye.UP?M=-1:T===Ye.DOWN&&(M=1),M!==0&&x(M);break}case Ye.LEFT:{if(u)break;f?w():S();break}case Ye.RIGHT:{if(u)break;f?S():w();break}case Ye.BACKSPACE:{u||S();break}case Ye.ENTER:{if(h.length){var R=g[y],D=(R==null?void 0:R[lo])||[];D.length?o(D.map(function(O){return O[r.value]}),D[D.length-1]):o(h,g[y])}break}case Ye.ESC:c(!1),d&&P.stopPropagation()}},onKeyUp:function(){}}})};var O0=s.forwardRef(function(t,e){var r,n,a,o,l=rl(),i=l.prefixCls,u=l.multiple,c=l.searchValue,d=l.toggleOpen,f=l.notFoundContent,v=l.direction,m=s.useRef(),h=v==="rtl",y=s.useContext(Io),g=y.options,b=y.values,x=y.halfValues,S=y.fieldNames,w=y.changeOnSelect,E=y.onSelect,P=y.searchOptions,T=y.dropdownPrefixCls,M=y.loadData,R=y.expandTrigger,D=T||i,O=s.useState([]),$=ee(O,2),F=$[0],N=$[1],k=function(Q){if(!(!M||c)){var ie=go(Q,g,S),le=ie.map(function(ve){var ce=ve.option;return ce}),ge=le[le.length-1];if(ge&&!eo(ge,S)){var Pe=wr(Q);N(function(ve){return[].concat(De(ve),[Pe])}),M(le)}}};s.useEffect(function(){F.length&&F.forEach(function(J){var Q=g0(J),ie=go(Q,g,S,!0).map(function(ge){var Pe=ge.option;return Pe}),le=ie[ie.length-1];(!le||le[S.children]||eo(le,S))&&N(function(ge){return ge.filter(function(Pe){return Pe!==J})})})},[g,F,S]);var I=s.useMemo(function(){return new Set(da(b))},[b]),L=s.useMemo(function(){return new Set(da(x))},[x]),j=$0(),_=ee(j,2),A=_[0],K=_[1],z=function(Q){K(Q),k(Q)},V=function(Q){var ie=Q.disabled,le=eo(Q,S);return!ie&&(le||w||u)},X=function(Q,ie){var le=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;E(Q),!u&&(ie||w&&(R==="hover"||le))&&d(!1)},W=s.useMemo(function(){return c?P:g},[c,P,g]),Z=s.useMemo(function(){for(var J=[{options:W}],Q=W,ie=function(){var ve=A[le],ce=Q.find(function(oe){return oe[S.value]===ve}),fe=ce==null?void 0:ce[S.children];if(!(fe!=null&&fe.length))return"break";Q=fe,J.push({options:fe})},le=0;le":$,N=t.loadingIcon,k=t.children,I=t.dropdownMatchSelectWidth,L=I===void 0?!1:I,j=t.showCheckedStrategy,_=j===void 0?bv:j,A=Le(t,I0),K=Gf(r),z=!!f,V=xt(l,{value:i,postState:uc}),X=ee(V,2),W=X[0],Z=X[1],U=s.useMemo(function(){return y0(o)},[JSON.stringify(o)]),ae=s.useMemo(function(){return g||[]},[g]),q=P0(ae,U),te=s.useCallback(function(Je){var Se=q();return Je.map(function(He){var je=Se[He].nodes;return je.map(function(ze){return ze[U.value]})})},[q,U]),ue=xt("",{value:v,postState:function(Se){return Se||""}}),Y=ee(ue,2),J=Y[0],Q=Y[1],ie=function(Se,He){Q(Se),He.source!=="blur"&&m&&m(Se)},le=R0(h),ge=ee(le,2),Pe=ge[0],ve=ge[1],ce=M0(J,ae,U,b||a,ve,u),fe=E0(ae,U),oe=s.useMemo(function(){var Je=fe(W),Se=ee(Je,2),He=Se[0],je=Se[1];if(!z||!W.length)return[He,[],je];var ze=da(He),ye=q(),de=wn(ze,!0,ye),Ce=de.checkedKeys,Me=de.halfCheckedKeys;return[te(Ce),te(Me),je]},[z,W,q,te,fe]),se=ee(oe,3),he=se[0],be=se[1],ke=se[2],Fe=s.useMemo(function(){var Je=da(he),Se=lc(Je,q,_);return[].concat(De(ke),De(te(Se)))},[he,q,te,ke,_]),Ee=C0(Fe,ae,U,z,d),Re=sc(function(Je){if(Z(Je),c){var Se=uc(Je),He=Se.map(function(ye){return go(ye,ae,U).map(function(de){return de.option})}),je=z?Se:Se[0],ze=z?He:He[0];c(je,ze)}}),we=sc(function(Je){if(Q(""),!z)Re(Je);else{var Se=wr(Je),He=da(he),je=da(be),ze=He.includes(Se),ye=ke.some(function(it){return wr(it)===Se}),de=he,Ce=ke;if(ye&&!ze)Ce=ke.filter(function(it){return wr(it)!==Se});else{var Me=ze?He.filter(function(it){return it!==Se}):[].concat(De(He),[Se]),Be=q(),nt;if(ze){var Ne=wn(Me,{checked:!1,halfCheckedKeys:je},Be);nt=Ne.checkedKeys}else{var xe=wn(Me,!0,Be);nt=xe.checkedKeys}var qe=lc(nt,q,_);de=te(qe)}Re([].concat(De(Ce),De(de)))}}),Ge=function(Se,He){if(He.type==="clear"){Re([]);return}var je=He.values[0].valueCells;we(je)},Qe=w!==void 0?w:S,ct=P||E,dt=R||M,mt=function(Se){D==null||D(Se),O==null||O(Se)},We=s.useMemo(function(){return{options:ae,fieldNames:U,values:he,halfValues:be,changeOnSelect:u,onSelect:we,checkable:f,searchOptions:ce,dropdownPrefixCls:b,loadData:x,expandTrigger:y,expandIcon:F,loadingIcon:N,dropdownMenuColumnStyle:T}},[ae,U,he,be,u,we,f,ce,b,x,y,F,N,T]),Oe=!(J?ce:ae).length,ot=J&&ve.matchInputWidth||Oe?{}:{minWidth:"auto"};return s.createElement(Io.Provider,{value:We},s.createElement(qf,re({},A,{ref:e,id:K,prefixCls:a,dropdownMatchSelectWidth:L,dropdownStyle:ot,displayValues:Ee,onDisplayValuesChange:Ge,mode:z?"multiple":void 0,searchValue:J,onSearch:ie,showSearch:Pe,OptionList:O0,emptyOptions:Oe,open:Qe,dropdownClassName:ct,placement:dt,onDropdownVisibleChange:mt,getRawInputElement:function(){return k}})))});jo.SHOW_PARENT=bv;jo.SHOW_CHILD=Cv;var L0=globalThis&&globalThis.__rest||function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,n=Object.getOwnPropertySymbols(t);a2&&arguments[2]!==void 0?arguments[2]:!0,te=function(){T(function(Y){var J=new Map(Y),Q=J.delete(U);return Q?J:Y})};return T(function(ue){return new Map(ue).set(U,{url:ae,canPreview:q})}),te},W=function(U){U.stopPropagation(),k(!1),_(null)};return s.useEffect(function(){O(z)},[z]),s.useEffect(function(){!N&&A&&O(z)},[z,A,N]),s.createElement(p1,{value:{isPreviewGroup:!0,previewUrls:V,setPreviewUrls:T,current:D,setCurrent:O,setShowPreview:k,setMousePosition:_,registerImage:X}},a,s.createElement(Mv,re({"aria-hidden":!N,visible:N,prefixCls:n,onClose:W,mousePosition:j,src:V.get(D),icons:l,getContainer:h,countRender:x},S)))},Si=1,wi=50,qa=1,y1=.2,b1=function(e){var r,n=e.visible,a=e.maskTransitionName,o=e.getContainer,l=e.prefixCls,i=e.rootClassName,u=e.icons,c=e.countRender,d=e.showSwitch,f=e.showProgress,v=e.current,m=e.count,h=e.scale,y=e.onSwitchLeft,g=e.onSwitchRight,b=e.onClose,x=e.onZoomIn,S=e.onZoomOut,w=e.onRotateRight,E=e.onRotateLeft,P=u.rotateLeft,T=u.rotateRight,M=u.zoomIn,R=u.zoomOut,D=u.close,O=u.left,$=u.right,F="".concat(l,"-operations-operation"),N="".concat(l,"-operations-icon"),k=[{icon:D,onClick:b,type:"close"},{icon:M,onClick:x,type:"zoomIn",disabled:h===wi},{icon:R,onClick:S,type:"zoomOut",disabled:h===Si},{icon:T,onClick:w,type:"rotateRight"},{icon:P,onClick:E,type:"rotateLeft"}],I=s.createElement(s.Fragment,null,d&&s.createElement(s.Fragment,null,s.createElement("div",{className:pe("".concat(l,"-switch-left"),B({},"".concat(l,"-switch-left-disabled"),v===0)),onClick:y},O),s.createElement("div",{className:pe("".concat(l,"-switch-right"),B({},"".concat(l,"-switch-right-disabled"),v===m-1)),onClick:g},$)),s.createElement("ul",{className:"".concat(l,"-operations")},f&&s.createElement("li",{className:"".concat(l,"-operations-progress")},(r=c==null?void 0:c(v+1,m))!==null&&r!==void 0?r:"".concat(v+1," / ").concat(m)),k.map(function(L){var j,_=L.icon,A=L.onClick,K=L.type,z=L.disabled;return s.createElement("li",{className:pe(F,(j={},B(j,"".concat(l,"-operations-operation-").concat(K),!0),B(j,"".concat(l,"-operations-operation-disabled"),!!z),j)),onClick:A,key:K},s.isValidElement(_)?s.cloneElement(_,{className:N}):_)})));return s.createElement(qs,{visible:n,motionName:a},function(L){var j=L.className,_=L.style;return s.createElement(Mp,{open:!0,getContainer:o??document.body},s.createElement("div",{className:pe("".concat(l,"-operations-wrapper"),j,i),style:_},I))})},cc={x:0,y:0,rotate:0,scale:1};function C1(t){var e=s.useRef(null),r=s.useRef([]),n=s.useState(cc),a=ee(n,2),o=a[0],l=a[1],i=function(){l(cc)},u=function(f){e.current===null&&(r.current=[],e.current=mo(function(){l(function(v){var m=v;return r.current.forEach(function(h){m=p(p({},m),h)}),e.current=null,m})})),r.current.push(p(p({},o),f))},c=function(f,v,m){var h=t.current,y=h.width,g=h.height,b=h.offsetWidth,x=h.offsetHeight,S=h.offsetLeft,w=h.offsetTop,E=f,P=o.scale*f;P>wi?(E=wi/o.scale,P=wi):Pn){if(e>0)return B({},t,o);if(e<0&&an)return B({},t,e<0?o:-o);return{}}function x1(t,e,r,n){var a=Fv(),o=a.width,l=a.height,i=null;return t<=o&&e<=l?i={x:0,y:0}:(t>o||e>l)&&(i=p(p({},dc("x",r,t,o)),dc("y",n,e,l))),i}var S1=["prefixCls","src","alt","onClose","afterClose","visible","icons","rootClassName","getContainer","countRender","scaleStep","transitionName","maskTransitionName"],Mv=function(e){var r=e.prefixCls,n=e.src,a=e.alt,o=e.onClose;e.afterClose;var l=e.visible,i=e.icons,u=i===void 0?{}:i,c=e.rootClassName,d=e.getContainer,f=e.countRender,v=e.scaleStep,m=v===void 0?.5:v,h=e.transitionName,y=h===void 0?"zoom":h,g=e.maskTransitionName,b=g===void 0?"fade":g,x=Le(e,S1),S=s.useRef(),w=s.useRef({deltaX:0,deltaY:0,transformX:0,transformY:0}),E=s.useState(!1),P=ee(E,2),T=P[0],M=P[1],R=s.useContext(vu),D=R.previewUrls,O=R.current,$=R.isPreviewGroup,F=R.setCurrent,N=D.size,k=Array.from(D.keys()),I=k.indexOf(O),L=$?D.get(O):n,j=$&&N>1,_=$&&N>=1,A=C1(S),K=A.transform,z=A.resetTransform,V=A.updateTransform,X=A.dispatchZoonChange,W=K.rotate,Z=K.scale,U=pe(B({},"".concat(r,"-moving"),T)),ae=function(){z()},q=function(){X(qa+m)},te=function(){X(qa-m)},ue=function(){V({rotate:W+90})},Y=function(){V({rotate:W-90})},J=function(oe){oe.preventDefault(),oe.stopPropagation(),I>0&&F(k[I-1])},Q=function(oe){oe.preventDefault(),oe.stopPropagation(),I0&&(be=qa/be),X(be,oe.clientX,oe.clientY)}},ve=s.useCallback(function(fe){!l||!j||(fe.keyCode===Ye.LEFT?I>0&&F(k[I-1]):fe.keyCode===Ye.RIGHT&&I=0||i.relatedTarget.className.indexOf("".concat(f,"-item"))>=0))&&d(n.getValidValue()))},n.go=function(i){var u=n.state.goInputText;u!==""&&(i.keyCode===Br.ENTER||i.type==="click")&&(n.setState({goInputText:""}),n.props.quickGo(n.getValidValue()))},n}return Cn(r,[{key:"getValidValue",value:function(){var a=this.state.goInputText;return!a||isNaN(a)?void 0:Number(a)}},{key:"getPageSizeOptions",value:function(){var a=this.props,o=a.pageSize,l=a.pageSizeOptions;return l.some(function(i){return i.toString()===o.toString()})?l:l.concat([o.toString()]).sort(function(i,u){var c=isNaN(Number(i))?0:Number(i),d=isNaN(Number(u))?0:Number(u);return c-d})}},{key:"render",value:function(){var a=this,o=this.props,l=o.pageSize,i=o.locale,u=o.rootPrefixCls,c=o.changeSize,d=o.quickGo,f=o.goButton,v=o.selectComponentClass,m=o.buildOptionText,h=o.selectPrefixCls,y=o.disabled,g=this.state.goInputText,b="".concat(u,"-options"),x=v,S=null,w=null,E=null;if(!c&&!d)return null;var P=this.getPageSizeOptions();if(c&&x){var T=P.map(function(M,R){return G.createElement(x.Option,{key:R,value:M.toString()},(m||a.buildOptionText)(M))});S=G.createElement(x,{disabled:y,prefixCls:h,showSearch:!1,className:"".concat(b,"-size-changer"),optionLabelProp:"children",dropdownMatchSelectWidth:!1,value:(l||P[0]).toString(),onChange:this.changeSize,getPopupContainer:function(R){return R.parentNode},"aria-label":i.page_size,defaultOpen:!1},T)}return d&&(f&&(E=typeof f=="boolean"?G.createElement("button",{type:"button",onClick:this.go,onKeyUp:this.go,disabled:y,className:"".concat(b,"-quick-jumper-button")},i.jump_to_confirm):G.createElement("span",{onClick:this.go,onKeyUp:this.go},f)),w=G.createElement("div",{className:"".concat(b,"-quick-jumper")},i.jump_to,G.createElement("input",{disabled:y,type:"text",value:g,onChange:this.handleChange,onKeyUp:this.go,onBlur:this.handleBlur,"aria-label":i.page}),i.page,E)),G.createElement("li",{className:"".concat(b)},S,w)}}]),r}(G.Component);$v.defaultProps={pageSizeOptions:["10","20","50","100"]};function ds(){}function mc(t){var e=Number(t);return typeof e=="number"&&!isNaN(e)&&isFinite(e)&&Math.floor(e)===e}function oy(t,e,r){return r}function yr(t,e,r){var n=typeof t>"u"?e.pageSize:t;return Math.floor((r.total-1)/n)+1}var Dv=function(t){gn(r,t);var e=yn(r);function r(n){var a;bn(this,r),a=e.call(this,n),a.getJumpPrevPage=function(){return Math.max(1,a.state.current-(a.props.showLessItems?3:5))},a.getJumpNextPage=function(){return Math.min(yr(void 0,a.state,a.props),a.state.current+(a.props.showLessItems?3:5))},a.getItemIcon=function(c,d){var f=a.props.prefixCls,v=c||G.createElement("button",{type:"button","aria-label":d,className:"".concat(f,"-item-link")});return typeof c=="function"&&(v=G.createElement(c,p({},a.props))),v},a.savePaginationNode=function(c){a.paginationNode=c},a.isValid=function(c){var d=a.props.total;return mc(c)&&c!==a.state.current&&mc(d)&&d>0},a.shouldDisplayQuickJumper=function(){var c=a.props,d=c.showQuickJumper,f=c.total,v=a.state.pageSize;return f<=v?!1:d},a.handleKeyDown=function(c){(c.keyCode===Br.ARROW_UP||c.keyCode===Br.ARROW_DOWN)&&c.preventDefault()},a.handleKeyUp=function(c){var d=a.getValidValue(c),f=a.state.currentInputValue;d!==f&&a.setState({currentInputValue:d}),c.keyCode===Br.ENTER?a.handleChange(d):c.keyCode===Br.ARROW_UP?a.handleChange(d-1):c.keyCode===Br.ARROW_DOWN&&a.handleChange(d+1)},a.handleBlur=function(c){var d=a.getValidValue(c);a.handleChange(d)},a.changePageSize=function(c){var d=a.state.current,f=yr(c,a.state,a.props);d=d>f?f:d,f===0&&(d=a.state.current),typeof c=="number"&&("pageSize"in a.props||a.setState({pageSize:c}),"current"in a.props||a.setState({current:d,currentInputValue:d})),a.props.onShowSizeChange(d,c),"onChange"in a.props&&a.props.onChange&&a.props.onChange(d,c)},a.handleChange=function(c){var d=a.props,f=d.disabled,v=d.onChange,m=a.state,h=m.pageSize,y=m.current,g=m.currentInputValue;if(a.isValid(c)&&!f){var b=yr(void 0,a.state,a.props),x=c;return c>b?x=b:c<1&&(x=1),"current"in a.props||a.setState({current:x}),x!==g&&a.setState({currentInputValue:x}),v(x,h),x}return y},a.prev=function(){a.hasPrev()&&a.handleChange(a.state.current-1)},a.next=function(){a.hasNext()&&a.handleChange(a.state.current+1)},a.jumpPrev=function(){a.handleChange(a.getJumpPrevPage())},a.jumpNext=function(){a.handleChange(a.getJumpNextPage())},a.hasPrev=function(){return a.state.current>1},a.hasNext=function(){return a.state.current2?f-2:0),m=2;m=l?u=l:u=Number(o),u}},{key:"getShowSizeChanger",value:function(){var a=this.props,o=a.showSizeChanger,l=a.total,i=a.totalBoundaryShowSizeChanger;return typeof o<"u"?o:l>i}},{key:"renderPrev",value:function(a){var o=this.props,l=o.prevIcon,i=o.itemRender,u=i(a,"prev",this.getItemIcon(l,"prev page")),c=!this.hasPrev();return s.isValidElement(u)?s.cloneElement(u,{disabled:c}):u}},{key:"renderNext",value:function(a){var o=this.props,l=o.nextIcon,i=o.itemRender,u=i(a,"next",this.getItemIcon(l,"next page")),c=!this.hasNext();return s.isValidElement(u)?s.cloneElement(u,{disabled:c}):u}},{key:"render",value:function(){var a=this,o=this.props,l=o.prefixCls,i=o.className,u=o.style,c=o.disabled,d=o.hideOnSinglePage,f=o.total,v=o.locale,m=o.showQuickJumper,h=o.showLessItems,y=o.showTitle,g=o.showTotal,b=o.simple,x=o.itemRender,S=o.showPrevNextJumpers,w=o.jumpPrevIcon,E=o.jumpNextIcon,P=o.selectComponentClass,T=o.selectPrefixCls,M=o.pageSizeOptions,R=this.state,D=R.current,O=R.pageSize,$=R.currentInputValue;if(d===!0&&f<=O)return null;var F=yr(void 0,this.state,this.props),N=[],k=null,I=null,L=null,j=null,_=null,A=m&&m.goButton,K=h?1:2,z=D-1>0?D-1:0,V=D+1f?f:D*O]));if(b)return A&&(typeof A=="boolean"?_=G.createElement("button",{type:"button",onClick:this.handleGoTO,onKeyUp:this.handleGoTO},v.jump_to_confirm):_=G.createElement("span",{onClick:this.handleGoTO,onKeyUp:this.handleGoTO},A),_=G.createElement("li",{title:y?"".concat(v.jump_to).concat(D,"/").concat(F):null,className:"".concat(l,"-simple-pager")},_)),G.createElement("ul",re({className:pe(l,"".concat(l,"-simple"),B({},"".concat(l,"-disabled"),c),i),style:u,ref:this.savePaginationNode},X),W,G.createElement("li",{title:y?v.prev_page:null,onClick:this.prev,tabIndex:this.hasPrev()?0:null,onKeyPress:this.runIfEnterPrev,className:pe("".concat(l,"-prev"),B({},"".concat(l,"-disabled"),!this.hasPrev())),"aria-disabled":!this.hasPrev()},this.renderPrev(z)),G.createElement("li",{title:y?"".concat(D,"/").concat(F):null,className:"".concat(l,"-simple-pager")},G.createElement("input",{type:"text",value:$,disabled:c,onKeyDown:this.handleKeyDown,onKeyUp:this.handleKeyUp,onChange:this.handleKeyUp,onBlur:this.handleBlur,size:"3"}),G.createElement("span",{className:"".concat(l,"-slash")},"/"),F),G.createElement("li",{title:y?v.next_page:null,onClick:this.next,tabIndex:this.hasPrev()?0:null,onKeyPress:this.runIfEnterNext,className:pe("".concat(l,"-next"),B({},"".concat(l,"-disabled"),!this.hasNext())),"aria-disabled":!this.hasNext()},this.renderNext(V)),_);if(F<=3+K*2){var Z={locale:v,rootPrefixCls:l,onClick:this.handleChange,onKeyPress:this.runIfEnter,showTitle:y,itemRender:x};F||N.push(G.createElement(Xa,re({},Z,{key:"noPager",page:1,className:"".concat(l,"-item-disabled")})));for(var U=1;U<=F;U+=1){var ae=D===U;N.push(G.createElement(Xa,re({},Z,{key:U,page:U,active:ae})))}}else{var q=h?v.prev_3:v.prev_5,te=h?v.next_3:v.next_5;S&&(k=G.createElement("li",{title:y?q:null,key:"prev",onClick:this.jumpPrev,tabIndex:"0",onKeyPress:this.runIfEnterJumpPrev,className:pe("".concat(l,"-jump-prev"),B({},"".concat(l,"-jump-prev-custom-icon"),!!w))},x(this.getJumpPrevPage(),"jump-prev",this.getItemIcon(w,"prev page"))),I=G.createElement("li",{title:y?te:null,key:"next",tabIndex:"0",onClick:this.jumpNext,onKeyPress:this.runIfEnterJumpNext,className:pe("".concat(l,"-jump-next"),B({},"".concat(l,"-jump-next-custom-icon"),!!E))},x(this.getJumpNextPage(),"jump-next",this.getItemIcon(E,"next page")))),j=G.createElement(Xa,{locale:v,last:!0,rootPrefixCls:l,onClick:this.handleChange,onKeyPress:this.runIfEnter,key:F,page:F,active:!1,showTitle:y,itemRender:x}),L=G.createElement(Xa,{locale:v,rootPrefixCls:l,onClick:this.handleChange,onKeyPress:this.runIfEnter,key:1,page:1,active:!1,showTitle:y,itemRender:x});var ue=Math.max(1,D-K),Y=Math.min(D+K,F);D-1<=K&&(Y=1+K*2),F-D<=K&&(ue=F-K*2);for(var J=ue;J<=Y;J+=1){var Q=D===J;N.push(G.createElement(Xa,{locale:v,rootPrefixCls:l,onClick:this.handleChange,onKeyPress:this.runIfEnter,key:J,page:J,active:Q,showTitle:y,itemRender:x}))}D-1>=K*2&&D!==1+2&&(N[0]=s.cloneElement(N[0],{className:"".concat(l,"-item-after-jump-prev")}),N.unshift(k)),F-D>=K*2&&D!==F-2&&(N[N.length-1]=s.cloneElement(N[N.length-1],{className:"".concat(l,"-item-before-jump-next")}),N.push(I)),ue!==1&&N.unshift(L),Y!==F&&N.push(j)}var ie=!this.hasPrev()||!F,le=!this.hasNext()||!F;return G.createElement("ul",re({className:pe(l,i,B({},"".concat(l,"-disabled"),c)),style:u,ref:this.savePaginationNode},X),W,G.createElement("li",{title:y?v.prev_page:null,onClick:this.prev,tabIndex:ie?null:0,onKeyPress:this.runIfEnterPrev,className:pe("".concat(l,"-prev"),B({},"".concat(l,"-disabled"),ie)),"aria-disabled":ie},this.renderPrev(z)),N,G.createElement("li",{title:y?v.next_page:null,onClick:this.next,tabIndex:le?null:0,onKeyPress:this.runIfEnterNext,className:pe("".concat(l,"-next"),B({},"".concat(l,"-disabled"),le)),"aria-disabled":le},this.renderNext(V)),G.createElement($v,{disabled:c,locale:v,rootPrefixCls:l,selectComponentClass:P,selectPrefixCls:T,changeSize:this.getShowSizeChanger()?this.changePageSize:null,current:D,pageSize:O,pageSizeOptions:M,quickGo:this.shouldDisplayQuickJumper()?this.handleChange:null,goButton:A}))}}],[{key:"getDerivedStateFromProps",value:function(a,o){var l={};if("current"in a&&(l.current=a.current,a.current!==o.current&&(l.currentInputValue=l.current)),"pageSize"in a&&a.pageSize!==o.pageSize){var i=o.current,u=yr(a.pageSize,o,a);i=i>u?u:i,"current"in a||(l.current=i,l.currentInputValue=i),l.pageSize=a.pageSize}return l}}]),r}(G.Component);Dv.defaultProps={defaultCurrent:1,total:0,defaultPageSize:10,onChange:ds,className:"",selectPrefixCls:"rc-select",prefixCls:"rc-pagination",selectComponentClass:null,hideOnSinglePage:!1,showPrevNextJumpers:!0,showQuickJumper:!1,showLessItems:!1,showTitle:!0,onShowSizeChange:ds,locale:sp,style:{},itemRender:oy,totalBoundaryShowSizeChanger:50};var Ov=function(e){return s.createElement(Mr,re({},e,{size:"small"}))},Iv=function(e){return s.createElement(Mr,re({},e,{size:"middle"}))};Ov.Option=Mr.Option;Iv.Option=Mr.Option;var iy=globalThis&&globalThis.__rest||function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,n=Object.getOwnPropertySymbols(t);a=d&&iv?"true":"false","aria-posinset":v+1,"aria-setsize":m,tabIndex:u?-1:0},G.createElement("div",{className:"".concat(c,"-first")},y),G.createElement("div",{className:"".concat(c,"-second")},y)));return f&&(g=f(g,this.props)),g}}]),r}(G.Component);function hc(){}var _v=function(t){gn(r,t);var e=yn(r);function r(n){var a;bn(this,r),a=e.call(this,n),a.stars=void 0,a.rate=void 0,a.onHover=function(l,i){var u=a.props.onHoverChange,c=a.getStarValue(i,l.pageX),d=a.state.cleanedValue;c!==d&&a.setState({hoverValue:c,cleanedValue:null}),u(c)},a.onMouseLeave=function(){var l=a.props.onHoverChange;a.setState({hoverValue:void 0,cleanedValue:null}),l(void 0)},a.onClick=function(l,i){var u=a.props.allowClear,c=a.state.value,d=a.getStarValue(i,l.pageX),f=!1;u&&(f=d===c),a.onMouseLeave(),a.changeValue(f?0:d),a.setState({cleanedValue:f?d:null})},a.onFocus=function(){var l=a.props.onFocus;a.setState({focused:!0}),l&&l()},a.onBlur=function(){var l=a.props.onBlur;a.setState({focused:!1}),l&&l()},a.onKeyDown=function(l){var i=l.keyCode,u=a.props,c=u.count,d=u.allowHalf,f=u.onKeyDown,v=u.direction,m=v==="rtl",h=a.state.value;i===Ye.RIGHT&&h0&&!m||i===Ye.RIGHT&&h>0&&m?(d?h-=.5:h-=1,a.changeValue(h),l.preventDefault()):i===Ye.LEFT&&hm/2||!c&&o-v=r}function Gy(t){return t&&Ve(t)==="object"&&!Array.isArray(t)&&!s.isValidElement(t)}function qy(t){return typeof t=="string"?!0:mp(t)}var Xy=function(e){var r=e.ellipsis,n=e.rowType,a=e.children,o,l=r===!0?{showTitle:!0}:r;return l&&(l.showTitle||n==="header")&&(typeof a=="string"||typeof a=="number"?o=a.toString():s.isValidElement(a)&&typeof a.props.children=="string"&&(o=a.props.children)),o};function Zy(t,e){var r,n,a,o=t.prefixCls,l=t.className,i=t.record,u=t.index,c=t.renderIndex,d=t.dataIndex,f=t.render,v=t.children,m=t.component,h=m===void 0?"td":m,y=t.colSpan,g=t.rowSpan,b=t.fixLeft,x=t.fixRight,S=t.firstFixLeft,w=t.lastFixLeft,E=t.firstFixRight,P=t.lastFixRight,T=t.appendNode,M=t.additionalProps,R=M===void 0?{}:M,D=t.ellipsis,O=t.align,$=t.rowType,F=t.isSticky,N=t.hovering,k=t.onHover,I="".concat(o,"-cell"),L=s.useContext(Bv),j=s.useContext(Vv),_=s.useContext(ul),A=_.allColumnsFixedLeft,K=s.useMemo(function(){if(fs(v))return[v];var oe=Kv(i,d),se=oe,he=void 0;if(f){var be=f(oe,i,c);Gy(be)?(se=be.children,he=be.props,L.renderWithProps=!0):se=be}return[se,he]},[L.renderWithProps?Math.random():0,v,d,L,i,f,c]),z=ee(K,2),V=z[0],X=z[1],W=V;Ve(W)==="object"&&!Array.isArray(W)&&!s.isValidElement(W)&&(W=null),D&&(w||E)&&(W=s.createElement("span",{className:"".concat(I,"-content")},W));var Z=X||{},U=Z.colSpan,ae=Z.rowSpan,q=Z.style,te=Z.className,ue=Le(Z,Uy),Y=(r=U!==void 0?U:y)!==null&&r!==void 0?r:1,J=(n=ae!==void 0?ae:g)!==null&&n!==void 0?n:1;if(Y===0||J===0)return null;var Q={},ie=typeof b=="number"&&j,le=typeof x=="number"&&j;ie&&(Q.position="sticky",Q.left=b),le&&(Q.position="sticky",Q.right=x);var ge={};O&&(ge.textAlign=O);var Pe=function(se){var he;i&&k(u,u+J-1),R==null||(he=R.onMouseEnter)===null||he===void 0||he.call(R,se)},ve=function(se){var he;i&&k(-1,-1),R==null||(he=R.onMouseLeave)===null||he===void 0||he.call(R,se)},ce=Xy({rowType:$,ellipsis:D,children:V}),fe=p(p(p({title:ce},ue),R),{},{colSpan:Y!==1?Y:null,rowSpan:J!==1?J:null,className:pe(I,l,(a={},B(a,"".concat(I,"-fix-left"),ie&&j),B(a,"".concat(I,"-fix-left-first"),S&&j),B(a,"".concat(I,"-fix-left-last"),w&&j),B(a,"".concat(I,"-fix-left-all"),w&&A&&j),B(a,"".concat(I,"-fix-right"),le&&j),B(a,"".concat(I,"-fix-right-first"),E&&j),B(a,"".concat(I,"-fix-right-last"),P&&j),B(a,"".concat(I,"-ellipsis"),D),B(a,"".concat(I,"-with-append"),T),B(a,"".concat(I,"-fix-sticky"),(ie||le)&&F&&j),B(a,"".concat(I,"-row-hover"),!X&&N),a),R.className,te),style:p(p(p(p({},R.style),ge),Q),q),onMouseEnter:Pe,onMouseLeave:ve,ref:qy(h)?e:null});return s.createElement(h,fe,T,W)}var Hv=s.forwardRef(Zy);Hv.displayName="Cell";var Qy=["expanded","className","hovering"],Jy=s.memo(Hv,function(t,e){return e.shouldCellUpdate?Qy.every(function(r){return t[r]===e[r]})&&!e.shouldCellUpdate(e.record,t.record):tu(t,e)}),Ko=s.forwardRef(function(t,e){var r=t.index,n=t.additionalProps,a=n===void 0?{}:n,o=t.colSpan,l=t.rowSpan,i=a.colSpan,u=a.rowSpan,c=o??i,d=l??u,f=Wy(zv,function(h){var y=Yy(r,d||1,h==null?void 0:h.startRow,h==null?void 0:h.endRow);return{onHover:h==null?void 0:h.onHover,hovering:y}}),v=f.onHover,m=f.hovering;return s.createElement(Jy,re({},t,{colSpan:c,rowSpan:d,hovering:m,ref:e,onHover:v}))});Ko.displayName="WrappedCell";var Un=s.createContext(null);function mu(t,e,r,n,a){var o=r[t]||{},l=r[e]||{},i,u;o.fixed==="left"?i=n.left[t]:l.fixed==="right"&&(u=n.right[e]);var c=!1,d=!1,f=!1,v=!1,m=r[e+1],h=r[t-1];if(a==="rtl"){if(i!==void 0){var y=h&&h.fixed==="left";v=!y}else if(u!==void 0){var g=m&&m.fixed==="right";f=!g}}else if(i!==void 0){var b=m&&m.fixed==="left";c=!b}else if(u!==void 0){var x=h&&h.fixed==="right";d=!x}return{fixLeft:i,fixRight:u,lastFixLeft:c,firstFixRight:d,lastFixRight:f,firstFixLeft:v,isSticky:n.isSticky}}function Wv(t){var e=t.cells,r=t.stickyOffsets,n=t.flattenColumns,a=t.rowComponent,o=t.cellComponent,l=t.onHeaderRow,i=t.index,u=s.useContext(Un),c=u.prefixCls,d=u.direction,f;l&&(f=l(e.map(function(m){return m.column}),i));var v=sl(e.map(function(m){return m.column}));return s.createElement(a,f,e.map(function(m,h){var y=m.column,g=mu(m.colStart,m.colEnd,n,r,d),b;return y&&y.onHeaderCell&&(b=m.column.onHeaderCell(y)),s.createElement(Ko,re({},m,{ellipsis:y.ellipsis,align:y.align,component:o,prefixCls:c,key:v[h]},g,{additionalProps:b,rowType:"header"}))}))}Wv.displayName="HeaderRow";function eb(t){var e=[];function r(l,i){var u=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0;e[u]=e[u]||[];var c=i,d=l.filter(Boolean).map(function(f){var v={key:f.key,className:f.className||"",children:f.title,column:f,colStart:c},m=1,h=f.children;return h&&h.length>0&&(m=r(h,c,u+1).reduce(function(y,g){return y+g},0),v.hasSubColumns=!0),"colSpan"in f&&(m=f.colSpan),"rowSpan"in f&&(v.rowSpan=f.rowSpan),v.colSpan=m,v.colEnd=v.colStart+m-1,e[u].push(v),c+=m,m});return d}r(t,0);for(var n=e.length,a=function(i){e[i].forEach(function(u){!("rowSpan"in u)&&!u.hasSubColumns&&(u.rowSpan=n-i)})},o=0;o1?ie-1:0),ge=1;ge0?[].concat(De(e),De(vs(o).map(function(l){return p({fixed:a},l)}))):[].concat(De(e),[p(p({},r),{},{fixed:a})])},[])}function ub(t){return t.map(function(e){var r=e.fixed,n=Le(e,sb),a=r;return r==="left"?a="right":r==="right"&&(a="left"),p({fixed:a},n)})}function cb(t,e){var r=t.prefixCls,n=t.columns,a=t.children,o=t.expandable,l=t.expandedKeys,i=t.columnTitle,u=t.getRowKey,c=t.onTriggerExpand,d=t.expandIcon,f=t.rowExpandable,v=t.expandIconColumnIndex,m=t.direction,h=t.expandRowByClick,y=t.columnWidth,g=t.fixed,b=s.useMemo(function(){return n||hu(a)},[n,a]),x=s.useMemo(function(){if(o){var E,P=b.slice();if(!P.includes(Hr)){var T=v||0;T>=0&&P.splice(T,0,Hr)}var M=P.indexOf(Hr);P=P.filter(function($,F){return $!==Hr||F===M});var R=b[M],D;(g==="left"||g)&&!v?D="left":(g==="right"||g)&&v===b.length?D="right":D=R?R.fixed:null;var O=(E={},B(E,so,{className:"".concat(r,"-expand-icon-col"),columnType:"EXPAND_COLUMN"}),B(E,"title",i),B(E,"fixed",D),B(E,"className","".concat(r,"-row-expand-icon-cell")),B(E,"width",y),B(E,"render",function(F,N,k){var I=u(N,k),L=l.has(I),j=f?f(N):!0,_=d({prefixCls:r,expanded:L,expandable:j,record:N,onExpand:c});return h?s.createElement("span",{onClick:function(K){return K.stopPropagation()}},_):_}),E);return P.map(function($){return $===Hr?O:$})}return b.filter(function($){return $!==Hr})},[o,b,u,l,d,m]),S=s.useMemo(function(){var E=x;return e&&(E=e(E)),E.length||(E=[{render:function(){return null}}]),E},[e,x,m]),w=s.useMemo(function(){return m==="rtl"?ub(vs(S)):vs(S)},[S,m]);return[S,w]}function Qv(t){var e=s.useRef(t),r=s.useState({}),n=ee(r,2),a=n[1],o=s.useRef(null),l=s.useRef([]);function i(u){l.current.push(u);var c=Promise.resolve();o.current=c,c.then(function(){if(o.current===c){var d=l.current,f=e.current;l.current=[],d.forEach(function(v){e.current=v(e.current)}),o.current=null,f!==e.current&&a({})}})}return s.useEffect(function(){return function(){o.current=null}},[]),[e.current,i]}function db(t){var e=s.useRef(t||null),r=s.useRef();function n(){window.clearTimeout(r.current)}function a(l){e.current=l,n(),r.current=window.setTimeout(function(){e.current=null,r.current=void 0},100)}function o(){return e.current}return s.useEffect(function(){return n},[]),[a,o]}function fb(t,e,r){var n=s.useMemo(function(){for(var a=[],o=[],l=0,i=0,u=0;u=0;i-=1){var u=e[i],c=r&&r[i],d=c&&c[so];if(u||d||l){var f=d||{};f.columnType;var v=Le(f,vb);a.unshift(s.createElement("col",re({key:i,style:{width:u}},v))),l=!0}}return s.createElement("colgroup",null,a)}function Cc(t){var e=t.className,r=t.children;return s.createElement("div",{className:e},r)}var em=s.createContext({});function mb(t){var e=t.className,r=t.index,n=t.children,a=t.colSpan,o=a===void 0?1:a,l=t.rowSpan,i=t.align,u=s.useContext(Un),c=u.prefixCls,d=u.direction,f=s.useContext(em),v=f.scrollColumnIndex,m=f.stickyOffsets,h=f.flattenColumns,y=r+o-1,g=y+1===v?o+1:o,b=mu(r,r+g-1,h,m,d);return s.createElement(Ko,re({className:e,index:r,component:"td",prefixCls:c,record:null,dataIndex:null,align:i,colSpan:g,rowSpan:l,render:function(){return n}},b))}var hb=["children"];function pb(t){var e=t.children,r=Le(t,hb);return s.createElement("tr",r,e)}function cl(t){var e=t.children;return e}cl.Row=pb;cl.Cell=mb;function gi(t){var e=t.children,r=t.stickyOffsets,n=t.flattenColumns,a=s.useContext(Un),o=a.prefixCls,l=n.length-1,i=n[l],u=s.useMemo(function(){return{stickyOffsets:r,flattenColumns:n,scrollColumnIndex:i!=null&&i.scrollbar?l:null}},[i,n,l,r]);return s.createElement(em.Provider,{value:u},s.createElement("tfoot",{className:"".concat(o,"-summary")},e))}var tm=cl;function gb(t){var e,r=t.prefixCls,n=t.record,a=t.onExpand,o=t.expanded,l=t.expandable,i="".concat(r,"-row-expand-icon");if(!l)return s.createElement("span",{className:pe(i,"".concat(r,"-row-spaced"))});var u=function(d){a(n,d),d.stopPropagation()};return s.createElement("span",{className:pe(i,(e={},B(e,"".concat(r,"-row-expanded"),o),B(e,"".concat(r,"-row-collapsed"),!o),e)),onClick:u})}function yb(t,e,r){var n=[];function a(o){(o||[]).forEach(function(l,i){n.push(e(l,i)),a(l[r])})}return a(t),n}var bb=function(e,r){var n,a,o=e.scrollBodyRef,l=e.onScroll,i=e.offsetScroll,u=e.container,c=s.useContext(Un),d=c.prefixCls,f=((n=o.current)===null||n===void 0?void 0:n.scrollWidth)||0,v=((a=o.current)===null||a===void 0?void 0:a.clientWidth)||0,m=f&&v*(v/f),h=s.useRef(),y=Qv({scrollLeft:0,isHiddenScrollBar:!1}),g=ee(y,2),b=g[0],x=g[1],S=s.useRef({delta:0,x:0}),w=s.useState(!1),E=ee(w,2),P=E[0],T=E[1],M=function(){T(!1)},R=function(N){N.persist(),S.current.delta=N.pageX-b.scrollLeft,S.current.x=0,T(!0),N.preventDefault()},D=function(N){var k,I=N||((k=window)===null||k===void 0?void 0:k.event),L=I.buttons;if(!P||L===0){P&&T(!1);return}var j=S.current.x+N.pageX-S.current.x-S.current.delta;j<=0&&(j=0),j+m>=v&&(j=v-m),l({scrollLeft:j/v*(f+2)}),S.current.x=N.pageX},O=function(){if(o.current){var N=cs(o.current).top,k=N+o.current.offsetHeight,I=u===window?document.documentElement.scrollTop+window.innerHeight:cs(u).top+u.clientHeight;k-Xu()<=I||N>=I-i?x(function(L){return p(p({},L),{},{isHiddenScrollBar:!0})}):x(function(L){return p(p({},L),{},{isHiddenScrollBar:!1})})}},$=function(N){x(function(k){return p(p({},k),{},{scrollLeft:N/f*v||0})})};return s.useImperativeHandle(r,function(){return{setScrollLeft:$}}),s.useEffect(function(){var F=tr(document.body,"mouseup",M,!1),N=tr(document.body,"mousemove",D,!1);return O(),function(){F.remove(),N.remove()}},[m,P]),s.useEffect(function(){var F=tr(u,"scroll",O,!1),N=tr(window,"resize",O,!1);return function(){F.remove(),N.remove()}},[u]),s.useEffect(function(){b.isHiddenScrollBar||x(function(F){var N=o.current;return N?p(p({},F),{},{scrollLeft:N.scrollLeft/N.scrollWidth*N.clientWidth}):F})},[b.isHiddenScrollBar]),f<=v||!m||b.isHiddenScrollBar?null:s.createElement("div",{style:{height:Xu(),width:v,bottom:i},className:"".concat(d,"-sticky-scroll")},s.createElement("div",{onMouseDown:R,ref:h,className:pe("".concat(d,"-sticky-scroll-bar"),B({},"".concat(d,"-sticky-scroll-bar-active"),P)),style:{width:"".concat(m,"px"),transform:"translate3d(".concat(b.scrollLeft,"px, 0, 0)")}}))};const Cb=s.forwardRef(bb);var xc=hp()?window:null;function xb(t,e){var r=Ve(t)==="object"?t:{},n=r.offsetHeader,a=n===void 0?0:n,o=r.offsetSummary,l=o===void 0?0:o,i=r.offsetScroll,u=i===void 0?0:i,c=r.getContainer,d=c===void 0?function(){return xc}:c,f=d()||xc;return s.useMemo(function(){var v=!!t;return{isSticky:v,stickyClassName:v?"".concat(e,"-sticky-holder"):"",offsetHeader:a,offsetSummary:l,offsetScroll:u,container:f}},[u,a,l,e,f])}var Sb=["className","noData","columns","flattenColumns","colWidths","columCount","stickyOffsets","direction","fixHeader","stickyTopOffset","stickyBottomOffset","stickyClassName","onScroll","maxContentScroll","children"];function wb(t,e){return s.useMemo(function(){for(var r=[],n=0;n=0})},[o]),D=o[o.length-1],O={fixed:D?D.fixed:null,scrollbar:!0,onHeaderCell:function(){return{className:"".concat(S,"-cell-scrollbar")}}},$=s.useMemo(function(){return P?[].concat(De(a),[O]):a},[P,a]),F=s.useMemo(function(){return P?[].concat(De(o),[O]):o},[P,o]),N=s.useMemo(function(){var I=u.right,L=u.left;return p(p({},u),{},{left:c==="rtl"?[].concat(De(L.map(function(j){return j+P})),[0]):L,right:c==="rtl"?I:[].concat(De(I.map(function(j){return j+P})),[0]),isSticky:E})},[P,u,E]),k=wb(l,i);return s.createElement("div",{style:p({overflow:"hidden"},E?{top:f,bottom:v}:{}),ref:M,className:pe(r,B({},m,!!m))},s.createElement("table",{style:{tableLayout:"fixed",visibility:n||k?null:"hidden"}},(!n||!y||R)&&s.createElement(Jv,{colWidths:k?[].concat(De(k),[P]):[],columCount:i+1,columns:F}),g(p(p({},b),{},{stickyOffsets:N,columns:$,flattenColumns:F}))))});ms.displayName="FixedHolder";var Pb=[],Eb={},Pi="rc-table-internal-hook",Rb=s.memo(function(t){var e=t.children;return e},function(t,e){return tu(t.props,e.props)?t.pingLeft!==e.pingLeft||t.pingRight!==e.pingRight:!1});function na(t){var e,r=t.prefixCls,n=t.className,a=t.rowClassName,o=t.style,l=t.data,i=t.rowKey,u=t.scroll,c=t.tableLayout,d=t.direction,f=t.title,v=t.footer,m=t.summary,h=t.id,y=t.showHeader,g=t.components,b=t.emptyText,x=t.onRow,S=t.onHeaderRow,w=t.internalHooks,E=t.transformColumns,P=t.internalRefs,T=t.sticky,M=l||Pb,R=!!M.length,D=s.useCallback(function(st,ht){return Kv(g||{},st)||ht},[g]),O=s.useMemo(function(){return typeof i=="function"?i:function(st){var ht=st&&st[i];return ht}},[i]),$=ib(t),F=$.expandIcon,N=$.expandedRowKeys,k=$.defaultExpandedRowKeys,I=$.defaultExpandAllRows,L=$.expandedRowRender,j=$.columnTitle,_=$.onExpand,A=$.onExpandedRowsChange,K=$.expandRowByClick,z=$.rowExpandable,V=$.expandIconColumnIndex,X=$.expandedRowClassName,W=$.childrenColumnName,Z=$.indentSize,U=F||gb,ae=W||"children",q=s.useMemo(function(){return L?"row":t.expandable&&w===Pi&&t.expandable.__PARENT_RENDER_ICON__||M.some(function(st){return st&&Ve(st)==="object"&&st[ae]})?"nest":!1},[!!L,M]),te=s.useState(function(){return k||(I?yb(M,O,ae):[])}),ue=ee(te,2),Y=ue[0],J=ue[1],Q=s.useMemo(function(){return new Set(N||Y||[])},[N,Y]),ie=s.useCallback(function(st){var ht=O(st,M.indexOf(st)),Nt,Zt=Q.has(ht);Zt?(Q.delete(ht),Nt=De(Q)):Nt=[].concat(De(Q),[ht]),J(Nt),_&&_(!Zt,st),A&&A(Nt)},[O,Q,M,_,A]),le=s.useState(0),ge=ee(le,2),Pe=ge[0],ve=ge[1],ce=cb(p(p(p({},t),$),{},{expandable:!!L,columnTitle:j,expandedKeys:Q,getRowKey:O,onTriggerExpand:ie,expandIcon:U,expandIconColumnIndex:V,direction:d}),w===Pi?E:null),fe=ee(ce,2),oe=fe[0],se=fe[1],he=s.useMemo(function(){return{columns:oe,flattenColumns:se}},[oe,se]),be=s.useRef(),ke=s.useRef(),Fe=s.useRef(),Ee=s.useRef(),Re=s.useRef(),we=s.useState(!1),Ge=ee(we,2),Qe=Ge[0],ct=Ge[1],dt=s.useState(!1),mt=ee(dt,2),We=mt[0],Oe=mt[1],ot=Qv(new Map),Je=ee(ot,2),Se=Je[0],He=Je[1],je=sl(se),ze=je.map(function(st){return Se.get(st)}),ye=s.useMemo(function(){return ze},[ze.join("_")]),de=fb(ye,se.length,d),Ce=u&&fs(u.y),Me=u&&fs(u.x)||!!$.fixed,Be=Me&&se.some(function(st){var ht=st.fixed;return ht}),nt=s.useRef(),Ne=xb(T,r),xe=Ne.isSticky,qe=Ne.offsetHeader,it=Ne.offsetSummary,ft=Ne.offsetScroll,At=Ne.stickyClassName,Kt=Ne.container,kt=m==null?void 0:m(M),zt=(Ce||xe)&&s.isValidElement(kt)&&kt.type===cl&&kt.props.fixed,et,tt,lt;Ce&&(tt={overflowY:"scroll",maxHeight:u.y}),Me&&(et={overflowX:"auto"},Ce||(tt={overflowY:"hidden"}),lt={width:(u==null?void 0:u.x)===!0?"auto":u==null?void 0:u.x,minWidth:"100%"});var ut=s.useCallback(function(st,ht){Mf(be.current)&&He(function(Nt){if(Nt.get(st)!==ht){var Zt=new Map(Nt);return Zt.set(st,ht),Zt}return Nt})},[]),wt=db(null),St=ee(wt,2),Ae=St[0],Ue=St[1];function Ie(st,ht){ht&&(typeof ht=="function"?ht(st):ht.scrollLeft!==st&&(ht.scrollLeft=st))}var _e=function(ht){var Nt=ht.currentTarget,Zt=ht.scrollLeft,Ba=d==="rtl",cn=typeof Zt=="number"?Zt:Nt.scrollLeft,vr=Nt||Eb;if(!Ue()||Ue()===vr){var mr;Ae(vr),Ie(cn,ke.current),Ie(cn,Fe.current),Ie(cn,Re.current),Ie(cn,(mr=nt.current)===null||mr===void 0?void 0:mr.setScrollLeft)}if(Nt){var jr=Nt.scrollWidth,hr=Nt.clientWidth;if(jr===hr){ct(!1),Oe(!1);return}Ba?(ct(-cn0)):(ct(cn>0),Oe(cni))return!1;var c=o.get(t),d=o.get(e);if(c&&d)return c==e&&d==t;var f=-1,v=!0,m=r&CC?new pC:void 0;for(o.set(t,e),o.set(e,t);++f0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],r=t.length,n=e.length;if(Math.abs(r-n)!==1)return{add:!1,key:null};function a(o,l){var i=new Map;o.forEach(function(c){i.set(c,!0)});var u=l.filter(function(c){return!i.has(c)});return u.length===1?u[0]:null}return r ").concat(e);return e}var mm=s.forwardRef(function(t,e){var r=t.prefixCls,n=t.data;t.selectable,t.checkable;var a=t.expandedKeys,o=t.selectedKeys,l=t.checkedKeys,i=t.loadedKeys,u=t.loadingKeys,c=t.halfCheckedKeys,d=t.keyEntities,f=t.disabled,v=t.dragging,m=t.dragOverNodeKey,h=t.dropPosition,y=t.motion,g=t.height,b=t.itemHeight,x=t.virtual,S=t.focusable,w=t.activeItem,E=t.focused,P=t.tabIndex,T=t.onKeyDown,M=t.onFocus,R=t.onBlur,D=t.onActiveChange,O=t.onListChangeStart,$=t.onListChangeEnd,F=Le(t,mS),N=s.useRef(null),k=s.useRef(null);s.useImperativeHandle(e,function(){return{scrollTo:function(fe){N.current.scrollTo(fe)},getIndentWidth:function(){return k.current.offsetWidth}}});var I=s.useState(a),L=ee(I,2),j=L[0],_=L[1],A=s.useState(n),K=ee(A,2),z=K[0],V=K[1],X=s.useState(n),W=ee(X,2),Z=W[0],U=W[1],ae=s.useState([]),q=ee(ae,2),te=q[0],ue=q[1],Y=s.useState(null),J=ee(Y,2),Q=J[0],ie=J[1],le=s.useRef(n);le.current=n;function ge(){var ce=le.current;V(ce),U(ce),ue([]),ie(null),$()}Ji(function(){_(a);var ce=vS(j,a);if(ce.key!==null)if(ce.add){var fe=z.findIndex(function(Fe){var Ee=Fe.key;return Ee===ce.key}),oe=Yc(Hc(z,n,ce.key),x,g,b),se=z.slice();se.splice(fe+1,0,Uc),U(se),ue(oe),ie("show")}else{var he=n.findIndex(function(Fe){var Ee=Fe.key;return Ee===ce.key}),be=Yc(Hc(n,z,ce.key),x,g,b),ke=n.slice();ke.splice(he+1,0,Uc),U(ke),ue(be),ie("hide")}else z!==n&&(V(n),U(n))},[a,n]),s.useEffect(function(){v||ge()},[v]);var Pe=y?Z:n,ve={expandedKeys:a,selectedKeys:o,loadedKeys:i,loadingKeys:u,checkedKeys:l,halfCheckedKeys:c,dragOverNodeKey:m,dropPosition:h,keyEntities:d};return s.createElement(s.Fragment,null,E&&w&&s.createElement("span",{style:Wc,"aria-live":"assertive"},pS(w)),s.createElement("div",null,s.createElement("input",{style:Wc,disabled:S===!1||f,tabIndex:S!==!1?P:null,onKeyDown:T,onFocus:M,onBlur:R,value:"",onChange:hS,"aria-label":"for screen reader"})),s.createElement("div",{className:"".concat(r,"-treenode"),"aria-hidden":!0,style:{position:"absolute",pointerEvents:"none",visibility:"hidden",height:0,overflow:"hidden",border:0,padding:0}},s.createElement("div",{className:"".concat(r,"-indent")},s.createElement("div",{ref:k,className:"".concat(r,"-indent-unit")}))),s.createElement(Lp,re({},F,{data:Pe,itemKey:Gc,height:g,fullHeight:!1,virtual:x,itemHeight:b,prefixCls:"".concat(r,"-list"),ref:N,onVisibleChange:function(fe,oe){var se=new Set(fe),he=oe.filter(function(be){return!se.has(be)});he.some(function(be){return Gc(be)===Qr})&&ge()}}),function(ce){var fe=ce.pos,oe=re({},(dm(ce.data),ce.data)),se=ce.title,he=ce.key,be=ce.isStart,ke=ce.isEnd,Fe=_o(he,fe);delete oe.key,delete oe.children;var Ee=io(Fe,ve);return s.createElement(fS,re({},oe,Ee,{title:se,active:!!w&&he===w.key,pos:fe,data:ce.data,isStart:be,isEnd:ke,motion:y,motionNodes:he===Qr?te:null,motionType:Q,onMotionStart:O,onMotionEnd:ge,treeNodeRequiredProps:ve,onMouseMove:function(){D(null)}}))}))});mm.displayName="NodeList";function An(t,e){if(!t)return[];var r=t.slice(),n=r.indexOf(e);return n>=0&&r.splice(n,1),r}function Jn(t,e){var r=(t||[]).slice();return r.indexOf(e)===-1&&r.push(e),r}function wu(t){return t.split("-")}function gS(t,e){var r=[],n=vn(e,t);function a(){var o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];o.forEach(function(l){var i=l.key,u=l.children;r.push(i),a(u)})}return a(n.children),r}function yS(t){if(t.parent){var e=wu(t.pos);return Number(e[e.length-1])===t.parent.children.length-1}return!1}function bS(t){var e=wu(t.pos);return Number(e[e.length-1])===0}function qc(t,e,r,n,a,o,l,i,u,c){var d,f=t.clientX,v=t.clientY,m=t.target.getBoundingClientRect(),h=m.top,y=m.height,g=(c==="rtl"?-1:1)*(((a==null?void 0:a.x)||0)-f),b=(g-12)/n,x=vn(i,r.props.eventKey);if(v-1.5?o({dragNode:$,dropNode:F,dropPosition:1})?R=1:N=!1:o({dragNode:$,dropNode:F,dropPosition:0})?R=0:o({dragNode:$,dropNode:F,dropPosition:1})?R=1:N=!1:o({dragNode:$,dropNode:F,dropPosition:1})?R=1:N=!1,{dropPosition:R,dropLevelOffset:D,dropTargetKey:x.key,dropTargetPos:x.pos,dragOverNodeKey:M,dropContainerKey:R===0?null:((d=x.parent)===null||d===void 0?void 0:d.key)||null,dropAllowed:N}}function Xc(t,e){if(t){var r=e.multiple;return r?t.slice():t.length?[t[0]]:t}}function Ll(t){if(!t)return null;var e;if(Array.isArray(t))e={checkedKeys:t,halfCheckedKeys:void 0};else if(Ve(t)==="object")e={checkedKeys:t.checked||void 0,halfCheckedKeys:t.halfChecked||void 0};else return rn(!1,"`checkedKeys` is not an array or an object"),null;return e}function xs(t,e){var r=new Set;function n(a){if(!r.has(a)){var o=vn(e,a);if(o){r.add(a);var l=o.parent,i=o.node;i.disabled||l&&n(l.key)}}}return(t||[]).forEach(function(a){n(a)}),De(r)}var CS=10,pl=function(t){gn(r,t);var e=yn(r);function r(){var n;bn(this,r);for(var a=arguments.length,o=new Array(a),l=0;l2&&arguments[2]!==void 0?arguments[2]:!1,f=n.state,v=f.dragChildrenKeys,m=f.dropPosition,h=f.dropTargetKey,y=f.dropTargetPos,g=f.dropAllowed;if(g){var b=n.props.onDrop;if(n.setState({dragOverNodeKey:null}),n.cleanDragState(),h!==null){var x=p(p({},io(h,n.getTreeNodeRequiredProps())),{},{active:((c=n.getActiveItem())===null||c===void 0?void 0:c.key)===h,data:vn(n.state.keyEntities,h).node}),S=v.indexOf(h)!==-1;rn(!S,"Can not drop to dragNode's children node. This is a bug of rc-tree. Please report an issue.");var w=wu(y),E={event:i,node:Wt(x),dragNode:n.dragNode?Wt(n.dragNode.props):null,dragNodesKeys:[n.dragNode.props.eventKey].concat(v),dropToGap:m!==0,dropPosition:m+Number(w[w.length-1])};d||b==null||b(E),n.dragNode=null}}},n.cleanDragState=function(){var i=n.state.draggingNodeKey;i!==null&&n.setState({draggingNodeKey:null,dropPosition:null,dropContainerKey:null,dropTargetKey:null,dropLevelOffset:null,dropAllowed:!0,dragOverNodeKey:null}),n.dragStartMousePosition=null,n.currentMouseOverDroppableNodeKey=null},n.triggerExpandActionExpand=function(i,u){var c=n.state,d=c.expandedKeys,f=c.flattenNodes,v=u.expanded,m=u.key,h=u.isLeaf;if(!(h||i.shiftKey||i.metaKey||i.ctrlKey)){var y=f.filter(function(b){return b.key===m})[0],g=Wt(p(p({},io(m,n.getTreeNodeRequiredProps())),{},{data:y.data}));n.setExpandedKeys(v?An(d,m):Jn(d,m)),n.onNodeExpand(i,g)}},n.onNodeClick=function(i,u){var c=n.props,d=c.onClick,f=c.expandAction;f==="click"&&n.triggerExpandActionExpand(i,u),d==null||d(i,u)},n.onNodeDoubleClick=function(i,u){var c=n.props,d=c.onDoubleClick,f=c.expandAction;f==="doubleClick"&&n.triggerExpandActionExpand(i,u),d==null||d(i,u)},n.onNodeSelect=function(i,u){var c=n.state.selectedKeys,d=n.state,f=d.keyEntities,v=d.fieldNames,m=n.props,h=m.onSelect,y=m.multiple,g=u.selected,b=u[v.key],x=!g;x?y?c=Jn(c,b):c=[b]:c=An(c,b);var S=c.map(function(w){var E=vn(f,w);return E?E.node:null}).filter(function(w){return w});n.setUncontrolledState({selectedKeys:c}),h==null||h(c,{event:"select",selected:x,node:u,selectedNodes:S,nativeEvent:i.nativeEvent})},n.onNodeCheck=function(i,u,c){var d=n.state,f=d.keyEntities,v=d.checkedKeys,m=d.halfCheckedKeys,h=n.props,y=h.checkStrictly,g=h.onCheck,b=u.key,x,S={event:"check",node:u,checked:c,nativeEvent:i.nativeEvent};if(y){var w=c?Jn(v,b):An(v,b),E=An(m,b);x={checked:w,halfChecked:E},S.checkedNodes=w.map(function(O){return vn(f,O)}).filter(function(O){return O}).map(function(O){return O.node}),n.setUncontrolledState({checkedKeys:w})}else{var P=wn([].concat(De(v),[b]),!0,f),T=P.checkedKeys,M=P.halfCheckedKeys;if(!c){var R=new Set(T);R.delete(b);var D=wn(Array.from(R),{checked:!1,halfCheckedKeys:M},f);T=D.checkedKeys,M=D.halfCheckedKeys}x=T,S.checkedNodes=[],S.checkedNodesPositions=[],S.halfCheckedKeys=M,T.forEach(function(O){var $=vn(f,O);if($){var F=$.node,N=$.pos;S.checkedNodes.push(F),S.checkedNodesPositions.push({node:F,pos:N})}}),n.setUncontrolledState({checkedKeys:T},!1,{halfCheckedKeys:M})}g==null||g(x,S)},n.onNodeLoad=function(i){var u=i.key,c=new Promise(function(d,f){n.setState(function(v){var m=v.loadedKeys,h=m===void 0?[]:m,y=v.loadingKeys,g=y===void 0?[]:y,b=n.props,x=b.loadData,S=b.onLoad;if(!x||h.indexOf(u)!==-1||g.indexOf(u)!==-1)return null;var w=x(i);return w.then(function(){var E=n.state.loadedKeys,P=Jn(E,u);S==null||S(P,{event:"load",node:i}),n.setUncontrolledState({loadedKeys:P}),n.setState(function(T){return{loadingKeys:An(T.loadingKeys,u)}}),d()}).catch(function(E){if(n.setState(function(T){return{loadingKeys:An(T.loadingKeys,u)}}),n.loadingRetryTimes[u]=(n.loadingRetryTimes[u]||0)+1,n.loadingRetryTimes[u]>=CS){var P=n.state.loadedKeys;rn(!1,"Retry for `loadData` many times but still failed. No more retry."),n.setUncontrolledState({loadedKeys:Jn(P,u)}),d()}f(E)}),{loadingKeys:Jn(g,u)}})});return c.catch(function(){}),c},n.onNodeMouseEnter=function(i,u){var c=n.props.onMouseEnter;c==null||c({event:i,node:u})},n.onNodeMouseLeave=function(i,u){var c=n.props.onMouseLeave;c==null||c({event:i,node:u})},n.onNodeContextMenu=function(i,u){var c=n.props.onRightClick;c&&(i.preventDefault(),c({event:i,node:u}))},n.onFocus=function(){var i=n.props.onFocus;n.setState({focused:!0});for(var u=arguments.length,c=new Array(u),d=0;d1&&arguments[1]!==void 0?arguments[1]:!1,c=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null;if(!n.destroyed){var d=!1,f=!0,v={};Object.keys(i).forEach(function(m){if(m in n.props){f=!1;return}d=!0,v[m]=i[m]}),d&&(!u||f)&&n.setState(p(p({},v),c))}},n.scrollTo=function(i){n.listRef.current.scrollTo(i)},n}return Cn(r,[{key:"componentDidMount",value:function(){this.destroyed=!1,this.onUpdated()}},{key:"componentDidUpdate",value:function(){this.onUpdated()}},{key:"onUpdated",value:function(){var a=this.props.activeKey;a!==void 0&&a!==this.state.activeKey&&(this.setState({activeKey:a}),a!==null&&this.scrollTo({key:a}))}},{key:"componentWillUnmount",value:function(){window.removeEventListener("dragend",this.onWindowDragEnd),this.destroyed=!0}},{key:"resetDragState",value:function(){this.setState({dragOverNodeKey:null,dropPosition:null,dropLevelOffset:null,dropTargetKey:null,dropContainerKey:null,dropTargetPos:null,dropAllowed:!1})}},{key:"render",value:function(){var a,o=this.state,l=o.focused,i=o.flattenNodes,u=o.keyEntities,c=o.draggingNodeKey,d=o.activeKey,f=o.dropLevelOffset,v=o.dropContainerKey,m=o.dropTargetKey,h=o.dropPosition,y=o.dragOverNodeKey,g=o.indent,b=this.props,x=b.prefixCls,S=b.className,w=b.style,E=b.showLine,P=b.focusable,T=b.tabIndex,M=T===void 0?0:T,R=b.selectable,D=b.showIcon,O=b.icon,$=b.switcherIcon,F=b.draggable,N=b.checkable,k=b.checkStrictly,I=b.disabled,L=b.motion,j=b.loadData,_=b.filterTreeNode,A=b.height,K=b.itemHeight,z=b.virtual,V=b.titleRender,X=b.dropIndicatorRender,W=b.onContextMenu,Z=b.onScroll,U=b.direction,ae=b.rootClassName,q=b.rootStyle,te=eu(this.props,{aria:!0,data:!0}),ue;return F&&(Ve(F)==="object"?ue=F:typeof F=="function"?ue={nodeDraggable:F}:ue={}),s.createElement(Su.Provider,{value:{prefixCls:x,selectable:R,showIcon:D,icon:O,switcherIcon:$,draggable:ue,draggingNodeKey:c,checkable:N,checkStrictly:k,disabled:I,keyEntities:u,dropLevelOffset:f,dropContainerKey:v,dropTargetKey:m,dropPosition:h,dragOverNodeKey:y,indent:g,direction:U,dropIndicatorRender:X,loadData:j,filterTreeNode:_,titleRender:V,onNodeClick:this.onNodeClick,onNodeDoubleClick:this.onNodeDoubleClick,onNodeExpand:this.onNodeExpand,onNodeSelect:this.onNodeSelect,onNodeCheck:this.onNodeCheck,onNodeLoad:this.onNodeLoad,onNodeMouseEnter:this.onNodeMouseEnter,onNodeMouseLeave:this.onNodeMouseLeave,onNodeContextMenu:this.onNodeContextMenu,onNodeDragStart:this.onNodeDragStart,onNodeDragEnter:this.onNodeDragEnter,onNodeDragOver:this.onNodeDragOver,onNodeDragLeave:this.onNodeDragLeave,onNodeDragEnd:this.onNodeDragEnd,onNodeDrop:this.onNodeDrop}},s.createElement("div",{role:"tree",className:pe(x,S,ae,(a={},B(a,"".concat(x,"-show-line"),E),B(a,"".concat(x,"-focused"),l),B(a,"".concat(x,"-active-focused"),d!==null),a)),style:q},s.createElement(mm,re({ref:this.listRef,prefixCls:x,style:w,data:i,disabled:I,selectable:R,checkable:!!N,motion:L,dragging:c!==null,height:A,itemHeight:K,virtual:z,focusable:P,focused:l,tabIndex:M,activeItem:this.getActiveItem(),onFocus:this.onFocus,onBlur:this.onBlur,onKeyDown:this.onKeyDown,onActiveChange:this.onActiveChange,onListChangeStart:this.onListChangeStart,onListChangeEnd:this.onListChangeEnd,onContextMenu:W,onScroll:Z},this.getTreeNodeRequiredProps(),te))))}}],[{key:"getDerivedStateFromProps",value:function(a,o){var l=o.prevProps,i={prevProps:a};function u(P){return!l&&P in a||l&&l[P]!==a[P]}var c,d=o.fieldNames;if(u("fieldNames")&&(d=Ni(a.fieldNames),i.fieldNames=d),u("treeData")?c=a.treeData:u("children")&&(rn(!1,"`children` of Tree is deprecated. Please use `treeData` instead."),c=Sv(a.children)),c){i.treeData=c;var f=Lo(c,{fieldNames:d});i.keyEntities=p(B({},Qr,vm),f.keyEntities)}var v=i.keyEntities||o.keyEntities;if(u("expandedKeys")||l&&u("autoExpandParent"))i.expandedKeys=a.autoExpandParent||!l&&a.defaultExpandParent?xs(a.expandedKeys,v):a.expandedKeys;else if(!l&&a.defaultExpandAll){var m=p({},v);delete m[Qr],i.expandedKeys=Object.keys(m).map(function(P){return m[P].key})}else!l&&a.defaultExpandedKeys&&(i.expandedKeys=a.autoExpandParent||a.defaultExpandParent?xs(a.defaultExpandedKeys,v):a.defaultExpandedKeys);if(i.expandedKeys||delete i.expandedKeys,c||i.expandedKeys){var h=Ol(c||o.treeData,i.expandedKeys||o.expandedKeys,d);i.flattenNodes=h}if(a.selectable&&(u("selectedKeys")?i.selectedKeys=Xc(a.selectedKeys,a):!l&&a.defaultSelectedKeys&&(i.selectedKeys=Xc(a.defaultSelectedKeys,a))),a.checkable){var y;if(u("checkedKeys")?y=Ll(a.checkedKeys)||{}:!l&&a.defaultCheckedKeys?y=Ll(a.defaultCheckedKeys)||{}:c&&(y=Ll(a.checkedKeys)||{checkedKeys:o.checkedKeys,halfCheckedKeys:o.halfCheckedKeys}),y){var g=y,b=g.checkedKeys,x=b===void 0?[]:b,S=g.halfCheckedKeys,w=S===void 0?[]:S;if(!a.checkStrictly){var E=wn(x,!0,v);x=E.checkedKeys,w=E.halfCheckedKeys}i.checkedKeys=x,i.halfCheckedKeys=w}}return u("loadedKeys")&&(i.loadedKeys=a.loadedKeys),i}}]),r}(s.Component);pl.defaultProps={prefixCls:"rc-tree",showLine:!1,showIcon:!0,selectable:!0,multiple:!1,checkable:!1,disabled:!1,checkStrictly:!1,draggable:!1,defaultExpandParent:!0,autoExpandParent:!1,defaultExpandAll:!1,defaultExpandedKeys:[],defaultCheckedKeys:[],defaultSelectedKeys:[],dropIndicatorRender:aS,allowDrop:function(){return!0},expandAction:!1};pl.TreeNode=ba;var xS={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M300 276.5a56 56 0 1056-97 56 56 0 00-56 97zm0 284a56 56 0 1056-97 56 56 0 00-56 97zM640 228a56 56 0 10112 0 56 56 0 00-112 0zm0 284a56 56 0 10112 0 56 56 0 00-112 0zM300 844.5a56 56 0 1056-97 56 56 0 00-56 97zM640 796a56 56 0 10112 0 56 56 0 00-112 0z"}}]},name:"holder",theme:"outlined"};const SS=xS;var wS=function(e,r){return s.createElement(Ft,p(p({},e),{},{ref:r,icon:SS}))},PS=s.forwardRef(wS);const ES=PS;var Zc=4;function RS(t){var e=t.dropPosition,r=t.dropLevelOffset,n=t.prefixCls,a=t.indent,o=t.direction,l=o===void 0?"ltr":o,i=l==="ltr"?"left":"right",u=l==="ltr"?"right":"left",c=B(B({},i,-r*a+Zc),u,0);switch(e){case-1:c.top=-3;break;case 1:c.bottom=-3;break;default:c.bottom=-3,c[i]=a+Zc;break}return G.createElement("div",{style:c,className:"".concat(n,"-drop-indicator")})}var kS={icon:{tag:"svg",attrs:{viewBox:"0 0 1024 1024",focusable:"false"},children:[{tag:"path",attrs:{d:"M840.4 300H183.6c-19.7 0-30.7 20.8-18.5 35l328.4 380.8c9.4 10.9 27.5 10.9 37 0L858.9 335c12.2-14.2 1.2-35-18.5-35z"}}]},name:"caret-down",theme:"filled"};const FS=kS;var MS=function(e,r){return s.createElement(Ft,p(p({},e),{},{ref:r,icon:FS}))},NS=s.forwardRef(MS);const TS=NS;var $S={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M854.6 288.6L639.4 73.4c-6-6-14.1-9.4-22.6-9.4H192c-17.7 0-32 14.3-32 32v832c0 17.7 14.3 32 32 32h640c17.7 0 32-14.3 32-32V311.3c0-8.5-3.4-16.7-9.4-22.7zM790.2 326H602V137.8L790.2 326zm1.8 562H232V136h302v216a42 42 0 0042 42h216v494z"}}]},name:"file",theme:"outlined"};const DS=$S;var OS=function(e,r){return s.createElement(Ft,p(p({},e),{},{ref:r,icon:DS}))},IS=s.forwardRef(OS);const hm=IS;var _S={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M328 544h368c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8H328c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8z"}},{tag:"path",attrs:{d:"M880 112H144c-17.7 0-32 14.3-32 32v736c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V144c0-17.7-14.3-32-32-32zm-40 728H184V184h656v656z"}}]},name:"minus-square",theme:"outlined"};const LS=_S;var jS=function(e,r){return s.createElement(Ft,p(p({},e),{},{ref:r,icon:LS}))},AS=s.forwardRef(jS);const KS=AS;var VS={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M328 544h152v152c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V544h152c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8H544V328c0-4.4-3.6-8-8-8h-48c-4.4 0-8 3.6-8 8v152H328c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8z"}},{tag:"path",attrs:{d:"M880 112H144c-17.7 0-32 14.3-32 32v736c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V144c0-17.7-14.3-32-32-32zm-40 728H184V184h656v656z"}}]},name:"plus-square",theme:"outlined"};const zS=VS;var BS=function(e,r){return s.createElement(Ft,p(p({},e),{},{ref:r,icon:zS}))},HS=s.forwardRef(BS);const WS=HS;function pm(t,e,r,n){var a=n.isLeaf,o=n.expanded,l=n.loading;if(l)return s.createElement(Ma,{className:"".concat(t,"-switcher-loading-icon")});var i;if(r&&Ve(r)==="object"&&(i=r.showLeafIcon),a){if(!r)return null;if(typeof i!="boolean"&&i){var u=typeof i=="function"?i(n):i,c="".concat(t,"-switcher-line-custom-icon");return Ju(u)?ho(u,{className:pe(u.props.className||"",c)}):u}return i?s.createElement(hm,{className:"".concat(t,"-switcher-line-icon")}):s.createElement("span",{className:"".concat(t,"-switcher-leaf-line")})}var d="".concat(t,"-switcher-icon"),f=typeof e=="function"?e(n):e;return Ju(f)?ho(f,{className:pe(f.props.className||"",d)}):f||(r?o?s.createElement(KS,{className:"".concat(t,"-switcher-line-icon")}):s.createElement(WS,{className:"".concat(t,"-switcher-line-icon")}):s.createElement(TS,{className:d}))}var US=s.forwardRef(function(t,e){var r=s.useContext(Ut),n=r.getPrefixCls,a=r.direction,o=r.virtual,l=t.prefixCls,i=t.className,u=t.showIcon,c=u===void 0?!1:u,d=t.showLine,f=t.switcherIcon,v=t.blockNode,m=v===void 0?!1:v,h=t.children,y=t.checkable,g=y===void 0?!1:y,b=t.selectable,x=b===void 0?!0:b,S=t.draggable,w=t.motion,E=w===void 0?re(re({},xp),{motionAppear:!1}):w,P=n("tree",l),T=re(re({},t),{checkable:g,selectable:x,showIcon:c,motion:E,blockNode:m,showLine:!!d,dropIndicatorRender:RS}),M=s.useMemo(function(){if(!S)return!1;var R={};switch(Ve(S)){case"function":R.nodeDraggable=S;break;case"object":R=re({},S);break}return R.icon!==!1&&(R.icon=R.icon||s.createElement(ES,null)),R},[S]);return s.createElement(pl,re({itemHeight:20,ref:e,virtual:o},T,{prefixCls:P,className:pe(B(B(B(B({},"".concat(P,"-icon-hide"),!c),"".concat(P,"-block-node"),m),"".concat(P,"-unselectable"),!x),"".concat(P,"-rtl"),a==="rtl"),i),direction:a,checkable:g&&s.createElement("span",{className:"".concat(P,"-checkbox-inner")}),selectable:x,switcherIcon:function(D){return pm(P,f,d,D)},draggable:M}),h)});const gm=US;var YS={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M928 444H820V330.4c0-17.7-14.3-32-32-32H473L355.7 186.2a8.15 8.15 0 00-5.5-2.2H96c-17.7 0-32 14.3-32 32v592c0 17.7 14.3 32 32 32h698c13 0 24.8-7.9 29.7-20l134-332c1.5-3.8 2.3-7.9 2.3-12 0-17.7-14.3-32-32-32zM136 256h188.5l119.6 114.4H748V444H238c-13 0-24.8 7.9-29.7 20L136 643.2V256zm635.3 512H159l103.3-256h612.4L771.3 768z"}}]},name:"folder-open",theme:"outlined"};const GS=YS;var qS=function(e,r){return s.createElement(Ft,p(p({},e),{},{ref:r,icon:GS}))},XS=s.forwardRef(qS);const ZS=XS;var QS={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M880 298.4H521L403.7 186.2a8.15 8.15 0 00-5.5-2.2H144c-17.7 0-32 14.3-32 32v592c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V330.4c0-17.7-14.3-32-32-32zM840 768H184V256h188.5l119.6 114.4H840V768z"}}]},name:"folder",theme:"outlined"};const JS=QS;var e4=function(e,r){return s.createElement(Ft,p(p({},e),{},{ref:r,icon:JS}))},t4=s.forwardRef(e4);const n4=t4;var er;(function(t){t[t.None=0]="None",t[t.Start=1]="Start",t[t.End=2]="End"})(er||(er={}));function Pu(t,e){function r(n){var a=n.key,o=n.children;e(a,n)!==!1&&Pu(o||[],e)}t.forEach(r)}function r4(t){var e=t.treeData,r=t.expandedKeys,n=t.startKey,a=t.endKey,o=[],l=er.None;if(n&&n===a)return[n];if(!n||!a)return[];function i(u){return u===n||u===a}return Pu(e,function(u){if(l===er.End)return!1;if(i(u)){if(o.push(u),l===er.None)l=er.Start;else if(l===er.Start)return l=er.End,!1}else l===er.Start&&o.push(u);return r.includes(u)}),o}function jl(t,e){var r=De(e),n=[];return Pu(t,function(a,o){var l=r.indexOf(a);return l!==-1&&(n.push(o),r.splice(l,1)),!!r.length}),n}var Qc=globalThis&&globalThis.__rest||function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,n=Object.getOwnPropertySymbols(t);a0&&arguments[0]!==void 0?arguments[0]:{confirm:!1,closeDropdown:!1},we=Re.confirm,Ge=Re.closeDropdown;we&&ue([]),Ge&&$(!1),q(""),j(E?(P||[]).map(function(Qe){return String(Qe)}):[])},Q=function(){var Re=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{closeDropdown:!0},we=Re.closeDropdown;we&&$(!1),ue(L())},ie=function(Re){Re&&N!==void 0&&j(Al(N)),$(Re),!Re&&!a.filterDropdown&&Y()},le=pe(B({},"".concat(o,"-menu-without-submenu"),!f4(a.filters||[]))),ge=function(Re){if(Re.target.checked){var we=va(a==null?void 0:a.filters).map(function(Ge){return String(Ge)});j(we)}else j([])},Pe=function Ee(Re){var we=Re.filters;return(we||[]).map(function(Ge,Qe){var ct=String(Ge.value),dt={title:Ge.text,key:Ge.value!==void 0?ct:String(Qe)};return Ge.children&&(dt.children=Ee({filters:Ge.children})),dt})},ve=function Ee(Re){var we;return re(re({},Re),{text:Re.title,value:Re.key,children:((we=Re.children)===null||we===void 0?void 0:we.map(function(Ge){return Ee(Ge)}))||[]})},ce;if(typeof a.filterDropdown=="function")ce=a.filterDropdown({prefixCls:"".concat(o,"-custom"),setSelectedKeys:function(Re){return _({selectedKeys:Re})},selectedKeys:L(),confirm:Q,clearFilters:J,filters:a.filters,visible:F,close:function(){$(!1)}});else if(a.filterDropdown)ce=a.filterDropdown;else{var fe=L()||[],oe=function(){return(a.filters||[]).length===0?s.createElement(Qu,{image:Qu.PRESENTED_IMAGE_SIMPLE,description:h.filterEmptyText,imageStyle:{height:24},style:{margin:0,padding:"16px 0"}}):c==="tree"?s.createElement(s.Fragment,null,s.createElement(ed,{filterSearch:f,value:ae,onChange:te,tablePrefixCls:r,locale:h}),s.createElement("div",{className:"".concat(r,"-filter-dropdown-tree")},i?s.createElement(ha,{checked:fe.length===va(a.filters).length,indeterminate:fe.length>0&&fe.length0?o:t}),v=Math.ceil((o||t)/f.pageSize);f.current>v&&(f.current=v||1);var m=function(g,b){d({current:g??1,pageSize:b||f.pageSize})},h=function(g,b){var x;e&&((x=e.onChange)===null||x===void 0||x.call(e,g,b)),m(g,b),r(g,b||(f==null?void 0:f.pageSize))};return e===!1?[{},function(){}]:[re(re({},f),{onChange:h}),m]}var br={},ws="SELECT_ALL",Ps="SELECT_INVERT",Es="SELECT_NONE",rd=[];function Pm(t,e){var r=[];return(t||[]).forEach(function(n){r.push(n),n&&Ve(n)==="object"&&e in n&&(r=[].concat(De(r),De(Pm(n[e],e))))}),r}function b4(t,e){var r=t||{},n=r.preserveSelectedRowKeys,a=r.selectedRowKeys,o=r.defaultSelectedRowKeys,l=r.getCheckboxProps,i=r.onChange,u=r.onSelect,c=r.onSelectAll,d=r.onSelectInvert,f=r.onSelectNone,v=r.onSelectMultiple,m=r.columnWidth,h=r.type,y=r.selections,g=r.fixed,b=r.renderCell,x=r.hideSelectAll,S=r.checkStrictly,w=S===void 0?!0:S,E=e.prefixCls,P=e.data,T=e.pageData,M=e.getRecordByKey,R=e.getRowKey,D=e.expandType,O=e.childrenColumnName,$=e.locale,F=e.getPopupContainer,N=xt(a||o||rd,{value:a}),k=ee(N,2),I=k[0],L=k[1],j=s.useRef(new Map),_=s.useCallback(function(ve){if(n){var ce=new Map;ve.forEach(function(fe){var oe=M(fe);!oe&&j.current.has(fe)&&(oe=j.current.get(fe)),ce.set(fe,oe)}),j.current=ce}},[M,n]);s.useEffect(function(){_(I)},[I]);var A=s.useMemo(function(){return w?{keyEntities:null}:Lo(P,{externalGetKey:R,childrenPropName:O})},[P,R,w,O]),K=A.keyEntities,z=s.useMemo(function(){return Pm(T,O)},[T,O]),V=s.useMemo(function(){var ve=new Map;return z.forEach(function(ce,fe){var oe=R(ce,fe),se=(l?l(ce):null)||{};ve.set(oe,se)}),ve},[z,R,l]),X=s.useCallback(function(ve){var ce;return!!(!((ce=V.get(R(ve)))===null||ce===void 0)&&ce.disabled)},[V,R]),W=s.useMemo(function(){if(w)return[I||[],[]];var ve=wn(I,!0,K,X),ce=ve.checkedKeys,fe=ve.halfCheckedKeys;return[ce||[],fe]},[I,w,K,X]),Z=ee(W,2),U=Z[0],ae=Z[1],q=s.useMemo(function(){var ve=h==="radio"?U.slice(0,1):U;return new Set(ve)},[U,h]),te=s.useMemo(function(){return h==="radio"?new Set:new Set(ae)},[ae,h]),ue=s.useState(null),Y=ee(ue,2),J=Y[0],Q=Y[1];s.useEffect(function(){t||L(rd)},[!!t]);var ie=s.useCallback(function(ve,ce){var fe,oe;_(ve),n?(fe=ve,oe=ve.map(function(se){return j.current.get(se)})):(fe=[],oe=[],ve.forEach(function(se){var he=M(se);he!==void 0&&(fe.push(se),oe.push(he))})),L(fe),i==null||i(fe,oe,{type:ce})},[L,M,i,n]),le=s.useCallback(function(ve,ce,fe,oe){if(u){var se=fe.map(function(he){return M(he)});u(M(ve),ce,se,oe)}ie(fe,"single")},[u,M,ie]),ge=s.useMemo(function(){if(!y||x)return null;var ve=y===!0?[ws,Ps,Es]:y;return ve.map(function(ce){return ce===ws?{key:"all",text:$.selectionAll,onSelect:function(){ie(P.map(function(oe,se){return R(oe,se)}).filter(function(oe){var se=V.get(oe);return!(se!=null&&se.disabled)||q.has(oe)}),"all")}}:ce===Ps?{key:"invert",text:$.selectInvert,onSelect:function(){var oe=new Set(q);T.forEach(function(he,be){var ke=R(he,be),Fe=V.get(ke);Fe!=null&&Fe.disabled||(oe.has(ke)?oe.delete(ke):oe.add(ke))});var se=Array.from(oe);d&&d(se),ie(se,"invert")}}:ce===Es?{key:"none",text:$.selectNone,onSelect:function(){f==null||f(),ie(Array.from(q).filter(function(oe){var se=V.get(oe);return se==null?void 0:se.disabled}),"none")}}:ce}).map(function(ce){return re(re({},ce),{onSelect:function(){for(var oe,se,he=arguments.length,be=new Array(he),ke=0;ke2&&arguments[2]!==void 0?arguments[2]:!1,at=re(re({},fe),Ue);_e&&(fe.resetPagination(),at.pagination.current&&(at.pagination.current=1),c&&c.onChange&&c.onChange(1,at.pagination.pageSize)),R&&R.scrollToFirstRowOnChange!==!1&&le.body.current&&Xp(0,{getContainer:function(){return le.body.current}}),b==null||b(at.pagination,at.filters,at.sorter,{currentDataSource:nd(ks(U,at.sorterStates,Q),at.filterStates),action:Ie})},se=function(Ue,Ie){oe({sorter:Ue,sorterStates:Ie},"sort",!1)},he=T4({prefixCls:te,mergedColumns:L,onSorterChange:se,sortDirections:D||["ascend","descend"],tableLocale:Z,showSorterTooltip:F}),be=ee(he,4),ke=be[0],Fe=be[1],Ee=be[2],Re=be[3],we=s.useMemo(function(){return ks(U,Fe,Q)},[U,Fe]);fe.sorter=Re(),fe.sorterStates=Fe;var Ge=function(Ue,Ie){oe({filters:Ue,filterStates:Ie},"filter",!0)},Qe=m4({prefixCls:te,locale:Z,dropdownPrefixCls:ue,mergedColumns:L,onFilterChange:Ge,getPopupContainer:x}),ct=ee(Qe,3),dt=ct[0],mt=ct[1],We=ct[2],Oe=nd(we,mt);fe.filters=We,fe.filterStates=mt;var ot=s.useMemo(function(){var Ae={};return Object.keys(We).forEach(function(Ue){We[Ue]!==null&&(Ae[Ue]=We[Ue])}),re(re({},Ee),{filters:Ae})},[Ee,We]),Je=$4(ot),Se=ee(Je,1),He=Se[0],je=function(Ue,Ie){oe({pagination:re(re({},fe.pagination),{current:Ue,pageSize:Ie})},"paginate")},ze=y4(Oe.length,c,je),ye=ee(ze,2),de=ye[0],Ce=ye[1];fe.pagination=c===!1?{}:p4(c,de),fe.resetPagination=Ce;var Me=s.useMemo(function(){if(c===!1||!de.pageSize)return Oe;var Ae=de.current,Ue=Ae===void 0?1:Ae,Ie=de.total,_e=de.pageSize,at=_e===void 0?wm:_e;return Oe.lengthat?Oe.slice((Ue-1)*at,Ue*at):Oe:Oe.slice((Ue-1)*at,Ue*at)},[!!c,Oe,de&&de.current,de&&de.pageSize,de&&de.total]),Be=b4(d,{prefixCls:te,data:Oe,pageData:Me,getRowKey:ge,getRecordByKey:ce,expandType:ie,childrenColumnName:Q,locale:Z,getPopupContainer:x}),nt=ee(Be,2),Ne=nt[0],xe=nt[1],qe=function(Ue,Ie,_e){var at;return typeof m=="function"?at=pe(m(Ue,Ie,_e)):at=pe(m),pe(B({},"".concat(te,"-row-selected"),xe.has(ge(Ue,Ie))),at)};Y.__PARENT_RENDER_ICON__=Y.expandIcon,Y.expandIcon=Y.expandIcon||w||Mb(Z),ie==="nest"&&Y.expandIconColumnIndex===void 0?Y.expandIconColumnIndex=d?1:0:Y.expandIconColumnIndex>0&&d&&(Y.expandIconColumnIndex-=1),typeof Y.indentSize!="number"&&(Y.indentSize=typeof M=="number"?M:15);var it=s.useCallback(function(Ae){return He(Ne(dt(ke(Ae))))},[ke,dt,Ne]),ft,At;if(c!==!1&&(de!=null&&de.total)){var Kt;de.size?Kt=de.size:Kt=W==="small"||W==="middle"?"small":void 0;var kt=function(Ue){return s.createElement(sy,re({},de,{className:pe("".concat(te,"-pagination ").concat(te,"-pagination-").concat(Ue),de.className),size:Kt}))},zt=X==="rtl"?"left":"right",et=de.position;if(et!==null&&Array.isArray(et)){var tt=et.find(function(Ae){return Ae.includes("top")}),lt=et.find(function(Ae){return Ae.includes("bottom")}),ut=et.every(function(Ae){return"".concat(Ae)==="none"});!tt&&!lt&&!ut&&(At=kt(zt)),tt&&(ft=kt(tt.toLowerCase().replace("top",""))),lt&&(At=kt(lt.toLowerCase().replace("bottom","")))}else At=kt(zt)}var wt;typeof S=="boolean"?wt={spinning:S}:Ve(S)==="object"&&(wt=re({spinning:!0},S));var St=pe("".concat(te,"-wrapper"),B({},"".concat(te,"-wrapper-rtl"),X==="rtl"),n);return s.createElement("div",{ref:e,className:St,style:a},s.createElement(kr,re({spinning:!1},wt),ft,s.createElement(na,re({},j,{columns:L,direction:X,expandable:Y,prefixCls:te,className:pe(B(B(B(B({},"".concat(te,"-middle"),W==="middle"),"".concat(te,"-small"),W==="small"),"".concat(te,"-bordered"),l),"".concat(te,"-empty"),U.length===0)),data:Me,rowKey:ge,rowClassName:qe,emptyText:O&&O.emptyText||(V||iu)("Table"),internalHooks:Pi,internalRefs:le,transformColumns:it})),At))}var I4=s.forwardRef(O4),lr=I4;lr.SELECTION_COLUMN=br;lr.EXPAND_COLUMN=na.EXPAND_COLUMN;lr.SELECTION_ALL=ws;lr.SELECTION_INVERT=Ps;lr.SELECTION_NONE=Es;lr.Column=kb;lr.ColumnGroup=Fb;lr.Summary=tm;const Ca=lr;var _4=globalThis&&globalThis.__rest||function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,n=Object.getOwnPropertySymbols(t);a1&&arguments[1]!==void 0?arguments[1]:"0",v=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;return d.map(function(m,h){var y="".concat(f,"-").concat(h),g=m[o.value],b=r.includes(g),x=c(m[o.children]||[],y,b),S=s.createElement(Ru,m,x.map(function(E){return E.node}));if(e===g&&(l=S),b){var w={pos:y,node:S,children:x};return v||i.push(w),w}return null}).filter(function(m){return m})}i||(i=[],c(n),i.sort(function(d,f){var v=d.node.props.value,m=f.node.props.value,h=r.indexOf(v),y=r.indexOf(m);return h-y}))}Object.defineProperty(t,"triggerNode",{get:function(){return rn(!1,"`triggerNode` is deprecated. Please consider decoupling data with node."),u(),l}}),Object.defineProperty(t,"allCheckedNodes",{get:function(){return rn(!1,"`allCheckedNodes` is deprecated. Please consider decoupling data with node."),u(),a?i:i.map(function(d){var f=d.node;return f})}})}function Y4(t,e){var r=e.id,n=e.pId,a=e.rootPId,o={},l=[],i=t.map(function(u){var c=p({},u),d=c[r];return o[d]=c,c.key=c.key||d,c});return i.forEach(function(u){var c=u[n],d=o[c];d&&(d.children=d.children||[],d.children.push(u)),(c===a||!d&&a===null)&&l.push(u)}),l}function G4(t,e,r){return s.useMemo(function(){return t?r?Y4(t,p({id:"id",pId:"pId",rootPId:null},r!==!0?r:{})):t:Dm(e)},[e,r,t])}const q4=function(t){var e=s.useRef({valueLabels:new Map});return s.useMemo(function(){var r=e.current.valueLabels,n=new Map,a=t.map(function(o){var l,i=o.value,u=(l=o.label)!==null&&l!==void 0?l:r.get(i);return n.set(i,u),p(p({},o),{},{label:u})});return e.current.valueLabels=n,[a]},[t])};function ud(t){var e=s.useRef();e.current=t;var r=s.useCallback(function(){return e.current.apply(e,arguments)},[]);return r}const X4=function(t,e){return s.useMemo(function(){var r=Lo(t,{fieldNames:e,initWrapper:function(a){return p(p({},a),{},{valueEntities:new Map})},processEntity:function(a,o){var l=a.node[e.value];o.valueEntities.set(l,a)}});return r},[t,e])},Z4=function(t,e,r,n){return s.useMemo(function(){var a=t.map(function(u){var c=u.value;return c}),o=e.map(function(u){var c=u.value;return c}),l=a.filter(function(u){return!n[u]});if(r){var i=wn(a,!0,n);a=i.checkedKeys,o=i.halfCheckedKeys}return[Array.from(new Set([].concat(De(l),De(a)))),o]},[t,e,r,n])},Q4=function(t,e,r){var n=r.treeNodeFilterProp,a=r.filterTreeNode,o=r.fieldNames,l=o.children;return s.useMemo(function(){if(!e||a===!1)return t;var i;if(typeof a=="function")i=a;else{var u=e.toUpperCase();i=function(f,v){var m=v[n];return String(m).toUpperCase().includes(u)}}function c(d){var f=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return d.map(function(v){var m=v[l],h=f||i(e,Ms(v)),y=c(m||[],h);return h||y.length?p(p({},v),{},B({isLeaf:void 0},l,y)):null}).filter(function(v){return v})}return c(t)},[t,e,l,n,a])};var J4=["id","prefixCls","value","defaultValue","onChange","onSelect","onDeselect","searchValue","inputValue","onSearch","autoClearSearchValue","filterTreeNode","treeNodeFilterProp","showCheckedStrategy","treeNodeLabelProp","multiple","treeCheckable","treeCheckStrictly","labelInValue","fieldNames","treeDataSimpleMode","treeData","children","loadData","treeLoadedKeys","onTreeLoad","treeDefaultExpandAll","treeExpandedKeys","treeDefaultExpandedKeys","onTreeExpand","treeExpandAction","virtual","listHeight","listItemHeight","onDropdownVisibleChange","dropdownMatchSelectWidth","treeLine","treeIcon","showTreeIcon","switcherIcon","treeMotion"];function e3(t){return!t||Ve(t)!=="object"}var t3=s.forwardRef(function(t,e){var r=t.id,n=t.prefixCls,a=n===void 0?"rc-tree-select":n,o=t.value,l=t.defaultValue,i=t.onChange,u=t.onSelect,c=t.onDeselect,d=t.searchValue,f=t.inputValue,v=t.onSearch,m=t.autoClearSearchValue,h=m===void 0?!0:m,y=t.filterTreeNode,g=t.treeNodeFilterProp,b=g===void 0?"value":g,x=t.showCheckedStrategy,S=x===void 0?gl:x,w=t.treeNodeLabelProp,E=t.multiple,P=t.treeCheckable,T=t.treeCheckStrictly,M=t.labelInValue,R=t.fieldNames,D=t.treeDataSimpleMode,O=t.treeData,$=t.children,F=t.loadData,N=t.treeLoadedKeys,k=t.onTreeLoad,I=t.treeDefaultExpandAll,L=t.treeExpandedKeys,j=t.treeDefaultExpandedKeys,_=t.onTreeExpand,A=t.treeExpandAction,K=t.virtual,z=t.listHeight,V=z===void 0?200:z,X=t.listItemHeight,W=X===void 0?20:X,Z=t.onDropdownVisibleChange,U=t.dropdownMatchSelectWidth,ae=U===void 0?!0:U,q=t.treeLine,te=t.treeIcon,ue=t.showTreeIcon,Y=t.switcherIcon,J=t.treeMotion,Q=Le(t,J4),ie=Gf(r),le=P&&!T,ge=P||T,Pe=T||M,ve=ge||E,ce=xt(l,{value:o}),fe=ee(ce,2),oe=fe[0],se=fe[1],he=s.useMemo(function(){return V4(R)},[JSON.stringify(R)]),be=xt("",{value:d!==void 0?d:f,postState:function(tt){return tt||""}}),ke=ee(be,2),Fe=ke[0],Ee=ke[1],Re=function(tt){Ee(tt),v==null||v(tt)},we=G4(O,$,D),Ge=X4(we,he),Qe=Ge.keyEntities,ct=Ge.valueEntities,dt=s.useCallback(function(et){var tt=[],lt=[];return et.forEach(function(ut){ct.has(ut)?lt.push(ut):tt.push(ut)}),{missingRawValues:tt,existRawValues:lt}},[ct]),mt=Q4(we,Fe,{fieldNames:he,treeNodeFilterProp:b,filterTreeNode:y}),We=s.useCallback(function(et){if(et){if(w)return et[w];for(var tt=he._title,lt=0;lt=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(c){throw c},f:a}}throw new TypeError(`Invalid attempt to iterate non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var o,l=!0,i=!1;return{s:function(){r=r.call(t)},n:function(){var c=r.next();return l=c.done,c},e:function(c){i=!0,o=c},f:function(){try{l||r.return==null||r.return()}finally{if(i)throw o}}}}/*! ***************************************************************************** Copyright (c) Microsoft Corporation. diff --git a/dist/assets/Tags-26d753a4.js b/dist/assets/Tags-957e9e21.js similarity index 92% rename from dist/assets/Tags-26d753a4.js rename to dist/assets/Tags-957e9e21.js index 85147c6c9372a11cf0695a310e8661ca2a0f83e2..3af67bee731d094fe9628066178b8cfbb6998840 100644 --- a/dist/assets/Tags-26d753a4.js +++ b/dist/assets/Tags-957e9e21.js @@ -1 +1 @@ -import{r as s,a as J,z as G,B as H,d as q,c as K,A as _,i as E,j as o}from"./umi-9940633e.js";import{t as U,B as w}from"./button-eaadfeb4.js";import{i as b,o as X}from"./_setToString-98c064b8.js";import{a as z,D as F}from"./index-6a5b1b3e.js";import{T as R}from"./useDebounce-5d6283a5.js";import{r as T}from"./index-da8ccbdf.js";import{i as Q,n as I}from"./util-477962f3.js";import{u as W}from"./useAsyncFn-b0803fd6.js";import{E as Y}from"./EditOutlined-fac0ac1a.js";import{a as Z}from"./progress-06af2db7.js";var N=z.Option;function L(a){return a&&a.type&&(a.type.isSelectOption||a.type.isSelectOptGroup)}var V=function(n,r){var C=n.prefixCls,p=n.className,x=n.popupClassName,g=n.dropdownClassName,l=n.children,O=n.dataSource,u=U(l),i;if(u.length===1&&b(u[0])&&!L(u[0])){var f=J(u,1);i=f[0]}var c=i?function(){return i}:void 0,v;return u.length&&L(u[0])?v=l:v=O?O.map(function(d){if(b(d))return d;switch(G(d)){case"string":return s.createElement(N,{key:d,value:d},d);case"object":{var S=d.value;return s.createElement(N,{key:S,value:S},d.text)}default:return}}):[],s.createElement(H,null,function(d){var S=d.getPrefixCls,y=S("select",C);return s.createElement(z,q({ref:r},X(n,["dataSource"]),{prefixCls:y,popupClassName:x||g,className:K("".concat(y,"-auto-complete"),p),mode:z.SECRET_COMBOBOX_MODE_DO_NOT_USE},{getInputElement:c}),v)})},$=s.forwardRef(V);$.Option=N;const ee=$;var te={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M696 480H544V328c0-4.4-3.6-8-8-8h-48c-4.4 0-8 3.6-8 8v152H328c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8h152v152c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V544h152c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8z"}},{tag:"path",attrs:{d:"M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372z"}}]},name:"plus-circle",theme:"outlined"};const se=te;var ae=function(n,r){return s.createElement(_,E(E({},n),{},{ref:r,icon:se}))},re=s.forwardRef(ae);const Te=re;var ne={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M938 458.8l-29.6-312.6c-1.5-16.2-14.4-29-30.6-30.6L565.2 86h-.4c-3.2 0-5.7 1-7.6 2.9L88.9 557.2a9.96 9.96 0 000 14.1l363.8 363.8c1.9 1.9 4.4 2.9 7.1 2.9s5.2-1 7.1-2.9l468.3-468.3c2-2.1 3-5 2.8-8zM459.7 834.7L189.3 564.3 589 164.6 836 188l23.4 247-399.7 399.7zM680 256c-48.5 0-88 39.5-88 88s39.5 88 88 88 88-39.5 88-88-39.5-88-88-88zm0 120c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32z"}}]},name:"tag",theme:"outlined"};const ie=ne;var ce=function(n,r){return s.createElement(_,E(E({},n),{},{ref:r,icon:ie}))},oe=s.forwardRef(ce);const le=oe;var ue=function(a,n,r){if(!Q)return[n,I,I];if(!a)throw new Error("useLocalStorage key may not be falsy");var C=r?r.raw?function(i){return i}:r.deserializer:JSON.parse,p=s.useRef(function(i){try{var f=r?r.raw?String:r.serializer:JSON.stringify,c=localStorage.getItem(i);return c!==null?C(c):(n&&localStorage.setItem(i,f(n)),n)}catch{return n}}),x=s.useState(function(){return p.current(a)}),g=x[0],l=x[1];s.useLayoutEffect(function(){return l(p.current(a))},[a]);var O=s.useCallback(function(i){try{var f=typeof i=="function"?i(g):i;if(typeof f>"u")return;var c=void 0;r?r.raw?typeof f=="string"?c=f:c=JSON.stringify(f):r.serializer?c=r.serializer(f):c=JSON.stringify(f):c=JSON.stringify(f),localStorage.setItem(a,c),l(C(c))}catch{}},[a,l]),u=s.useCallback(function(){try{localStorage.removeItem(a),l(void 0)}catch{}},[a,l]);return[g,O,u]};const fe=ue,de=({id:a,tagList:n,onChange:r,preview:C})=>{const[p,x]=s.useState(""),g=s.useRef(null),[l,O]=fe("TAG_PRIORITIES",{}),[u,i]=s.useState(!1),[f,c]=s.useState(null),[v,d]=s.useState(!1),[S,y]=W(async()=>T.get("/api/tags"),[]);s.useLayoutEffect(()=>{var e;u&&((e=g.current)==null||e.focus())},[u]);const h=f||n,A=s.useMemo(()=>{var e;return((e=S.value)==null?void 0:e.filter(t=>!h.some(m=>m.id===t.id)).sort((t,m)=>(l[m.id]||0)-(l[t.id]||0)).filter(t=>t.name.indexOf(p)>-1).map(t=>({value:t.name})))??[]},[h,S.value,l,p]),B=async e=>{const t=await T.post("/api/tags",{data:{name:e}});return{name:e,id:t.id}},P=async(e,t)=>{O({...l,[t]:Date.now()});const m=await T.post(`/api/musicSets/${e}/tags/${t}`);return!!(m!=null&&m.success)},M=async(e,t)=>{const m=await T.delete(`/api/musicSets/${e}/tags/${t}`);return!!(m!=null&&m.success)},D=async()=>{if(!p){i(!1);return}const e=await B(p);if(a&&await P(a,e.id),p&&!h.some(t=>t.id===e.id)){const t=[...h,e];c(t),r&&r(t)}i(!1),x("")},k=async e=>{a&&await M(a,e.id);const t=h.filter(m=>m.id!==e.id);c(t),r&&r(t)},j=s.useCallback(async()=>{await y(),d(!v)},[]);return o.jsxs(o.Fragment,{children:[C?o.jsx("div",{onClick:j,children:h.length?h.map(e=>o.jsx(R,{style:{display:"inline-block",fontSize:"12px",marginRight:"5px",marginBottom:"5px"},children:e.name},e.id)):o.jsx(w,{type:"dashed",icon:o.jsx(Y,{}),size:"small"})}):o.jsx(w,{title:"标签",icon:o.jsx(le,{}),onClick:j}),o.jsx(F,{title:"标签管理",placement:"right",onClose:()=>d(!1),open:v,mask:!0,style:{marginTop:"64px",height:"calc(100vh - 64px)"},children:o.jsxs("div",{className:"score-tags",children:[o.jsx("div",{className:"list",children:h.map(e=>o.jsx(R,{closable:!0,onClose:()=>k(e),style:{display:"inline-block",marginRight:"5px",marginBottom:"5px"},children:e.name},e.id))}),u&&o.jsx(ee,{ref:g,size:"small",backfill:!0,options:A,style:{width:100},onChange:e=>{x(e)},placeholder:"输入",onBlur:()=>D(),onSelect:()=>{setTimeout(()=>{var e;(e=g.current)==null||e.blur()},0)},onKeyDown:e=>{e.key==="Enter"&&g.current.blur()}}),!u&&o.jsx(w,{className:"site-tag-plus",size:"small",onClick:()=>i(!0),children:o.jsx(Z,{})})]})})]})},Ee=de;export{ee as A,Te as P,Ee as S,le as T,fe as u}; +import{r as s,a as J,z as G,B as H,d as q,c as K,A as _,i as E,j as o}from"./umi-a12c8253.js";import{t as U,B as w}from"./button-f56a19a0.js";import{i as b,o as X}from"./_setToString-ca5ad23e.js";import{a as z,D as F}from"./index-c353c509.js";import{T as R}from"./useDebounce-b5b4777f.js";import{r as T}from"./index-5722ce0d.js";import{i as Q,n as I}from"./util-590d1471.js";import{u as W}from"./useAsyncFn-b4ac32aa.js";import{E as Y}from"./EditOutlined-d468c101.js";import{a as Z}from"./progress-81ce73da.js";var N=z.Option;function L(a){return a&&a.type&&(a.type.isSelectOption||a.type.isSelectOptGroup)}var V=function(n,r){var C=n.prefixCls,p=n.className,x=n.popupClassName,g=n.dropdownClassName,l=n.children,O=n.dataSource,u=U(l),i;if(u.length===1&&b(u[0])&&!L(u[0])){var f=J(u,1);i=f[0]}var c=i?function(){return i}:void 0,v;return u.length&&L(u[0])?v=l:v=O?O.map(function(d){if(b(d))return d;switch(G(d)){case"string":return s.createElement(N,{key:d,value:d},d);case"object":{var S=d.value;return s.createElement(N,{key:S,value:S},d.text)}default:return}}):[],s.createElement(H,null,function(d){var S=d.getPrefixCls,y=S("select",C);return s.createElement(z,q({ref:r},X(n,["dataSource"]),{prefixCls:y,popupClassName:x||g,className:K("".concat(y,"-auto-complete"),p),mode:z.SECRET_COMBOBOX_MODE_DO_NOT_USE},{getInputElement:c}),v)})},$=s.forwardRef(V);$.Option=N;const ee=$;var te={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M696 480H544V328c0-4.4-3.6-8-8-8h-48c-4.4 0-8 3.6-8 8v152H328c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8h152v152c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V544h152c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8z"}},{tag:"path",attrs:{d:"M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372z"}}]},name:"plus-circle",theme:"outlined"};const se=te;var ae=function(n,r){return s.createElement(_,E(E({},n),{},{ref:r,icon:se}))},re=s.forwardRef(ae);const Te=re;var ne={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M938 458.8l-29.6-312.6c-1.5-16.2-14.4-29-30.6-30.6L565.2 86h-.4c-3.2 0-5.7 1-7.6 2.9L88.9 557.2a9.96 9.96 0 000 14.1l363.8 363.8c1.9 1.9 4.4 2.9 7.1 2.9s5.2-1 7.1-2.9l468.3-468.3c2-2.1 3-5 2.8-8zM459.7 834.7L189.3 564.3 589 164.6 836 188l23.4 247-399.7 399.7zM680 256c-48.5 0-88 39.5-88 88s39.5 88 88 88 88-39.5 88-88-39.5-88-88-88zm0 120c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32z"}}]},name:"tag",theme:"outlined"};const ie=ne;var ce=function(n,r){return s.createElement(_,E(E({},n),{},{ref:r,icon:ie}))},oe=s.forwardRef(ce);const le=oe;var ue=function(a,n,r){if(!Q)return[n,I,I];if(!a)throw new Error("useLocalStorage key may not be falsy");var C=r?r.raw?function(i){return i}:r.deserializer:JSON.parse,p=s.useRef(function(i){try{var f=r?r.raw?String:r.serializer:JSON.stringify,c=localStorage.getItem(i);return c!==null?C(c):(n&&localStorage.setItem(i,f(n)),n)}catch{return n}}),x=s.useState(function(){return p.current(a)}),g=x[0],l=x[1];s.useLayoutEffect(function(){return l(p.current(a))},[a]);var O=s.useCallback(function(i){try{var f=typeof i=="function"?i(g):i;if(typeof f>"u")return;var c=void 0;r?r.raw?typeof f=="string"?c=f:c=JSON.stringify(f):r.serializer?c=r.serializer(f):c=JSON.stringify(f):c=JSON.stringify(f),localStorage.setItem(a,c),l(C(c))}catch{}},[a,l]),u=s.useCallback(function(){try{localStorage.removeItem(a),l(void 0)}catch{}},[a,l]);return[g,O,u]};const fe=ue,de=({id:a,tagList:n,onChange:r,preview:C})=>{const[p,x]=s.useState(""),g=s.useRef(null),[l,O]=fe("TAG_PRIORITIES",{}),[u,i]=s.useState(!1),[f,c]=s.useState(null),[v,d]=s.useState(!1),[S,y]=W(async()=>T.get("/api/tags"),[]);s.useLayoutEffect(()=>{var e;u&&((e=g.current)==null||e.focus())},[u]);const h=f||n,A=s.useMemo(()=>{var e;return((e=S.value)==null?void 0:e.filter(t=>!h.some(m=>m.id===t.id)).sort((t,m)=>(l[m.id]||0)-(l[t.id]||0)).filter(t=>t.name.indexOf(p)>-1).map(t=>({value:t.name})))??[]},[h,S.value,l,p]),B=async e=>{const t=await T.post("/api/tags",{data:{name:e}});return{name:e,id:t.id}},P=async(e,t)=>{O({...l,[t]:Date.now()});const m=await T.post(`/api/musicSets/${e}/tags/${t}`);return!!(m!=null&&m.success)},M=async(e,t)=>{const m=await T.delete(`/api/musicSets/${e}/tags/${t}`);return!!(m!=null&&m.success)},D=async()=>{if(!p){i(!1);return}const e=await B(p);if(a&&await P(a,e.id),p&&!h.some(t=>t.id===e.id)){const t=[...h,e];c(t),r&&r(t)}i(!1),x("")},k=async e=>{a&&await M(a,e.id);const t=h.filter(m=>m.id!==e.id);c(t),r&&r(t)},j=s.useCallback(async()=>{await y(),d(!v)},[]);return o.jsxs(o.Fragment,{children:[C?o.jsx("div",{onClick:j,children:h.length?h.map(e=>o.jsx(R,{style:{display:"inline-block",fontSize:"12px",marginRight:"5px",marginBottom:"5px"},children:e.name},e.id)):o.jsx(w,{type:"dashed",icon:o.jsx(Y,{}),size:"small"})}):o.jsx(w,{title:"标签",icon:o.jsx(le,{}),onClick:j}),o.jsx(F,{title:"标签管理",placement:"right",onClose:()=>d(!1),open:v,mask:!0,style:{marginTop:"64px",height:"calc(100vh - 64px)"},children:o.jsxs("div",{className:"score-tags",children:[o.jsx("div",{className:"list",children:h.map(e=>o.jsx(R,{closable:!0,onClose:()=>k(e),style:{display:"inline-block",marginRight:"5px",marginBottom:"5px"},children:e.name},e.id))}),u&&o.jsx(ee,{ref:g,size:"small",backfill:!0,options:A,style:{width:100},onChange:e=>{x(e)},placeholder:"输入",onBlur:()=>D(),onSelect:()=>{setTimeout(()=>{var e;(e=g.current)==null||e.blur()},0)},onKeyDown:e=>{e.key==="Enter"&&g.current.blur()}}),!u&&o.jsx(w,{className:"site-tag-plus",size:"small",onClick:()=>i(!0),children:o.jsx(Z,{})})]})})]})},Ee=de;export{ee as A,Te as P,Ee as S,le as T,fe as u}; diff --git a/dist/assets/TextArea-b3aeb374.js b/dist/assets/TextArea-ec8ab387.js similarity index 99% rename from dist/assets/TextArea-b3aeb374.js rename to dist/assets/TextArea-ec8ab387.js index 448a3ac2c876bbbd8b3efb87d8b2677f38ece08d..baea08a09e81db4b460f30e63c80f9d56835ded8 100644 --- a/dist/assets/TextArea-b3aeb374.js +++ b/dist/assets/TextArea-ec8ab387.js @@ -1,4 +1,4 @@ -import{r as f,G as Et,U as Bt,F as Ke,E as Ge,a5 as Gr,aF as zi,i as k,a1 as kt,z as ge,d as L,a6 as $n,au as bn,a as q,a4 as wn,aJ as zt,K as Ce,c as ee,w as Ae,t as Li,R as G,e as zn,T as Ve,bi as It,M as Ln,aj as it,ak as Oe,b as h,J as _,_ as Z,bm as vt,al as $e,am as De,C as at,V as Hn,A as Hi,S as Yr,Y as Xr,H as ir,I as Wi,av as ji}from"./umi-9940633e.js";import{o as qt,t as xt,i as Ui,A as Bi,c as Lt}from"./_setToString-98c064b8.js";import{t as Wn,C as qi,u as Ki,N as ar}from"./button-eaadfeb4.js";var Cn=f.createContext(null);function Gi(e){var t=e.children,n=e.onBatchResize,r=f.useRef(0),i=f.useRef([]),o=f.useContext(Cn),a=f.useCallback(function(u,s,l){r.current+=1;var c=r.current;i.current.push({size:u,element:s,data:l}),Promise.resolve().then(function(){c===r.current&&(n==null||n(i.current),i.current=[])}),o==null||o(u,s,l)},[n,o]);return f.createElement(Cn.Provider,{value:a},t)}var Zr=function(){if(typeof Map<"u")return Map;function e(t,n){var r=-1;return t.some(function(i,o){return i[0]===n?(r=o,!0):!1}),r}return function(){function t(){this.__entries__=[]}return Object.defineProperty(t.prototype,"size",{get:function(){return this.__entries__.length},enumerable:!0,configurable:!0}),t.prototype.get=function(n){var r=e(this.__entries__,n),i=this.__entries__[r];return i&&i[1]},t.prototype.set=function(n,r){var i=e(this.__entries__,n);~i?this.__entries__[i][1]=r:this.__entries__.push([n,r])},t.prototype.delete=function(n){var r=this.__entries__,i=e(r,n);~i&&r.splice(i,1)},t.prototype.has=function(n){return!!~e(this.__entries__,n)},t.prototype.clear=function(){this.__entries__.splice(0)},t.prototype.forEach=function(n,r){r===void 0&&(r=null);for(var i=0,o=this.__entries__;i0},e.prototype.connect_=function(){!En||this.connected_||(document.addEventListener("transitionend",this.onTransitionEnd_),window.addEventListener("resize",this.refresh),ea?(this.mutationsObserver_=new MutationObserver(this.refresh),this.mutationsObserver_.observe(document,{attributes:!0,childList:!0,characterData:!0,subtree:!0})):(document.addEventListener("DOMSubtreeModified",this.refresh),this.mutationEventsAdded_=!0),this.connected_=!0)},e.prototype.disconnect_=function(){!En||!this.connected_||(document.removeEventListener("transitionend",this.onTransitionEnd_),window.removeEventListener("resize",this.refresh),this.mutationsObserver_&&this.mutationsObserver_.disconnect(),this.mutationEventsAdded_&&document.removeEventListener("DOMSubtreeModified",this.refresh),this.mutationsObserver_=null,this.mutationEventsAdded_=!1,this.connected_=!1)},e.prototype.onTransitionEnd_=function(t){var n=t.propertyName,r=n===void 0?"":n,i=Ji.some(function(o){return!!~r.indexOf(o)});i&&this.refresh()},e.getInstance=function(){return this.instance_||(this.instance_=new e),this.instance_},e.instance_=null,e}(),Qr=function(e,t){for(var n=0,r=Object.keys(t);n"u"||!(Element instanceof Object))){if(!(t instanceof nt(t).Element))throw new TypeError('parameter 1 is not of type "Element".');var n=this.observations_;n.has(t)||(n.set(t,new la(t)),this.controller_.addObserver(this),this.controller_.refresh())}},e.prototype.unobserve=function(t){if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");if(!(typeof Element>"u"||!(Element instanceof Object))){if(!(t instanceof nt(t).Element))throw new TypeError('parameter 1 is not of type "Element".');var n=this.observations_;n.has(t)&&(n.delete(t),n.size||this.controller_.removeObserver(this))}},e.prototype.disconnect=function(){this.clearActive(),this.observations_.clear(),this.controller_.removeObserver(this)},e.prototype.gatherActive=function(){var t=this;this.clearActive(),this.observations_.forEach(function(n){n.isActive()&&t.activeObservations_.push(n)})},e.prototype.broadcastActive=function(){if(this.hasActive()){var t=this.callbackCtx_,n=this.activeObservations_.map(function(r){return new ca(r.target,r.broadcastRect())});this.callback_.call(t,n,t),this.clearActive()}},e.prototype.clearActive=function(){this.activeObservations_.splice(0)},e.prototype.hasActive=function(){return this.activeObservations_.length>0},e}(),ei=typeof WeakMap<"u"?new WeakMap:new Zr,ti=function(){function e(t){if(!(this instanceof e))throw new TypeError("Cannot call a class as a function.");if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");var n=ta.getInstance(),r=new fa(t,n,this);ei.set(this,r)}return e}();["observe","unobserve","disconnect"].forEach(function(e){ti.prototype[e]=function(){var t;return(t=ei.get(this))[e].apply(t,arguments)}});var ni=function(){return typeof Ht.ResizeObserver<"u"?Ht.ResizeObserver:ti}(),ze=new Map;function da(e){e.forEach(function(t){var n,r=t.target;(n=ze.get(r))===null||n===void 0||n.forEach(function(i){return i(r)})})}var ri=new ni(da);function va(e,t){ze.has(e)||(ze.set(e,new Set),ri.observe(e)),ze.get(e).add(t)}function pa(e,t){ze.has(e)&&(ze.get(e).delete(t),ze.get(e).size||(ri.unobserve(e),ze.delete(e)))}var ha=function(e){Et(n,e);var t=Bt(n);function n(){return Ke(this,n),t.apply(this,arguments)}return Ge(n,[{key:"render",value:function(){return this.props.children}}]),n}(f.Component);function ga(e,t){var n=e.children,r=e.disabled,i=f.useRef(null),o=f.useRef(null),a=f.useContext(Cn),u=typeof n=="function",s=u?n(i):n,l=f.useRef({width:-1,height:-1,offsetWidth:-1,offsetHeight:-1}),c=!u&&f.isValidElement(s)&&Gr(s),d=c?s.ref:null,v=zi(d,i),m=function(){var p;return kt(i.current)||(i.current&&ge(i.current)==="object"?kt((p=i.current)===null||p===void 0?void 0:p.nativeElement):null)||kt(o.current)};f.useImperativeHandle(t,function(){return m()});var y=f.useRef(e);y.current=e;var g=f.useCallback(function(b){var p=y.current,C=p.onResize,w=p.data,x=b.getBoundingClientRect(),E=x.width,P=x.height,S=b.offsetWidth,N=b.offsetHeight,F=Math.floor(E),R=Math.floor(P);if(l.current.width!==F||l.current.height!==R||l.current.offsetWidth!==S||l.current.offsetHeight!==N){var O={width:F,height:R,offsetWidth:S,offsetHeight:N};l.current=O;var T=S===Math.round(E)?E:S,M=N===Math.round(P)?P:N,I=k(k({},O),{},{offsetWidth:T,offsetHeight:M});a==null||a(I,b,w),C&&Promise.resolve().then(function(){C(I,b)})}},[]);return f.useEffect(function(){var b=m();return b&&!r&&va(b,g),function(){return pa(b,g)}},[i.current,r]),f.createElement(ha,{ref:o},c?f.cloneElement(s,{ref:v}):s)}var ma=f.forwardRef(ga),ya="rc-observer-key";function ba(e,t){var n=e.children,r=typeof n=="function"?[n]:Wn(n);return r.map(function(i,o){var a=(i==null?void 0:i.key)||"".concat(ya,"-").concat(o);return f.createElement(ma,L({},e,{key:a,ref:o===0?t:void 0}),i)})}var Gt=f.forwardRef(ba);Gt.Collection=Gi;var sr=$n()?f.useLayoutEffect:f.useEffect,Be=function(t,n){var r=f.useRef(!0);sr(function(){return t(r.current)},n),sr(function(){return r.current=!1,function(){r.current=!0}},[])},ur=function(t,n){Be(function(r){if(!r)return t()},n)};function rn(e){return e!==void 0}function St(e,t){var n=t||{},r=n.defaultValue,i=n.value,o=n.onChange,a=n.postState,u=bn(function(){return rn(i)?i:rn(r)?typeof r=="function"?r():r:typeof e=="function"?e():e}),s=q(u,2),l=s[0],c=s[1],d=i!==void 0?i:l,v=a?a(d):d,m=wn(o),y=bn([d]),g=q(y,2),b=g[0],p=g[1];ur(function(){var w=b[0];l!==w&&m(l,w)},[b]),ur(function(){rn(i)||c(i)},[i]);var C=wn(function(w,x){c(w,x),p([d],x)});return[v,C]}function pt(e,t,n,r){var i=zt.unstable_batchedUpdates?function(a){zt.unstable_batchedUpdates(n,a)}:n;return e!=null&&e.addEventListener&&e.addEventListener(t,i,r),{remove:function(){e!=null&&e.removeEventListener&&e.removeEventListener(t,i,r)}}}const wa=function(){if(typeof navigator>"u"||typeof window>"u")return!1;var e=navigator.userAgent||navigator.vendor||window.opera;return/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(e)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55\/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk\/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-/i.test(e==null?void 0:e.substr(0,4))};var H={MAC_ENTER:3,BACKSPACE:8,TAB:9,NUM_CENTER:12,ENTER:13,SHIFT:16,CTRL:17,ALT:18,PAUSE:19,CAPS_LOCK:20,ESC:27,SPACE:32,PAGE_UP:33,PAGE_DOWN:34,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,PRINT_SCREEN:44,INSERT:45,DELETE:46,ZERO:48,ONE:49,TWO:50,THREE:51,FOUR:52,FIVE:53,SIX:54,SEVEN:55,EIGHT:56,NINE:57,QUESTION_MARK:63,A:65,B:66,C:67,D:68,E:69,F:70,G:71,H:72,I:73,J:74,K:75,L:76,M:77,N:78,O:79,P:80,Q:81,R:82,S:83,T:84,U:85,V:86,W:87,X:88,Y:89,Z:90,META:91,WIN_KEY_RIGHT:92,CONTEXT_MENU:93,NUM_ZERO:96,NUM_ONE:97,NUM_TWO:98,NUM_THREE:99,NUM_FOUR:100,NUM_FIVE:101,NUM_SIX:102,NUM_SEVEN:103,NUM_EIGHT:104,NUM_NINE:105,NUM_MULTIPLY:106,NUM_PLUS:107,NUM_MINUS:109,NUM_PERIOD:110,NUM_DIVISION:111,F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,F10:121,F11:122,F12:123,NUMLOCK:144,SEMICOLON:186,DASH:189,EQUALS:187,COMMA:188,PERIOD:190,SLASH:191,APOSTROPHE:192,SINGLE_QUOTE:222,OPEN_SQUARE_BRACKET:219,BACKSLASH:220,CLOSE_SQUARE_BRACKET:221,WIN_KEY:224,MAC_FF_META:224,WIN_IME:229,isTextModifyingKeyEvent:function(t){var n=t.keyCode;if(t.altKey&&!t.ctrlKey||t.metaKey||n>=H.F1&&n<=H.F12)return!1;switch(n){case H.ALT:case H.CAPS_LOCK:case H.CONTEXT_MENU:case H.CTRL:case H.DOWN:case H.END:case H.ESC:case H.HOME:case H.INSERT:case H.LEFT:case H.MAC_FF_META:case H.META:case H.NUMLOCK:case H.NUM_CENTER:case H.PAGE_DOWN:case H.PAGE_UP:case H.PAUSE:case H.PRINT_SCREEN:case H.RIGHT:case H.SHIFT:case H.UP:case H.WIN_KEY:case H.WIN_KEY_RIGHT:return!1;default:return!0}},isCharacterKey:function(t){if(t>=H.ZERO&&t<=H.NINE||t>=H.NUM_ZERO&&t<=H.NUM_MULTIPLY||t>=H.A&&t<=H.Z||window.navigator.userAgent.indexOf("WebKit")!==-1&&t===0)return!0;switch(t){case H.SPACE:case H.QUESTION_MARK:case H.NUM_PLUS:case H.NUM_MINUS:case H.NUM_PERIOD:case H.NUM_DIVISION:case H.SEMICOLON:case H.DASH:case H.EQUALS:case H.COMMA:case H.PERIOD:case H.SLASH:case H.APOSTROPHE:case H.SINGLE_QUOTE:case H.OPEN_SQUARE_BRACKET:case H.BACKSLASH:case H.CLOSE_SQUARE_BRACKET:return!0;default:return!1}}},Ca=`accept acceptCharset accessKey action allowFullScreen allowTransparency +import{r as f,G as Et,U as Bt,F as Ke,E as Ge,a5 as Gr,aF as zi,i as k,a1 as kt,z as ge,d as L,a6 as $n,au as bn,a as q,a4 as wn,aJ as zt,K as Ce,c as ee,w as Ae,t as Li,R as G,e as zn,T as Ve,bi as It,M as Ln,aj as it,ak as Oe,b as h,J as _,_ as Z,bm as vt,al as $e,am as De,C as at,V as Hn,A as Hi,S as Yr,Y as Xr,H as ir,I as Wi,av as ji}from"./umi-a12c8253.js";import{o as qt,t as xt,i as Ui,A as Bi,c as Lt}from"./_setToString-ca5ad23e.js";import{t as Wn,C as qi,u as Ki,N as ar}from"./button-f56a19a0.js";var Cn=f.createContext(null);function Gi(e){var t=e.children,n=e.onBatchResize,r=f.useRef(0),i=f.useRef([]),o=f.useContext(Cn),a=f.useCallback(function(u,s,l){r.current+=1;var c=r.current;i.current.push({size:u,element:s,data:l}),Promise.resolve().then(function(){c===r.current&&(n==null||n(i.current),i.current=[])}),o==null||o(u,s,l)},[n,o]);return f.createElement(Cn.Provider,{value:a},t)}var Zr=function(){if(typeof Map<"u")return Map;function e(t,n){var r=-1;return t.some(function(i,o){return i[0]===n?(r=o,!0):!1}),r}return function(){function t(){this.__entries__=[]}return Object.defineProperty(t.prototype,"size",{get:function(){return this.__entries__.length},enumerable:!0,configurable:!0}),t.prototype.get=function(n){var r=e(this.__entries__,n),i=this.__entries__[r];return i&&i[1]},t.prototype.set=function(n,r){var i=e(this.__entries__,n);~i?this.__entries__[i][1]=r:this.__entries__.push([n,r])},t.prototype.delete=function(n){var r=this.__entries__,i=e(r,n);~i&&r.splice(i,1)},t.prototype.has=function(n){return!!~e(this.__entries__,n)},t.prototype.clear=function(){this.__entries__.splice(0)},t.prototype.forEach=function(n,r){r===void 0&&(r=null);for(var i=0,o=this.__entries__;i0},e.prototype.connect_=function(){!En||this.connected_||(document.addEventListener("transitionend",this.onTransitionEnd_),window.addEventListener("resize",this.refresh),ea?(this.mutationsObserver_=new MutationObserver(this.refresh),this.mutationsObserver_.observe(document,{attributes:!0,childList:!0,characterData:!0,subtree:!0})):(document.addEventListener("DOMSubtreeModified",this.refresh),this.mutationEventsAdded_=!0),this.connected_=!0)},e.prototype.disconnect_=function(){!En||!this.connected_||(document.removeEventListener("transitionend",this.onTransitionEnd_),window.removeEventListener("resize",this.refresh),this.mutationsObserver_&&this.mutationsObserver_.disconnect(),this.mutationEventsAdded_&&document.removeEventListener("DOMSubtreeModified",this.refresh),this.mutationsObserver_=null,this.mutationEventsAdded_=!1,this.connected_=!1)},e.prototype.onTransitionEnd_=function(t){var n=t.propertyName,r=n===void 0?"":n,i=Ji.some(function(o){return!!~r.indexOf(o)});i&&this.refresh()},e.getInstance=function(){return this.instance_||(this.instance_=new e),this.instance_},e.instance_=null,e}(),Qr=function(e,t){for(var n=0,r=Object.keys(t);n"u"||!(Element instanceof Object))){if(!(t instanceof nt(t).Element))throw new TypeError('parameter 1 is not of type "Element".');var n=this.observations_;n.has(t)||(n.set(t,new la(t)),this.controller_.addObserver(this),this.controller_.refresh())}},e.prototype.unobserve=function(t){if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");if(!(typeof Element>"u"||!(Element instanceof Object))){if(!(t instanceof nt(t).Element))throw new TypeError('parameter 1 is not of type "Element".');var n=this.observations_;n.has(t)&&(n.delete(t),n.size||this.controller_.removeObserver(this))}},e.prototype.disconnect=function(){this.clearActive(),this.observations_.clear(),this.controller_.removeObserver(this)},e.prototype.gatherActive=function(){var t=this;this.clearActive(),this.observations_.forEach(function(n){n.isActive()&&t.activeObservations_.push(n)})},e.prototype.broadcastActive=function(){if(this.hasActive()){var t=this.callbackCtx_,n=this.activeObservations_.map(function(r){return new ca(r.target,r.broadcastRect())});this.callback_.call(t,n,t),this.clearActive()}},e.prototype.clearActive=function(){this.activeObservations_.splice(0)},e.prototype.hasActive=function(){return this.activeObservations_.length>0},e}(),ei=typeof WeakMap<"u"?new WeakMap:new Zr,ti=function(){function e(t){if(!(this instanceof e))throw new TypeError("Cannot call a class as a function.");if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");var n=ta.getInstance(),r=new fa(t,n,this);ei.set(this,r)}return e}();["observe","unobserve","disconnect"].forEach(function(e){ti.prototype[e]=function(){var t;return(t=ei.get(this))[e].apply(t,arguments)}});var ni=function(){return typeof Ht.ResizeObserver<"u"?Ht.ResizeObserver:ti}(),ze=new Map;function da(e){e.forEach(function(t){var n,r=t.target;(n=ze.get(r))===null||n===void 0||n.forEach(function(i){return i(r)})})}var ri=new ni(da);function va(e,t){ze.has(e)||(ze.set(e,new Set),ri.observe(e)),ze.get(e).add(t)}function pa(e,t){ze.has(e)&&(ze.get(e).delete(t),ze.get(e).size||(ri.unobserve(e),ze.delete(e)))}var ha=function(e){Et(n,e);var t=Bt(n);function n(){return Ke(this,n),t.apply(this,arguments)}return Ge(n,[{key:"render",value:function(){return this.props.children}}]),n}(f.Component);function ga(e,t){var n=e.children,r=e.disabled,i=f.useRef(null),o=f.useRef(null),a=f.useContext(Cn),u=typeof n=="function",s=u?n(i):n,l=f.useRef({width:-1,height:-1,offsetWidth:-1,offsetHeight:-1}),c=!u&&f.isValidElement(s)&&Gr(s),d=c?s.ref:null,v=zi(d,i),m=function(){var p;return kt(i.current)||(i.current&&ge(i.current)==="object"?kt((p=i.current)===null||p===void 0?void 0:p.nativeElement):null)||kt(o.current)};f.useImperativeHandle(t,function(){return m()});var y=f.useRef(e);y.current=e;var g=f.useCallback(function(b){var p=y.current,C=p.onResize,w=p.data,x=b.getBoundingClientRect(),E=x.width,P=x.height,S=b.offsetWidth,N=b.offsetHeight,F=Math.floor(E),R=Math.floor(P);if(l.current.width!==F||l.current.height!==R||l.current.offsetWidth!==S||l.current.offsetHeight!==N){var O={width:F,height:R,offsetWidth:S,offsetHeight:N};l.current=O;var T=S===Math.round(E)?E:S,M=N===Math.round(P)?P:N,I=k(k({},O),{},{offsetWidth:T,offsetHeight:M});a==null||a(I,b,w),C&&Promise.resolve().then(function(){C(I,b)})}},[]);return f.useEffect(function(){var b=m();return b&&!r&&va(b,g),function(){return pa(b,g)}},[i.current,r]),f.createElement(ha,{ref:o},c?f.cloneElement(s,{ref:v}):s)}var ma=f.forwardRef(ga),ya="rc-observer-key";function ba(e,t){var n=e.children,r=typeof n=="function"?[n]:Wn(n);return r.map(function(i,o){var a=(i==null?void 0:i.key)||"".concat(ya,"-").concat(o);return f.createElement(ma,L({},e,{key:a,ref:o===0?t:void 0}),i)})}var Gt=f.forwardRef(ba);Gt.Collection=Gi;var sr=$n()?f.useLayoutEffect:f.useEffect,Be=function(t,n){var r=f.useRef(!0);sr(function(){return t(r.current)},n),sr(function(){return r.current=!1,function(){r.current=!0}},[])},ur=function(t,n){Be(function(r){if(!r)return t()},n)};function rn(e){return e!==void 0}function St(e,t){var n=t||{},r=n.defaultValue,i=n.value,o=n.onChange,a=n.postState,u=bn(function(){return rn(i)?i:rn(r)?typeof r=="function"?r():r:typeof e=="function"?e():e}),s=q(u,2),l=s[0],c=s[1],d=i!==void 0?i:l,v=a?a(d):d,m=wn(o),y=bn([d]),g=q(y,2),b=g[0],p=g[1];ur(function(){var w=b[0];l!==w&&m(l,w)},[b]),ur(function(){rn(i)||c(i)},[i]);var C=wn(function(w,x){c(w,x),p([d],x)});return[v,C]}function pt(e,t,n,r){var i=zt.unstable_batchedUpdates?function(a){zt.unstable_batchedUpdates(n,a)}:n;return e!=null&&e.addEventListener&&e.addEventListener(t,i,r),{remove:function(){e!=null&&e.removeEventListener&&e.removeEventListener(t,i,r)}}}const wa=function(){if(typeof navigator>"u"||typeof window>"u")return!1;var e=navigator.userAgent||navigator.vendor||window.opera;return/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(e)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55\/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk\/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-/i.test(e==null?void 0:e.substr(0,4))};var H={MAC_ENTER:3,BACKSPACE:8,TAB:9,NUM_CENTER:12,ENTER:13,SHIFT:16,CTRL:17,ALT:18,PAUSE:19,CAPS_LOCK:20,ESC:27,SPACE:32,PAGE_UP:33,PAGE_DOWN:34,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,PRINT_SCREEN:44,INSERT:45,DELETE:46,ZERO:48,ONE:49,TWO:50,THREE:51,FOUR:52,FIVE:53,SIX:54,SEVEN:55,EIGHT:56,NINE:57,QUESTION_MARK:63,A:65,B:66,C:67,D:68,E:69,F:70,G:71,H:72,I:73,J:74,K:75,L:76,M:77,N:78,O:79,P:80,Q:81,R:82,S:83,T:84,U:85,V:86,W:87,X:88,Y:89,Z:90,META:91,WIN_KEY_RIGHT:92,CONTEXT_MENU:93,NUM_ZERO:96,NUM_ONE:97,NUM_TWO:98,NUM_THREE:99,NUM_FOUR:100,NUM_FIVE:101,NUM_SIX:102,NUM_SEVEN:103,NUM_EIGHT:104,NUM_NINE:105,NUM_MULTIPLY:106,NUM_PLUS:107,NUM_MINUS:109,NUM_PERIOD:110,NUM_DIVISION:111,F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,F10:121,F11:122,F12:123,NUMLOCK:144,SEMICOLON:186,DASH:189,EQUALS:187,COMMA:188,PERIOD:190,SLASH:191,APOSTROPHE:192,SINGLE_QUOTE:222,OPEN_SQUARE_BRACKET:219,BACKSLASH:220,CLOSE_SQUARE_BRACKET:221,WIN_KEY:224,MAC_FF_META:224,WIN_IME:229,isTextModifyingKeyEvent:function(t){var n=t.keyCode;if(t.altKey&&!t.ctrlKey||t.metaKey||n>=H.F1&&n<=H.F12)return!1;switch(n){case H.ALT:case H.CAPS_LOCK:case H.CONTEXT_MENU:case H.CTRL:case H.DOWN:case H.END:case H.ESC:case H.HOME:case H.INSERT:case H.LEFT:case H.MAC_FF_META:case H.META:case H.NUMLOCK:case H.NUM_CENTER:case H.PAGE_DOWN:case H.PAGE_UP:case H.PAUSE:case H.PRINT_SCREEN:case H.RIGHT:case H.SHIFT:case H.UP:case H.WIN_KEY:case H.WIN_KEY_RIGHT:return!1;default:return!0}},isCharacterKey:function(t){if(t>=H.ZERO&&t<=H.NINE||t>=H.NUM_ZERO&&t<=H.NUM_MULTIPLY||t>=H.A&&t<=H.Z||window.navigator.userAgent.indexOf("WebKit")!==-1&&t===0)return!0;switch(t){case H.SPACE:case H.QUESTION_MARK:case H.NUM_PLUS:case H.NUM_MINUS:case H.NUM_PERIOD:case H.NUM_DIVISION:case H.SEMICOLON:case H.DASH:case H.EQUALS:case H.COMMA:case H.PERIOD:case H.SLASH:case H.APOSTROPHE:case H.SINGLE_QUOTE:case H.OPEN_SQUARE_BRACKET:case H.BACKSLASH:case H.CLOSE_SQUARE_BRACKET:return!0;default:return!1}}},Ca=`accept acceptCharset accessKey action allowFullScreen allowTransparency alt async autoComplete autoFocus autoPlay capture cellPadding cellSpacing challenge charSet checked classID className colSpan cols content contentEditable contextMenu controls coords crossOrigin data dateTime default defer dir disabled download draggable diff --git a/dist/assets/UploadOutlined-e9942b1c.js b/dist/assets/UploadOutlined-31d12a4f.js similarity index 98% rename from dist/assets/UploadOutlined-e9942b1c.js rename to dist/assets/UploadOutlined-31d12a4f.js index 99d42bc345a42d915b68f9eee8f587bbe424b3fa..b7c578096adf98bbdf8990dce8154f9986f5d2ac 100644 --- a/dist/assets/UploadOutlined-e9942b1c.js +++ b/dist/assets/UploadOutlined-31d12a4f.js @@ -1 +1 @@ -import{T as it,G as Xe,U as Je,F as Ze,_ as ue,E as Ye,K as lt,c as _,b as F,R as Me,d as w,r as i,aj as st,ak as Se,z as Qe,A as Ue,i as X,a as Pe,C as je,e as et,ap as ct,L as _e,V as ut,W as dt,Z as pt,t as He}from"./umi-9940633e.js";import{p as ft,E as vt,T as mt,k as ht,b as gt,u as wt}from"./TextArea-b3aeb374.js";import{B as qe}from"./button-eaadfeb4.js";import{c as We,i as Ke}from"./_setToString-98c064b8.js";import{D as yt}from"./DeleteOutlined-a511b2d4.js";import{D as bt}from"./DownloadOutlined-0b32cbf8.js";import{P as It}from"./progress-06af2db7.js";function Ct(t,e){var a="cannot ".concat(t.method," ").concat(t.action," ").concat(e.status,"'"),n=new Error(a);return n.status=e.status,n.method=t.method,n.url=t.action,n}function Ge(t){var e=t.responseText||t.response;if(!e)return e;try{return JSON.parse(e)}catch{return e}}function Et(t){var e=new XMLHttpRequest;t.onProgress&&e.upload&&(e.upload.onprogress=function(l){l.total>0&&(l.percent=l.loaded/l.total*100),t.onProgress(l)});var a=new FormData;t.data&&Object.keys(t.data).forEach(function(o){var l=t.data[o];if(Array.isArray(l)){l.forEach(function(s){a.append("".concat(o,"[]"),s)});return}a.append(o,l)}),t.file instanceof Blob?a.append(t.filename,t.file,t.file.name):a.append(t.filename,t.file),e.onerror=function(l){t.onError(l)},e.onload=function(){return e.status<200||e.status>=300?t.onError(Ct(t,e),Ge(e)):t.onSuccess(Ge(e),e)},e.open(t.method,t.action,!0),t.withCredentials&&"withCredentials"in e&&(e.withCredentials=!0);var n=t.headers||{};return n["X-Requested-With"]!==null&&e.setRequestHeader("X-Requested-With","XMLHttpRequest"),Object.keys(n).forEach(function(o){n[o]!==null&&e.setRequestHeader(o,n[o])}),e.send(a),{abort:function(){e.abort()}}}var Rt=+new Date,Ft=0;function $e(){return"rc-upload-".concat(Rt,"-").concat(++Ft)}const Ne=function(t,e){if(t&&e){var a=Array.isArray(e)?e:e.split(","),n=t.name||"",o=t.type||"",l=o.replace(/\/.*$/,"");return a.some(function(s){var r=s.trim();if(/^\*(\/\*)?$/.test(s))return!0;if(r.charAt(0)==="."){var d=n.toLowerCase(),c=r.toLowerCase(),u=[c];return(c===".jpg"||c===".jpeg")&&(u=[".jpg",".jpeg"]),u.some(function(h){return d.endsWith(h)})}return/\/\*$/.test(r)?l===r.replace(/\/.*$/,""):o===r?!0:/^\w+$/.test(r)?(it(!1,"Upload takes an invalidate 'accept' type '".concat(r,"'.Skip for check.")),!0):!1})}return!0};function Pt(t,e){var a=t.createReader(),n=[];function o(){a.readEntries(function(l){var s=Array.prototype.slice.apply(l);n=n.concat(s);var r=!s.length;r?e(n):o()})}o()}var Ut=function(e,a,n){var o=function l(s,r){s&&(s.path=r||"",s.isFile?s.file(function(d){n(d)&&(s.fullPath&&!d.webkitRelativePath&&(Object.defineProperties(d,{webkitRelativePath:{writable:!0}}),d.webkitRelativePath=s.fullPath.replace(/^\//,""),Object.defineProperties(d,{webkitRelativePath:{writable:!1}})),a([d]))}):s.isDirectory&&Pt(s,function(d){d.forEach(function(c){l(c,"".concat(r).concat(s.name,"/"))})}))};e.forEach(function(l){o(l.webkitGetAsEntry())})},kt=["component","prefixCls","className","disabled","id","style","multiple","accept","capture","children","directory","openFileDialogOnClick","onMouseEnter","onMouseLeave"],Dt=function(t){Xe(a,t);var e=Je(a);function a(){var n;Ze(this,a);for(var o=arguments.length,l=new Array(o),s=0;s0&&arguments[0]!==void 0?arguments[0]:"",a=e.split("/"),n=a[a.length-1],o=n.split(/#|\?/)[0];return(/\.[^./\\]*$/.exec(o)||[""])[0]},tt=function(e){return e.indexOf("image/")===0},Kt=function(e){if(e.type&&!e.thumbUrl)return tt(e.type);var a=e.thumbUrl||e.url||"",n=Wt(a);return/^data:image\//.test(a)||/(webp|svg|png|gif|jpg|jpeg|jfif|bmp|dpg|ico|heic|heif)$/i.test(n)?!0:!(/^data:/.test(a)||n)},oe=200;function Gt(t){return new Promise(function(e){if(!t.type||!tt(t.type)){e("");return}var a=document.createElement("canvas");a.width=oe,a.height=oe,a.style.cssText="position: fixed; left: 0; top: 0; width: ".concat(oe,"px; height: ").concat(oe,"px; z-index: 9999; display: none;"),document.body.appendChild(a);var n=a.getContext("2d"),o=new Image;if(o.onload=function(){var r=o.width,d=o.height,c=oe,u=oe,h=0,m=0;r>d?(u=d*(oe/r),m=-(u-c)/2):(c=r*(oe/d),h=-(c-u)/2),n.drawImage(o,h,m,c,u);var y=a.toDataURL();document.body.removeChild(a),window.URL.revokeObjectURL(o.src),e(y)},o.crossOrigin="anonymous",t.type.startsWith("image/svg+xml")){var l=new FileReader;l.onload=function(){l.result&&(o.src=l.result)},l.readAsDataURL(t)}else if(t.type.startsWith("image/gif")){var s=new FileReader;s.onload=function(){s.result&&e(s.result)},s.readAsDataURL(t)}else o.src=window.URL.createObjectURL(t)})}var Xt=i.forwardRef(function(t,e){var a=t.prefixCls,n=t.className,o=t.style,l=t.locale,s=t.listType,r=t.file,d=t.items,c=t.progress,u=t.iconRender,h=t.actionIconRender,m=t.itemRender,y=t.isImgUrl,O=t.showPreviewIcon,S=t.showRemoveIcon,L=t.showDownloadIcon,U=t.previewIcon,T=t.removeIcon,$=t.downloadIcon,M=t.onPreview,p=t.onDownload,x=t.onClose,N,H,Q=r.status,de=i.useState(Q),ee=Pe(de,2),A=ee[0],pe=ee[1];i.useEffect(function(){Q!=="removed"&&pe(Q)},[Q]);var fe=i.useState(!1),ve=Pe(fe,2),me=ve[0],Ce=ve[1],te=i.useRef(null);i.useEffect(function(){return te.current=setTimeout(function(){Ce(!0)},300),function(){te.current&&clearTimeout(te.current)}},[]);var he="".concat(a,"-span"),ne=u(r),ie=i.createElement("div",{className:"".concat(a,"-text-icon")},ne);if(s==="picture"||s==="picture-card")if(A==="uploading"||!r.thumbUrl&&!r.url){var ge=_(F(F({},"".concat(a,"-list-item-thumbnail"),!0),"".concat(a,"-list-item-file"),A!=="uploading"));ie=i.createElement("div",{className:ge},ne)}else{var q=y!=null&&y(r)?i.createElement("img",{src:r.thumbUrl||r.url,alt:r.name,className:"".concat(a,"-list-item-image"),crossOrigin:r.crossOrigin}):ne,Ee=_(F(F({},"".concat(a,"-list-item-thumbnail"),!0),"".concat(a,"-list-item-file"),y&&!y(r)));ie=i.createElement("a",{className:Ee,onClick:function(I){return M(r,I)},href:r.url||r.thumbUrl,target:"_blank",rel:"noopener noreferrer"},q)}var we=_(F(F(F({},"".concat(a,"-list-item"),!0),"".concat(a,"-list-item-").concat(A),!0),"".concat(a,"-list-item-list-type-").concat(s),!0)),k=typeof r.linkProps=="string"?JSON.parse(r.linkProps):r.linkProps,le=S?h((typeof T=="function"?T(r):T)||i.createElement(yt,null),function(){return x(r)},a,l.removeFile):null,ye=L&&A==="done"?h((typeof $=="function"?$(r):$)||i.createElement(bt,null),function(){return p(r)},a,l.downloadFile):null,se=s!=="picture-card"&&i.createElement("span",{key:"download-delete",className:_("".concat(a,"-list-item-card-actions"),{picture:s==="picture"})},ye,le),G=_("".concat(a,"-list-item-name")),Re=r.url?[i.createElement("a",w({key:"view",target:"_blank",rel:"noopener noreferrer",className:G,title:r.name},k,{href:r.url,onClick:function(I){return M(r,I)}}),r.name),se]:[i.createElement("span",{key:"view",className:G,onClick:function(I){return M(r,I)},title:r.name},r.name),se],re={pointerEvents:"none",opacity:.5},J=O?i.createElement("a",{href:r.url||r.thumbUrl,target:"_blank",rel:"noopener noreferrer",style:r.url||r.thumbUrl?void 0:re,onClick:function(I){return M(r,I)},title:l.previewFile},typeof U=="function"?U(r):U||i.createElement(vt,null)):null,ae=s==="picture-card"&&A!=="uploading"&&i.createElement("span",{className:"".concat(a,"-list-item-actions")},J,A==="done"&&ye,le),b;r.response&&typeof r.response=="string"?b=r.response:b=((N=r.error)===null||N===void 0?void 0:N.statusText)||((H=r.error)===null||H===void 0?void 0:H.message)||l.uploadError;var g=i.createElement("span",{className:he},ie,Re),D=i.useContext(je),j=D.getPrefixCls,W=j(),Z=i.createElement("div",{className:we},i.createElement("div",{className:"".concat(a,"-list-item-info")},g),ae,me&&i.createElement(et,{motionName:"".concat(W,"-fade"),visible:A==="uploading",motionDeadline:2e3},function(K){var I=K.className,ce="percent"in r?i.createElement(It,w({},c,{type:"line",percent:r.percent})):null;return i.createElement("div",{className:_("".concat(a,"-list-item-progress"),I)},ce)})),be=_("".concat(a,"-list-").concat(s,"-container"),n),Ie=A==="error"?i.createElement(mt,{title:b,getPopupContainer:function(I){return I.parentNode}},Z):Z;return i.createElement("div",{className:be,style:o,ref:e},m?m(Ie,r,d,{download:p.bind(null,r),preview:M.bind(null,r),remove:x.bind(null,r)}):Ie)});const Jt=Xt;var Le=w({},ht);delete Le.onAppearEnd;delete Le.onEnterEnd;delete Le.onLeaveEnd;var Zt=function(e,a){var n=e.listType,o=n===void 0?"text":n,l=e.previewFile,s=l===void 0?Gt:l,r=e.onPreview,d=e.onDownload,c=e.onRemove,u=e.locale,h=e.iconRender,m=e.isImageUrl,y=m===void 0?Kt:m,O=e.prefixCls,S=e.items,L=S===void 0?[]:S,U=e.showPreviewIcon,T=U===void 0?!0:U,$=e.showRemoveIcon,M=$===void 0?!0:$,p=e.showDownloadIcon,x=p===void 0?!1:p,N=e.removeIcon,H=e.previewIcon,Q=e.downloadIcon,de=e.progress,ee=de===void 0?{strokeWidth:2,showInfo:!1}:de,A=e.appendAction,pe=e.appendActionVisible,fe=pe===void 0?!0:pe,ve=e.itemRender,me=e.disabled,Ce=gt(),te=i.useState(!1),he=Pe(te,2),ne=he[0],ie=he[1];i.useEffect(function(){o!=="picture"&&o!=="picture-card"||(L||[]).forEach(function(b){typeof document>"u"||typeof window>"u"||!window.FileReader||!window.File||!(b.originFileObj instanceof File||b.originFileObj instanceof Blob)||b.thumbUrl!==void 0||(b.thumbUrl="",s&&s(b.originFileObj).then(function(g){b.thumbUrl=g||"",Ce()}))})},[o,L,s]),i.useEffect(function(){ie(!0)},[]);var ge=function(g,D){if(r)return D==null||D.preventDefault(),r(g)},q=function(g){typeof d=="function"?d(g):g.url&&window.open(g.url)},Ee=function(g){c==null||c(g)},we=function(g){if(h)return h(g,o);var D=g.status==="uploading",j=y&&y(g)?i.createElement(Ht,null):i.createElement(Nt,null),W=D?i.createElement(_e,null):i.createElement(jt,null);return o==="picture"?W=D?i.createElement(_e,null):j:o==="picture-card"&&(W=D?u.uploading:j),W},k=function(g,D,j,W){var Z={type:"text",size:"small",title:W,disabled:me,onClick:function(K){D(),Ke(g)&&g.props.onClick&&g.props.onClick(K)},className:"".concat(j,"-list-item-card-actions-btn")};if(Ke(g)){var be=We(g,w(w({},g.props),{onClick:function(){}}));return i.createElement(qe,w({},Z,{icon:be}))}return i.createElement(qe,w({},Z),i.createElement("span",null,g))};i.useImperativeHandle(a,function(){return{handlePreview:ge,handleDownload:q}});var le=i.useContext(je),ye=le.getPrefixCls,se=le.direction,G=ye("upload",O),Re=_(F(F(F({},"".concat(G,"-list"),!0),"".concat(G,"-list-").concat(o),!0),"".concat(G,"-list-rtl"),se==="rtl")),re=ue(L.map(function(b){return{key:b.uid,file:b}})),J=o==="picture-card"?"animate-inline":"animate",ae={motionDeadline:2e3,motionName:"".concat(G,"-").concat(J),keys:re,motionAppear:ne};return o!=="picture-card"&&(ae=w(w({},Le),ae)),i.createElement("div",{className:Re},i.createElement(ct,w({},ae,{component:!1}),function(b){var g=b.key,D=b.file,j=b.className,W=b.style;return i.createElement(Jt,{key:g,locale:u,prefixCls:G,className:j,style:W,file:D,items:L,progress:ee,listType:o,isImgUrl:y,showPreviewIcon:T,showRemoveIcon:M,showDownloadIcon:x,removeIcon:N,previewIcon:H,downloadIcon:Q,iconRender:we,actionIconRender:k,itemRender:ve,onPreview:ge,onDownload:q,onClose:Ee})}),A&&i.createElement(et,w({},ae,{visible:fe,forceRender:!0}),function(b){var g=b.className,D=b.style;return We(A,function(j){return{className:_(j.className,g),style:w(w(w({},D),{pointerEvents:g?"none":void 0}),j.style)}})}))},Yt=i.forwardRef(Zt);const Qt=Yt;var en=globalThis&&globalThis.__awaiter||function(t,e,a,n){function o(l){return l instanceof a?l:new a(function(s){s(l)})}return new(a||(a=Promise))(function(l,s){function r(u){try{c(n.next(u))}catch(h){s(h)}}function d(u){try{c(n.throw(u))}catch(h){s(h)}}function c(u){u.done?l(u.value):o(u.value).then(r,d)}c((n=n.apply(t,e||[])).next())})},Fe="__LIST_IGNORE_".concat(Date.now(),"__"),tn=function(e,a){var n=e.fileList,o=e.defaultFileList,l=e.onRemove,s=e.showUploadList,r=s===void 0?!0:s,d=e.listType,c=d===void 0?"text":d,u=e.onPreview,h=e.onDownload,m=e.onChange,y=e.onDrop,O=e.previewFile,S=e.disabled,L=e.locale,U=e.iconRender,T=e.isImageUrl,$=e.progress,M=e.prefixCls,p=e.className,x=e.type,N=x===void 0?"select":x,H=e.children,Q=e.style,de=e.itemRender,ee=e.maxCount,A=e.data,pe=A===void 0?{}:A,fe=e.multiple,ve=fe===void 0?!1:fe,me=e.action,Ce=me===void 0?"":me,te=e.accept,he=te===void 0?"":te,ne=e.supportServerRender,ie=ne===void 0?!0:ne,ge=i.useContext(ut),q=S??ge,Ee=wt(o||[],{value:n,postState:function(v){return v??[]}}),we=Pe(Ee,2),k=we[0],le=we[1],ye=i.useState("drop"),se=Pe(ye,2),G=se[0],Re=se[1],re=i.useRef(null);i.useMemo(function(){var z=Date.now();(n||[]).forEach(function(v,E){!v.uid&&!Object.isFrozen(v)&&(v.uid="__AUTO__".concat(z,"_").concat(E,"__"))})},[n]);var J=function(v,E,P){var f=ue(E);ee===1?f=f.slice(-1):ee&&(f=f.slice(0,ee)),He.flushSync(function(){le(f)});var C={file:v,fileList:f};P&&(C.event=P),He.flushSync(function(){m==null||m(C)})},ae=function(v,E){return en(void 0,void 0,void 0,Se().mark(function P(){var f,C,B,V;return Se().wrap(function(R){for(;;)switch(R.prev=R.next){case 0:if(f=e.beforeUpload,C=e.transformFile,B=v,!f){R.next=13;break}return R.next=5,f(v,E);case 5:if(V=R.sent,V!==!1){R.next=8;break}return R.abrupt("return",!1);case 8:if(delete v[Fe],V!==Fe){R.next=12;break}return Object.defineProperty(v,Fe,{value:!0,configurable:!0}),R.abrupt("return",!1);case 12:Qe(V)==="object"&&V&&(B=V);case 13:if(!C){R.next=17;break}return R.next=16,C(B);case 16:B=R.sent;case 17:return R.abrupt("return",B);case 18:case"end":return R.stop()}},P)}))},b=function(v){var E=v.filter(function(C){return!C.file[Fe]});if(E.length){var P=E.map(function(C){return ke(C.file)}),f=ue(k);P.forEach(function(C){f=De(C,f)}),P.forEach(function(C,B){var V=C;if(E[B].parsedFile)C.status="uploading";else{var Y=C.originFileObj,R;try{R=new File([Y],Y.name,{type:Y.type})}catch{R=new Blob([Y],{type:Y.type}),R.name=Y.name,R.lastModifiedDate=new Date,R.lastModified=new Date().getTime()}R.uid=C.uid,V=R}J(V,f)})}},g=function(v,E,P){try{typeof v=="string"&&(v=JSON.parse(v))}catch{}if(Te(E,k)){var f=ke(E);f.status="done",f.percent=100,f.response=v,f.xhr=P;var C=De(f,k);J(f,C)}},D=function(v,E){if(Te(E,k)){var P=ke(E);P.status="uploading",P.percent=v.percent;var f=De(P,k);J(P,f,v)}},j=function(v,E,P){if(Te(P,k)){var f=ke(P);f.error=v,f.response=E,f.status="error";var C=De(f,k);J(f,C)}},W=function(v){var E;Promise.resolve(typeof l=="function"?l(v):l).then(function(P){var f;if(P!==!1){var C=qt(v,k);C&&(E=w(w({},v),{status:"removed"}),k==null||k.forEach(function(B){var V=E.uid!==void 0?"uid":"name";B[V]===E[V]&&!Object.isFrozen(B)&&(B.status="removed")}),(f=re.current)===null||f===void 0||f.abort(E),J(E,C))}})},Z=function(v){Re(v.type),v.type==="drop"&&(y==null||y(v))};i.useImperativeHandle(a,function(){return{onBatchStart:b,onSuccess:g,onProgress:D,onError:j,fileList:k,upload:re.current}});var be=i.useContext(je),Ie=be.getPrefixCls,K=be.direction,I=Ie("upload",M),ce=w(w({onBatchStart:b,onError:j,onProgress:D,onSuccess:g},e),{data:pe,multiple:ve,action:Ce,accept:he,supportServerRender:ie,prefixCls:I,disabled:q,beforeUpload:ae,onChange:void 0});delete ce.className,delete ce.style,(!H||q)&&delete ce.id;var xe=function(v,E){return r?i.createElement(dt,{componentName:"Upload",defaultLocale:pt.Upload},function(P){var f=typeof r=="boolean"?{}:r,C=f.showRemoveIcon,B=f.showPreviewIcon,V=f.showDownloadIcon,Y=f.removeIcon,R=f.previewIcon,Ve=f.downloadIcon;return i.createElement(Qt,{prefixCls:I,listType:c,items:k,previewFile:O,onPreview:u,onDownload:h,onRemove:W,showRemoveIcon:!q&&C,showPreviewIcon:B,showDownloadIcon:V,removeIcon:Y,previewIcon:R,downloadIcon:Ve,iconRender:U,locale:w(w({},P),L),isImageUrl:T,progress:$,appendAction:v,appendActionVisible:E,itemRender:de,disabled:q})}):v};if(N==="drag"){var rt=_(I,F(F(F(F(F({},"".concat(I,"-drag"),!0),"".concat(I,"-drag-uploading"),k.some(function(z){return z.status==="uploading"})),"".concat(I,"-drag-hover"),G==="dragover"),"".concat(I,"-disabled"),q),"".concat(I,"-rtl"),K==="rtl"),p);return i.createElement("span",null,i.createElement("div",{className:rt,onDrop:Z,onDragOver:Z,onDragLeave:Z,style:Q},i.createElement(Ae,w({},ce,{ref:re,className:"".concat(I,"-btn")}),i.createElement("div",{className:"".concat(I,"-drag-container")},H))),xe())}var at=_(I,F(F(F(F({},"".concat(I,"-select"),!0),"".concat(I,"-select-").concat(c),!0),"".concat(I,"-disabled"),q),"".concat(I,"-rtl"),K==="rtl")),ot=function(v){return i.createElement("div",{className:at,style:v},i.createElement(Ae,w({},ce,{ref:re})))},Be=ot(H?void 0:{display:"none"});return c==="picture-card"?i.createElement("span",{className:_("".concat(I,"-picture-card-wrapper"),p)},xe(Be,!!H)):i.createElement("span",{className:p},Be,xe())},nn=i.forwardRef(tn);const nt=nn;var rn=globalThis&&globalThis.__rest||function(t,e){var a={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(a[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,n=Object.getOwnPropertySymbols(t);o0&&(l.percent=l.loaded/l.total*100),t.onProgress(l)});var a=new FormData;t.data&&Object.keys(t.data).forEach(function(o){var l=t.data[o];if(Array.isArray(l)){l.forEach(function(s){a.append("".concat(o,"[]"),s)});return}a.append(o,l)}),t.file instanceof Blob?a.append(t.filename,t.file,t.file.name):a.append(t.filename,t.file),e.onerror=function(l){t.onError(l)},e.onload=function(){return e.status<200||e.status>=300?t.onError(Ct(t,e),Ge(e)):t.onSuccess(Ge(e),e)},e.open(t.method,t.action,!0),t.withCredentials&&"withCredentials"in e&&(e.withCredentials=!0);var n=t.headers||{};return n["X-Requested-With"]!==null&&e.setRequestHeader("X-Requested-With","XMLHttpRequest"),Object.keys(n).forEach(function(o){n[o]!==null&&e.setRequestHeader(o,n[o])}),e.send(a),{abort:function(){e.abort()}}}var Rt=+new Date,Ft=0;function $e(){return"rc-upload-".concat(Rt,"-").concat(++Ft)}const Ne=function(t,e){if(t&&e){var a=Array.isArray(e)?e:e.split(","),n=t.name||"",o=t.type||"",l=o.replace(/\/.*$/,"");return a.some(function(s){var r=s.trim();if(/^\*(\/\*)?$/.test(s))return!0;if(r.charAt(0)==="."){var d=n.toLowerCase(),c=r.toLowerCase(),u=[c];return(c===".jpg"||c===".jpeg")&&(u=[".jpg",".jpeg"]),u.some(function(h){return d.endsWith(h)})}return/\/\*$/.test(r)?l===r.replace(/\/.*$/,""):o===r?!0:/^\w+$/.test(r)?(it(!1,"Upload takes an invalidate 'accept' type '".concat(r,"'.Skip for check.")),!0):!1})}return!0};function Pt(t,e){var a=t.createReader(),n=[];function o(){a.readEntries(function(l){var s=Array.prototype.slice.apply(l);n=n.concat(s);var r=!s.length;r?e(n):o()})}o()}var Ut=function(e,a,n){var o=function l(s,r){s&&(s.path=r||"",s.isFile?s.file(function(d){n(d)&&(s.fullPath&&!d.webkitRelativePath&&(Object.defineProperties(d,{webkitRelativePath:{writable:!0}}),d.webkitRelativePath=s.fullPath.replace(/^\//,""),Object.defineProperties(d,{webkitRelativePath:{writable:!1}})),a([d]))}):s.isDirectory&&Pt(s,function(d){d.forEach(function(c){l(c,"".concat(r).concat(s.name,"/"))})}))};e.forEach(function(l){o(l.webkitGetAsEntry())})},kt=["component","prefixCls","className","disabled","id","style","multiple","accept","capture","children","directory","openFileDialogOnClick","onMouseEnter","onMouseLeave"],Dt=function(t){Xe(a,t);var e=Je(a);function a(){var n;Ze(this,a);for(var o=arguments.length,l=new Array(o),s=0;s0&&arguments[0]!==void 0?arguments[0]:"",a=e.split("/"),n=a[a.length-1],o=n.split(/#|\?/)[0];return(/\.[^./\\]*$/.exec(o)||[""])[0]},tt=function(e){return e.indexOf("image/")===0},Kt=function(e){if(e.type&&!e.thumbUrl)return tt(e.type);var a=e.thumbUrl||e.url||"",n=Wt(a);return/^data:image\//.test(a)||/(webp|svg|png|gif|jpg|jpeg|jfif|bmp|dpg|ico|heic|heif)$/i.test(n)?!0:!(/^data:/.test(a)||n)},oe=200;function Gt(t){return new Promise(function(e){if(!t.type||!tt(t.type)){e("");return}var a=document.createElement("canvas");a.width=oe,a.height=oe,a.style.cssText="position: fixed; left: 0; top: 0; width: ".concat(oe,"px; height: ").concat(oe,"px; z-index: 9999; display: none;"),document.body.appendChild(a);var n=a.getContext("2d"),o=new Image;if(o.onload=function(){var r=o.width,d=o.height,c=oe,u=oe,h=0,m=0;r>d?(u=d*(oe/r),m=-(u-c)/2):(c=r*(oe/d),h=-(c-u)/2),n.drawImage(o,h,m,c,u);var y=a.toDataURL();document.body.removeChild(a),window.URL.revokeObjectURL(o.src),e(y)},o.crossOrigin="anonymous",t.type.startsWith("image/svg+xml")){var l=new FileReader;l.onload=function(){l.result&&(o.src=l.result)},l.readAsDataURL(t)}else if(t.type.startsWith("image/gif")){var s=new FileReader;s.onload=function(){s.result&&e(s.result)},s.readAsDataURL(t)}else o.src=window.URL.createObjectURL(t)})}var Xt=i.forwardRef(function(t,e){var a=t.prefixCls,n=t.className,o=t.style,l=t.locale,s=t.listType,r=t.file,d=t.items,c=t.progress,u=t.iconRender,h=t.actionIconRender,m=t.itemRender,y=t.isImgUrl,O=t.showPreviewIcon,S=t.showRemoveIcon,L=t.showDownloadIcon,U=t.previewIcon,T=t.removeIcon,$=t.downloadIcon,M=t.onPreview,p=t.onDownload,x=t.onClose,N,H,Q=r.status,de=i.useState(Q),ee=Pe(de,2),A=ee[0],pe=ee[1];i.useEffect(function(){Q!=="removed"&&pe(Q)},[Q]);var fe=i.useState(!1),ve=Pe(fe,2),me=ve[0],Ce=ve[1],te=i.useRef(null);i.useEffect(function(){return te.current=setTimeout(function(){Ce(!0)},300),function(){te.current&&clearTimeout(te.current)}},[]);var he="".concat(a,"-span"),ne=u(r),ie=i.createElement("div",{className:"".concat(a,"-text-icon")},ne);if(s==="picture"||s==="picture-card")if(A==="uploading"||!r.thumbUrl&&!r.url){var ge=_(F(F({},"".concat(a,"-list-item-thumbnail"),!0),"".concat(a,"-list-item-file"),A!=="uploading"));ie=i.createElement("div",{className:ge},ne)}else{var q=y!=null&&y(r)?i.createElement("img",{src:r.thumbUrl||r.url,alt:r.name,className:"".concat(a,"-list-item-image"),crossOrigin:r.crossOrigin}):ne,Ee=_(F(F({},"".concat(a,"-list-item-thumbnail"),!0),"".concat(a,"-list-item-file"),y&&!y(r)));ie=i.createElement("a",{className:Ee,onClick:function(I){return M(r,I)},href:r.url||r.thumbUrl,target:"_blank",rel:"noopener noreferrer"},q)}var we=_(F(F(F({},"".concat(a,"-list-item"),!0),"".concat(a,"-list-item-").concat(A),!0),"".concat(a,"-list-item-list-type-").concat(s),!0)),k=typeof r.linkProps=="string"?JSON.parse(r.linkProps):r.linkProps,le=S?h((typeof T=="function"?T(r):T)||i.createElement(yt,null),function(){return x(r)},a,l.removeFile):null,ye=L&&A==="done"?h((typeof $=="function"?$(r):$)||i.createElement(bt,null),function(){return p(r)},a,l.downloadFile):null,se=s!=="picture-card"&&i.createElement("span",{key:"download-delete",className:_("".concat(a,"-list-item-card-actions"),{picture:s==="picture"})},ye,le),G=_("".concat(a,"-list-item-name")),Re=r.url?[i.createElement("a",w({key:"view",target:"_blank",rel:"noopener noreferrer",className:G,title:r.name},k,{href:r.url,onClick:function(I){return M(r,I)}}),r.name),se]:[i.createElement("span",{key:"view",className:G,onClick:function(I){return M(r,I)},title:r.name},r.name),se],re={pointerEvents:"none",opacity:.5},J=O?i.createElement("a",{href:r.url||r.thumbUrl,target:"_blank",rel:"noopener noreferrer",style:r.url||r.thumbUrl?void 0:re,onClick:function(I){return M(r,I)},title:l.previewFile},typeof U=="function"?U(r):U||i.createElement(vt,null)):null,ae=s==="picture-card"&&A!=="uploading"&&i.createElement("span",{className:"".concat(a,"-list-item-actions")},J,A==="done"&&ye,le),b;r.response&&typeof r.response=="string"?b=r.response:b=((N=r.error)===null||N===void 0?void 0:N.statusText)||((H=r.error)===null||H===void 0?void 0:H.message)||l.uploadError;var g=i.createElement("span",{className:he},ie,Re),D=i.useContext(je),j=D.getPrefixCls,W=j(),Z=i.createElement("div",{className:we},i.createElement("div",{className:"".concat(a,"-list-item-info")},g),ae,me&&i.createElement(et,{motionName:"".concat(W,"-fade"),visible:A==="uploading",motionDeadline:2e3},function(K){var I=K.className,ce="percent"in r?i.createElement(It,w({},c,{type:"line",percent:r.percent})):null;return i.createElement("div",{className:_("".concat(a,"-list-item-progress"),I)},ce)})),be=_("".concat(a,"-list-").concat(s,"-container"),n),Ie=A==="error"?i.createElement(mt,{title:b,getPopupContainer:function(I){return I.parentNode}},Z):Z;return i.createElement("div",{className:be,style:o,ref:e},m?m(Ie,r,d,{download:p.bind(null,r),preview:M.bind(null,r),remove:x.bind(null,r)}):Ie)});const Jt=Xt;var Le=w({},ht);delete Le.onAppearEnd;delete Le.onEnterEnd;delete Le.onLeaveEnd;var Zt=function(e,a){var n=e.listType,o=n===void 0?"text":n,l=e.previewFile,s=l===void 0?Gt:l,r=e.onPreview,d=e.onDownload,c=e.onRemove,u=e.locale,h=e.iconRender,m=e.isImageUrl,y=m===void 0?Kt:m,O=e.prefixCls,S=e.items,L=S===void 0?[]:S,U=e.showPreviewIcon,T=U===void 0?!0:U,$=e.showRemoveIcon,M=$===void 0?!0:$,p=e.showDownloadIcon,x=p===void 0?!1:p,N=e.removeIcon,H=e.previewIcon,Q=e.downloadIcon,de=e.progress,ee=de===void 0?{strokeWidth:2,showInfo:!1}:de,A=e.appendAction,pe=e.appendActionVisible,fe=pe===void 0?!0:pe,ve=e.itemRender,me=e.disabled,Ce=gt(),te=i.useState(!1),he=Pe(te,2),ne=he[0],ie=he[1];i.useEffect(function(){o!=="picture"&&o!=="picture-card"||(L||[]).forEach(function(b){typeof document>"u"||typeof window>"u"||!window.FileReader||!window.File||!(b.originFileObj instanceof File||b.originFileObj instanceof Blob)||b.thumbUrl!==void 0||(b.thumbUrl="",s&&s(b.originFileObj).then(function(g){b.thumbUrl=g||"",Ce()}))})},[o,L,s]),i.useEffect(function(){ie(!0)},[]);var ge=function(g,D){if(r)return D==null||D.preventDefault(),r(g)},q=function(g){typeof d=="function"?d(g):g.url&&window.open(g.url)},Ee=function(g){c==null||c(g)},we=function(g){if(h)return h(g,o);var D=g.status==="uploading",j=y&&y(g)?i.createElement(Ht,null):i.createElement(Nt,null),W=D?i.createElement(_e,null):i.createElement(jt,null);return o==="picture"?W=D?i.createElement(_e,null):j:o==="picture-card"&&(W=D?u.uploading:j),W},k=function(g,D,j,W){var Z={type:"text",size:"small",title:W,disabled:me,onClick:function(K){D(),Ke(g)&&g.props.onClick&&g.props.onClick(K)},className:"".concat(j,"-list-item-card-actions-btn")};if(Ke(g)){var be=We(g,w(w({},g.props),{onClick:function(){}}));return i.createElement(qe,w({},Z,{icon:be}))}return i.createElement(qe,w({},Z),i.createElement("span",null,g))};i.useImperativeHandle(a,function(){return{handlePreview:ge,handleDownload:q}});var le=i.useContext(je),ye=le.getPrefixCls,se=le.direction,G=ye("upload",O),Re=_(F(F(F({},"".concat(G,"-list"),!0),"".concat(G,"-list-").concat(o),!0),"".concat(G,"-list-rtl"),se==="rtl")),re=ue(L.map(function(b){return{key:b.uid,file:b}})),J=o==="picture-card"?"animate-inline":"animate",ae={motionDeadline:2e3,motionName:"".concat(G,"-").concat(J),keys:re,motionAppear:ne};return o!=="picture-card"&&(ae=w(w({},Le),ae)),i.createElement("div",{className:Re},i.createElement(ct,w({},ae,{component:!1}),function(b){var g=b.key,D=b.file,j=b.className,W=b.style;return i.createElement(Jt,{key:g,locale:u,prefixCls:G,className:j,style:W,file:D,items:L,progress:ee,listType:o,isImgUrl:y,showPreviewIcon:T,showRemoveIcon:M,showDownloadIcon:x,removeIcon:N,previewIcon:H,downloadIcon:Q,iconRender:we,actionIconRender:k,itemRender:ve,onPreview:ge,onDownload:q,onClose:Ee})}),A&&i.createElement(et,w({},ae,{visible:fe,forceRender:!0}),function(b){var g=b.className,D=b.style;return We(A,function(j){return{className:_(j.className,g),style:w(w(w({},D),{pointerEvents:g?"none":void 0}),j.style)}})}))},Yt=i.forwardRef(Zt);const Qt=Yt;var en=globalThis&&globalThis.__awaiter||function(t,e,a,n){function o(l){return l instanceof a?l:new a(function(s){s(l)})}return new(a||(a=Promise))(function(l,s){function r(u){try{c(n.next(u))}catch(h){s(h)}}function d(u){try{c(n.throw(u))}catch(h){s(h)}}function c(u){u.done?l(u.value):o(u.value).then(r,d)}c((n=n.apply(t,e||[])).next())})},Fe="__LIST_IGNORE_".concat(Date.now(),"__"),tn=function(e,a){var n=e.fileList,o=e.defaultFileList,l=e.onRemove,s=e.showUploadList,r=s===void 0?!0:s,d=e.listType,c=d===void 0?"text":d,u=e.onPreview,h=e.onDownload,m=e.onChange,y=e.onDrop,O=e.previewFile,S=e.disabled,L=e.locale,U=e.iconRender,T=e.isImageUrl,$=e.progress,M=e.prefixCls,p=e.className,x=e.type,N=x===void 0?"select":x,H=e.children,Q=e.style,de=e.itemRender,ee=e.maxCount,A=e.data,pe=A===void 0?{}:A,fe=e.multiple,ve=fe===void 0?!1:fe,me=e.action,Ce=me===void 0?"":me,te=e.accept,he=te===void 0?"":te,ne=e.supportServerRender,ie=ne===void 0?!0:ne,ge=i.useContext(ut),q=S??ge,Ee=wt(o||[],{value:n,postState:function(v){return v??[]}}),we=Pe(Ee,2),k=we[0],le=we[1],ye=i.useState("drop"),se=Pe(ye,2),G=se[0],Re=se[1],re=i.useRef(null);i.useMemo(function(){var z=Date.now();(n||[]).forEach(function(v,E){!v.uid&&!Object.isFrozen(v)&&(v.uid="__AUTO__".concat(z,"_").concat(E,"__"))})},[n]);var J=function(v,E,P){var f=ue(E);ee===1?f=f.slice(-1):ee&&(f=f.slice(0,ee)),He.flushSync(function(){le(f)});var C={file:v,fileList:f};P&&(C.event=P),He.flushSync(function(){m==null||m(C)})},ae=function(v,E){return en(void 0,void 0,void 0,Se().mark(function P(){var f,C,B,V;return Se().wrap(function(R){for(;;)switch(R.prev=R.next){case 0:if(f=e.beforeUpload,C=e.transformFile,B=v,!f){R.next=13;break}return R.next=5,f(v,E);case 5:if(V=R.sent,V!==!1){R.next=8;break}return R.abrupt("return",!1);case 8:if(delete v[Fe],V!==Fe){R.next=12;break}return Object.defineProperty(v,Fe,{value:!0,configurable:!0}),R.abrupt("return",!1);case 12:Qe(V)==="object"&&V&&(B=V);case 13:if(!C){R.next=17;break}return R.next=16,C(B);case 16:B=R.sent;case 17:return R.abrupt("return",B);case 18:case"end":return R.stop()}},P)}))},b=function(v){var E=v.filter(function(C){return!C.file[Fe]});if(E.length){var P=E.map(function(C){return ke(C.file)}),f=ue(k);P.forEach(function(C){f=De(C,f)}),P.forEach(function(C,B){var V=C;if(E[B].parsedFile)C.status="uploading";else{var Y=C.originFileObj,R;try{R=new File([Y],Y.name,{type:Y.type})}catch{R=new Blob([Y],{type:Y.type}),R.name=Y.name,R.lastModifiedDate=new Date,R.lastModified=new Date().getTime()}R.uid=C.uid,V=R}J(V,f)})}},g=function(v,E,P){try{typeof v=="string"&&(v=JSON.parse(v))}catch{}if(Te(E,k)){var f=ke(E);f.status="done",f.percent=100,f.response=v,f.xhr=P;var C=De(f,k);J(f,C)}},D=function(v,E){if(Te(E,k)){var P=ke(E);P.status="uploading",P.percent=v.percent;var f=De(P,k);J(P,f,v)}},j=function(v,E,P){if(Te(P,k)){var f=ke(P);f.error=v,f.response=E,f.status="error";var C=De(f,k);J(f,C)}},W=function(v){var E;Promise.resolve(typeof l=="function"?l(v):l).then(function(P){var f;if(P!==!1){var C=qt(v,k);C&&(E=w(w({},v),{status:"removed"}),k==null||k.forEach(function(B){var V=E.uid!==void 0?"uid":"name";B[V]===E[V]&&!Object.isFrozen(B)&&(B.status="removed")}),(f=re.current)===null||f===void 0||f.abort(E),J(E,C))}})},Z=function(v){Re(v.type),v.type==="drop"&&(y==null||y(v))};i.useImperativeHandle(a,function(){return{onBatchStart:b,onSuccess:g,onProgress:D,onError:j,fileList:k,upload:re.current}});var be=i.useContext(je),Ie=be.getPrefixCls,K=be.direction,I=Ie("upload",M),ce=w(w({onBatchStart:b,onError:j,onProgress:D,onSuccess:g},e),{data:pe,multiple:ve,action:Ce,accept:he,supportServerRender:ie,prefixCls:I,disabled:q,beforeUpload:ae,onChange:void 0});delete ce.className,delete ce.style,(!H||q)&&delete ce.id;var xe=function(v,E){return r?i.createElement(dt,{componentName:"Upload",defaultLocale:pt.Upload},function(P){var f=typeof r=="boolean"?{}:r,C=f.showRemoveIcon,B=f.showPreviewIcon,V=f.showDownloadIcon,Y=f.removeIcon,R=f.previewIcon,Ve=f.downloadIcon;return i.createElement(Qt,{prefixCls:I,listType:c,items:k,previewFile:O,onPreview:u,onDownload:h,onRemove:W,showRemoveIcon:!q&&C,showPreviewIcon:B,showDownloadIcon:V,removeIcon:Y,previewIcon:R,downloadIcon:Ve,iconRender:U,locale:w(w({},P),L),isImageUrl:T,progress:$,appendAction:v,appendActionVisible:E,itemRender:de,disabled:q})}):v};if(N==="drag"){var rt=_(I,F(F(F(F(F({},"".concat(I,"-drag"),!0),"".concat(I,"-drag-uploading"),k.some(function(z){return z.status==="uploading"})),"".concat(I,"-drag-hover"),G==="dragover"),"".concat(I,"-disabled"),q),"".concat(I,"-rtl"),K==="rtl"),p);return i.createElement("span",null,i.createElement("div",{className:rt,onDrop:Z,onDragOver:Z,onDragLeave:Z,style:Q},i.createElement(Ae,w({},ce,{ref:re,className:"".concat(I,"-btn")}),i.createElement("div",{className:"".concat(I,"-drag-container")},H))),xe())}var at=_(I,F(F(F(F({},"".concat(I,"-select"),!0),"".concat(I,"-select-").concat(c),!0),"".concat(I,"-disabled"),q),"".concat(I,"-rtl"),K==="rtl")),ot=function(v){return i.createElement("div",{className:at,style:v},i.createElement(Ae,w({},ce,{ref:re})))},Be=ot(H?void 0:{display:"none"});return c==="picture-card"?i.createElement("span",{className:_("".concat(I,"-picture-card-wrapper"),p)},xe(Be,!!H)):i.createElement("span",{className:p},Be,xe())},nn=i.forwardRef(tn);const nt=nn;var rn=globalThis&&globalThis.__rest||function(t,e){var a={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(a[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,n=Object.getOwnPropertySymbols(t);o-1}var ta=ea,ra=h;function na(a,e){var t=this.__data__,r=ra(t,a);return r<0?(++this.size,t.push([a,e])):t[r][1]=e,this}var sa=na,ia=R,oa=Y,ua=k,ca=ta,ha=sa;function o(a){var e=-1,t=a==null?0:a.length;for(this.clear();++e-1&&a%1==0&&a-1&&a%1==0&&a<=vt}var pt=lt;function ft(a){return a}var _t=ft,dt=d,gt=E,$t=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,yt=/^\w*$/;function mt(a,e){if(dt(a))return!1;var t=typeof a;return t=="number"||t=="symbol"||t=="boolean"||a==null||gt(a)?!0:yt.test(a)||!$t.test(a)||e!=null&&a in Object(e)}var Ct=mt,M=Be,bt="Expected a function";function $(a,e){if(typeof a!="function"||e!=null&&typeof e!="function")throw new TypeError(bt);var t=function(){var r=arguments,n=e?e.apply(this,r):r[0],s=t.cache;if(s.has(n))return s.get(n);var i=a.apply(this,r);return t.cache=s.set(n,i)||s,i};return t.cache=new($.Cache||M),t}$.Cache=M;var Ot=$,Pt=Ot,It=500;function St(a){var e=Pt(a,function(r){return t.size===It&&t.clear(),r}),t=e.cache;return e}var wt=St,xt=wt,Et=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,At=/\\(\\)?/g,Tt=xt(function(a){var e=[];return a.charCodeAt(0)===46&&e.push(""),a.replace(Et,function(t,r,n,s){e.push(n?s.replace(At,"$1"):r||t)}),e}),Dt=Tt,Nt=d,Mt=Ct,Ht=Dt,zt=F;function Gt(a,e){return Nt(a)?a:Mt(a,e)?[a]:Ht(zt(a))}var H=Gt,Ft=E,jt=1/0;function Kt(a){if(typeof a=="string"||Ft(a))return a;var e=a+"";return e=="0"&&1/a==-jt?"-0":e}var z=Kt,Vt=H,Rt=z;function Lt(a,e){e=Vt(e,a);for(var t=0,r=e.length;a!=null&&t0){if(++e>=br)return arguments[0]}else e=0;return a.apply(void 0,arguments)}}var Sr=Ir,wr=Cr,xr=Sr,Er=xr(wr),Vr=Er;export{Dr as A,H as B,va as _,Ya as a,Be as b,Nr as c,zr as d,D as e,pt as f,it as g,ht as h,A as i,ya as j,g as k,xa as l,_t as m,T as n,Tr as o,Gr as p,Fr as q,Ct as r,z as s,Mr as t,jr as u,ir as v,Kr as w,Vr as x,Hr as y,j as z}; +import{r as _,ab as S,a8 as w,ac as x,aa as d,bn as E,bp as F}from"./umi-a12c8253.js";function Tr(a,e){var t=Object.assign({},a);return Array.isArray(e)&&e.forEach(function(r){delete t[r]}),t}var A=_.isValidElement;function Dr(a){return a&&A(a)&&a.type===_.Fragment}function j(a,e,t){return A(a)?_.cloneElement(a,typeof t=="function"?t(a.props||{}):t):e}function Nr(a,e){return j(a,a,e)}var Mr=function(){for(var e=arguments.length,t=new Array(e),r=0;r-1}var ta=ea,ra=h;function na(a,e){var t=this.__data__,r=ra(t,a);return r<0?(++this.size,t.push([a,e])):t[r][1]=e,this}var sa=na,ia=R,oa=Y,ua=k,ca=ta,ha=sa;function o(a){var e=-1,t=a==null?0:a.length;for(this.clear();++e-1&&a%1==0&&a-1&&a%1==0&&a<=vt}var pt=lt;function ft(a){return a}var _t=ft,dt=d,gt=E,$t=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,yt=/^\w*$/;function mt(a,e){if(dt(a))return!1;var t=typeof a;return t=="number"||t=="symbol"||t=="boolean"||a==null||gt(a)?!0:yt.test(a)||!$t.test(a)||e!=null&&a in Object(e)}var Ct=mt,M=Be,bt="Expected a function";function $(a,e){if(typeof a!="function"||e!=null&&typeof e!="function")throw new TypeError(bt);var t=function(){var r=arguments,n=e?e.apply(this,r):r[0],s=t.cache;if(s.has(n))return s.get(n);var i=a.apply(this,r);return t.cache=s.set(n,i)||s,i};return t.cache=new($.Cache||M),t}$.Cache=M;var Ot=$,Pt=Ot,It=500;function St(a){var e=Pt(a,function(r){return t.size===It&&t.clear(),r}),t=e.cache;return e}var wt=St,xt=wt,Et=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,At=/\\(\\)?/g,Tt=xt(function(a){var e=[];return a.charCodeAt(0)===46&&e.push(""),a.replace(Et,function(t,r,n,s){e.push(n?s.replace(At,"$1"):r||t)}),e}),Dt=Tt,Nt=d,Mt=Ct,Ht=Dt,zt=F;function Gt(a,e){return Nt(a)?a:Mt(a,e)?[a]:Ht(zt(a))}var H=Gt,Ft=E,jt=1/0;function Kt(a){if(typeof a=="string"||Ft(a))return a;var e=a+"";return e=="0"&&1/a==-jt?"-0":e}var z=Kt,Vt=H,Rt=z;function Lt(a,e){e=Vt(e,a);for(var t=0,r=e.length;a!=null&&t0){if(++e>=br)return arguments[0]}else e=0;return a.apply(void 0,arguments)}}var Sr=Ir,wr=Cr,xr=Sr,Er=xr(wr),Vr=Er;export{Dr as A,H as B,va as _,Ya as a,Be as b,Nr as c,zr as d,D as e,pt as f,it as g,ht as h,A as i,ya as j,g as k,xa as l,_t as m,T as n,Tr as o,Gr as p,Fr as q,Ct as r,z as s,Mr as t,jr as u,ir as v,Kr as w,Vr as x,Hr as y,j as z}; diff --git a/dist/assets/button-eaadfeb4.js b/dist/assets/button-f56a19a0.js similarity index 98% rename from dist/assets/button-eaadfeb4.js rename to dist/assets/button-f56a19a0.js index 7dc389e7eeabdbc3564599cd8aad7f1124a7283e..91264e4bb97946372cf9ad69c62ad778391b7f86 100644 --- a/dist/assets/button-eaadfeb4.js +++ b/dist/assets/button-f56a19a0.js @@ -1,4 +1,4 @@ -import{R as S,bo as $e,r as i,C as w,c as R,b as u,d as O,w as U,G as Ae,F as We,J as De,bf as je,a5 as Be,M as Fe,E as Me,B as Ge,H as ve,I as Ve,av as Ue,L as pe,e as He,S as Je,V as qe,a as ge,z as Ke}from"./umi-9940633e.js";import{c as be,t as q,o as Qe,A as Xe}from"./_setToString-98c064b8.js";function H(a){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=[];return S.Children.forEach(a,function(e){e==null&&!t.keepEmpty||(Array.isArray(e)?n=n.concat(H(e)):$e(e)&&e.props?n=n.concat(H(e.props.children,t)):n.push(e))}),n}var ye=globalThis&&globalThis.__rest||function(a,t){var n={};for(var e in a)Object.prototype.hasOwnProperty.call(a,e)&&t.indexOf(e)<0&&(n[e]=a[e]);if(a!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,e=Object.getOwnPropertySymbols(a);r1&&arguments[1]!==void 0?arguments[1]:1,n=tt++,e=t;function r(){e-=1,e<=0?(a(),delete k[n]):k[n]=U(r)}return k[n]=U(r),n}z.cancel=function(t){t!==void 0&&(U.cancel(k[t]),delete k[t])};z.ids=k;function nt(a,t,n){return t=ve(t),Ve(a,Ue()?Reflect.construct(t,n||[],ve(a).constructor):t.apply(a,n))}var F;function Ce(a){return!a||a.offsetParent===null||a.hidden}function at(a){return a instanceof Document?a.body:Array.from(a.childNodes).find(function(t){return(t==null?void 0:t.nodeType)===Node.ELEMENT_NODE})}function rt(a){var t=(a||"").match(/rgba?\((\d*), (\d*), (\d*)(, [\d.]*)?\)/);return t&&t[1]&&t[2]&&t[3]?!(t[1]===t[2]&&t[2]===t[3]):!0}var xe=function(a){Ae(t,a);function t(){var n;return We(this,t),n=nt(this,t,arguments),n.containerRef=i.createRef(),n.animationStart=!1,n.destroyed=!1,n.onClick=function(e,r){var o,c,s=n.props,l=s.insertExtraNode,v=s.disabled;if(!(v||!e||Ce(e)||e.className.includes("-leave"))){n.extraNode=document.createElement("div");var p=De(n),g=p.extraNode,b=n.context.getPrefixCls;g.className="".concat(b(""),"-click-animating-node");var C=n.getAttributeName();if(e.setAttribute(C,"true"),r&&r!=="#fff"&&r!=="#ffffff"&&r!=="rgb(255, 255, 255)"&&r!=="rgba(255, 255, 255, 1)"&&rt(r)&&!/rgba\((?:\d*, ){3}0\)/.test(r)&&r!=="transparent"){g.style.borderColor=r;var x=((o=e.getRootNode)===null||o===void 0?void 0:o.call(e))||e.ownerDocument,f=(c=at(x))!==null&&c!==void 0?c:x;F=je(` +import{R as S,bo as $e,r as i,C as w,c as R,b as u,d as O,w as U,G as Ae,F as We,J as De,bf as je,a5 as Be,M as Fe,E as Me,B as Ge,H as ve,I as Ve,av as Ue,L as pe,e as He,S as Je,V as qe,a as ge,z as Ke}from"./umi-a12c8253.js";import{c as be,t as q,o as Qe,A as Xe}from"./_setToString-ca5ad23e.js";function H(a){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=[];return S.Children.forEach(a,function(e){e==null&&!t.keepEmpty||(Array.isArray(e)?n=n.concat(H(e)):$e(e)&&e.props?n=n.concat(H(e.props.children,t)):n.push(e))}),n}var ye=globalThis&&globalThis.__rest||function(a,t){var n={};for(var e in a)Object.prototype.hasOwnProperty.call(a,e)&&t.indexOf(e)<0&&(n[e]=a[e]);if(a!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,e=Object.getOwnPropertySymbols(a);r1&&arguments[1]!==void 0?arguments[1]:1,n=tt++,e=t;function r(){e-=1,e<=0?(a(),delete k[n]):k[n]=U(r)}return k[n]=U(r),n}z.cancel=function(t){t!==void 0&&(U.cancel(k[t]),delete k[t])};z.ids=k;function nt(a,t,n){return t=ve(t),Ve(a,Ue()?Reflect.construct(t,n||[],ve(a).constructor):t.apply(a,n))}var F;function Ce(a){return!a||a.offsetParent===null||a.hidden}function at(a){return a instanceof Document?a.body:Array.from(a.childNodes).find(function(t){return(t==null?void 0:t.nodeType)===Node.ELEMENT_NODE})}function rt(a){var t=(a||"").match(/rgba?\((\d*), (\d*), (\d*)(, [\d.]*)?\)/);return t&&t[1]&&t[2]&&t[3]?!(t[1]===t[2]&&t[2]===t[3]):!0}var xe=function(a){Ae(t,a);function t(){var n;return We(this,t),n=nt(this,t,arguments),n.containerRef=i.createRef(),n.animationStart=!1,n.destroyed=!1,n.onClick=function(e,r){var o,c,s=n.props,l=s.insertExtraNode,v=s.disabled;if(!(v||!e||Ce(e)||e.className.includes("-leave"))){n.extraNode=document.createElement("div");var p=De(n),g=p.extraNode,b=n.context.getPrefixCls;g.className="".concat(b(""),"-click-animating-node");var C=n.getAttributeName();if(e.setAttribute(C,"true"),r&&r!=="#fff"&&r!=="#ffffff"&&r!=="rgb(255, 255, 255)"&&r!=="rgba(255, 255, 255, 1)"&&rt(r)&&!/rgba\((?:\d*, ){3}0\)/.test(r)&&r!=="transparent"){g.style.borderColor=r;var x=((o=e.getRootNode)===null||o===void 0?void 0:o.call(e))||e.ownerDocument,f=(c=at(x))!==null&&c!==void 0?c:x;F=je(` [`.concat(b(""),"-click-animating-without-extra-node='true']::after, .").concat(b(""),`-click-animating-node { --antd-wave-shadow-color: `).concat(r,`; }`),"antd-wave",{csp:n.csp,attachTo:f})}l&&e.appendChild(g),["transition","animation"].forEach(function(m){e.addEventListener("".concat(m,"start"),n.onTransitionStart),e.addEventListener("".concat(m,"end"),n.onTransitionEnd)})}},n.onTransitionStart=function(e){if(!n.destroyed){var r=n.containerRef.current;!e||e.target!==r||n.animationStart||n.resetEffect(r)}},n.onTransitionEnd=function(e){!e||e.animationName!=="fadeEffect"||n.resetEffect(e.target)},n.bindAnimationEvent=function(e){if(!(!e||!e.getAttribute||e.getAttribute("disabled")||e.className.includes("disabled"))){var r=function(c){if(!(c.target.tagName==="INPUT"||Ce(c.target))){n.resetEffect(e);var s=getComputedStyle(e).getPropertyValue("border-top-color")||getComputedStyle(e).getPropertyValue("border-color")||getComputedStyle(e).getPropertyValue("background-color");n.clickWaveTimeoutId=window.setTimeout(function(){return n.onClick(e,s)},0),z.cancel(n.animationStartId),n.animationStart=!0,n.animationStartId=z(function(){n.animationStart=!1},10)}};return e.addEventListener("click",r,!0),{cancel:function(){e.removeEventListener("click",r,!0)}}}},n.renderWave=function(e){var r=e.csp,o=n.props.children;if(n.csp=r,!i.isValidElement(o))return o;var c=n.containerRef;return Be(o)&&(c=Fe(o.ref,n.containerRef)),be(o,{ref:c})},n}return Me(t,[{key:"componentDidMount",value:function(){this.destroyed=!1;var e=this.containerRef.current;!e||e.nodeType!==1||(this.instance=this.bindAnimationEvent(e))}},{key:"componentWillUnmount",value:function(){this.instance&&this.instance.cancel(),this.clickWaveTimeoutId&&clearTimeout(this.clickWaveTimeoutId),this.destroyed=!0}},{key:"getAttributeName",value:function(){var e=this.context.getPrefixCls,r=this.props.insertExtraNode;return r?"".concat(e(""),"-click-animating"):"".concat(e(""),"-click-animating-without-extra-node")}},{key:"resetEffect",value:function(e){var r=this;if(!(!e||e===this.extraNode||!(e instanceof Element))){var o=this.props.insertExtraNode,c=this.getAttributeName();e.setAttribute(c,"false"),F&&(F.innerHTML=""),o&&this.extraNode&&e.contains(this.extraNode)&&e.removeChild(this.extraNode),["transition","animation"].forEach(function(s){e.removeEventListener("".concat(s,"start"),r.onTransitionStart),e.removeEventListener("".concat(s,"end"),r.onTransitionEnd)})}}},{key:"render",value:function(){return i.createElement(Ge,null,this.renderWave)}}]),t}(i.Component);xe.contextType=w;const it=xe;var ot=globalThis&&globalThis.__rest||function(a,t){var n={};for(var e in a)Object.prototype.hasOwnProperty.call(a,e)&&t.indexOf(e)<0&&(n[e]=a[e]);if(a!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,e=Object.getOwnPropertySymbols(a);r=4.5;case"AAlarge":return o>=3;case"AAAsmall":return o>=7;default:return!1}}function Ya(e,r,t){t===void 0&&(t={includeFallbackColors:!1,level:"AA",size:"small"});for(var n=null,a=0,o=t.includeFallbackColors,u=t.level,f=t.size,y=0,s=r;ya&&(a=h,n=new De(E))}return Ga(e,n,{level:u,size:f})||!o?n:(t.includeFallbackColors=!1,Ya(e,["#fff","#000"],t))}function Qu(e,r){var t=new De(e),n="#"+Vr(t.r,t.g,t.b,t.a),a=n,o=t.gradientType?"GradientType = 1, ":"";if(r){var u=new De(r);a="#"+Vr(u.r,u.g,u.b,u.a)}return"progid:DXImageTransform.Microsoft.gradient(".concat(o,"startColorstr=").concat(n,",endColorstr=").concat(a,")")}function Xu(e,r){var t={r:Dr(e.r),g:Dr(e.g),b:Dr(e.b)};return e.a!==void 0&&(t.a=Number(e.a)),new De(t,r)}function Ju(){return new De({r:Math.random(),g:Math.random(),b:Math.random()})}function Ha(e){if(e===void 0&&(e={}),e.count!==void 0&&e.count!==null){var r=e.count,t=[];for(e.count=void 0;r>t.length;)e.count=null,e.seed&&(e.seed+=1),t.push(Ha(e));return e.count=r,t}var n=Zu(e.hue,e.seed),a=el(n,e),o=tl(n,a,e),u={h:n,s:a,v:o};return e.alpha!==void 0&&(u.a=e.alpha),new De(u)}function Zu(e,r){var t=nl(e),n=Zt(t,r);return n<0&&(n=360+n),n}function el(e,r){if(r.hue==="monochrome")return 0;if(r.luminosity==="random")return Zt([0,100],r.seed);var t=Ka(e).saturationRange,n=t[0],a=t[1];switch(r.luminosity){case"bright":n=55;break;case"dark":n=a-10;break;case"light":a=55;break}return Zt([n,a],r.seed)}function tl(e,r,t){var n=rl(e,r),a=100;switch(t.luminosity){case"dark":a=n+20;break;case"light":n=(a+n)/2;break;case"random":n=0,a=100;break}return Zt([n,a],t.seed)}function rl(e,r){for(var t=Ka(e).lowerBounds,n=0;n=a&&r<=u){var y=(f-o)/(u-a),s=o-y*a;return y*r+s}}return 0}function nl(e){var r=parseInt(e,10);if(!Number.isNaN(r)&&r<360&&r>0)return[r,r];if(typeof e=="string"){var t=mn.find(function(u){return u.name===e});if(t){var n=Va(t);if(n.hueRange)return n.hueRange}var a=new De(e);if(a.isValid){var o=a.toHsv().h;return[o,o]}}return[0,360]}function Ka(e){e>=334&&e<=360&&(e-=360);for(var r=0,t=mn;r=a.hueRange[0]&&e<=a.hueRange[1])return a}throw Error("Color not found")}function Zt(e,r){if(r===void 0)return Math.floor(e[0]+Math.random()*(e[1]+1-e[0]));var t=e[1]||1,n=e[0]||0;r=(r*9301+49297)%233280;var a=r/233280;return Math.floor(n+a*(t-n))}function Va(e){var r=e.lowerBounds[0][0],t=e.lowerBounds[e.lowerBounds.length-1][0],n=e.lowerBounds[e.lowerBounds.length-1][1],a=e.lowerBounds[0][1];return{name:e.name,hueRange:e.hueRange,lowerBounds:e.lowerBounds,saturationRange:[r,t],brightnessRange:[n,a]}}var mn=[{name:"monochrome",hueRange:null,lowerBounds:[[0,0],[100,0]]},{name:"red",hueRange:[-26,18],lowerBounds:[[20,100],[30,92],[40,89],[50,85],[60,78],[70,70],[80,60],[90,55],[100,50]]},{name:"orange",hueRange:[19,46],lowerBounds:[[20,100],[30,93],[40,88],[50,86],[60,85],[70,70],[100,70]]},{name:"yellow",hueRange:[47,62],lowerBounds:[[25,100],[40,94],[50,89],[60,86],[70,84],[80,82],[90,80],[100,75]]},{name:"green",hueRange:[63,178],lowerBounds:[[30,100],[40,90],[50,85],[60,81],[70,74],[80,64],[90,50],[100,40]]},{name:"blue",hueRange:[179,257],lowerBounds:[[20,100],[30,86],[40,80],[50,74],[60,60],[70,52],[80,44],[90,39],[100,35]]},{name:"purple",hueRange:[258,282],lowerBounds:[[20,100],[30,87],[40,79],[50,70],[60,65],[70,59],[80,52],[90,45],[100,42]]},{name:"pink",hueRange:[283,334],lowerBounds:[[20,100],[30,90],[40,86],[60,84],[80,80],[90,75],[100,73]]}];const al=Object.freeze(Object.defineProperty({__proto__:null,TinyColor:De,bounds:mn,convertDecimalToHex:Ru,convertHexToDecimal:Ou,default:ta,fromRatio:Xu,hslToRgb:Eu,hsvToRgb:Su,inputToRGB:Iu,isReadable:Ga,isValidCSSUnit:Tu,legacyRandom:Ju,mostReadable:Ya,names:Mu,numberInputToObject:Nu,parseIntFromHex:$u,random:Ha,readability:pn,rgbToHex:ku,rgbToHsl:Au,rgbToHsv:Du,rgbToRgb:ju,rgbaToArgbHex:Vr,rgbaToHex:Lu,stringInputToObject:qu,tinycolor:ta,toMsFilter:Qu},Symbol.toStringTag,{value:"Module"})),ol=Object.freeze(Object.defineProperty({__proto__:null,CSSMotionList:Fu,Provider:Bu,default:Wu},Symbol.toStringTag,{value:"Module"})),il=Object.freeze(Object.defineProperty({__proto__:null,default:zu},Symbol.toStringTag,{value:"Module"})),ul=Object.freeze(Object.defineProperty({__proto__:null,Panel:Ku,default:Hu},Symbol.toStringTag,{value:"Module"}));var Qa={exports:{}};(function(e){function r(){return e.exports=r=Object.assign?Object.assign.bind():function(t){for(var n=1;n=4.5;case"AAlarge":return o>=3;case"AAAsmall":return o>=7;default:return!1}}function Ya(e,r,t){t===void 0&&(t={includeFallbackColors:!1,level:"AA",size:"small"});for(var n=null,a=0,o=t.includeFallbackColors,u=t.level,f=t.size,y=0,s=r;ya&&(a=h,n=new De(E))}return Ga(e,n,{level:u,size:f})||!o?n:(t.includeFallbackColors=!1,Ya(e,["#fff","#000"],t))}function Qu(e,r){var t=new De(e),n="#"+Vr(t.r,t.g,t.b,t.a),a=n,o=t.gradientType?"GradientType = 1, ":"";if(r){var u=new De(r);a="#"+Vr(u.r,u.g,u.b,u.a)}return"progid:DXImageTransform.Microsoft.gradient(".concat(o,"startColorstr=").concat(n,",endColorstr=").concat(a,")")}function Xu(e,r){var t={r:Dr(e.r),g:Dr(e.g),b:Dr(e.b)};return e.a!==void 0&&(t.a=Number(e.a)),new De(t,r)}function Ju(){return new De({r:Math.random(),g:Math.random(),b:Math.random()})}function Ha(e){if(e===void 0&&(e={}),e.count!==void 0&&e.count!==null){var r=e.count,t=[];for(e.count=void 0;r>t.length;)e.count=null,e.seed&&(e.seed+=1),t.push(Ha(e));return e.count=r,t}var n=Zu(e.hue,e.seed),a=el(n,e),o=tl(n,a,e),u={h:n,s:a,v:o};return e.alpha!==void 0&&(u.a=e.alpha),new De(u)}function Zu(e,r){var t=nl(e),n=Zt(t,r);return n<0&&(n=360+n),n}function el(e,r){if(r.hue==="monochrome")return 0;if(r.luminosity==="random")return Zt([0,100],r.seed);var t=Ka(e).saturationRange,n=t[0],a=t[1];switch(r.luminosity){case"bright":n=55;break;case"dark":n=a-10;break;case"light":a=55;break}return Zt([n,a],r.seed)}function tl(e,r,t){var n=rl(e,r),a=100;switch(t.luminosity){case"dark":a=n+20;break;case"light":n=(a+n)/2;break;case"random":n=0,a=100;break}return Zt([n,a],t.seed)}function rl(e,r){for(var t=Ka(e).lowerBounds,n=0;n=a&&r<=u){var y=(f-o)/(u-a),s=o-y*a;return y*r+s}}return 0}function nl(e){var r=parseInt(e,10);if(!Number.isNaN(r)&&r<360&&r>0)return[r,r];if(typeof e=="string"){var t=mn.find(function(u){return u.name===e});if(t){var n=Va(t);if(n.hueRange)return n.hueRange}var a=new De(e);if(a.isValid){var o=a.toHsv().h;return[o,o]}}return[0,360]}function Ka(e){e>=334&&e<=360&&(e-=360);for(var r=0,t=mn;r=a.hueRange[0]&&e<=a.hueRange[1])return a}throw Error("Color not found")}function Zt(e,r){if(r===void 0)return Math.floor(e[0]+Math.random()*(e[1]+1-e[0]));var t=e[1]||1,n=e[0]||0;r=(r*9301+49297)%233280;var a=r/233280;return Math.floor(n+a*(t-n))}function Va(e){var r=e.lowerBounds[0][0],t=e.lowerBounds[e.lowerBounds.length-1][0],n=e.lowerBounds[e.lowerBounds.length-1][1],a=e.lowerBounds[0][1];return{name:e.name,hueRange:e.hueRange,lowerBounds:e.lowerBounds,saturationRange:[r,t],brightnessRange:[n,a]}}var mn=[{name:"monochrome",hueRange:null,lowerBounds:[[0,0],[100,0]]},{name:"red",hueRange:[-26,18],lowerBounds:[[20,100],[30,92],[40,89],[50,85],[60,78],[70,70],[80,60],[90,55],[100,50]]},{name:"orange",hueRange:[19,46],lowerBounds:[[20,100],[30,93],[40,88],[50,86],[60,85],[70,70],[100,70]]},{name:"yellow",hueRange:[47,62],lowerBounds:[[25,100],[40,94],[50,89],[60,86],[70,84],[80,82],[90,80],[100,75]]},{name:"green",hueRange:[63,178],lowerBounds:[[30,100],[40,90],[50,85],[60,81],[70,74],[80,64],[90,50],[100,40]]},{name:"blue",hueRange:[179,257],lowerBounds:[[20,100],[30,86],[40,80],[50,74],[60,60],[70,52],[80,44],[90,39],[100,35]]},{name:"purple",hueRange:[258,282],lowerBounds:[[20,100],[30,87],[40,79],[50,70],[60,65],[70,59],[80,52],[90,45],[100,42]]},{name:"pink",hueRange:[283,334],lowerBounds:[[20,100],[30,90],[40,86],[60,84],[80,80],[90,75],[100,73]]}];const al=Object.freeze(Object.defineProperty({__proto__:null,TinyColor:De,bounds:mn,convertDecimalToHex:Ru,convertHexToDecimal:Ou,default:ta,fromRatio:Xu,hslToRgb:Eu,hsvToRgb:Su,inputToRGB:Iu,isReadable:Ga,isValidCSSUnit:Tu,legacyRandom:Ju,mostReadable:Ya,names:Mu,numberInputToObject:Nu,parseIntFromHex:$u,random:Ha,readability:pn,rgbToHex:ku,rgbToHsl:Au,rgbToHsv:Du,rgbToRgb:ju,rgbaToArgbHex:Vr,rgbaToHex:Lu,stringInputToObject:qu,tinycolor:ta,toMsFilter:Qu},Symbol.toStringTag,{value:"Module"})),ol=Object.freeze(Object.defineProperty({__proto__:null,CSSMotionList:Fu,Provider:Bu,default:Wu},Symbol.toStringTag,{value:"Module"})),il=Object.freeze(Object.defineProperty({__proto__:null,default:zu},Symbol.toStringTag,{value:"Module"})),ul=Object.freeze(Object.defineProperty({__proto__:null,Panel:Ku,default:Hu},Symbol.toStringTag,{value:"Module"}));var Qa={exports:{}};(function(e){function r(){return e.exports=r=Object.assign?Object.assign.bind():function(t){for(var n=1;n1024*1024*1.999&&a!==h)e=U(e),i=e.type||l;else return navigator.msSaveBlob?navigator.msSaveBlob(U(e),c):p(e);else if(/([\x80-\xff])/.test(e)){var u=0,v=new Uint8Array(e.length),A=v.length;for(u;u1024*1024*1.999&&a!==h)e=U(e),i=e.type||l;else return navigator.msSaveBlob?navigator.msSaveBlob(U(e),c):p(e);else if(/([\x80-\xff])/.test(e)){var u=0,v=new Uint8Array(e.length),A=v.length;for(u;u{document.fonts.ready.then(()=>{u(document.fonts.check("40px Emmentaler-26"))})},[]);const c=Object.keys(l);return e.jsxs("div",{className:"font-test-page",children:[e.jsxs("div",{className:"font-test-header",children:[e.jsx("h1",{children:"Emmentaler-26 Font Glyphs"}),e.jsxs("div",{className:"font-test-status",children:["Font status: ",e.jsx("span",{className:o?"loaded":"not-loaded",children:o?"Loaded":"Not loaded"}),e.jsxs("span",{className:"glyph-count",children:[Object.values(l).reduce((s,n)=>s+n.length,0)," glyphs"]})]}),e.jsxs("div",{className:"font-test-controls",children:[e.jsx("input",{type:"text",placeholder:"Filter glyphs...",value:E,onChange:s=>h(s.target.value)}),e.jsxs("label",{children:["Size:",e.jsx("input",{type:"range",min:20,max:80,value:r,onChange:s=>m(Number(s.target.value))}),r,"px"]})]}),e.jsx("div",{className:"font-test-toc",children:c.map(s=>e.jsxs("a",{href:`#cat-${s}`,children:[i[s]||s," (",l[s].length,")"]},s))})]}),c.map(s=>{const n=l[s].filter(([a,t])=>!E||a.toLowerCase().includes(E.toLowerCase())||t.toLowerCase().includes(E.toLowerCase()));return n.length===0?null:e.jsxs("div",{id:`cat-${s}`,className:"font-test-category",children:[e.jsxs("h2",{children:[i[s]||s," ",e.jsxs("span",{children:["(",n.length,")"]})]}),e.jsx("div",{className:"glyph-grid",children:n.map(([a,t])=>e.jsxs("div",{className:"glyph-cell",title:a,children:[e.jsx("div",{className:"glyph-render",style:{fontSize:r},children:e.jsx("i",{className:`emmentaler glyph-${a}`})}),e.jsx("div",{className:"glyph-unicode",style:{fontSize:r},children:String.fromCodePoint(parseInt(t,16))}),e.jsx("div",{className:"glyph-name",children:a}),e.jsxs("div",{className:"glyph-code",children:["U+",t]})]},`${a}-${t}`))})]},s)})]})}export{f as default}; +import{r as d,j as e}from"./umi-a12c8253.js";const l={rests:[["rests-0","E000"],["rests-1","E001"],["rests-0o","E002"],["rests-1o","E003"],["rests-M3","E004"],["rests-M2","E005"],["rests-M1","E006"],["rests-M1o","E007"],["rests-2","E008"],["rests-2classical","E009"],["rests-2z","E00A"],["rests-3","E00B"],["rests-4","E00C"],["rests-5","E00D"],["rests-6","E00E"],["rests-7","E00F"],["rests-8","E010"],["rests-9","E011"],["rests-10","E012"],["rests-M3neomensural","E144"],["rests-M2neomensural","E145"],["rests-M1neomensural","E146"],["rests-0neomensural","E147"],["rests-1neomensural","E148"],["rests-2neomensural","E149"],["rests-3neomensural","E14A"],["rests-4neomensural","E14B"],["rests-M3mensural","E14C"],["rests-M2mensural","E14D"],["rests-M1mensural","E14E"],["rests-0mensural","E14F"],["rests-1mensural","E150"],["rests-2mensural","E151"],["rests-3mensural","E152"],["rests-4mensural","E153"]],accidentals:[["accidentals-sharp","E013"],["accidentals-sharp-arrowup","E014"],["accidentals-sharp-arrowdown","E015"],["accidentals-sharp-arrowboth","E016"],["accidentals-sharp-slashslash-stem","E017"],["accidentals-sharp-slashslashslash-stemstem","E018"],["accidentals-sharp-slashslashslash-stem","E019"],["accidentals-sharp-slash-stem","E01A"],["accidentals-sharp-slashslash-stemstemstem","E01B"],["accidentals-doublesharp","E01C"],["accidentals-natural","E01D"],["accidentals-natural-arrowup","E01E"],["accidentals-natural-arrowdown","E01F"],["accidentals-natural-arrowboth","E020"],["accidentals-flat","E021"],["accidentals-flat-arrowup","E022"],["accidentals-flat-arrowdown","E023"],["accidentals-flat-arrowboth","E024"],["accidentals-flat-slash","E025"],["accidentals-flat-slashslash","E026"],["accidentals-mirroredflat-flat","E027"],["accidentals-mirroredflat","E028"],["accidentals-mirroredflat-backslash","E029"],["accidentals-flatflat","E02A"],["accidentals-flatflat-slash","E02B"],["accidentals-rightparen","E02C"],["accidentals-leftparen","E02D"],["accidentals-medicaeaM1","E194"],["accidentals-vaticanaM1","E195"],["accidentals-vaticana0","E196"],["accidentals-mensural1","E197"],["accidentals-mensuralM1","E198"],["accidentals-hufnagelM1","E199"],["accidentals-kievan1","E19A"],["accidentals-kievanM1","E19B"]],arrowheads:[["arrowheads-open-01","E02E"],["arrowheads-open-0M1","E02F"],["arrowheads-open-11","E030"],["arrowheads-open-1M1","E031"],["arrowheads-close-01","E032"],["arrowheads-close-0M1","E033"],["arrowheads-close-11","E034"],["arrowheads-close-1M1","E035"]],dot:[["dot","E036"]],scripts:[["scripts-ufermata","E037"],["scripts-dfermata","E038"],["scripts-uhenzeshortfermata","E039"],["scripts-dhenzeshortfermata","E03A"],["scripts-uhenzelongfermata","E03B"],["scripts-dhenzelongfermata","E03C"],["scripts-ushortfermata","E03D"],["scripts-dshortfermata","E03E"],["scripts-uveryshortfermata","E03F"],["scripts-dveryshortfermata","E040"],["scripts-ulongfermata","E041"],["scripts-dlongfermata","E042"],["scripts-uverylongfermata","E043"],["scripts-dverylongfermata","E044"],["scripts-thumb","E045"],["scripts-sforzato","E046"],["scripts-espr","E047"],["scripts-staccato","E048"],["scripts-ustaccatissimo","E049"],["scripts-dstaccatissimo","E04A"],["scripts-tenuto","E04B"],["scripts-uportato","E04C"],["scripts-dportato","E04D"],["scripts-umarcato","E04E"],["scripts-dmarcato","E04F"],["scripts-open","E050"],["scripts-halfopen","E051"],["scripts-halfopenvertical","E052"],["scripts-stopped","E053"],["scripts-upbow","E054"],["scripts-downbow","E055"],["scripts-reverseturn","E056"],["scripts-turn","E057"],["scripts-slashturn","E058"],["scripts-haydnturn","E059"],["scripts-trill","E05A"],["scripts-upedalheel","E05B"],["scripts-dpedalheel","E05C"],["scripts-upedaltoe","E05D"],["scripts-dpedaltoe","E05E"],["scripts-flageolet","E05F"],["scripts-segno","E060"],["scripts-varsegno","E061"],["scripts-coda","E062"],["scripts-varcoda","E063"],["scripts-rcomma","E064"],["scripts-lcomma","E065"],["scripts-rvarcomma","E066"],["scripts-lvarcomma","E067"],["scripts-arpeggio","E068"],["scripts-trill_element","E069"],["scripts-arpeggio-arrow-M1","E06A"],["scripts-arpeggio-arrow-1","E06B"],["scripts-trillelement","E06C"],["scripts-prall","E06D"],["scripts-mordent","E06E"],["scripts-prallprall","E06F"],["scripts-prallmordent","E070"],["scripts-upprall","E071"],["scripts-upmordent","E072"],["scripts-prallup","E073"],["scripts-downprall","E074"],["scripts-downmordent","E075"],["scripts-pralldown","E076"],["scripts-lineprall","E077"],["scripts-caesura-curved","E078"],["scripts-caesura-straight","E079"],["scripts-tickmark","E07A"],["scripts-snappizzicato","E07B"],["scripts-ictus","E1CA"],["scripts-uaccentus","E1CB"],["scripts-daccentus","E1CC"],["scripts-usemicirculus","E1CD"],["scripts-dsemicirculus","E1CE"],["scripts-circulus","E1CF"],["scripts-augmentum","E1D0"],["scripts-usignumcongruentiae","E1D1"],["scripts-dsignumcongruentiae","E1D2"],["scripts-barline-kievan","E1D3"]],clefs:[["clefs-C","E07C"],["clefs-C_change","E07D"],["clefs-varC","E07E"],["clefs-varC_change","E07F"],["clefs-F","E080"],["clefs-F_change","E081"],["clefs-G","E082"],["clefs-G_change","E083"],["clefs-GG","E084"],["clefs-GG_change","E085"],["clefs-tenorG","E086"],["clefs-tenorG_change","E087"],["clefs-percussion","E088"],["clefs-percussion_change","E089"],["clefs-varpercussion","E08A"],["clefs-varpercussion_change","E08B"],["clefs-tab","E08C"],["clefs-tab_change","E08D"],["clefs-vaticana-do","E154"],["clefs-vaticana-do_change","E155"],["clefs-vaticana-fa","E156"],["clefs-vaticana-fa_change","E157"],["clefs-medicaea-do","E158"],["clefs-medicaea-do_change","E159"],["clefs-medicaea-fa","E15A"],["clefs-medicaea-fa_change","E15B"],["clefs-neomensural-c","E15C"],["clefs-neomensural-c_change","E15D"],["clefs-petrucci-c1","E15E"],["clefs-petrucci-c1_change","E15F"],["clefs-petrucci-c2","E160"],["clefs-petrucci-c2_change","E161"],["clefs-petrucci-c3","E162"],["clefs-petrucci-c3_change","E163"],["clefs-petrucci-c4","E164"],["clefs-petrucci-c4_change","E165"],["clefs-petrucci-c5","E166"],["clefs-petrucci-c5_change","E167"],["clefs-mensural-c","E168"],["clefs-mensural-c_change","E169"],["clefs-blackmensural-c","E16A"],["clefs-blackmensural-c_change","E16B"],["clefs-petrucci-f","E16C"],["clefs-petrucci-f_change","E16D"],["clefs-mensural-f","E16E"],["clefs-mensural-f_change","E16F"],["clefs-petrucci-g","E170"],["clefs-petrucci-g_change","E171"],["clefs-mensural-g","E172"],["clefs-mensural-g_change","E173"],["clefs-hufnagel-do","E174"],["clefs-hufnagel-do_change","E175"],["clefs-hufnagel-fa","E176"],["clefs-hufnagel-fa_change","E177"],["clefs-hufnagel-do-fa","E178"],["clefs-hufnagel-do-fa_change","E179"],["clefs-kievan-do","E17A"],["clefs-kievan-do_change","E17B"]],timesig:[["timesig-C44","E08E"],["timesig-C22","E08F"],["timesig-mensural44","E1B4"],["timesig-mensural22","E1B5"],["timesig-mensural32","E1B6"],["timesig-mensural64","E1B7"],["timesig-mensural94","E1B8"],["timesig-mensural34","E1B9"],["timesig-mensural68","E1BA"],["timesig-mensural98","E1BB"],["timesig-mensural48","E1BC"],["timesig-mensural68alt","E1BD"],["timesig-mensural24","E1BE"],["timesig-neomensural44","E1BF"],["timesig-neomensural22","E1C0"],["timesig-neomensural32","E1C1"],["timesig-neomensural64","E1C2"],["timesig-neomensural94","E1C3"],["timesig-neomensural34","E1C4"],["timesig-neomensural68","E1C5"],["timesig-neomensural98","E1C6"],["timesig-neomensural48","E1C7"],["timesig-neomensural68alt","E1C8"],["timesig-neomensural24","E1C9"]],pedal:[["pedal-star","E090"],["pedal-M","E091"],["pedal--","E092"],["pedal-P","E093"],["pedal-d","E094"],["pedal-e","E095"],["pedal-Ped","E096"]],brackettips:[["brackettips-up","E097"],["brackettips-down","E098"]],accordion:[["accordion-discant","E099"],["accordion-dot","E09A"],["accordion-freebass","E09B"],["accordion-stdbass","E09C"],["accordion-bayanbass","E09D"],["accordion-oldEE","E09E"],["accordion-push","E09F"],["accordion-pull","E0A0"]],ties:[["ties-lyric-short","E0A1"],["ties-lyric-default","E0A2"]],noteheads:[["noteheads-uM2","E0A3"],["noteheads-dM2","E0A4"],["noteheads-sM1","E0A5"],["noteheads-sM1double","E0A6"],["noteheads-s0","E0A7"],["noteheads-s1","E0A8"],["noteheads-s2","E0A9"],["noteheads-s0diamond","E0AA"],["noteheads-s1diamond","E0AB"],["noteheads-s2diamond","E0AC"],["noteheads-s0triangle","E0AD"],["noteheads-d1triangle","E0AE"],["noteheads-u1triangle","E0AF"],["noteheads-u2triangle","E0B0"],["noteheads-d2triangle","E0B1"],["noteheads-s0slash","E0B2"],["noteheads-s1slash","E0B3"],["noteheads-s2slash","E0B4"],["noteheads-s0cross","E0B5"],["noteheads-s1cross","E0B6"],["noteheads-s2cross","E0B7"],["noteheads-s2xcircle","E0B8"],["noteheads-s0do","E0B9"],["noteheads-d1do","E0BA"],["noteheads-u1do","E0BB"],["noteheads-d2do","E0BC"],["noteheads-u2do","E0BD"],["noteheads-s0doThin","E0BE"],["noteheads-d1doThin","E0BF"],["noteheads-u1doThin","E0C0"],["noteheads-d2doThin","E0C1"],["noteheads-u2doThin","E0C2"],["noteheads-s0re","E0C3"],["noteheads-u1re","E0C4"],["noteheads-d1re","E0C5"],["noteheads-u2re","E0C6"],["noteheads-d2re","E0C7"],["noteheads-s0reThin","E0C8"],["noteheads-u1reThin","E0C9"],["noteheads-d1reThin","E0CA"],["noteheads-u2reThin","E0CB"],["noteheads-d2reThin","E0CC"],["noteheads-s0mi","E0CD"],["noteheads-s1mi","E0CE"],["noteheads-s2mi","E0CF"],["noteheads-s0miMirror","E0D0"],["noteheads-s1miMirror","E0D1"],["noteheads-s2miMirror","E0D2"],["noteheads-s0miThin","E0D3"],["noteheads-s1miThin","E0D4"],["noteheads-s2miThin","E0D5"],["noteheads-u0fa","E0D6"],["noteheads-d0fa","E0D7"],["noteheads-u1fa","E0D8"],["noteheads-d1fa","E0D9"],["noteheads-u2fa","E0DA"],["noteheads-d2fa","E0DB"],["noteheads-u0faThin","E0DC"],["noteheads-d0faThin","E0DD"],["noteheads-u1faThin","E0DE"],["noteheads-d1faThin","E0DF"],["noteheads-u2faThin","E0E0"],["noteheads-d2faThin","E0E1"],["noteheads-s0sol","E0E2"],["noteheads-s1sol","E0E3"],["noteheads-s2sol","E0E4"],["noteheads-s0la","E0E5"],["noteheads-s1la","E0E6"],["noteheads-s2la","E0E7"],["noteheads-s0laThin","E0E8"],["noteheads-s1laThin","E0E9"],["noteheads-s2laThin","E0EA"],["noteheads-s0ti","E0EB"],["noteheads-u1ti","E0EC"],["noteheads-d1ti","E0ED"],["noteheads-u2ti","E0EE"],["noteheads-d2ti","E0EF"],["noteheads-s0tiThin","E0F0"],["noteheads-u1tiThin","E0F1"],["noteheads-d1tiThin","E0F2"],["noteheads-u2tiThin","E0F3"],["noteheads-d2tiThin","E0F4"],["noteheads-u0doFunk","E0F5"],["noteheads-d0doFunk","E0F6"],["noteheads-u1doFunk","E0F7"],["noteheads-d1doFunk","E0F8"],["noteheads-u2doFunk","E0F9"],["noteheads-d2doFunk","E0FA"],["noteheads-u0reFunk","E0FB"],["noteheads-d0reFunk","E0FC"],["noteheads-u1reFunk","E0FD"],["noteheads-d1reFunk","E0FE"],["noteheads-u2reFunk","E0FF"],["noteheads-d2reFunk","E100"],["noteheads-u0miFunk","E101"],["noteheads-d0miFunk","E102"],["noteheads-u1miFunk","E103"],["noteheads-d1miFunk","E104"],["noteheads-s2miFunk","E105"],["noteheads-u0faFunk","E106"],["noteheads-d0faFunk","E107"],["noteheads-u1faFunk","E108"],["noteheads-d1faFunk","E109"],["noteheads-u2faFunk","E10A"],["noteheads-d2faFunk","E10B"],["noteheads-s0solFunk","E10C"],["noteheads-s1solFunk","E10D"],["noteheads-s2solFunk","E10E"],["noteheads-s0laFunk","E10F"],["noteheads-s1laFunk","E110"],["noteheads-s2laFunk","E111"],["noteheads-u0tiFunk","E112"],["noteheads-d0tiFunk","E113"],["noteheads-u1tiFunk","E114"],["noteheads-d1tiFunk","E115"],["noteheads-u2tiFunk","E116"],["noteheads-d2tiFunk","E117"],["noteheads-s0doWalker","E118"],["noteheads-u1doWalker","E119"],["noteheads-d1doWalker","E11A"],["noteheads-u2doWalker","E11B"],["noteheads-d2doWalker","E11C"],["noteheads-s0reWalker","E11D"],["noteheads-u1reWalker","E11E"],["noteheads-d1reWalker","E11F"],["noteheads-u2reWalker","E120"],["noteheads-d2reWalker","E121"],["noteheads-s0miWalker","E122"],["noteheads-s1miWalker","E123"],["noteheads-s2miWalker","E124"],["noteheads-s0faWalker","E125"],["noteheads-u1faWalker","E126"],["noteheads-d1faWalker","E127"],["noteheads-u2faWalker","E128"],["noteheads-d2faWalker","E129"],["noteheads-s0laWalker","E12A"],["noteheads-s1laWalker","E12B"],["noteheads-s2laWalker","E12C"],["noteheads-s0tiWalker","E12D"],["noteheads-u1tiWalker","E12E"],["noteheads-d1tiWalker","E12F"],["noteheads-u2tiWalker","E130"],["noteheads-d2tiWalker","E131"],["noteheads-uM3neomensural","E1D6"],["noteheads-dM3neomensural","E1D7"],["noteheads-uM2neomensural","E1D8"],["noteheads-dM2neomensural","E1D9"],["noteheads-sM1neomensural","E1DA"],["noteheads-urM3neomensural","E1DB"],["noteheads-drM3neomensural","E1DC"],["noteheads-urM2neomensural","E1DD"],["noteheads-drM2neomensural","E1DE"],["noteheads-srM1neomensural","E1DF"],["noteheads-s0neomensural","E1E0"],["noteheads-s1neomensural","E1E1"],["noteheads-s2neomensural","E1E2"],["noteheads-s0harmonic","E1E3"],["noteheads-s2harmonic","E1E4"],["noteheads-uM3mensural","E1E5"],["noteheads-dM3mensural","E1E6"],["noteheads-sM3ligmensural","E1E7"],["noteheads-uM2mensural","E1E8"],["noteheads-dM2mensural","E1E9"],["noteheads-sM2ligmensural","E1EA"],["noteheads-sM1mensural","E1EB"],["noteheads-urM3mensural","E1EC"],["noteheads-drM3mensural","E1ED"],["noteheads-srM3ligmensural","E1EE"],["noteheads-urM2mensural","E1EF"],["noteheads-drM2mensural","E1F0"],["noteheads-srM2ligmensural","E1F1"],["noteheads-srM1mensural","E1F2"],["noteheads-uM3semimensural","E1F3"],["noteheads-dM3semimensural","E1F4"],["noteheads-sM3semiligmensural","E1F5"],["noteheads-uM2semimensural","E1F6"],["noteheads-dM2semimensural","E1F7"],["noteheads-sM2semiligmensural","E1F8"],["noteheads-sM1semimensural","E1F9"],["noteheads-urM3semimensural","E1FA"],["noteheads-drM3semimensural","E1FB"],["noteheads-srM3semiligmensural","E1FC"],["noteheads-urM2semimensural","E1FD"],["noteheads-drM2semimensural","E1FE"],["noteheads-srM2semiligmensural","E1FF"],["noteheads-srM1semimensural","E200"],["noteheads-uM3blackmensural","E201"],["noteheads-dM3blackmensural","E202"],["noteheads-sM3blackligmensural","E203"],["noteheads-uM2blackmensural","E204"],["noteheads-dM2blackmensural","E205"],["noteheads-sM2blackligmensural","E206"],["noteheads-sM1blackmensural","E207"],["noteheads-s0mensural","E208"],["noteheads-s1mensural","E209"],["noteheads-s2mensural","E20A"],["noteheads-s0blackmensural","E20B"],["noteheads-s0petrucci","E20C"],["noteheads-s1petrucci","E20D"],["noteheads-s2petrucci","E20E"],["noteheads-s0blackpetrucci","E20F"],["noteheads-s1blackpetrucci","E210"],["noteheads-s2blackpetrucci","E211"],["noteheads-svaticana-punctum","E212"],["noteheads-svaticana-punctum-cavum","E213"],["noteheads-svaticana-linea-punctum","E214"],["noteheads-svaticana-linea-punctum-cavum","E215"],["noteheads-svaticana-inclinatum","E216"],["noteheads-svaticana-lpes","E217"],["noteheads-svaticana-vlpes","E218"],["noteheads-svaticana-upes","E219"],["noteheads-svaticana-vupes","E21A"],["noteheads-svaticana-plica","E21B"],["noteheads-svaticana-vplica","E21C"],["noteheads-svaticana-epiphonus","E21D"],["noteheads-svaticana-vepiphonus","E21E"],["noteheads-svaticana-reverse-plica","E21F"],["noteheads-svaticana-reverse-vplica","E220"],["noteheads-svaticana-inner-cephalicus","E221"],["noteheads-svaticana-cephalicus","E222"],["noteheads-svaticana-quilisma","E223"],["noteheads-ssolesmes-incl-parvum","E224"],["noteheads-ssolesmes-auct-asc","E225"],["noteheads-ssolesmes-auct-desc","E226"],["noteheads-ssolesmes-incl-auctum","E227"],["noteheads-ssolesmes-stropha","E228"],["noteheads-ssolesmes-stropha-aucta","E229"],["noteheads-ssolesmes-oriscus","E22A"],["noteheads-smedicaea-inclinatum","E22B"],["noteheads-smedicaea-punctum","E22C"],["noteheads-smedicaea-rvirga","E22D"],["noteheads-smedicaea-virga","E22E"],["noteheads-shufnagel-punctum","E22F"],["noteheads-shufnagel-virga","E230"],["noteheads-shufnagel-lpes","E231"],["noteheads-sM2kievan","E232"],["noteheads-sM1kievan","E233"],["noteheads-s0kievan","E234"],["noteheads-d2kievan","E235"],["noteheads-u2kievan","E236"],["noteheads-s1kievan","E237"],["noteheads-sr1kievan","E238"],["noteheads-d3kievan","E239"],["noteheads-u3kievan","E23A"]],flags:[["flags-u3","E132"],["flags-u4","E133"],["flags-u5","E134"],["flags-u6","E135"],["flags-u7","E136"],["flags-u8","E137"],["flags-u9","E138"],["flags-u10","E139"],["flags-d3","E13A"],["flags-d4","E13B"],["flags-d5","E13C"],["flags-d6","E13D"],["flags-d7","E13E"],["flags-d8","E13F"],["flags-d9","E140"],["flags-d10","E141"],["flags-ugrace","E142"],["flags-dgrace","E143"],["flags-mensuralu03","E19C"],["flags-mensuralu13","E19D"],["flags-mensuralu23","E19E"],["flags-mensurald03","E19F"],["flags-mensurald13","E1A0"],["flags-mensurald23","E1A1"],["flags-mensuralu04","E1A2"],["flags-mensuralu14","E1A3"],["flags-mensuralu24","E1A4"],["flags-mensurald04","E1A5"],["flags-mensurald14","E1A6"],["flags-mensurald24","E1A7"],["flags-mensuralu05","E1A8"],["flags-mensuralu15","E1A9"],["flags-mensuralu25","E1AA"],["flags-mensurald05","E1AB"],["flags-mensurald15","E1AC"],["flags-mensurald25","E1AD"],["flags-mensuralu06","E1AE"],["flags-mensuralu16","E1AF"],["flags-mensuralu26","E1B0"],["flags-mensurald06","E1B1"],["flags-mensurald16","E1B2"],["flags-mensurald26","E1B3"]],custodes:[["custodes-hufnagel-u0","E17C"],["custodes-hufnagel-u1","E17D"],["custodes-hufnagel-u2","E17E"],["custodes-hufnagel-d0","E17F"],["custodes-hufnagel-d1","E180"],["custodes-hufnagel-d2","E181"],["custodes-medicaea-u0","E182"],["custodes-medicaea-u1","E183"],["custodes-medicaea-u2","E184"],["custodes-medicaea-d0","E185"],["custodes-medicaea-d1","E186"],["custodes-medicaea-d2","E187"],["custodes-vaticana-u0","E188"],["custodes-vaticana-u1","E189"],["custodes-vaticana-u2","E18A"],["custodes-vaticana-d0","E18B"],["custodes-vaticana-d1","E18C"],["custodes-vaticana-d2","E18D"],["custodes-mensural-u0","E18E"],["custodes-mensural-u1","E18F"],["custodes-mensural-u2","E190"],["custodes-mensural-d0","E191"],["custodes-mensural-d1","E192"],["custodes-mensural-d2","E193"]],dots:[["dots-dotvaticana","E1D4"],["dots-dotkievan","E1D5"]]},i={rests:"Rests",accidentals:"Accidentals",arrowheads:"Arrowheads",dot:"Dot",scripts:"Scripts & Articulations",clefs:"Clefs",timesig:"Time Signatures",pedal:"Pedal",brackettips:"Bracket Tips",accordion:"Accordion",ties:"Ties",noteheads:"Noteheads",flags:"Flags",custodes:"Custodes",dots:"Dots"};function f(){const[o,u]=d.useState(!1),[E,h]=d.useState(""),[r,m]=d.useState(40);d.useEffect(()=>{document.fonts.ready.then(()=>{u(document.fonts.check("40px Emmentaler-26"))})},[]);const c=Object.keys(l);return e.jsxs("div",{className:"font-test-page",children:[e.jsxs("div",{className:"font-test-header",children:[e.jsx("h1",{children:"Emmentaler-26 Font Glyphs"}),e.jsxs("div",{className:"font-test-status",children:["Font status: ",e.jsx("span",{className:o?"loaded":"not-loaded",children:o?"Loaded":"Not loaded"}),e.jsxs("span",{className:"glyph-count",children:[Object.values(l).reduce((s,n)=>s+n.length,0)," glyphs"]})]}),e.jsxs("div",{className:"font-test-controls",children:[e.jsx("input",{type:"text",placeholder:"Filter glyphs...",value:E,onChange:s=>h(s.target.value)}),e.jsxs("label",{children:["Size:",e.jsx("input",{type:"range",min:20,max:80,value:r,onChange:s=>m(Number(s.target.value))}),r,"px"]})]}),e.jsx("div",{className:"font-test-toc",children:c.map(s=>e.jsxs("a",{href:`#cat-${s}`,children:[i[s]||s," (",l[s].length,")"]},s))})]}),c.map(s=>{const n=l[s].filter(([a,t])=>!E||a.toLowerCase().includes(E.toLowerCase())||t.toLowerCase().includes(E.toLowerCase()));return n.length===0?null:e.jsxs("div",{id:`cat-${s}`,className:"font-test-category",children:[e.jsxs("h2",{children:[i[s]||s," ",e.jsxs("span",{children:["(",n.length,")"]})]}),e.jsx("div",{className:"glyph-grid",children:n.map(([a,t])=>e.jsxs("div",{className:"glyph-cell",title:a,children:[e.jsx("div",{className:"glyph-render",style:{fontSize:r},children:e.jsx("i",{className:`emmentaler glyph-${a}`})}),e.jsx("div",{className:"glyph-unicode",style:{fontSize:r},children:String.fromCodePoint(parseInt(t,16))}),e.jsx("div",{className:"glyph-name",children:a}),e.jsxs("div",{className:"glyph-code",children:["U+",t]})]},`${a}-${t}`))})]},s)})]})}export{f as default}; diff --git a/dist/assets/gauge-ca236465.js b/dist/assets/gauge-822f711f.js similarity index 91% rename from dist/assets/gauge-ca236465.js rename to dist/assets/gauge-822f711f.js index ad7b0c771a4d43fde789b03bba239da8f0705004..3e4660ae254361c91f02aa4866c2096c766b0597 100644 --- a/dist/assets/gauge-ca236465.js +++ b/dist/assets/gauge-822f711f.js @@ -1 +1 @@ -import{r as e,j as r}from"./umi-9940633e.js";import{G as d}from"./gaugeRendererGL-41abf4c6.js";const a=[["source1.png","gauge1.png"],["source2.png","gauge2.png"]];function l(){const n=e.useRef(),t=e.useRef(),s=e.useRef(),[c,o]=e.useState(),[u,g]=e.useState(0);return e.useEffect(()=>{o(new d({source:n.current,gauge:t.current,canvas:s.current}))},[n.current,t.current,s.current]),r.jsxs("div",{children:[r.jsx("img",{ref:n,src:`/test.local/${a[u][0]}`}),r.jsx("img",{ref:t,src:`/test.local/${a[u][1]}`}),r.jsx("canvas",{ref:s}),r.jsx("button",{onClick:()=>g((u+1)%a.length),children:"change"}),r.jsx("button",{onClick:()=>{c.updateMaterial({width:t.current.width}),c.updateGeometry(),c.render()},children:"render"})]})}export{l as default}; +import{r as e,j as r}from"./umi-a12c8253.js";import{G as d}from"./gaugeRendererGL-41abf4c6.js";const a=[["source1.png","gauge1.png"],["source2.png","gauge2.png"]];function l(){const n=e.useRef(),t=e.useRef(),s=e.useRef(),[c,o]=e.useState(),[u,g]=e.useState(0);return e.useEffect(()=>{o(new d({source:n.current,gauge:t.current,canvas:s.current}))},[n.current,t.current,s.current]),r.jsxs("div",{children:[r.jsx("img",{ref:n,src:`/test.local/${a[u][0]}`}),r.jsx("img",{ref:t,src:`/test.local/${a[u][1]}`}),r.jsx("canvas",{ref:s}),r.jsx("button",{onClick:()=>g((u+1)%a.length),children:"change"}),r.jsx("button",{onClick:()=>{c.updateMaterial({width:t.current.width}),c.updateGeometry(),c.render()},children:"render"})]})}export{l as default}; diff --git a/dist/assets/index-f5d9ea7b.js b/dist/assets/index-02e1374a.js similarity index 96% rename from dist/assets/index-f5d9ea7b.js rename to dist/assets/index-02e1374a.js index a1deab610e38353ca7d1d27368ef72c10ef2498c..7eddc25171b0fff654a08a2ccb047332911c6062 100644 --- a/dist/assets/index-f5d9ea7b.js +++ b/dist/assets/index-02e1374a.js @@ -1 +1 @@ -import{r as c,j as t}from"./umi-9940633e.js";const p=({layout:e,positions:o,nameDict:n={},...l})=>{const m=c.useMemo(()=>e.groups.filter(s=>o[s.range[0]]&&o[s.range[1]]).map(s=>{const r=o[s.range[0]],a=o[s.range[1]];return{key:s.key,type:s.group.type,level:s.group.level||0,top:r.y-r.radius,bottom:a.y+a.radius,name:n[s.key]}}),[e,o,n]);return t.jsx("g",{...l,className:"staff-brackets",onClick:()=>{debugger},children:m.map(s=>t.jsxs("g",{className:"group",transform:`translate(${s.level*-1.2}, 0)`,children:[s.type===2&&t.jsxs("g",{className:"bracket",children:[t.jsx("rect",{x:"-1.2",y:s.top,width:"0.45",height:s.bottom-s.top}),t.jsx("g",{transform:`translate(-1.2, ${s.top-.21})`,children:t.jsx("path",{transform:"scale(0.0040, -0.0040)",d:"M0 -56v91c0 12 10 21 22 21h43c164 0 281 136 377 272c10 14 32 -1 22 -15c-103 -145 -222 -369 -399 -369h-65z"})}),t.jsx("g",{transform:`translate(-1.2, ${s.bottom+.21})`,children:t.jsx("path",{transform:"scale(0.0040, -0.0040)",d:"M0 56h65c177 0 296 -224 399 -369c10 -14 -12 -29 -22 -15c-96 136 -213 272 -377 272h-43c-12 0 -22 9 -22 21v91z"})})]}),s.type===3&&t.jsxs("g",{className:"square",children:[t.jsx("line",{x1:"-0.9",x2:"-0.9",y1:s.top,y2:s.bottom,strokeWidth:"0.1"}),t.jsx("line",{x1:"-0.9",x2:"0",y1:s.top,y2:s.top,strokeWidth:"0.1"}),t.jsx("line",{x1:"-0.9",x2:"0",y1:s.bottom,y2:s.bottom,strokeWidth:"0.1"})]}),s.type===1&&t.jsx("g",{className:"brace",transform:`translate(-0.2, ${(s.top+s.bottom)/2})`,children:t.jsx("path",{transform:`scale(0.0040, ${-.004*(s.bottom-s.top)/15.1825})`,d:"M-208 -1336c0 312 124 616 124 912c0 156 -36 300 -144 416c0 4 -4 4 -4 8s4 4 4 8c108 116 144 260 144 416c0 296 -124 600 -124 912c0 212 52 420 196 576c16 16 40 -8 24 -24c-108 -120 -144 -264 -144 -420c0 -292 116 -588 116 -896c0 -212 -48 -416 -188 -572c140 -156 188 -360 188 -572c0 -308 -116 -604 -116 -896c0 -156 36 -300 144 -420c16 -16 -8 -40 -24 -24c-144 156 -196 364 -196 576z"})}),s.name&&t.jsx("g",{className:"name",transform:`translate(-2, ${(s.top+s.bottom)/2+1})`,children:t.jsx("text",{fontSize:2,children:s.name})})]},s.key))})};export{p as S}; +import{r as c,j as t}from"./umi-a12c8253.js";const p=({layout:e,positions:o,nameDict:n={},...l})=>{const m=c.useMemo(()=>e.groups.filter(s=>o[s.range[0]]&&o[s.range[1]]).map(s=>{const r=o[s.range[0]],a=o[s.range[1]];return{key:s.key,type:s.group.type,level:s.group.level||0,top:r.y-r.radius,bottom:a.y+a.radius,name:n[s.key]}}),[e,o,n]);return t.jsx("g",{...l,className:"staff-brackets",onClick:()=>{debugger},children:m.map(s=>t.jsxs("g",{className:"group",transform:`translate(${s.level*-1.2}, 0)`,children:[s.type===2&&t.jsxs("g",{className:"bracket",children:[t.jsx("rect",{x:"-1.2",y:s.top,width:"0.45",height:s.bottom-s.top}),t.jsx("g",{transform:`translate(-1.2, ${s.top-.21})`,children:t.jsx("path",{transform:"scale(0.0040, -0.0040)",d:"M0 -56v91c0 12 10 21 22 21h43c164 0 281 136 377 272c10 14 32 -1 22 -15c-103 -145 -222 -369 -399 -369h-65z"})}),t.jsx("g",{transform:`translate(-1.2, ${s.bottom+.21})`,children:t.jsx("path",{transform:"scale(0.0040, -0.0040)",d:"M0 56h65c177 0 296 -224 399 -369c10 -14 -12 -29 -22 -15c-96 136 -213 272 -377 272h-43c-12 0 -22 9 -22 21v91z"})})]}),s.type===3&&t.jsxs("g",{className:"square",children:[t.jsx("line",{x1:"-0.9",x2:"-0.9",y1:s.top,y2:s.bottom,strokeWidth:"0.1"}),t.jsx("line",{x1:"-0.9",x2:"0",y1:s.top,y2:s.top,strokeWidth:"0.1"}),t.jsx("line",{x1:"-0.9",x2:"0",y1:s.bottom,y2:s.bottom,strokeWidth:"0.1"})]}),s.type===1&&t.jsx("g",{className:"brace",transform:`translate(-0.2, ${(s.top+s.bottom)/2})`,children:t.jsx("path",{transform:`scale(0.0040, ${-.004*(s.bottom-s.top)/15.1825})`,d:"M-208 -1336c0 312 124 616 124 912c0 156 -36 300 -144 416c0 4 -4 4 -4 8s4 4 4 8c108 116 144 260 144 416c0 296 -124 600 -124 912c0 212 52 420 196 576c16 16 40 -8 24 -24c-108 -120 -144 -264 -144 -420c0 -292 116 -588 116 -896c0 -212 -48 -416 -188 -572c140 -156 188 -360 188 -572c0 -308 -116 -604 -116 -896c0 -156 36 -300 144 -420c16 -16 -8 -40 -24 -24c-144 156 -196 364 -196 576z"})}),s.name&&t.jsx("g",{className:"name",transform:`translate(-2, ${(s.top+s.bottom)/2+1})`,children:t.jsx("text",{fontSize:2,children:s.name})})]},s.key))})};export{p as S}; diff --git a/dist/assets/index-ca9cbeed.js b/dist/assets/index-0c92fedd.js similarity index 99% rename from dist/assets/index-ca9cbeed.js rename to dist/assets/index-0c92fedd.js index 6583ffec95e7f0b9c3ac2e1fc1846603e7de82d1..a47a199f4cdb2c096bf54eb67788f7760753e591 100644 --- a/dist/assets/index-ca9cbeed.js +++ b/dist/assets/index-0c92fedd.js @@ -1,4 +1,4 @@ -import{r as xe,A as pn,i as At,g as as,j as Re,aH as ls,R as et,o as Mn,d as je,aI as Ui,t as cs,aJ as ds,c as Bt,m as ei}from"./umi-9940633e.js";import{q as us,a as Lt,v as hs}from"./parser-9472c317.js";import{f as Qi,D as ps,F as ti,z as gs,B as fs}from"./index-1a249a16.js";import{B as $t}from"./button-eaadfeb4.js";import{o as ms,b as vs,i as Cs,n as ys,I as bs}from"./util-477962f3.js";import{a as Rn}from"./index-6a5b1b3e.js";import{C as Is,S as ni}from"./TextArea-b3aeb374.js";import{S as As}from"./index-1b65ca98.js";import{t as ws,w as xs,u as Ss,P as Es,x as ks,I as ii}from"./tiny-invariant-00aeb6f0.js";import{f as Rs,c as Ts}from"./index-d0e185c0.js";import{c as Ls,d as qi,g as $s}from"./confirm-f5a212e9.js";import{A as Bs,_ as er,u as Hr,r as tr}from"./index-da8ccbdf.js";import{S as Ds}from"./schedulePool-cc4538c2.js";import{a as Ns}from"./progress-06af2db7.js";var _s={icon:{tag:"svg",attrs:{"fill-rule":"evenodd",viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M880 112c17.7 0 32 14.3 32 32v736c0 17.7-14.3 32-32 32H144c-17.7 0-32-14.3-32-32V144c0-17.7 14.3-32 32-32zm-40 72H184v656h656V184zM640.01 338.83c.03 0 .05.01.09.06l45.02 45.01a.2.2 0 01.05.09.12.12 0 010 .07c0 .02-.01.04-.05.08L557.25 512l127.87 127.86a.27.27 0 01.05.06v.02a.12.12 0 010 .07c0 .03-.01.05-.05.09l-45.02 45.02a.2.2 0 01-.09.05.12.12 0 01-.07 0c-.02 0-.04-.01-.08-.05L512 557.25 384.14 685.12c-.04.04-.06.05-.08.05a.12.12 0 01-.07 0c-.03 0-.05-.01-.09-.05l-45.02-45.02a.2.2 0 01-.05-.09.12.12 0 010-.07c0-.02.01-.04.06-.08L466.75 512 338.88 384.14a.27.27 0 01-.05-.06l-.01-.02a.12.12 0 010-.07c0-.03.01-.05.05-.09l45.02-45.02a.2.2 0 01.09-.05.12.12 0 01.07 0c.02 0 .04.01.08.06L512 466.75l127.86-127.86c.04-.05.06-.06.08-.06a.12.12 0 01.07 0z"}}]},name:"close-square",theme:"outlined"};const Ms=_s;var Ps=function(f,S){return xe.createElement(pn,At(At({},f),{},{ref:S,icon:Ms}))},Fs=xe.forwardRef(Ps);const Ws=Fs;var Os={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M180 176h-60c-4.4 0-8 3.6-8 8v656c0 4.4 3.6 8 8 8h60c4.4 0 8-3.6 8-8V184c0-4.4-3.6-8-8-8zm724 0h-60c-4.4 0-8 3.6-8 8v656c0 4.4 3.6 8 8 8h60c4.4 0 8-3.6 8-8V184c0-4.4-3.6-8-8-8zM785.3 504.3L657.7 403.6a7.23 7.23 0 00-11.7 5.7V476H378v-62.8c0-6-7-9.4-11.7-5.7L238.7 508.3a7.14 7.14 0 000 11.3l127.5 100.8c4.7 3.7 11.7.4 11.7-5.7V548h268v62.8c0 6 7 9.4 11.7 5.7l127.5-100.8c3.8-2.9 3.8-8.5.2-11.4z"}}]},name:"column-width",theme:"outlined"};const Gs=Os;var Hs=function(f,S){return xe.createElement(pn,At(At({},f),{},{ref:S,icon:Gs}))},Vs=xe.forwardRef(Hs);const Zs=Vs;var js={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm-80 600c0 4.4-3.6 8-8 8h-48c-4.4 0-8-3.6-8-8V360c0-4.4 3.6-8 8-8h48c4.4 0 8 3.6 8 8v304zm224 0c0 4.4-3.6 8-8 8h-48c-4.4 0-8-3.6-8-8V360c0-4.4 3.6-8 8-8h48c4.4 0 8 3.6 8 8v304z"}}]},name:"pause-circle",theme:"filled"};const Ks=js;var zs=function(f,S){return xe.createElement(pn,At(At({},f),{},{ref:S,icon:Ks}))},Xs=xe.forwardRef(zs);const Ys=Xs;var Js={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm144.1 454.9L437.7 677.8a8.02 8.02 0 01-12.7-6.5V353.7a8 8 0 0112.7-6.5L656.1 506a7.9 7.9 0 010 12.9z"}}]},name:"play-circle",theme:"filled"};const Us=Js;var Qs=function(f,S){return xe.createElement(pn,At(At({},f),{},{ref:S,icon:Us}))},qs=xe.forwardRef(Qs);const ea=qs;var ta={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M926.8 397.1l-396-288a31.81 31.81 0 00-37.6 0l-396 288a31.99 31.99 0 00-11.6 35.8l151.3 466a32 32 0 0030.4 22.1h489.5c13.9 0 26.1-8.9 30.4-22.1l151.3-466c4.2-13.2-.5-27.6-11.7-35.8zM838.6 417l-98.5 32-200-144.7V199.9L838.6 417zM466 567.2l-89.1 122.3-55.2-169.2L466 567.2zm-116.3-96.8L484 373.3v140.8l-134.3-43.7zM512 599.2l93.9 128.9H418.1L512 599.2zm28.1-225.9l134.2 97.1L540.1 514V373.3zM558 567.2l144.3-46.9-55.2 169.2L558 567.2zm-74-367.3v104.4L283.9 449l-98.5-32L484 199.9zM169.3 470.8l86.5 28.1 80.4 246.4-53.8 73.9-113.1-348.4zM327.1 853l50.3-69h269.3l50.3 69H327.1zm414.5-33.8l-53.8-73.9 80.4-246.4 86.5-28.1-113.1 348.4z"}}]},name:"radar-chart",theme:"outlined"};const na=ta;var ia=function(f,S){return xe.createElement(pn,At(At({},f),{},{ref:S,icon:na}))},ra=xe.forwardRef(ia);const oa=ra;function sa(){var p=xe.useRef(!0);return p.current?(p.current=!1,!0):p.current}var aa=function(p,f){var S=xe.useState(f),W=S[0],J=S[1];return W==null?[p,J]:[W,J]};const la=aa;var ca=Cs?window:null,nr=function(p){return!!p.addEventListener},ir=function(p){return!!p.on},da=function(p,f,S,W){S===void 0&&(S=ca),xe.useEffect(function(){if(f&&S)return nr(S)?ms(S,p,f,W):ir(S)&&S.on(p,f,W),function(){nr(S)?vs(S,p,f,W):ir(S)&&S.off(p,f,W)}},[p,f,S,JSON.stringify(W)])};const ua=da;var ha=function(p){return typeof p=="function"?p:typeof p=="string"?function(f){return f.key===p}:p?function(){return!0}:function(){return!1}},pa=function(p,f,S,W){f===void 0&&(f=ys),S===void 0&&(S={}),W===void 0&&(W=[p]);var J=S.event,N=J===void 0?"keydown":J,s=S.target,E=S.options,Z=xe.useMemo(function(){var b=ha(p),R=function($){if(b($))return f($)};return R},W);ua(N,Z,s,E)};const Tn=pa;function ga(p,f,S){if(f===void 0&&(f=10),f<1)throw new Error("Capacity has to be greater than 1, got '"+f+"'");var W=sa(),J=xe.useState(p),N=J[0],s=J[1],E=xe.useRef(S??[]),Z=xe.useRef(0);W&&(E.current.length?(E.current[E.current.length-1]!==p&&E.current.push(p),E.current.length>f&&(E.current=E.current.slice(E.current.length-f))):E.current.push(p),Z.current=E.current.length&&E.current.length-1);var b=xe.useCallback(function($){s(function(F){return $=ws($,F),$!==F&&(Z.currentf&&(E.current=E.current.slice(E.current.length-f))),$})},[N,f]),R=xe.useMemo(function(){return{history:E.current,position:Z.current,capacity:f,back:function($){$===void 0&&($=1),Z.current&&s(function(){return Z.current-=Math.min($,Z.current),E.current[Z.current]})},forward:function($){$===void 0&&($=1),Z.current!==E.current.length-1&&s(function(){return Z.current=Math.min(Z.current+$,E.current.length-1),E.current[Z.current]})},go:function($){$!==Z.current&&s(function(){return Z.current=$<0?Math.max(E.current.length+$,0):Math.min(E.current.length-1,$),E.current[Z.current]})}}},[N]);return[N,b,R]}var fa=function(p){p===void 0&&(p=new Set);var f=xe.useState(p),S=f[0],W=f[1],J=xe.useMemo(function(){var s=function(b){return W(function(R){return new Set(er(Array.from(R),[b]))})},E=function(b){return W(function(R){return new Set(Array.from(R).filter(function($){return $!==b}))})},Z=function(b){return W(function(R){return R.has(b)?new Set(Array.from(R).filter(function($){return $!==b})):new Set(er(Array.from(R),[b]))})};return{add:s,remove:E,toggle:Z,reset:function(){return W(p)},clear:function(){return W(new Set)}}},[W]),N=Bs({has:xe.useCallback(function(s){return S.has(s)},[S])},J);return[S,N]};const ma=fa,Vr=["#ff4d4e","#52c41a","#1990ff","#faad13","#9932CD","#871F78","#6B238E","#2F4F4F","#97694F","#B22222","#D9D919","#A67D3D","#8C7853","#A67D3D","#5F9F9F","#D98719","#B87333","#FF7F00","#42426F","#5C4033","#2F4F2F","#4A766E","#4F4F2F","#7093DB","#855E42","#545454","#856363","#D19275","#8E2323","#238E23","#CD7F32","#DBDB70","#C0C0C0","#527F76","#93DB70","#215E21","#4E2F2F","#9F9F5F","#C0D9D9","#A8A8A8","#8F8FBD","#E9C2A6","#32CD32","#E47833","#8E236B","#32CD99","#3232CD","#6B8E23","#EAEAAE","#9370DB","#426F42","#7F00FF","#7FFF00","#70DBDB","#DB7093","#A68064","#2F2F4F","#23238E","#4D4DFF","#FF6EC7","#00009C","#EBC79E","#CFB53B","#FF7F00","#FF2400","#DB70DB","#8FBC8F","#BC8F8F","#EAADEA","#D9D9F3","#5959AB","#6F4242","#BC1717","#238E68","#6B4226","#8E6B23","#E6E8FA","#3299CC","#007FFF","#FF1CAE","#00FF7F","#236B8E","#38B0DE","#DB9370","#D8BFD8","#ADEAEA","#5C4033","#CDCDCD","#4F2F4F","#CC3299","#D8D8BF","#99CC32","#FFB6C1","#FFC0CB","#DC143C","#FFF0F5","#FF69B4","#DA70D6","#FF1493","#D8BFD8","#DDA0DD","#FF00FF","#FF00FF","#8B008B","#800080","#BA55D3","#9400D3","#9932CC","#4B0082","#8A2BE2","#9370DB","#7B68EE","#6A5ACD","#483D8B","#E6E6FA","#F8F8FF","#0000FF","#0000CD","#191970","#00008B","#000080","#4169E1","#6495ED","#B0C4DE","#778899","#708090","#1E90FF","#F0F8FF","#4682B4","#87CEFA","#87CEEB","#00BFFF","#ADD8E6","#B0E0E6","#5F9EA0","#F0FFFF","#E1FFFF","#AFEEEE","#00FFFF","#00FFFF","#00CED1","#2F4F4F","#008B8B","#008080","#48D1CC","#20B2AA","#40E0D0","#7FFFAA","#00FA9A","#F5FFFA","#00FF7F","#3CB371","#2E8B57","#F0FFF0","#90EE90","#98FB98","#8FBC8F","#32CD32","#00FF00","#228B22","#008000","#006400","#7FFF00","#7CFC00","#ADFF2F","#556B2F","#6B8E23","#FAFAD2","#FFFFF0","#FFFFE0","#FFFF00","#808000","#BDB76B","#FFFACD","#EEE8AA","#F0E68C","#FFD700","#FFF8DC","#DAA520","#FFFAF0","#FDF5E6","#F5DEB3","#FFE4B5","#FFA500","#FFEFD5","#FFEBCD","#FAEBD7","#D2B48C","#DEB887","#FFE4C4","#FF8C00","#FAF0E6","#CD853F","#FFDAB9","#F4A460","#D2691E","#8B4513","#FFF5EE","#A0522D","#FFA07A","#FF7F50","#FF4500","#FF6347","#FFE4E1","#FFFAFA","#F08080","#BC8F8F","#CD5C5C","#FF0000","#A52A2A","#DCDCDC","#8B0000","#800000","#F5F5F5","#D3D3D3","#C0C0C0","#A9A9A9","#808080","#696969","#FFFFFF","#FF0000","#00FF00","#0000FF","#FF00FF","#00FFFF","#FFFF00","#000000"];var Zr={exports:{}};/*! +import{r as xe,A as pn,i as At,g as as,j as Re,aH as ls,R as et,o as Mn,d as je,aI as Ui,t as cs,aJ as ds,c as Bt,m as ei}from"./umi-a12c8253.js";import{q as us,a as Lt,v as hs}from"./parser-b66b074b.js";import{f as Qi,D as ps,F as ti,z as gs,B as fs}from"./index-43517c6d.js";import{B as $t}from"./button-f56a19a0.js";import{o as ms,b as vs,i as Cs,n as ys,I as bs}from"./util-590d1471.js";import{a as Rn}from"./index-c353c509.js";import{C as Is,S as ni}from"./TextArea-ec8ab387.js";import{S as As}from"./index-40bfaf7c.js";import{t as ws,w as xs,u as Ss,P as Es,x as ks,I as ii}from"./tiny-invariant-28d484ad.js";import{f as Rs,c as Ts}from"./index-ead1f686.js";import{c as Ls,d as qi,g as $s}from"./confirm-57060cff.js";import{A as Bs,_ as er,u as Hr,r as tr}from"./index-5722ce0d.js";import{S as Ds}from"./schedulePool-cc4538c2.js";import{a as Ns}from"./progress-81ce73da.js";var _s={icon:{tag:"svg",attrs:{"fill-rule":"evenodd",viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M880 112c17.7 0 32 14.3 32 32v736c0 17.7-14.3 32-32 32H144c-17.7 0-32-14.3-32-32V144c0-17.7 14.3-32 32-32zm-40 72H184v656h656V184zM640.01 338.83c.03 0 .05.01.09.06l45.02 45.01a.2.2 0 01.05.09.12.12 0 010 .07c0 .02-.01.04-.05.08L557.25 512l127.87 127.86a.27.27 0 01.05.06v.02a.12.12 0 010 .07c0 .03-.01.05-.05.09l-45.02 45.02a.2.2 0 01-.09.05.12.12 0 01-.07 0c-.02 0-.04-.01-.08-.05L512 557.25 384.14 685.12c-.04.04-.06.05-.08.05a.12.12 0 01-.07 0c-.03 0-.05-.01-.09-.05l-45.02-45.02a.2.2 0 01-.05-.09.12.12 0 010-.07c0-.02.01-.04.06-.08L466.75 512 338.88 384.14a.27.27 0 01-.05-.06l-.01-.02a.12.12 0 010-.07c0-.03.01-.05.05-.09l45.02-45.02a.2.2 0 01.09-.05.12.12 0 01.07 0c.02 0 .04.01.08.06L512 466.75l127.86-127.86c.04-.05.06-.06.08-.06a.12.12 0 01.07 0z"}}]},name:"close-square",theme:"outlined"};const Ms=_s;var Ps=function(f,S){return xe.createElement(pn,At(At({},f),{},{ref:S,icon:Ms}))},Fs=xe.forwardRef(Ps);const Ws=Fs;var Os={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M180 176h-60c-4.4 0-8 3.6-8 8v656c0 4.4 3.6 8 8 8h60c4.4 0 8-3.6 8-8V184c0-4.4-3.6-8-8-8zm724 0h-60c-4.4 0-8 3.6-8 8v656c0 4.4 3.6 8 8 8h60c4.4 0 8-3.6 8-8V184c0-4.4-3.6-8-8-8zM785.3 504.3L657.7 403.6a7.23 7.23 0 00-11.7 5.7V476H378v-62.8c0-6-7-9.4-11.7-5.7L238.7 508.3a7.14 7.14 0 000 11.3l127.5 100.8c4.7 3.7 11.7.4 11.7-5.7V548h268v62.8c0 6 7 9.4 11.7 5.7l127.5-100.8c3.8-2.9 3.8-8.5.2-11.4z"}}]},name:"column-width",theme:"outlined"};const Gs=Os;var Hs=function(f,S){return xe.createElement(pn,At(At({},f),{},{ref:S,icon:Gs}))},Vs=xe.forwardRef(Hs);const Zs=Vs;var js={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm-80 600c0 4.4-3.6 8-8 8h-48c-4.4 0-8-3.6-8-8V360c0-4.4 3.6-8 8-8h48c4.4 0 8 3.6 8 8v304zm224 0c0 4.4-3.6 8-8 8h-48c-4.4 0-8-3.6-8-8V360c0-4.4 3.6-8 8-8h48c4.4 0 8 3.6 8 8v304z"}}]},name:"pause-circle",theme:"filled"};const Ks=js;var zs=function(f,S){return xe.createElement(pn,At(At({},f),{},{ref:S,icon:Ks}))},Xs=xe.forwardRef(zs);const Ys=Xs;var Js={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm144.1 454.9L437.7 677.8a8.02 8.02 0 01-12.7-6.5V353.7a8 8 0 0112.7-6.5L656.1 506a7.9 7.9 0 010 12.9z"}}]},name:"play-circle",theme:"filled"};const Us=Js;var Qs=function(f,S){return xe.createElement(pn,At(At({},f),{},{ref:S,icon:Us}))},qs=xe.forwardRef(Qs);const ea=qs;var ta={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M926.8 397.1l-396-288a31.81 31.81 0 00-37.6 0l-396 288a31.99 31.99 0 00-11.6 35.8l151.3 466a32 32 0 0030.4 22.1h489.5c13.9 0 26.1-8.9 30.4-22.1l151.3-466c4.2-13.2-.5-27.6-11.7-35.8zM838.6 417l-98.5 32-200-144.7V199.9L838.6 417zM466 567.2l-89.1 122.3-55.2-169.2L466 567.2zm-116.3-96.8L484 373.3v140.8l-134.3-43.7zM512 599.2l93.9 128.9H418.1L512 599.2zm28.1-225.9l134.2 97.1L540.1 514V373.3zM558 567.2l144.3-46.9-55.2 169.2L558 567.2zm-74-367.3v104.4L283.9 449l-98.5-32L484 199.9zM169.3 470.8l86.5 28.1 80.4 246.4-53.8 73.9-113.1-348.4zM327.1 853l50.3-69h269.3l50.3 69H327.1zm414.5-33.8l-53.8-73.9 80.4-246.4 86.5-28.1-113.1 348.4z"}}]},name:"radar-chart",theme:"outlined"};const na=ta;var ia=function(f,S){return xe.createElement(pn,At(At({},f),{},{ref:S,icon:na}))},ra=xe.forwardRef(ia);const oa=ra;function sa(){var p=xe.useRef(!0);return p.current?(p.current=!1,!0):p.current}var aa=function(p,f){var S=xe.useState(f),W=S[0],J=S[1];return W==null?[p,J]:[W,J]};const la=aa;var ca=Cs?window:null,nr=function(p){return!!p.addEventListener},ir=function(p){return!!p.on},da=function(p,f,S,W){S===void 0&&(S=ca),xe.useEffect(function(){if(f&&S)return nr(S)?ms(S,p,f,W):ir(S)&&S.on(p,f,W),function(){nr(S)?vs(S,p,f,W):ir(S)&&S.off(p,f,W)}},[p,f,S,JSON.stringify(W)])};const ua=da;var ha=function(p){return typeof p=="function"?p:typeof p=="string"?function(f){return f.key===p}:p?function(){return!0}:function(){return!1}},pa=function(p,f,S,W){f===void 0&&(f=ys),S===void 0&&(S={}),W===void 0&&(W=[p]);var J=S.event,N=J===void 0?"keydown":J,s=S.target,E=S.options,Z=xe.useMemo(function(){var b=ha(p),R=function($){if(b($))return f($)};return R},W);ua(N,Z,s,E)};const Tn=pa;function ga(p,f,S){if(f===void 0&&(f=10),f<1)throw new Error("Capacity has to be greater than 1, got '"+f+"'");var W=sa(),J=xe.useState(p),N=J[0],s=J[1],E=xe.useRef(S??[]),Z=xe.useRef(0);W&&(E.current.length?(E.current[E.current.length-1]!==p&&E.current.push(p),E.current.length>f&&(E.current=E.current.slice(E.current.length-f))):E.current.push(p),Z.current=E.current.length&&E.current.length-1);var b=xe.useCallback(function($){s(function(F){return $=ws($,F),$!==F&&(Z.currentf&&(E.current=E.current.slice(E.current.length-f))),$})},[N,f]),R=xe.useMemo(function(){return{history:E.current,position:Z.current,capacity:f,back:function($){$===void 0&&($=1),Z.current&&s(function(){return Z.current-=Math.min($,Z.current),E.current[Z.current]})},forward:function($){$===void 0&&($=1),Z.current!==E.current.length-1&&s(function(){return Z.current=Math.min(Z.current+$,E.current.length-1),E.current[Z.current]})},go:function($){$!==Z.current&&s(function(){return Z.current=$<0?Math.max(E.current.length+$,0):Math.min(E.current.length-1,$),E.current[Z.current]})}}},[N]);return[N,b,R]}var fa=function(p){p===void 0&&(p=new Set);var f=xe.useState(p),S=f[0],W=f[1],J=xe.useMemo(function(){var s=function(b){return W(function(R){return new Set(er(Array.from(R),[b]))})},E=function(b){return W(function(R){return new Set(Array.from(R).filter(function($){return $!==b}))})},Z=function(b){return W(function(R){return R.has(b)?new Set(Array.from(R).filter(function($){return $!==b})):new Set(er(Array.from(R),[b]))})};return{add:s,remove:E,toggle:Z,reset:function(){return W(p)},clear:function(){return W(new Set)}}},[W]),N=Bs({has:xe.useCallback(function(s){return S.has(s)},[S])},J);return[S,N]};const ma=fa,Vr=["#ff4d4e","#52c41a","#1990ff","#faad13","#9932CD","#871F78","#6B238E","#2F4F4F","#97694F","#B22222","#D9D919","#A67D3D","#8C7853","#A67D3D","#5F9F9F","#D98719","#B87333","#FF7F00","#42426F","#5C4033","#2F4F2F","#4A766E","#4F4F2F","#7093DB","#855E42","#545454","#856363","#D19275","#8E2323","#238E23","#CD7F32","#DBDB70","#C0C0C0","#527F76","#93DB70","#215E21","#4E2F2F","#9F9F5F","#C0D9D9","#A8A8A8","#8F8FBD","#E9C2A6","#32CD32","#E47833","#8E236B","#32CD99","#3232CD","#6B8E23","#EAEAAE","#9370DB","#426F42","#7F00FF","#7FFF00","#70DBDB","#DB7093","#A68064","#2F2F4F","#23238E","#4D4DFF","#FF6EC7","#00009C","#EBC79E","#CFB53B","#FF7F00","#FF2400","#DB70DB","#8FBC8F","#BC8F8F","#EAADEA","#D9D9F3","#5959AB","#6F4242","#BC1717","#238E68","#6B4226","#8E6B23","#E6E8FA","#3299CC","#007FFF","#FF1CAE","#00FF7F","#236B8E","#38B0DE","#DB9370","#D8BFD8","#ADEAEA","#5C4033","#CDCDCD","#4F2F4F","#CC3299","#D8D8BF","#99CC32","#FFB6C1","#FFC0CB","#DC143C","#FFF0F5","#FF69B4","#DA70D6","#FF1493","#D8BFD8","#DDA0DD","#FF00FF","#FF00FF","#8B008B","#800080","#BA55D3","#9400D3","#9932CC","#4B0082","#8A2BE2","#9370DB","#7B68EE","#6A5ACD","#483D8B","#E6E6FA","#F8F8FF","#0000FF","#0000CD","#191970","#00008B","#000080","#4169E1","#6495ED","#B0C4DE","#778899","#708090","#1E90FF","#F0F8FF","#4682B4","#87CEFA","#87CEEB","#00BFFF","#ADD8E6","#B0E0E6","#5F9EA0","#F0FFFF","#E1FFFF","#AFEEEE","#00FFFF","#00FFFF","#00CED1","#2F4F4F","#008B8B","#008080","#48D1CC","#20B2AA","#40E0D0","#7FFFAA","#00FA9A","#F5FFFA","#00FF7F","#3CB371","#2E8B57","#F0FFF0","#90EE90","#98FB98","#8FBC8F","#32CD32","#00FF00","#228B22","#008000","#006400","#7FFF00","#7CFC00","#ADFF2F","#556B2F","#6B8E23","#FAFAD2","#FFFFF0","#FFFFE0","#FFFF00","#808000","#BDB76B","#FFFACD","#EEE8AA","#F0E68C","#FFD700","#FFF8DC","#DAA520","#FFFAF0","#FDF5E6","#F5DEB3","#FFE4B5","#FFA500","#FFEFD5","#FFEBCD","#FAEBD7","#D2B48C","#DEB887","#FFE4C4","#FF8C00","#FAF0E6","#CD853F","#FFDAB9","#F4A460","#D2691E","#8B4513","#FFF5EE","#A0522D","#FFA07A","#FF7F50","#FF4500","#FF6347","#FFE4E1","#FFFAFA","#F08080","#BC8F8F","#CD5C5C","#FF0000","#A52A2A","#DCDCDC","#8B0000","#800000","#F5F5F5","#D3D3D3","#C0C0C0","#A9A9A9","#808080","#696969","#FFFFFF","#FF0000","#00FF00","#0000FF","#FF00FF","#00FFFF","#FFFF00","#000000"];var Zr={exports:{}};/*! * jsoneditor.js * * @brief diff --git a/dist/assets/index-87811a39.js b/dist/assets/index-0e657c85.js similarity index 94% rename from dist/assets/index-87811a39.js rename to dist/assets/index-0e657c85.js index f46346a2af8e49eab80695bac7d03ca42318c1fb..341946b5bd9cddb880cbe512287a81ef8ecefe89 100644 --- a/dist/assets/index-87811a39.js +++ b/dist/assets/index-0e657c85.js @@ -1 +1 @@ -import{w as P,_ as D,r as A,a as H,C as Z,c as F,b as _,d as G,e as O,g as q,u as V,j as i,m as X,h as b}from"./umi-9940633e.js";import{q as W,P as $,Q as ee,L as te}from"./index-a694f10d.js";import{T as ae,S as ie,P as se}from"./Tags-26d753a4.js";import{u as re,r as T,n as L}from"./index-da8ccbdf.js";import{s as ne,V as oe,g as le,I as M,P as ce}from"./Table-dcae5cc9.js";import{u as ge,a as de,S as Ae}from"./TextArea-b3aeb374.js";import{o as me,c as ue}from"./_setToString-98c064b8.js";import{B as R}from"./button-eaadfeb4.js";import{L as k,a as S}from"./util-477962f3.js";import{u as z}from"./useAsyncFn-b0803fd6.js";import{u as he}from"./useDebounce-5d6283a5.js";import{D as Ee}from"./DeleteOutlined-a511b2d4.js";import"./EditOutlined-fac0ac1a.js";import"./index-6a5b1b3e.js";import"./progress-06af2db7.js";import"./index-e846d634.js";import"./index-690c95dc.js";import"./index-1b65ca98.js";function fe(a){var e,o=function(l){return function(){e=null,a.apply(void 0,D(l))}},r=function(){if(e==null){for(var l=arguments.length,g=new Array(l),m=0;mC)}),n=function(){var x=e.target,C=x||v,I=C();m.current=de(I,"scroll",function(w){f(w)}),f({target:I})};A.useEffect(function(){return n(),function(){m.current&&m.current.remove(),f.cancel()}},[e.target]);var B=function(x){var C=e.onClick,I=e.target,w=e.duration,Y=w===void 0?450:w;ne(0,{getContainer:I||v,duration:Y}),typeof C=="function"&&C(x)},y=A.useContext(Z),p=y.getPrefixCls,N=y.direction,j=e.prefixCls,s=e.className,t=s===void 0?"":s,c=p("back-top",j),d=p(),Q=F(c,_({},"".concat(c,"-rtl"),N==="rtl"),t),u=me(e,["prefixCls","className","children","visibilityHeight","target","visible"]);return A.createElement("div",G({},u,{className:Q,onClick:B,ref:g}),A.createElement(Qe,{prefixCls:c,rootPrefixCls:d,visible:h},e.children))};const Be=A.memo(ve),ye=["B","kB","MB","GB","TB","PB","EB","ZB","YB"],xe=["B","kiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"],Ce=["b","kbit","Mbit","Gbit","Tbit","Pbit","Ebit","Zbit","Ybit"],Ie=["b","kibit","Mibit","Gibit","Tibit","Pibit","Eibit","Zibit","Yibit"],U=(a,e,o)=>{let r=a;return typeof e=="string"||Array.isArray(e)?r=a.toLocaleString(e,o):(e===!0||o!==void 0)&&(r=a.toLocaleString(void 0,o)),r};var Se=(a,e)=>{if(!Number.isFinite(a))throw new TypeError(`Expected a finite number, got ${typeof a}: ${a}`);e=Object.assign({bits:!1,binary:!1},e);const o=e.bits?e.binary?Ie:Ce:e.binary?xe:ye;if(e.signed&&a===0)return` 0 ${o[0]}`;const r=a<0,h=r?"-":e.signed?"+":"";r&&(a=-a);let l;if(e.minimumFractionDigits!==void 0&&(l={minimumFractionDigits:e.minimumFractionDigits}),e.maximumFractionDigits!==void 0&&(l=Object.assign({maximumFractionDigits:e.maximumFractionDigits},l)),a<1){const f=U(a,e.locale,l);return h+f+" "+o[0]}const g=Math.min(Math.floor(e.binary?Math.log(a)/Math.log(1024):Math.log10(a)/3),o.length-1);a/=Math.pow(e.binary?1024:1e3,g),l||(a=a.toPrecision(3));const m=U(Number(a),e.locale,l),v=o[g];return h+m+" "+v};const pe=q(Se);const Ne="_title_jd9ry_1",je="_header_jd9ry_4",we="_logo_jd9ry_14",be="_imageFastPreview_jd9ry_18",Te="_list_jd9ry_53",J={title:Ne,header:je,logo:we,imageFastPreview:be,"site-tag-plus":"_site-tag-plus_jd9ry_34","ant-table-row":"_ant-table-row_jd9ry_38","ant-tag":"_ant-tag_jd9ry_44",delete:"_delete_jd9ry_47","score-tags":"_score-tags_jd9ry_50",list:Te},Me=i.jsx("svg",{style:{width:"1.4em",height:"1.4em",margin:"0 10px"},viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"200",height:"200",children:i.jsx("path",{d:"M960 1024H64a64 64 0 0 1-64-64V64a64 64 0 0 1 64-64h896a64 64 0 0 1 64 64v896a64 64 0 0 1-64 64z m0-896a64 64 0 0 0-64-64H128a64 64 0 0 0-64 64v768a64 64 0 0 0 64 64h768a64 64 0 0 0 64-64V128z m-128 640h-128a64 64 0 0 1 0-128h64V576h-64a64 64 0 0 1 0-128h64V384h-64a64 64 0 0 1 0-128h128a64 64 0 0 1 64 64v384a64 64 0 0 1-64 64z m-320-128a64 64 0 0 1 0 128H384a64 64 0 0 1-64-64V512a64 64 0 0 1 64-64h64V384H384a64 64 0 0 1 0-128h128a64 64 0 0 1 64 64v192a64 64 0 0 1-64 64H448v64h64z m-320 128a64 64 0 0 1-64-64V320a64 64 0 0 1 128 0v384a64 64 0 0 1-64 64z"})}),Je=i.jsxs("svg",{style:{width:"1.5em",height:"1.5em",margin:"0 10px"},viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"200",height:"200",children:[i.jsx("path",{d:"M428.62 383.7l193.23-45.33v-31.94l-193.23 45.48zM374.7 656c-10.23-8.15-25.15-13.26-41.74-13.26-16.59 0-31.52 5.11-42.02 13.26-8.85 7.19-14.65 16.59-14.65 26.54 0 10.23 5.8 19.63 14.65 26.82 10.5 8.15 25.44 12.99 42.02 12.99 16.59 0 31.51-4.84 41.74-12.99 9.26-7.19 14.93-16.59 14.93-26.82 0.01-9.95-5.67-19.35-14.93-26.54zM607.2 602.65v-0.14c-10.5-8.15-25.44-13.14-42.02-13.14-16.59 0-31.51 4.98-42.02 13.14-8.85 7.05-14.65 16.59-14.65 26.68 0 9.95 5.8 19.49 14.65 26.54 10.52 8.29 25.44 13.26 42.02 13.26 16.59 0 31.52-4.97 42.02-13.26 8.85-6.78 14.38-16.32 14.65-25.99v-0.96c-0.14-9.97-5.8-19.22-14.65-26.13z",fill:"#000000"}),i.jsx("path",{d:"M512 64C264.58 64 64 264.58 64 512s200.58 448 448 448 448-200.58 448-448S759.42 64 512 64z m148.83 565.19v0.82c-0.28 22.26-11.61 42.3-29.85 56.4-17.14 13.55-40.37 21.56-65.8 21.56s-48.79-8.01-65.93-21.29c-18.39-14.51-29.72-34.69-29.72-57.49 0-22.67 11.34-42.86 29.72-57.23 17.14-13.4 40.35-21.57 65.93-21.57 21.02 0 40.64 5.68 56.67 15.34V362.27l-193.23 45.48V683.64c-0.28 22.13-11.75 42.03-29.87 56.41-17.14 13.26-40.35 21.43-65.79 21.43-25.43 0-48.79-8.17-65.8-21.43-18.51-14.65-29.99-34.69-29.99-57.51 0-22.39 11.48-42.84 29.99-57.23 17.01-13.26 40.37-21.29 65.8-21.29 21 0 40.78 5.53 56.67 15.07V333.94l0.27-0.68v-0.28l0.14-0.27V332.02l0.14-0.28 0.14-0.27v-0.55h0.13l0.14-0.7v-0.28c0.41-0.96 0.98-2.06 1.53-2.9v-0.27l0.27-0.14v-0.28l0.28-0.13 0.13-0.57 0.28-0.27 0.55-0.55v-0.55h0.28l0.13-0.28 0.28-0.27 0.27-0.14v-0.14l0.28-0.27 1.1-0.84v-0.27h0.14l0.41-0.28 0.14-0.27h0.14l0.82-0.84 0.28-0.14 0.27-0.14v-0.13l0.28-0.14 0.82-0.41v-0.14l0.69-0.41h0.14c0.84-0.42 1.66-0.7 2.63-0.98 0.82-0.55 1.78-0.82 2.9-0.82l230.83-54.32c10.23-2.35 20.18 3.6 23.23 13.26v0.28c0.82 2.07 1.1 4.15 1.1 6.49v346.11z",fill:"#000000"})]});function We(){var N,j;const a=re(),e=A.useRef(),[o,r]=A.useState(null),h=A.useRef(null),[l,g]=A.useState([]),[m,v]=z(async()=>await T.get("/api/tags"),[]),f=V(),n=A.useMemo(()=>{try{const s=W.parse(f.search),t=JSON.parse(decodeURIComponent(s.search))||{};return K(t)}catch{return{}}},[f.search]);A.useEffect(()=>{v()},[]);const[B,y]=z(async()=>{var s;try{const t=await T("/api/musicSets",{params:{total:(s=B.value)==null?void 0:s.total,limit:50,offset:0,...n}});return{data:t.rows,success:!0,total:t.count}}catch(t){console.error(t)}return{data:void 0,success:!1}},[n]);he(()=>{y()},1e3,[n]);const p=[{title:a.formatMessage({id:"home.column.preview"}),dataIndex:"content",width:54,hideInSearch:!0,render:(s,t,c)=>i.jsx(M,{width:40,height:40,preview:!1,onMouseEnter:()=>{var Q,u;const d=(u=(Q=t.content)==null?void 0:Q.images)==null?void 0:u[0];r(d?{...d,url:L(d.url)}:null)},onMouseLeave:()=>r(null),onClick:()=>{r(null),g(t.content.images.map(d=>L(d.url)))},style:{cursor:"pointer"},src:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMIAAADDCAYAAADQvc6UAAABRWlDQ1BJQ0MgUHJvZmlsZQAAKJFjYGASSSwoyGFhYGDIzSspCnJ3UoiIjFJgf8LAwSDCIMogwMCcmFxc4BgQ4ANUwgCjUcG3awyMIPqyLsis7PPOq3QdDFcvjV3jOD1boQVTPQrgSkktTgbSf4A4LbmgqISBgTEFyFYuLykAsTuAbJEioKOA7DkgdjqEvQHEToKwj4DVhAQ5A9k3gGyB5IxEoBmML4BsnSQk8XQkNtReEOBxcfXxUQg1Mjc0dyHgXNJBSWpFCYh2zi+oLMpMzyhRcASGUqqCZ16yno6CkYGRAQMDKMwhqj/fAIcloxgHQqxAjIHBEugw5sUIsSQpBobtQPdLciLEVJYzMPBHMDBsayhILEqEO4DxG0txmrERhM29nYGBddr//5/DGRjYNRkY/l7////39v///y4Dmn+LgeHANwDrkl1AuO+pmgAAADhlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAAqACAAQAAAABAAAAwqADAAQAAAABAAAAwwAAAAD9b/HnAAAHlklEQVR4Ae3dP3PTWBSGcbGzM6GCKqlIBRV0dHRJFarQ0eUT8LH4BnRU0NHR0UEFVdIlFRV7TzRksomPY8uykTk/zewQfKw/9znv4yvJynLv4uLiV2dBoDiBf4qP3/ARuCRABEFAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghgg0Aj8i0JO4OzsrPv69Wv+hi2qPHr0qNvf39+iI97soRIh4f3z58/u7du3SXX7Xt7Z2enevHmzfQe+oSN2apSAPj09TSrb+XKI/f379+08+A0cNRE2ANkupk+ACNPvkSPcAAEibACyXUyfABGm3yNHuAECRNgAZLuYPgEirKlHu7u7XdyytGwHAd8jjNyng4OD7vnz51dbPT8/7z58+NB9+/bt6jU/TI+AGWHEnrx48eJ/EsSmHzx40L18+fLyzxF3ZVMjEyDCiEDjMYZZS5wiPXnyZFbJaxMhQIQRGzHvWR7XCyOCXsOmiDAi1HmPMMQjDpbpEiDCiL358eNHurW/5SnWdIBbXiDCiA38/Pnzrce2YyZ4//59F3ePLNMl4PbpiL2J0L979+7yDtHDhw8vtzzvdGnEXdvUigSIsCLAWavHp/+qM0BcXMd/q25n1vF57TYBp0a3mUzilePj4+7k5KSLb6gt6ydAhPUzXnoPR0dHl79WGTNCfBnn1uvSCJdegQhLI1vvCk+fPu2ePXt2tZOYEV6/fn31dz+shwAR1sP1cqvLntbEN9MxA9xcYjsxS1jWR4AIa2Ibzx0tc44fYX/16lV6NDFLXH+YL32jwiACRBiEbf5KcXoTIsQSpzXx4N28Ja4BQoK7rgXiydbHjx/P25TaQAJEGAguWy0+2Q8PD6/Ki4R8EVl+bzBOnZY95fq9rj9zAkTI2SxdidBHqG9+skdw43borCXO/ZcJdraPWdv22uIEiLA4q7nvvCug8WTqzQveOH26fodo7g6uFe/a17W3+nFBAkRYENRdb1vkkz1CH9cPsVy/jrhr27PqMYvENYNlHAIesRiBYwRy0V+8iXP8+/fvX11Mr7L7ECueb/r48eMqm7FuI2BGWDEG8cm+7G3NEOfmdcTQw4h9/55lhm7DekRYKQPZF2ArbXTAyu4kDYB2YxUzwg0gi/41ztHnfQG26HbGel/crVrm7tNY+/1btkOEAZ2M05r4FB7r9GbAIdxaZYrHdOsgJ/wCEQY0J74TmOKnbxxT9n3FgGGWWsVdowHtjt9Nnvf7yQM2aZU/TIAIAxrw6dOnAWtZZcoEnBpNuTuObWMEiLAx1HY0ZQJEmHJ3HNvGCBBhY6jtaMoEiJB0Z29vL6ls58vxPcO8/zfrdo5qvKO+d3Fx8Wu8zf1dW4p/cPzLly/dtv9Ts/EbcvGAHhHyfBIhZ6NSiIBTo0LNNtScABFyNiqFCBChULMNNSdAhJyNSiECRCjUbEPNCRAhZ6NSiAARCjXbUHMCRMjZqBQiQIRCzTbUnAARcjYqhQgQoVCzDTUnQIScjUohAkQo1GxDzQkQIWejUogAEQo121BzAkTI2agUIkCEQs021JwAEXI2KoUIEKFQsw01J0CEnI1KIQJEKNRsQ80JECFno1KIABEKNdtQcwJEyNmoFCJAhELNNtScABFyNiqFCBChULMNNSdAhJyNSiECRCjUbEPNCRAhZ6NSiAARCjXbUHMCRMjZqBQiQIRCzTbUnAARcjYqhQgQoVCzDTUnQIScjUohAkQo1GxDzQkQIWejUogAEQo121BzAkTI2agUIkCEQs021JwAEXI2KoUIEKFQsw01J0CEnI1KIQJEKNRsQ80JECFno1KIABEKNdtQcwJEyNmoFCJAhELNNtScABFyNiqFCBChULMNNSdAhJyNSiECRCjUbEPNCRAhZ6NSiAARCjXbUHMCRMjZqBQiQIRCzTbUnAARcjYqhQgQoVCzDTUnQIScjUohAkQo1GxDzQkQIWejUogAEQo121BzAkTI2agUIkCEQs021JwAEXI2KoUIEKFQsw01J0CEnI1KIQJEKNRsQ80JECFno1KIABEKNdtQcwJEyNmoFCJAhELNNtScABFyNiqFCBChULMNNSdAhJyNSiEC/wGgKKC4YMA4TAAAAABJRU5ErkJggg=="})},{title:a.formatMessage({id:"home.column.name"}),dataIndex:"name",sorter:!0,initialValue:n.search,sortOrder:n.sortedBy==="name"&&n.sortedType?{asc:"ascend",desc:"descend"}[n.sortedType]:null,render:(s,t,c)=>i.jsx(k,{style:{display:"flex"},to:`/${{stave:"playground",simple:"numbered"}[t.type]}/${t.id}`,children:`${t.name||a.formatMessage({id:"common.untitled"})}`})},{title:a.formatMessage({id:"home.column.type"}),dataIndex:"type",width:"6em",sorter:!0,initialValue:n.search,sortOrder:n.sortedBy==="type"&&n.sortedType?{asc:"ascend",desc:"descend"}[n.sortedType]:null,render:(s,t,c)=>({stave:Je,simple:Me})[t.type]},{title:i.jsx(ae,{}),dataIndex:"tagIdList",width:"2em",valueType:"select",filters:!0,hideInSearch:!0,filteredValue:(n==null?void 0:n.tagIdList)||[],valueEnum:()=>{var s;return((s=m.value)==null?void 0:s.reduce((t,c)=>({...t,[c.id]:{text:c.name||" "}}),{}))||{}},render:(s,t,c)=>i.jsx(ie,{preview:!0,id:t.id,tagList:t.tagList,onChange:d=>{console.log("tags",d),t.tagList=d}},t.id)},{title:a.formatMessage({id:"home.column.pages"}),render:(s,t)=>{var c,d;return(d=(c=t.content)==null?void 0:c.images)==null?void 0:d.length},width:"4em",align:"center",hideInSearch:!0},{title:a.formatMessage({id:"home.column.size"}),width:"6em",render:(s,t)=>{var c,d,Q;return((c=t.content)==null?void 0:c.images)&&pe((Q=(d=t.content)==null?void 0:d.images)==null?void 0:Q.reduce((u,E)=>u+((E==null?void 0:E.size)??0),0))},align:"center",hideInSearch:!0},{title:a.formatMessage({id:"home.column.lastUpdate"}),width:"12em",dataIndex:"lastUpdateAt",sorter:!0,sortOrder:n.sortedBy==="lastUpdateAt"&&n.sortedType?{asc:"ascend",desc:"descend"}[n.sortedType]:null,hideInSearch:!0},{title:a.formatMessage({id:"home.column.actions"}),width:"4em",hideInSearch:!0,render:(s,t,c)=>[(!t.tagList||!t.tagList.length)&&i.jsx($,{title:a.formatMessage({id:"home.confirmDelete"}),okText:a.formatMessage({id:"common.confirm"}),cancelText:a.formatMessage({id:"common.cancel"}),icon:i.jsx(ee,{}),onConfirm:async()=>{await T.delete(`/api/musicSets/${t.id}`)&&(X.success(a.formatMessage({id:"home.deleteSuccess"})),await y())},children:i.jsx(R,{className:"delete",type:"link",children:i.jsx(Ee,{})})},"delete")]}];return i.jsxs(S,{children:[i.jsx(S.Header,{className:J.header,children:i.jsxs(Ae,{children:[i.jsx(k,{className:J.logo,to:"/",children:"STARRY✨"}),i.jsxs(R,{onClick:()=>{b.push("/playground")},children:[i.jsx(se,{}),a.formatMessage({id:"home.createStave"})]}),!1,i.jsx(te,{})]})}),i.jsx(S,{style:{minHeight:"100vh"},children:i.jsx(S.Content,{style:{padding:"0 50px 50px",marginTop:"104px",width:"unset"},children:i.jsx(ce,{loading:B.loading,dataSource:(N=B.value)==null?void 0:N.data,style:{maxWidth:"100em",margin:"0 auto"},actionRef:e,formRef:h,columns:p,search:{filterType:"light"},size:"small",options:{density:!1,reload:y},pagination:{total:(j=B.value)==null?void 0:j.total,pageSize:50,current:+n.offset/+n.limit+1||1},onChange:(s,t,c,d)=>{var E;const Q={ascend:"asc",descend:"desc"}[c.order],u={...n,offset:(s.current-1)*s.pageSize,limit:s.pageSize,tagIdList:t.tagIdList,search:n.search};c.order?(u.sortedBy=c.field,u.sortedType=Q):(u.sortedBy=null,u.sortedType=null),((E=t.tagIdList)==null?void 0:E.length)>0?u.tagIdList=t.tagIdList:u.tagIdList=null,console.log("onChange"),b.push({search:`search=${encodeURIComponent(JSON.stringify(K(u)))}`})},beforeSearchSubmit:s=>{const t={...n,search:s.name};console.log("beforeSearchSubmit",t),b.push({search:Object.values(t).filter(Boolean).length>0?`search=${encodeURIComponent(JSON.stringify(t))}`:""})},rowKey:"id"})})}),i.jsx(S.Footer,{style:{textAlign:"center"},children:a.formatMessage({id:"common.footer"})}),o&&i.jsx("div",{className:J.imageFastPreview,children:i.jsx("img",{src:o.url,style:{objectFit:"contain",objectPosition:"center",maxHeight:"100%",maxWidth:"100%",backgroundColor:"#ffffff",boxShadow:"0 0 10px 0px rgba(0,0,0,0.5)"},alt:""})}),i.jsx(Be,{}),i.jsx(M.PreviewGroup,{preview:{open:l.length>0,destroyOnClose:!0,onOpenChange:s=>{s||g([])}},children:l.map((s,t)=>i.jsx(M,{wrapperStyle:{fontSize:"12px"},height:40,src:s},t))})]})}function K(a){return Object.entries(a).reduce((e,[o,r])=>{var l,g;return(o==="tagIdList"&&((g=(l=r==null?void 0:r.filter)==null?void 0:l.call(r,m=>/^\d+$/.test(String(r))))==null?void 0:g.length)>0||r)&&(e[o]=r),e},{})}export{We as default}; +import{w as P,_ as D,r as A,a as H,C as Z,c as F,b as _,d as G,e as O,g as q,u as V,j as i,m as X,h as b}from"./umi-a12c8253.js";import{q as W,P as $,Q as ee,L as te}from"./index-a2a53045.js";import{T as ae,S as ie,P as se}from"./Tags-957e9e21.js";import{u as re,r as T,n as L}from"./index-5722ce0d.js";import{s as ne,V as oe,g as le,I as M,P as ce}from"./Table-d40746fd.js";import{u as ge,a as de,S as Ae}from"./TextArea-ec8ab387.js";import{o as me,c as ue}from"./_setToString-ca5ad23e.js";import{B as R}from"./button-f56a19a0.js";import{L as k,a as S}from"./util-590d1471.js";import{u as z}from"./useAsyncFn-b4ac32aa.js";import{u as he}from"./useDebounce-b5b4777f.js";import{D as Ee}from"./DeleteOutlined-e5d1e611.js";import"./EditOutlined-d468c101.js";import"./index-c353c509.js";import"./progress-81ce73da.js";import"./index-dfec1b5b.js";import"./index-868eaf8d.js";import"./index-40bfaf7c.js";function fe(a){var e,o=function(l){return function(){e=null,a.apply(void 0,D(l))}},r=function(){if(e==null){for(var l=arguments.length,g=new Array(l),m=0;mC)}),n=function(){var x=e.target,C=x||v,I=C();m.current=de(I,"scroll",function(w){f(w)}),f({target:I})};A.useEffect(function(){return n(),function(){m.current&&m.current.remove(),f.cancel()}},[e.target]);var B=function(x){var C=e.onClick,I=e.target,w=e.duration,Y=w===void 0?450:w;ne(0,{getContainer:I||v,duration:Y}),typeof C=="function"&&C(x)},y=A.useContext(Z),p=y.getPrefixCls,N=y.direction,j=e.prefixCls,s=e.className,t=s===void 0?"":s,c=p("back-top",j),d=p(),Q=F(c,_({},"".concat(c,"-rtl"),N==="rtl"),t),u=me(e,["prefixCls","className","children","visibilityHeight","target","visible"]);return A.createElement("div",G({},u,{className:Q,onClick:B,ref:g}),A.createElement(Qe,{prefixCls:c,rootPrefixCls:d,visible:h},e.children))};const Be=A.memo(ve),ye=["B","kB","MB","GB","TB","PB","EB","ZB","YB"],xe=["B","kiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"],Ce=["b","kbit","Mbit","Gbit","Tbit","Pbit","Ebit","Zbit","Ybit"],Ie=["b","kibit","Mibit","Gibit","Tibit","Pibit","Eibit","Zibit","Yibit"],U=(a,e,o)=>{let r=a;return typeof e=="string"||Array.isArray(e)?r=a.toLocaleString(e,o):(e===!0||o!==void 0)&&(r=a.toLocaleString(void 0,o)),r};var Se=(a,e)=>{if(!Number.isFinite(a))throw new TypeError(`Expected a finite number, got ${typeof a}: ${a}`);e=Object.assign({bits:!1,binary:!1},e);const o=e.bits?e.binary?Ie:Ce:e.binary?xe:ye;if(e.signed&&a===0)return` 0 ${o[0]}`;const r=a<0,h=r?"-":e.signed?"+":"";r&&(a=-a);let l;if(e.minimumFractionDigits!==void 0&&(l={minimumFractionDigits:e.minimumFractionDigits}),e.maximumFractionDigits!==void 0&&(l=Object.assign({maximumFractionDigits:e.maximumFractionDigits},l)),a<1){const f=U(a,e.locale,l);return h+f+" "+o[0]}const g=Math.min(Math.floor(e.binary?Math.log(a)/Math.log(1024):Math.log10(a)/3),o.length-1);a/=Math.pow(e.binary?1024:1e3,g),l||(a=a.toPrecision(3));const m=U(Number(a),e.locale,l),v=o[g];return h+m+" "+v};const pe=q(Se);const Ne="_title_jd9ry_1",je="_header_jd9ry_4",we="_logo_jd9ry_14",be="_imageFastPreview_jd9ry_18",Te="_list_jd9ry_53",J={title:Ne,header:je,logo:we,imageFastPreview:be,"site-tag-plus":"_site-tag-plus_jd9ry_34","ant-table-row":"_ant-table-row_jd9ry_38","ant-tag":"_ant-tag_jd9ry_44",delete:"_delete_jd9ry_47","score-tags":"_score-tags_jd9ry_50",list:Te},Me=i.jsx("svg",{style:{width:"1.4em",height:"1.4em",margin:"0 10px"},viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"200",height:"200",children:i.jsx("path",{d:"M960 1024H64a64 64 0 0 1-64-64V64a64 64 0 0 1 64-64h896a64 64 0 0 1 64 64v896a64 64 0 0 1-64 64z m0-896a64 64 0 0 0-64-64H128a64 64 0 0 0-64 64v768a64 64 0 0 0 64 64h768a64 64 0 0 0 64-64V128z m-128 640h-128a64 64 0 0 1 0-128h64V576h-64a64 64 0 0 1 0-128h64V384h-64a64 64 0 0 1 0-128h128a64 64 0 0 1 64 64v384a64 64 0 0 1-64 64z m-320-128a64 64 0 0 1 0 128H384a64 64 0 0 1-64-64V512a64 64 0 0 1 64-64h64V384H384a64 64 0 0 1 0-128h128a64 64 0 0 1 64 64v192a64 64 0 0 1-64 64H448v64h64z m-320 128a64 64 0 0 1-64-64V320a64 64 0 0 1 128 0v384a64 64 0 0 1-64 64z"})}),Je=i.jsxs("svg",{style:{width:"1.5em",height:"1.5em",margin:"0 10px"},viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"200",height:"200",children:[i.jsx("path",{d:"M428.62 383.7l193.23-45.33v-31.94l-193.23 45.48zM374.7 656c-10.23-8.15-25.15-13.26-41.74-13.26-16.59 0-31.52 5.11-42.02 13.26-8.85 7.19-14.65 16.59-14.65 26.54 0 10.23 5.8 19.63 14.65 26.82 10.5 8.15 25.44 12.99 42.02 12.99 16.59 0 31.51-4.84 41.74-12.99 9.26-7.19 14.93-16.59 14.93-26.82 0.01-9.95-5.67-19.35-14.93-26.54zM607.2 602.65v-0.14c-10.5-8.15-25.44-13.14-42.02-13.14-16.59 0-31.51 4.98-42.02 13.14-8.85 7.05-14.65 16.59-14.65 26.68 0 9.95 5.8 19.49 14.65 26.54 10.52 8.29 25.44 13.26 42.02 13.26 16.59 0 31.52-4.97 42.02-13.26 8.85-6.78 14.38-16.32 14.65-25.99v-0.96c-0.14-9.97-5.8-19.22-14.65-26.13z",fill:"#000000"}),i.jsx("path",{d:"M512 64C264.58 64 64 264.58 64 512s200.58 448 448 448 448-200.58 448-448S759.42 64 512 64z m148.83 565.19v0.82c-0.28 22.26-11.61 42.3-29.85 56.4-17.14 13.55-40.37 21.56-65.8 21.56s-48.79-8.01-65.93-21.29c-18.39-14.51-29.72-34.69-29.72-57.49 0-22.67 11.34-42.86 29.72-57.23 17.14-13.4 40.35-21.57 65.93-21.57 21.02 0 40.64 5.68 56.67 15.34V362.27l-193.23 45.48V683.64c-0.28 22.13-11.75 42.03-29.87 56.41-17.14 13.26-40.35 21.43-65.79 21.43-25.43 0-48.79-8.17-65.8-21.43-18.51-14.65-29.99-34.69-29.99-57.51 0-22.39 11.48-42.84 29.99-57.23 17.01-13.26 40.37-21.29 65.8-21.29 21 0 40.78 5.53 56.67 15.07V333.94l0.27-0.68v-0.28l0.14-0.27V332.02l0.14-0.28 0.14-0.27v-0.55h0.13l0.14-0.7v-0.28c0.41-0.96 0.98-2.06 1.53-2.9v-0.27l0.27-0.14v-0.28l0.28-0.13 0.13-0.57 0.28-0.27 0.55-0.55v-0.55h0.28l0.13-0.28 0.28-0.27 0.27-0.14v-0.14l0.28-0.27 1.1-0.84v-0.27h0.14l0.41-0.28 0.14-0.27h0.14l0.82-0.84 0.28-0.14 0.27-0.14v-0.13l0.28-0.14 0.82-0.41v-0.14l0.69-0.41h0.14c0.84-0.42 1.66-0.7 2.63-0.98 0.82-0.55 1.78-0.82 2.9-0.82l230.83-54.32c10.23-2.35 20.18 3.6 23.23 13.26v0.28c0.82 2.07 1.1 4.15 1.1 6.49v346.11z",fill:"#000000"})]});function We(){var N,j;const a=re(),e=A.useRef(),[o,r]=A.useState(null),h=A.useRef(null),[l,g]=A.useState([]),[m,v]=z(async()=>await T.get("/api/tags"),[]),f=V(),n=A.useMemo(()=>{try{const s=W.parse(f.search),t=JSON.parse(decodeURIComponent(s.search))||{};return K(t)}catch{return{}}},[f.search]);A.useEffect(()=>{v()},[]);const[B,y]=z(async()=>{var s;try{const t=await T("/api/musicSets",{params:{total:(s=B.value)==null?void 0:s.total,limit:50,offset:0,...n}});return{data:t.rows,success:!0,total:t.count}}catch(t){console.error(t)}return{data:void 0,success:!1}},[n]);he(()=>{y()},1e3,[n]);const p=[{title:a.formatMessage({id:"home.column.preview"}),dataIndex:"content",width:54,hideInSearch:!0,render:(s,t,c)=>i.jsx(M,{width:40,height:40,preview:!1,onMouseEnter:()=>{var Q,u;const d=(u=(Q=t.content)==null?void 0:Q.images)==null?void 0:u[0];r(d?{...d,url:L(d.url)}:null)},onMouseLeave:()=>r(null),onClick:()=>{r(null),g(t.content.images.map(d=>L(d.url)))},style:{cursor:"pointer"},src:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMIAAADDCAYAAADQvc6UAAABRWlDQ1BJQ0MgUHJvZmlsZQAAKJFjYGASSSwoyGFhYGDIzSspCnJ3UoiIjFJgf8LAwSDCIMogwMCcmFxc4BgQ4ANUwgCjUcG3awyMIPqyLsis7PPOq3QdDFcvjV3jOD1boQVTPQrgSkktTgbSf4A4LbmgqISBgTEFyFYuLykAsTuAbJEioKOA7DkgdjqEvQHEToKwj4DVhAQ5A9k3gGyB5IxEoBmML4BsnSQk8XQkNtReEOBxcfXxUQg1Mjc0dyHgXNJBSWpFCYh2zi+oLMpMzyhRcASGUqqCZ16yno6CkYGRAQMDKMwhqj/fAIcloxgHQqxAjIHBEugw5sUIsSQpBobtQPdLciLEVJYzMPBHMDBsayhILEqEO4DxG0txmrERhM29nYGBddr//5/DGRjYNRkY/l7////39v///y4Dmn+LgeHANwDrkl1AuO+pmgAAADhlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAAqACAAQAAAABAAAAwqADAAQAAAABAAAAwwAAAAD9b/HnAAAHlklEQVR4Ae3dP3PTWBSGcbGzM6GCKqlIBRV0dHRJFarQ0eUT8LH4BnRU0NHR0UEFVdIlFRV7TzRksomPY8uykTk/zewQfKw/9znv4yvJynLv4uLiV2dBoDiBf4qP3/ARuCRABEFAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghgg0Aj8i0JO4OzsrPv69Wv+hi2qPHr0qNvf39+iI97soRIh4f3z58/u7du3SXX7Xt7Z2enevHmzfQe+oSN2apSAPj09TSrb+XKI/f379+08+A0cNRE2ANkupk+ACNPvkSPcAAEibACyXUyfABGm3yNHuAECRNgAZLuYPgEirKlHu7u7XdyytGwHAd8jjNyng4OD7vnz51dbPT8/7z58+NB9+/bt6jU/TI+AGWHEnrx48eJ/EsSmHzx40L18+fLyzxF3ZVMjEyDCiEDjMYZZS5wiPXnyZFbJaxMhQIQRGzHvWR7XCyOCXsOmiDAi1HmPMMQjDpbpEiDCiL358eNHurW/5SnWdIBbXiDCiA38/Pnzrce2YyZ4//59F3ePLNMl4PbpiL2J0L979+7yDtHDhw8vtzzvdGnEXdvUigSIsCLAWavHp/+qM0BcXMd/q25n1vF57TYBp0a3mUzilePj4+7k5KSLb6gt6ydAhPUzXnoPR0dHl79WGTNCfBnn1uvSCJdegQhLI1vvCk+fPu2ePXt2tZOYEV6/fn31dz+shwAR1sP1cqvLntbEN9MxA9xcYjsxS1jWR4AIa2Ibzx0tc44fYX/16lV6NDFLXH+YL32jwiACRBiEbf5KcXoTIsQSpzXx4N28Ja4BQoK7rgXiydbHjx/P25TaQAJEGAguWy0+2Q8PD6/Ki4R8EVl+bzBOnZY95fq9rj9zAkTI2SxdidBHqG9+skdw43borCXO/ZcJdraPWdv22uIEiLA4q7nvvCug8WTqzQveOH26fodo7g6uFe/a17W3+nFBAkRYENRdb1vkkz1CH9cPsVy/jrhr27PqMYvENYNlHAIesRiBYwRy0V+8iXP8+/fvX11Mr7L7ECueb/r48eMqm7FuI2BGWDEG8cm+7G3NEOfmdcTQw4h9/55lhm7DekRYKQPZF2ArbXTAyu4kDYB2YxUzwg0gi/41ztHnfQG26HbGel/crVrm7tNY+/1btkOEAZ2M05r4FB7r9GbAIdxaZYrHdOsgJ/wCEQY0J74TmOKnbxxT9n3FgGGWWsVdowHtjt9Nnvf7yQM2aZU/TIAIAxrw6dOnAWtZZcoEnBpNuTuObWMEiLAx1HY0ZQJEmHJ3HNvGCBBhY6jtaMoEiJB0Z29vL6ls58vxPcO8/zfrdo5qvKO+d3Fx8Wu8zf1dW4p/cPzLly/dtv9Ts/EbcvGAHhHyfBIhZ6NSiIBTo0LNNtScABFyNiqFCBChULMNNSdAhJyNSiECRCjUbEPNCRAhZ6NSiAARCjXbUHMCRMjZqBQiQIRCzTbUnAARcjYqhQgQoVCzDTUnQIScjUohAkQo1GxDzQkQIWejUogAEQo121BzAkTI2agUIkCEQs021JwAEXI2KoUIEKFQsw01J0CEnI1KIQJEKNRsQ80JECFno1KIABEKNdtQcwJEyNmoFCJAhELNNtScABFyNiqFCBChULMNNSdAhJyNSiECRCjUbEPNCRAhZ6NSiAARCjXbUHMCRMjZqBQiQIRCzTbUnAARcjYqhQgQoVCzDTUnQIScjUohAkQo1GxDzQkQIWejUogAEQo121BzAkTI2agUIkCEQs021JwAEXI2KoUIEKFQsw01J0CEnI1KIQJEKNRsQ80JECFno1KIABEKNdtQcwJEyNmoFCJAhELNNtScABFyNiqFCBChULMNNSdAhJyNSiECRCjUbEPNCRAhZ6NSiAARCjXbUHMCRMjZqBQiQIRCzTbUnAARcjYqhQgQoVCzDTUnQIScjUohAkQo1GxDzQkQIWejUogAEQo121BzAkTI2agUIkCEQs021JwAEXI2KoUIEKFQsw01J0CEnI1KIQJEKNRsQ80JECFno1KIABEKNdtQcwJEyNmoFCJAhELNNtScABFyNiqFCBChULMNNSdAhJyNSiEC/wGgKKC4YMA4TAAAAABJRU5ErkJggg=="})},{title:a.formatMessage({id:"home.column.name"}),dataIndex:"name",sorter:!0,initialValue:n.search,sortOrder:n.sortedBy==="name"&&n.sortedType?{asc:"ascend",desc:"descend"}[n.sortedType]:null,render:(s,t,c)=>i.jsx(k,{style:{display:"flex"},to:`/${{stave:"playground",simple:"numbered"}[t.type]}/${t.id}`,children:`${t.name||a.formatMessage({id:"common.untitled"})}`})},{title:a.formatMessage({id:"home.column.type"}),dataIndex:"type",width:"6em",sorter:!0,initialValue:n.search,sortOrder:n.sortedBy==="type"&&n.sortedType?{asc:"ascend",desc:"descend"}[n.sortedType]:null,render:(s,t,c)=>({stave:Je,simple:Me})[t.type]},{title:i.jsx(ae,{}),dataIndex:"tagIdList",width:"2em",valueType:"select",filters:!0,hideInSearch:!0,filteredValue:(n==null?void 0:n.tagIdList)||[],valueEnum:()=>{var s;return((s=m.value)==null?void 0:s.reduce((t,c)=>({...t,[c.id]:{text:c.name||" "}}),{}))||{}},render:(s,t,c)=>i.jsx(ie,{preview:!0,id:t.id,tagList:t.tagList,onChange:d=>{console.log("tags",d),t.tagList=d}},t.id)},{title:a.formatMessage({id:"home.column.pages"}),render:(s,t)=>{var c,d;return(d=(c=t.content)==null?void 0:c.images)==null?void 0:d.length},width:"4em",align:"center",hideInSearch:!0},{title:a.formatMessage({id:"home.column.size"}),width:"6em",render:(s,t)=>{var c,d,Q;return((c=t.content)==null?void 0:c.images)&&pe((Q=(d=t.content)==null?void 0:d.images)==null?void 0:Q.reduce((u,E)=>u+((E==null?void 0:E.size)??0),0))},align:"center",hideInSearch:!0},{title:a.formatMessage({id:"home.column.lastUpdate"}),width:"12em",dataIndex:"lastUpdateAt",sorter:!0,sortOrder:n.sortedBy==="lastUpdateAt"&&n.sortedType?{asc:"ascend",desc:"descend"}[n.sortedType]:null,hideInSearch:!0},{title:a.formatMessage({id:"home.column.actions"}),width:"4em",hideInSearch:!0,render:(s,t,c)=>[(!t.tagList||!t.tagList.length)&&i.jsx($,{title:a.formatMessage({id:"home.confirmDelete"}),okText:a.formatMessage({id:"common.confirm"}),cancelText:a.formatMessage({id:"common.cancel"}),icon:i.jsx(ee,{}),onConfirm:async()=>{await T.delete(`/api/musicSets/${t.id}`)&&(X.success(a.formatMessage({id:"home.deleteSuccess"})),await y())},children:i.jsx(R,{className:"delete",type:"link",children:i.jsx(Ee,{})})},"delete")]}];return i.jsxs(S,{children:[i.jsx(S.Header,{className:J.header,children:i.jsxs(Ae,{children:[i.jsx(k,{className:J.logo,to:"/",children:"STARRY✨"}),i.jsxs(R,{onClick:()=>{b.push("/playground")},children:[i.jsx(se,{}),a.formatMessage({id:"home.createStave"})]}),!1,i.jsx(te,{})]})}),i.jsx(S,{style:{minHeight:"100vh"},children:i.jsx(S.Content,{style:{padding:"0 50px 50px",marginTop:"104px",width:"unset"},children:i.jsx(ce,{loading:B.loading,dataSource:(N=B.value)==null?void 0:N.data,style:{maxWidth:"100em",margin:"0 auto"},actionRef:e,formRef:h,columns:p,search:{filterType:"light"},size:"small",options:{density:!1,reload:y},pagination:{total:(j=B.value)==null?void 0:j.total,pageSize:50,current:+n.offset/+n.limit+1||1},onChange:(s,t,c,d)=>{var E;const Q={ascend:"asc",descend:"desc"}[c.order],u={...n,offset:(s.current-1)*s.pageSize,limit:s.pageSize,tagIdList:t.tagIdList,search:n.search};c.order?(u.sortedBy=c.field,u.sortedType=Q):(u.sortedBy=null,u.sortedType=null),((E=t.tagIdList)==null?void 0:E.length)>0?u.tagIdList=t.tagIdList:u.tagIdList=null,console.log("onChange"),b.push({search:`search=${encodeURIComponent(JSON.stringify(K(u)))}`})},beforeSearchSubmit:s=>{const t={...n,search:s.name};console.log("beforeSearchSubmit",t),b.push({search:Object.values(t).filter(Boolean).length>0?`search=${encodeURIComponent(JSON.stringify(t))}`:""})},rowKey:"id"})})}),i.jsx(S.Footer,{style:{textAlign:"center"},children:a.formatMessage({id:"common.footer"})}),o&&i.jsx("div",{className:J.imageFastPreview,children:i.jsx("img",{src:o.url,style:{objectFit:"contain",objectPosition:"center",maxHeight:"100%",maxWidth:"100%",backgroundColor:"#ffffff",boxShadow:"0 0 10px 0px rgba(0,0,0,0.5)"},alt:""})}),i.jsx(Be,{}),i.jsx(M.PreviewGroup,{preview:{open:l.length>0,destroyOnClose:!0,onOpenChange:s=>{s||g([])}},children:l.map((s,t)=>i.jsx(M,{wrapperStyle:{fontSize:"12px"},height:40,src:s},t))})]})}function K(a){return Object.entries(a).reduce((e,[o,r])=>{var l,g;return(o==="tagIdList"&&((g=(l=r==null?void 0:r.filter)==null?void 0:l.call(r,m=>/^\d+$/.test(String(r))))==null?void 0:g.length)>0||r)&&(e[o]=r),e},{})}export{We as default}; diff --git a/dist/assets/index-d3bdb233.js b/dist/assets/index-1d8a15fd.js similarity index 99% rename from dist/assets/index-d3bdb233.js rename to dist/assets/index-1d8a15fd.js index 9715a99559c74ecee1f8318be6c1495611dfd092..cdf5dd1397bd08de0822ba810c8189469dbf649f 100644 --- a/dist/assets/index-d3bdb233.js +++ b/dist/assets/index-1d8a15fd.js @@ -1 +1 @@ -import{r as s,j as e}from"./umi-9940633e.js";const t=()=>e.jsxs("defs",{className:"score-token-defs",children:[e.jsx("g",{id:"score-token-def-clefs-G",className:"token",children:e.jsx("text",{x:"-1.3",children:""})}),e.jsx("g",{id:"score-token-def-clefs-F",className:"token",children:e.jsx("text",{x:"-1.06",children:""})}),e.jsx("g",{id:"score-token-def-clefs-C",className:"token",children:e.jsx("text",{x:"-1.06",children:""})}),e.jsx("g",{id:"score-token-def-timesig-C44",className:"token",children:e.jsx("text",{x:"-0.9",y:"0",children:""})}),e.jsx("g",{id:"score-token-def-timesig-C22",className:"token",children:e.jsx("text",{x:"-0.9",y:"0",children:""})}),e.jsx("g",{id:"score-token-def-timesig0",className:"token",children:e.jsx("text",{x:"-0.7",y:"1",children:"0"})}),e.jsx("g",{id:"score-token-def-timesig1",className:"token",children:e.jsx("text",{x:"-0.7",y:"1",children:"1"})}),e.jsx("g",{id:"score-token-def-timesig2",className:"token",children:e.jsx("text",{x:"-0.7",y:"1",children:"2"})}),e.jsx("g",{id:"score-token-def-timesig3",className:"token",children:e.jsx("text",{x:"-0.7",y:"1",children:"3"})}),e.jsx("g",{id:"score-token-def-timesig4",className:"token",children:e.jsx("text",{x:"-0.7",y:"1",children:"4"})}),e.jsx("g",{id:"score-token-def-timesig5",className:"token",children:e.jsx("text",{x:"-0.7",y:"1",children:"5"})}),e.jsx("g",{id:"score-token-def-timesig6",className:"token",children:e.jsx("text",{x:"-0.7",y:"1",children:"6"})}),e.jsx("g",{id:"score-token-def-timesig7",className:"token",children:e.jsx("text",{x:"-0.7",y:"1",children:"7"})}),e.jsx("g",{id:"score-token-def-timesig8",className:"token",children:e.jsx("text",{x:"-0.7",y:"1",children:"8"})}),e.jsx("g",{id:"score-token-def-timesig9",className:"token",children:e.jsx("text",{x:"-0.7",y:"1",children:"9"})}),e.jsx("g",{id:"score-token-def-octave-a",className:"token",children:e.jsx("text",{y:"0.5",className:"plain",children:"𝄶---"})}),e.jsx("g",{id:"score-token-def-octave-b",className:"token",children:e.jsx("text",{y:"0.5",className:"plain",children:"𝄷---"})}),e.jsx("g",{id:"score-token-def-octave-0",className:"token",children:e.jsx("text",{x:"-0.7",y:"0.6",className:"plain",children:"┐"})}),e.jsx("g",{id:"score-token-def-octave-8",className:"token",children:e.jsx("text",{y:"0.5",className:"plain",children:"8-----"})}),e.jsx("g",{id:"score-token-def-n0",className:"token",children:e.jsx("g",{className:"number",children:e.jsx("text",{x:"-0.35",y:"0.5",children:"0"})})}),e.jsx("g",{id:"score-token-def-n1",className:"token",children:e.jsx("g",{className:"number",children:e.jsx("text",{x:"-0.35",y:"0.5",children:"1"})})}),e.jsx("g",{id:"score-token-def-n2",className:"token",children:e.jsx("g",{className:"number",children:e.jsx("text",{x:"-0.35",y:"0.5",children:"2"})})}),e.jsx("g",{id:"score-token-def-n3",className:"token",children:e.jsx("g",{className:"number",children:e.jsx("text",{x:"-0.35",y:"0.5",children:"3"})})}),e.jsx("g",{id:"score-token-def-n4",className:"token",children:e.jsx("g",{className:"number",children:e.jsx("text",{x:"-0.35",y:"0.5",children:"4"})})}),e.jsx("g",{id:"score-token-def-n5",className:"token",children:e.jsx("g",{className:"number",children:e.jsx("text",{x:"-0.35",y:"0.5",children:"5"})})}),e.jsx("g",{id:"score-token-def-n6",className:"token",children:e.jsx("g",{className:"number",children:e.jsx("text",{x:"-0.35",y:"0.5",children:"6"})})}),e.jsx("g",{id:"score-token-def-n7",className:"token",children:e.jsx("g",{className:"number",children:e.jsx("text",{x:"-0.35",y:"0.5",children:"7"})})}),e.jsx("g",{id:"score-token-def-n8",className:"token",children:e.jsx("g",{className:"number",children:e.jsx("text",{x:"-0.35",y:"0.5",children:"8"})})}),e.jsx("g",{id:"score-token-def-n9",className:"token",children:e.jsx("g",{className:"number",children:e.jsx("text",{x:"-0.35",y:"0.5",children:"9"})})}),e.jsx("g",{id:"score-token-def-accidentals-sharp",className:"token",children:e.jsx("text",{x:"-0.55",children:""})}),e.jsx("g",{id:"score-token-def-accidentals-doublesharp",className:"token",children:e.jsx("text",{x:"-0.5",children:""})}),e.jsx("g",{id:"score-token-def-accidentals-natural",className:"token",children:e.jsx("text",{x:"-0.3",children:""})}),e.jsx("g",{id:"score-token-def-accidentals-flat",className:"token",children:e.jsx("text",{x:"-0.3",children:""})}),e.jsx("g",{id:"score-token-def-accidentals-flatflat",className:"token",children:e.jsx("text",{x:"-0.5",children:""})}),e.jsxs("g",{id:"score-token-def-key-sharp",className:"token",children:[e.jsx("text",{x:"-0.55",children:""}),e.jsx("line",{x1:"-1",x2:"-1",y1:"-1",y2:"1",stroke:"black",strokeWidth:"0.08"})]}),e.jsxs("g",{id:"score-token-def-key-natural",className:"token",children:[e.jsx("text",{x:"-0.3",children:""}),e.jsx("line",{x1:"-1",x2:"-1",y1:"-1",y2:"1",stroke:"black",strokeWidth:"0.08"})]}),e.jsxs("g",{id:"score-token-def-key-flat",className:"token",children:[e.jsx("text",{x:"-0.3",children:""}),e.jsx("line",{x1:"-1",x2:"-1",y1:"-1",y2:"1",stroke:"black",strokeWidth:"0.08"})]}),e.jsx("g",{id:"score-token-def-noteheads-s0",className:"token",children:e.jsx("text",{x:"-0.913",children:""})}),e.jsx("g",{id:"score-token-def-noteheads-s1",className:"token",children:e.jsx("text",{x:"-0.632",children:""})}),e.jsx("g",{id:"score-token-def-noteheads-s2",className:"token",children:e.jsx("text",{x:"-0.599",children:""})}),e.jsxs("g",{id:"score-token-def-noteheads-s1-u",className:"token",children:[e.jsx("text",{x:"-1.264",children:""}),e.jsx("line",{x1:"0",x2:"0",y1:"-0.06",y2:"-3.5",stroke:"currentColor",strokeWidth:"0.12",strokeLinecap:"round",className:"stem"})]}),e.jsxs("g",{id:"score-token-def-noteheads-s2-u",className:"token",children:[e.jsx("text",{x:"-1.198",children:""}),e.jsx("line",{x1:"0",x2:"0",y1:"-0.06",y2:"-3.5",stroke:"currentColor",strokeWidth:"0.12",strokeLinecap:"round",className:"stem"})]}),e.jsxs("g",{id:"score-token-def-noteheads-s1-d",className:"token",children:[e.jsx("text",{children:""}),e.jsx("line",{x1:"0",x2:"0",y1:"0.16",y2:"3.5",stroke:"currentColor",strokeWidth:"0.12",strokeLinecap:"round",className:"stem"})]}),e.jsxs("g",{id:"score-token-def-noteheads-s2-d",className:"token",children:[e.jsx("text",{children:""}),e.jsx("line",{x1:"0",x2:"0",y1:"0.16",y2:"3.5",stroke:"currentColor",strokeWidth:"0.12",strokeLinecap:"round",className:"stem"})]}),e.jsx("g",{id:"score-token-def-rests-M1",className:"token",children:e.jsx("text",{x:"-0.75",y:"-1",children:""})}),e.jsx("g",{id:"score-token-def-rests-0",className:"token",children:e.jsx("text",{x:"-0.75",y:"-1",children:""})}),e.jsx("g",{id:"score-token-def-rests-0o",className:"token",children:e.jsx("text",{x:"-0.75",y:"-1",children:""})}),e.jsx("g",{id:"score-token-def-rests-1o",className:"token",children:e.jsx("text",{x:"-0.75",y:"0",children:""})}),e.jsx("g",{id:"score-token-def-rests-2",className:"token",children:e.jsx("text",{x:"-0.5",children:""})}),e.jsx("g",{id:"score-token-def-rests-3",className:"token",children:e.jsx("text",{x:"-0.5",children:""})}),e.jsx("g",{id:"score-token-def-rests-4",className:"token",children:e.jsx("text",{x:"-0.5",children:""})}),e.jsx("g",{id:"score-token-def-rests-5",className:"token",children:e.jsx("text",{x:"-0.5",children:""})}),e.jsx("g",{id:"score-token-def-rests-6",className:"token",children:e.jsx("text",{x:"-0.5",children:""})}),e.jsx("g",{id:"score-token-def-flags-u3",className:"token",children:e.jsx("text",{children:""})}),e.jsx("g",{id:"score-token-def-flags-u4",className:"token",children:e.jsx("text",{children:""})}),e.jsx("g",{id:"score-token-def-flags-u5",className:"token",children:e.jsx("text",{children:""})}),e.jsx("g",{id:"score-token-def-flags-u6",className:"token",children:e.jsx("text",{children:""})}),e.jsx("g",{id:"score-token-def-flags-u7",className:"token",children:e.jsx("text",{children:""})}),e.jsx("g",{id:"score-token-def-flags-u8",className:"token",children:e.jsx("text",{children:""})}),e.jsx("g",{id:"score-token-def-slur-begin",className:"token",children:e.jsx("path",{d:"M0 0C0.5 -0.5 1 -0.6 1.5 -0.6L1.5 -0.4C1 -0.4 0.5 -0.4 0 0z"})}),e.jsx("g",{id:"score-token-def-slur-end",className:"token",children:e.jsx("path",{d:"M0 0C-0.5 -0.5 -1 -0.6 -1.5 -0.6L-1.5 -0.4C-1 -0.4 -0.5 -0.4 0 0z"})}),e.jsxs("g",{id:"score-token-def-volta-left",className:"token",children:[e.jsx("text",{x:"-0.25",y:"-0.5",children:""}),e.jsx("text",{x:"-0.25",y:"0.5",children:""}),e.jsx("line",{x1:"-0.5",x2:"-0.5",y1:"-2",y2:"2"})]}),e.jsxs("g",{id:"score-token-def-volta-right",className:"token",children:[e.jsx("text",{x:"-0.25",y:"-0.5",children:""}),e.jsx("text",{x:"-0.25",y:"0.5",children:""}),e.jsx("line",{x1:"0.5",x2:"0.5",y1:"-2",y2:"2"})]}),e.jsxs("g",{id:"score-token-def-bar-terminal",className:"token",children:[e.jsx("rect",{x:"-0.064",y:"-2",width:"0.128",height:"4"}),e.jsx("rect",{x:"0.27",y:"-2",width:"0.4",height:"4"})]}),e.jsxs("g",{id:"score-token-def-bar-segment",className:"token",children:[e.jsx("rect",{x:"-0.359",y:"-2",width:"0.128",height:"4"}),e.jsx("rect",{x:"0.231",y:"-2",width:"0.128",height:"4"})]}),e.jsx("g",{id:"score-token-def-dot",className:"token",children:e.jsx("text",{children:""})}),e.jsxs("g",{id:"score-token-def-dotdot",className:"token",children:[e.jsx("text",{children:""}),e.jsx("text",{x:"0.8",children:""})]}),e.jsx("g",{id:"score-token-def-f",className:"token",children:e.jsx("text",{x:"-0.6",y:"0.5",children:"f"})}),e.jsx("g",{id:"score-token-def-m",className:"token",children:e.jsx("text",{x:"-0.9",y:"0.5",children:"m"})}),e.jsx("g",{id:"score-token-def-n",className:"token",children:e.jsx("text",{x:"-0.9",y:"0.5",children:"n"})}),e.jsx("g",{id:"score-token-def-p",className:"token",children:e.jsx("text",{x:"-0.5",y:"0.5",children:"p"})}),e.jsx("g",{id:"score-token-def-r",className:"token",children:e.jsx("text",{x:"-0.5",y:"0.5",children:"r"})}),e.jsx("g",{id:"score-token-def-s",className:"token",children:e.jsx("text",{x:"-0.5",y:"0.5",children:"s"})}),e.jsx("g",{id:"score-token-def-z",className:"token",children:e.jsx("text",{x:"-0.5",y:"0.5",children:"z"})}),e.jsx("g",{id:"score-token-def-scripts-ufermata",className:"token",children:e.jsx("text",{children:""})}),e.jsx("g",{id:"score-token-def-scripts-ushortfermata",className:"token",children:e.jsx("text",{children:""})}),e.jsx("g",{id:"score-token-def-scripts-sforzato",className:"token",children:e.jsx("text",{children:""})}),e.jsx("g",{id:"score-token-def-scripts-staccato",className:"token",children:e.jsx("text",{children:""})}),e.jsx("g",{id:"score-token-def-scripts-ustaccatissimo",className:"token",children:e.jsx("text",{children:""})}),e.jsx("g",{id:"score-token-def-scripts-turn",className:"token",children:e.jsx("text",{children:""})}),e.jsx("g",{id:"score-token-def-scripts-trill",className:"token",children:e.jsx("text",{y:"0.5",children:""})}),e.jsx("g",{id:"score-token-def-scripts-segno",className:"token",children:e.jsx("text",{children:""})}),e.jsx("g",{id:"score-token-def-scripts-coda",className:"token",children:e.jsx("text",{children:""})}),e.jsx("g",{id:"score-token-def-scripts-arpeggio",className:"token",children:e.jsx("text",{x:"-0.5",y:"0.5",children:""})}),e.jsx("g",{id:"score-token-def-scripts-prall",className:"token",children:e.jsx("text",{children:""})}),e.jsx("g",{id:"score-token-def-scripts-mordent",className:"token",children:e.jsx("text",{children:""})}),e.jsx("g",{id:"score-token-def-scripts-umarcato",className:"token",children:e.jsx("text",{children:""})}),e.jsx("g",{id:"score-token-def-scripts-tenuto",className:"token",children:e.jsx("text",{children:""})}),e.jsx("g",{id:"score-token-def-scripts-uportato",className:"token",children:e.jsx("text",{children:""})}),e.jsx("g",{id:"score-token-def-pedal-star",className:"token",children:e.jsx("text",{x:"-0.78",y:"0.78",children:""})}),e.jsx("g",{id:"score-token-def-pedal-Ped",className:"token",children:e.jsx("text",{x:"-1.6",y:"0.7",children:""})}),e.jsx("g",{id:"score-token-def-BOS",className:"token",children:e.jsx("text",{x:"-3",y:"1.04",children:"▶"})}),e.jsx("g",{id:"score-token-def-BeamLeft",className:"token",children:e.jsx("text",{x:"-0.73",y:"0.66",className:"s-beam",children:"├"})}),e.jsx("g",{id:"score-token-def-BeamContinue",className:"token",children:e.jsx("text",{x:"-0.73",y:"0.66",className:"s-beam",children:"┼"})}),e.jsx("g",{id:"score-token-def-BeamRight",className:"token",children:e.jsx("text",{x:"-0.73",y:"0.66",className:"s-beam",children:"┤"})}),e.jsx("g",{id:"score-token-def-GraceNotehead",className:"token",children:e.jsx("text",{x:"-0.36",className:"s-grace",children:""})})]}),n=s.memo(t);export{n as S}; +import{r as s,j as e}from"./umi-a12c8253.js";const t=()=>e.jsxs("defs",{className:"score-token-defs",children:[e.jsx("g",{id:"score-token-def-clefs-G",className:"token",children:e.jsx("text",{x:"-1.3",children:""})}),e.jsx("g",{id:"score-token-def-clefs-F",className:"token",children:e.jsx("text",{x:"-1.06",children:""})}),e.jsx("g",{id:"score-token-def-clefs-C",className:"token",children:e.jsx("text",{x:"-1.06",children:""})}),e.jsx("g",{id:"score-token-def-timesig-C44",className:"token",children:e.jsx("text",{x:"-0.9",y:"0",children:""})}),e.jsx("g",{id:"score-token-def-timesig-C22",className:"token",children:e.jsx("text",{x:"-0.9",y:"0",children:""})}),e.jsx("g",{id:"score-token-def-timesig0",className:"token",children:e.jsx("text",{x:"-0.7",y:"1",children:"0"})}),e.jsx("g",{id:"score-token-def-timesig1",className:"token",children:e.jsx("text",{x:"-0.7",y:"1",children:"1"})}),e.jsx("g",{id:"score-token-def-timesig2",className:"token",children:e.jsx("text",{x:"-0.7",y:"1",children:"2"})}),e.jsx("g",{id:"score-token-def-timesig3",className:"token",children:e.jsx("text",{x:"-0.7",y:"1",children:"3"})}),e.jsx("g",{id:"score-token-def-timesig4",className:"token",children:e.jsx("text",{x:"-0.7",y:"1",children:"4"})}),e.jsx("g",{id:"score-token-def-timesig5",className:"token",children:e.jsx("text",{x:"-0.7",y:"1",children:"5"})}),e.jsx("g",{id:"score-token-def-timesig6",className:"token",children:e.jsx("text",{x:"-0.7",y:"1",children:"6"})}),e.jsx("g",{id:"score-token-def-timesig7",className:"token",children:e.jsx("text",{x:"-0.7",y:"1",children:"7"})}),e.jsx("g",{id:"score-token-def-timesig8",className:"token",children:e.jsx("text",{x:"-0.7",y:"1",children:"8"})}),e.jsx("g",{id:"score-token-def-timesig9",className:"token",children:e.jsx("text",{x:"-0.7",y:"1",children:"9"})}),e.jsx("g",{id:"score-token-def-octave-a",className:"token",children:e.jsx("text",{y:"0.5",className:"plain",children:"𝄶---"})}),e.jsx("g",{id:"score-token-def-octave-b",className:"token",children:e.jsx("text",{y:"0.5",className:"plain",children:"𝄷---"})}),e.jsx("g",{id:"score-token-def-octave-0",className:"token",children:e.jsx("text",{x:"-0.7",y:"0.6",className:"plain",children:"┐"})}),e.jsx("g",{id:"score-token-def-octave-8",className:"token",children:e.jsx("text",{y:"0.5",className:"plain",children:"8-----"})}),e.jsx("g",{id:"score-token-def-n0",className:"token",children:e.jsx("g",{className:"number",children:e.jsx("text",{x:"-0.35",y:"0.5",children:"0"})})}),e.jsx("g",{id:"score-token-def-n1",className:"token",children:e.jsx("g",{className:"number",children:e.jsx("text",{x:"-0.35",y:"0.5",children:"1"})})}),e.jsx("g",{id:"score-token-def-n2",className:"token",children:e.jsx("g",{className:"number",children:e.jsx("text",{x:"-0.35",y:"0.5",children:"2"})})}),e.jsx("g",{id:"score-token-def-n3",className:"token",children:e.jsx("g",{className:"number",children:e.jsx("text",{x:"-0.35",y:"0.5",children:"3"})})}),e.jsx("g",{id:"score-token-def-n4",className:"token",children:e.jsx("g",{className:"number",children:e.jsx("text",{x:"-0.35",y:"0.5",children:"4"})})}),e.jsx("g",{id:"score-token-def-n5",className:"token",children:e.jsx("g",{className:"number",children:e.jsx("text",{x:"-0.35",y:"0.5",children:"5"})})}),e.jsx("g",{id:"score-token-def-n6",className:"token",children:e.jsx("g",{className:"number",children:e.jsx("text",{x:"-0.35",y:"0.5",children:"6"})})}),e.jsx("g",{id:"score-token-def-n7",className:"token",children:e.jsx("g",{className:"number",children:e.jsx("text",{x:"-0.35",y:"0.5",children:"7"})})}),e.jsx("g",{id:"score-token-def-n8",className:"token",children:e.jsx("g",{className:"number",children:e.jsx("text",{x:"-0.35",y:"0.5",children:"8"})})}),e.jsx("g",{id:"score-token-def-n9",className:"token",children:e.jsx("g",{className:"number",children:e.jsx("text",{x:"-0.35",y:"0.5",children:"9"})})}),e.jsx("g",{id:"score-token-def-accidentals-sharp",className:"token",children:e.jsx("text",{x:"-0.55",children:""})}),e.jsx("g",{id:"score-token-def-accidentals-doublesharp",className:"token",children:e.jsx("text",{x:"-0.5",children:""})}),e.jsx("g",{id:"score-token-def-accidentals-natural",className:"token",children:e.jsx("text",{x:"-0.3",children:""})}),e.jsx("g",{id:"score-token-def-accidentals-flat",className:"token",children:e.jsx("text",{x:"-0.3",children:""})}),e.jsx("g",{id:"score-token-def-accidentals-flatflat",className:"token",children:e.jsx("text",{x:"-0.5",children:""})}),e.jsxs("g",{id:"score-token-def-key-sharp",className:"token",children:[e.jsx("text",{x:"-0.55",children:""}),e.jsx("line",{x1:"-1",x2:"-1",y1:"-1",y2:"1",stroke:"black",strokeWidth:"0.08"})]}),e.jsxs("g",{id:"score-token-def-key-natural",className:"token",children:[e.jsx("text",{x:"-0.3",children:""}),e.jsx("line",{x1:"-1",x2:"-1",y1:"-1",y2:"1",stroke:"black",strokeWidth:"0.08"})]}),e.jsxs("g",{id:"score-token-def-key-flat",className:"token",children:[e.jsx("text",{x:"-0.3",children:""}),e.jsx("line",{x1:"-1",x2:"-1",y1:"-1",y2:"1",stroke:"black",strokeWidth:"0.08"})]}),e.jsx("g",{id:"score-token-def-noteheads-s0",className:"token",children:e.jsx("text",{x:"-0.913",children:""})}),e.jsx("g",{id:"score-token-def-noteheads-s1",className:"token",children:e.jsx("text",{x:"-0.632",children:""})}),e.jsx("g",{id:"score-token-def-noteheads-s2",className:"token",children:e.jsx("text",{x:"-0.599",children:""})}),e.jsxs("g",{id:"score-token-def-noteheads-s1-u",className:"token",children:[e.jsx("text",{x:"-1.264",children:""}),e.jsx("line",{x1:"0",x2:"0",y1:"-0.06",y2:"-3.5",stroke:"currentColor",strokeWidth:"0.12",strokeLinecap:"round",className:"stem"})]}),e.jsxs("g",{id:"score-token-def-noteheads-s2-u",className:"token",children:[e.jsx("text",{x:"-1.198",children:""}),e.jsx("line",{x1:"0",x2:"0",y1:"-0.06",y2:"-3.5",stroke:"currentColor",strokeWidth:"0.12",strokeLinecap:"round",className:"stem"})]}),e.jsxs("g",{id:"score-token-def-noteheads-s1-d",className:"token",children:[e.jsx("text",{children:""}),e.jsx("line",{x1:"0",x2:"0",y1:"0.16",y2:"3.5",stroke:"currentColor",strokeWidth:"0.12",strokeLinecap:"round",className:"stem"})]}),e.jsxs("g",{id:"score-token-def-noteheads-s2-d",className:"token",children:[e.jsx("text",{children:""}),e.jsx("line",{x1:"0",x2:"0",y1:"0.16",y2:"3.5",stroke:"currentColor",strokeWidth:"0.12",strokeLinecap:"round",className:"stem"})]}),e.jsx("g",{id:"score-token-def-rests-M1",className:"token",children:e.jsx("text",{x:"-0.75",y:"-1",children:""})}),e.jsx("g",{id:"score-token-def-rests-0",className:"token",children:e.jsx("text",{x:"-0.75",y:"-1",children:""})}),e.jsx("g",{id:"score-token-def-rests-0o",className:"token",children:e.jsx("text",{x:"-0.75",y:"-1",children:""})}),e.jsx("g",{id:"score-token-def-rests-1o",className:"token",children:e.jsx("text",{x:"-0.75",y:"0",children:""})}),e.jsx("g",{id:"score-token-def-rests-2",className:"token",children:e.jsx("text",{x:"-0.5",children:""})}),e.jsx("g",{id:"score-token-def-rests-3",className:"token",children:e.jsx("text",{x:"-0.5",children:""})}),e.jsx("g",{id:"score-token-def-rests-4",className:"token",children:e.jsx("text",{x:"-0.5",children:""})}),e.jsx("g",{id:"score-token-def-rests-5",className:"token",children:e.jsx("text",{x:"-0.5",children:""})}),e.jsx("g",{id:"score-token-def-rests-6",className:"token",children:e.jsx("text",{x:"-0.5",children:""})}),e.jsx("g",{id:"score-token-def-flags-u3",className:"token",children:e.jsx("text",{children:""})}),e.jsx("g",{id:"score-token-def-flags-u4",className:"token",children:e.jsx("text",{children:""})}),e.jsx("g",{id:"score-token-def-flags-u5",className:"token",children:e.jsx("text",{children:""})}),e.jsx("g",{id:"score-token-def-flags-u6",className:"token",children:e.jsx("text",{children:""})}),e.jsx("g",{id:"score-token-def-flags-u7",className:"token",children:e.jsx("text",{children:""})}),e.jsx("g",{id:"score-token-def-flags-u8",className:"token",children:e.jsx("text",{children:""})}),e.jsx("g",{id:"score-token-def-slur-begin",className:"token",children:e.jsx("path",{d:"M0 0C0.5 -0.5 1 -0.6 1.5 -0.6L1.5 -0.4C1 -0.4 0.5 -0.4 0 0z"})}),e.jsx("g",{id:"score-token-def-slur-end",className:"token",children:e.jsx("path",{d:"M0 0C-0.5 -0.5 -1 -0.6 -1.5 -0.6L-1.5 -0.4C-1 -0.4 -0.5 -0.4 0 0z"})}),e.jsxs("g",{id:"score-token-def-volta-left",className:"token",children:[e.jsx("text",{x:"-0.25",y:"-0.5",children:""}),e.jsx("text",{x:"-0.25",y:"0.5",children:""}),e.jsx("line",{x1:"-0.5",x2:"-0.5",y1:"-2",y2:"2"})]}),e.jsxs("g",{id:"score-token-def-volta-right",className:"token",children:[e.jsx("text",{x:"-0.25",y:"-0.5",children:""}),e.jsx("text",{x:"-0.25",y:"0.5",children:""}),e.jsx("line",{x1:"0.5",x2:"0.5",y1:"-2",y2:"2"})]}),e.jsxs("g",{id:"score-token-def-bar-terminal",className:"token",children:[e.jsx("rect",{x:"-0.064",y:"-2",width:"0.128",height:"4"}),e.jsx("rect",{x:"0.27",y:"-2",width:"0.4",height:"4"})]}),e.jsxs("g",{id:"score-token-def-bar-segment",className:"token",children:[e.jsx("rect",{x:"-0.359",y:"-2",width:"0.128",height:"4"}),e.jsx("rect",{x:"0.231",y:"-2",width:"0.128",height:"4"})]}),e.jsx("g",{id:"score-token-def-dot",className:"token",children:e.jsx("text",{children:""})}),e.jsxs("g",{id:"score-token-def-dotdot",className:"token",children:[e.jsx("text",{children:""}),e.jsx("text",{x:"0.8",children:""})]}),e.jsx("g",{id:"score-token-def-f",className:"token",children:e.jsx("text",{x:"-0.6",y:"0.5",children:"f"})}),e.jsx("g",{id:"score-token-def-m",className:"token",children:e.jsx("text",{x:"-0.9",y:"0.5",children:"m"})}),e.jsx("g",{id:"score-token-def-n",className:"token",children:e.jsx("text",{x:"-0.9",y:"0.5",children:"n"})}),e.jsx("g",{id:"score-token-def-p",className:"token",children:e.jsx("text",{x:"-0.5",y:"0.5",children:"p"})}),e.jsx("g",{id:"score-token-def-r",className:"token",children:e.jsx("text",{x:"-0.5",y:"0.5",children:"r"})}),e.jsx("g",{id:"score-token-def-s",className:"token",children:e.jsx("text",{x:"-0.5",y:"0.5",children:"s"})}),e.jsx("g",{id:"score-token-def-z",className:"token",children:e.jsx("text",{x:"-0.5",y:"0.5",children:"z"})}),e.jsx("g",{id:"score-token-def-scripts-ufermata",className:"token",children:e.jsx("text",{children:""})}),e.jsx("g",{id:"score-token-def-scripts-ushortfermata",className:"token",children:e.jsx("text",{children:""})}),e.jsx("g",{id:"score-token-def-scripts-sforzato",className:"token",children:e.jsx("text",{children:""})}),e.jsx("g",{id:"score-token-def-scripts-staccato",className:"token",children:e.jsx("text",{children:""})}),e.jsx("g",{id:"score-token-def-scripts-ustaccatissimo",className:"token",children:e.jsx("text",{children:""})}),e.jsx("g",{id:"score-token-def-scripts-turn",className:"token",children:e.jsx("text",{children:""})}),e.jsx("g",{id:"score-token-def-scripts-trill",className:"token",children:e.jsx("text",{y:"0.5",children:""})}),e.jsx("g",{id:"score-token-def-scripts-segno",className:"token",children:e.jsx("text",{children:""})}),e.jsx("g",{id:"score-token-def-scripts-coda",className:"token",children:e.jsx("text",{children:""})}),e.jsx("g",{id:"score-token-def-scripts-arpeggio",className:"token",children:e.jsx("text",{x:"-0.5",y:"0.5",children:""})}),e.jsx("g",{id:"score-token-def-scripts-prall",className:"token",children:e.jsx("text",{children:""})}),e.jsx("g",{id:"score-token-def-scripts-mordent",className:"token",children:e.jsx("text",{children:""})}),e.jsx("g",{id:"score-token-def-scripts-umarcato",className:"token",children:e.jsx("text",{children:""})}),e.jsx("g",{id:"score-token-def-scripts-tenuto",className:"token",children:e.jsx("text",{children:""})}),e.jsx("g",{id:"score-token-def-scripts-uportato",className:"token",children:e.jsx("text",{children:""})}),e.jsx("g",{id:"score-token-def-pedal-star",className:"token",children:e.jsx("text",{x:"-0.78",y:"0.78",children:""})}),e.jsx("g",{id:"score-token-def-pedal-Ped",className:"token",children:e.jsx("text",{x:"-1.6",y:"0.7",children:""})}),e.jsx("g",{id:"score-token-def-BOS",className:"token",children:e.jsx("text",{x:"-3",y:"1.04",children:"▶"})}),e.jsx("g",{id:"score-token-def-BeamLeft",className:"token",children:e.jsx("text",{x:"-0.73",y:"0.66",className:"s-beam",children:"├"})}),e.jsx("g",{id:"score-token-def-BeamContinue",className:"token",children:e.jsx("text",{x:"-0.73",y:"0.66",className:"s-beam",children:"┼"})}),e.jsx("g",{id:"score-token-def-BeamRight",className:"token",children:e.jsx("text",{x:"-0.73",y:"0.66",className:"s-beam",children:"┤"})}),e.jsx("g",{id:"score-token-def-GraceNotehead",className:"token",children:e.jsx("text",{x:"-0.36",className:"s-grace",children:""})})]}),n=s.memo(t);export{n as S}; diff --git a/dist/assets/index-607e1f59.js b/dist/assets/index-35668a9a.js similarity index 92% rename from dist/assets/index-607e1f59.js rename to dist/assets/index-35668a9a.js index 4b79b65a49f0302ba9901b0b7c7fb3b21f7dd54c..bdab0f72a0c16a077ea7769fd238f67c4071cef0 100644 --- a/dist/assets/index-607e1f59.js +++ b/dist/assets/index-35668a9a.js @@ -1 +1 @@ -import{r as x,j as e,c as S,f as E}from"./umi-9940633e.js";import{T as F,S as V,a as W,r as Y,s as z,L as U}from"./index-1a249a16.js";import{a as I,v as q}from"./parser-9472c317.js";import{S as D}from"./scheduler-a7fa9c3c.js";import{u as _,r as G,n as H}from"./index-da8ccbdf.js";import{S as J}from"./schedulePool-cc4538c2.js";import{B as X}from"./button-eaadfeb4.js";import{S as K}from"./index-f5d9ea7b.js";import{p as Q}from"./index-d0e185c0.js";import{S as Z}from"./index-d3bdb233.js";import{u as ee}from"./useAsync-b9da6d72.js";import{a as te,P as se}from"./PlaySquareOutlined-646d1a37.js";import"./_setToString-98c064b8.js";import"./download-cbece843.js";import"./jszip.min-37f7e998.js";import"./useAsyncFn-b0803fd6.js";const ne=({translateX:p=0,translateY:y,width:m,additionalLines:s,...o})=>e.jsxs("g",{...o,className:"staff-lines",transform:`translate(${p}, ${y})`,children:[new Array(5).fill(null).map((i,n)=>e.jsx("line",{x1:0,x2:m,y1:n-2,y2:n-2},n)),s&&s.map((i,n)=>e.jsx("g",{children:Array(Math.abs(i.n)).fill(null).map((f,r)=>e.jsx("line",{x1:i.left,x2:i.right,y1:i.n>0?3+r:-3-r,y2:i.n>0?3+r:-3-r},r))},n))]}),re=x.memo(ne),O=({score:p,page:y,pageIndex:m,system:s,systemIndex:o,staff:i,staffIndex:n})=>{var f;return e.jsx(e.Fragment,{children:e.jsxs("g",{className:S("staff",{moving:!1}),transform:`translate(0, ${i.top})`,children:[e.jsxs("g",{children:[e.jsx(re,{translateY:i.staffY,width:s.width,additionalLines:i.additionalLines}),(f=i==null?void 0:i.measures)==null?void 0:f.map((r,c)=>{var t;return e.jsxs("g",{children:[n===0&&e.jsx("text",{x:r.left,y:Math.min(5,i.staffY-3),fontSize:c===0?1.4:.9,fill:"#e65019",children:s.headMeasureIndex+c+1}),e.jsx("g",{transform:`translate(0, ${i.staffY})`,children:e.jsx("g",{className:"tokens",children:(t=r==null?void 0:r.tokens)==null?void 0:t.filter(a=>F.includes(a.type)).map((a,l)=>e.jsxs("g",{className:S("token",{}),transform:`translate(${a.x}, ${a.y})`,id:a.id,onClick:()=>console.log(a),children:[a.voice?e.jsxs("title",{children:["voice-",a.voiceIndices.join(",")]}):null,e.jsx("use",{xlinkHref:`#score-token-def-${a.typeId}`})]},l))})})]},c)})]}),e.jsx("g",{className:"measure-bars",children:s.measureBars.map((r,c)=>e.jsx("g",{className:S("measure-bar"),transform:`translate(${r}, ${i.staffY-2})`,children:e.jsx("line",{x1:0,x2:0,y1:0,y2:4})},c))})]})})};x.memo(O);const ae=p=>{var n,f;const{score:y,pageIndex:m,system:s,systemIndex:o}=p;if(s.staves.length===0)return e.jsx("g",{},o);const i=Q(y.staffLayoutCode);return e.jsxs("g",{className:S("system",{}),transform:`translate(${s.left}, ${s.top})`,children:[s.backgroundImage&&!((n=s.staves[0])!=null&&n.backgroundImage)&&!((f=s.staves[0])!=null&&f.maskImage)&&e.jsx("image",{className:"background",href:s.backgroundImage,...s.imagePosition||{}}),s.staves.length>=2&&e.jsx("line",{className:"connection",x1:0,x2:0,y1:s.connectionLine.top,y2:s.connectionLine.bottom}),s.staves.map((r,c)=>e.jsxs("g",{className:S("staff"),transform:`translate(0, ${r.top})`,children:[!r.maskImage&&r.backgroundImage&&e.jsx("image",{className:"background",href:r.backgroundImage,...r.imagePosition||{}}),r.maskImage&&e.jsx("image",{className:"background",href:r.maskImage,...r.imagePosition||{}})]},"staff-"+c)),s.staves.map((r,c)=>e.jsx(O,{...p,staff:r,staffIndex:c},c)),e.jsx("g",{className:"measure-bars",children:s.measureBars.map((r,c)=>e.jsx("g",{transform:`translate(${r}, 0)`,children:i.mask(s.staffMask).conjunctions.map((t,a)=>{const l=s.staves[a],d=s.staves[a+1];if(l&&d)return e.jsx("g",{transform:`translate(0, ${l.top+l.staffY+2})`,children:e.jsx("line",{className:S("staff-layout-measure-bar",{dashed:t===1,blank:t===0}),x1:"0",x2:"0",y1:0,y2:d.top+d.staffY-(l.top+l.staffY)-4})},a)})},c))}),e.jsx(K,{layout:i.mask(s.staffMask),positions:s.staffPositions,nameDict:(!s.prev||s.staffMask!==s.prev.staffMask)&&y.instrumentDict})]},o)},oe=x.memo(ae),ie=({score:p,pageIndex:y,cursorPosition:m,onSeekPosition:s})=>{var f,r,c;const o=p.pages[y],i=x.useRef(null);if(!o)return null;const n=x.useMemo(()=>{let t=0;if(m){let a=0;for(const[l,d]of p.pages.entries()){if(m.system>=a-1&&m.system{i.current&&i.current.scrollIntoView({block:"center",behavior:"smooth"})},[i.current,n]),e.jsx("div",{children:e.jsxs("svg",{className:S("graph",{}),style:{objectFit:"contain"},viewBox:`0 0 ${o.width} ${o.height}`,children:[e.jsx(Z,{}),(f=o==null?void 0:o.systems)==null?void 0:f.map((t,a)=>e.jsx(oe,{score:p,page:o,pageIndex:y,system:t,systemIndex:a},a)),(o==null?void 0:o.semantics)&&e.jsx("g",{children:(r=o==null?void 0:o.semantics)==null?void 0:r.map((t,a)=>{var l,d,b,v,k,w;if(t.semantic===V.rect_Text)return e.jsx("g",{transform:`translate(${t.x}, ${t.y}) ${(l=t.extension)!=null&&l.theta?`rotate(${((d=t.extension)==null?void 0:d.theta)*180/Math.PI})`:""}`,color:"rgba(25, 175, 230, 0.6)",children:e.jsxs("text",{dominantBaseline:"hanging",x:0,y:-((b=t.extension)==null?void 0:b.height)/2,textAnchor:"middle",style:{fontSize:(v=t.extension)==null?void 0:v.height},children:[(k=t.extension)==null?void 0:k.text,e.jsx("title",{children:((w=t.extension)==null?void 0:w.type)||t.semantic})]})},a)})}),(o==null?void 0:o.tokens)&&e.jsx("g",{children:(c=o==null?void 0:o.tokens)==null?void 0:c.map((t,a)=>{if(t.type===W.Text)return e.jsx("g",{transform:`translate(${t.x}, ${t.y})`,color:"rgba(25, 175, 230, 0.6)",className:"token",children:e.jsxs("text",{dominantBaseline:"hanging",x:0,y:-t.fontSize/2,textAnchor:"middle",style:{fontSize:t.fontSize},className:S(t.textType),children:[t.text,e.jsx("title",{children:t.textType})]})},a)})}),o.systems.map((t,a)=>{const l=p.pages.slice(0,y).reduce((d,b)=>d+b.systems.length,0)+a;return e.jsxs("g",{className:S("system"),transform:`translate(${t.left}, ${t.top})`,children:[e.jsx("rect",{style:{opacity:0},x:0,y:t.noteRange.top,width:t.width,height:t.noteRange.bottom-t.noteRange.top,onClick:d=>{const b=d.target,v=b.getBoundingClientRect(),k=d.clientX-v.left,w=b.getBBox(),g=k/v.width*w.width;s({system:l,x:g})}}),(m==null?void 0:m.system)===l?e.jsx("line",{ref:i,transform:`translate(${m.x}, 0)`,x1:0,x2:0,y1:t.noteRange.top,y2:t.noteRange.bottom,style:{stroke:"lightblue",strokeWidth:1}}):null]},a)})]})})},le=x.memo(ie),ce=p=>{var w;const y=_(),m=E(),s=x.useRef(new J(performance)),[o,i]=x.useState(),n=x.useRef(null),f=x.useRef(null),[r,c]=x.useState(!1),[t,a]=x.useState(!1),l=ee(async()=>{var j,$,N,M;const g=(m==null?void 0:m.id)||(($=(j=p==null?void 0:p.match)==null?void 0:j.params)==null?void 0:$.id),u=await G.get(`/api/musicSets/${g}`);if((N=u==null?void 0:u.content)!=null&&N.scoreURL){const B=await(await fetch(H(u.content.scoreURL))).json(),T=Y(B,z);return T.assemble(((M=T.settings)==null?void 0:M.semanticConfidenceThreshold)??1),T}return u},[]);x.useEffect(()=>{I.WebAudio.empty()&&I.loadPlugin({soundfontUrl:"/soundfont/",api:"webaudio"}).then(()=>{a(!0),console.debug("Soundfont loaded.")}),k()},[]);const d=x.useCallback(async g=>{if(!n.current){console.log("please create midi player first");return}const u=n.current.isPlaying;u&&(n.current.pause(),await new Promise(j=>setTimeout(j,0)),document.querySelectorAll(".notePlayOn").forEach(j=>j.classList.remove("notePlayOn"))),n.current.progressTicks=f.current.lookupTick(g),u&&v()},[]),b=async()=>{var g,u,j,$;(u=(g=I.WebAudio).needsWarmup)!=null&&u.call(g)&&await(($=(j=I.WebAudio).awaitWarmup)==null?void 0:$.call(j))},v=async()=>{var g;(g=n.current)!=null&&g.isPlaying?(n.current.pause(),c(!1)):(await b(),k(),n.current.play({nextFrame:()=>(f.current&&i(f.current.lookupPosition(n.current.progressTicks)),new Promise(u=>requestAnimationFrame(()=>u())))}),c(!0))},k=()=>{var B,T;if(!((T=(B=l.value)==null?void 0:B.systems)!=null&&T.length))return;const{notation:g,tokenMap:u}=l.value.spartito.perform(),j=l.value.getMeasureLayout(),$=j?j.serialize(U.Full):Array(g.measures.length).fill(null).map((h,L)=>L+1),N=g.toPerformingNotationWithEvents($);Math.round(6e7/N.tempos[0].tempo),f.current=D.createFromNotation(N,u);const M=n.current?n.current.progressTicks:0;n.current&&n.current.dispose(),n.current=new q(N,{cacheSpan:200,onMidi:(h,L)=>{let A=null;switch(h.subtype){case"noteOn":I.noteOn(h.channel,h.noteNumber,h.velocity,L),A=()=>{var P;return(P=h==null?void 0:h.ids)==null?void 0:P.map(C=>{const R=document.getElementById(C);R&&R.classList.add("notePlayOn")})};break;case"noteOff":I.noteOff(h.channel,h.noteNumber,L),A=()=>{var P;return(P=h==null?void 0:h.ids)==null?void 0:P.map(C=>{const R=document.getElementById(C);R&&R.classList.remove("notePlayOn")})};break}A&&s.current.appendTask(L,A)},onPlayFinish(){n.current&&(n.current.progressTicks=0),c(!1)},onTurnCursor(){n.current&&f.current&&i(f.current.lookupPosition(n.current.progressTicks))}}),n.current.progressTicks=M};return e.jsxs("div",{className:"viewer",children:[e.jsx(X,{style:{position:"fixed",top:"10px",left:"10px"},icon:r?e.jsx(te,{}):e.jsx(se,{}),onClick:v,disabled:!((w=l.value)!=null&&w.spartito)||!t,children:r?y.formatMessage({id:"common.pause"}):y.formatMessage({id:"common.play"})}),!l.loading&&l.value.pages.map((g,u)=>e.jsx(le,{score:l.value,pageIndex:u,cursorPosition:o,onSeekPosition:d},u))]})},Ne=x.memo(ce);export{Ne as default}; +import{r as x,j as e,c as S,f as E}from"./umi-a12c8253.js";import{T as F,S as V,a as W,r as Y,s as z,L as U}from"./index-43517c6d.js";import{a as I,v as q}from"./parser-b66b074b.js";import{S as D}from"./scheduler-a7fa9c3c.js";import{u as _,r as G,n as H}from"./index-5722ce0d.js";import{S as J}from"./schedulePool-cc4538c2.js";import{B as X}from"./button-f56a19a0.js";import{S as K}from"./index-02e1374a.js";import{p as Q}from"./index-ead1f686.js";import{S as Z}from"./index-1d8a15fd.js";import{u as ee}from"./useAsync-4e4b92b3.js";import{a as te,P as se}from"./PlaySquareOutlined-1144cdf9.js";import"./_setToString-ca5ad23e.js";import"./download-ef7cdf5d.js";import"./jszip.min-f65a05ae.js";import"./useAsyncFn-b4ac32aa.js";const ne=({translateX:p=0,translateY:y,width:m,additionalLines:s,...o})=>e.jsxs("g",{...o,className:"staff-lines",transform:`translate(${p}, ${y})`,children:[new Array(5).fill(null).map((i,n)=>e.jsx("line",{x1:0,x2:m,y1:n-2,y2:n-2},n)),s&&s.map((i,n)=>e.jsx("g",{children:Array(Math.abs(i.n)).fill(null).map((f,r)=>e.jsx("line",{x1:i.left,x2:i.right,y1:i.n>0?3+r:-3-r,y2:i.n>0?3+r:-3-r},r))},n))]}),re=x.memo(ne),O=({score:p,page:y,pageIndex:m,system:s,systemIndex:o,staff:i,staffIndex:n})=>{var f;return e.jsx(e.Fragment,{children:e.jsxs("g",{className:S("staff",{moving:!1}),transform:`translate(0, ${i.top})`,children:[e.jsxs("g",{children:[e.jsx(re,{translateY:i.staffY,width:s.width,additionalLines:i.additionalLines}),(f=i==null?void 0:i.measures)==null?void 0:f.map((r,c)=>{var t;return e.jsxs("g",{children:[n===0&&e.jsx("text",{x:r.left,y:Math.min(5,i.staffY-3),fontSize:c===0?1.4:.9,fill:"#e65019",children:s.headMeasureIndex+c+1}),e.jsx("g",{transform:`translate(0, ${i.staffY})`,children:e.jsx("g",{className:"tokens",children:(t=r==null?void 0:r.tokens)==null?void 0:t.filter(a=>F.includes(a.type)).map((a,l)=>e.jsxs("g",{className:S("token",{}),transform:`translate(${a.x}, ${a.y})`,id:a.id,onClick:()=>console.log(a),children:[a.voice?e.jsxs("title",{children:["voice-",a.voiceIndices.join(",")]}):null,e.jsx("use",{xlinkHref:`#score-token-def-${a.typeId}`})]},l))})})]},c)})]}),e.jsx("g",{className:"measure-bars",children:s.measureBars.map((r,c)=>e.jsx("g",{className:S("measure-bar"),transform:`translate(${r}, ${i.staffY-2})`,children:e.jsx("line",{x1:0,x2:0,y1:0,y2:4})},c))})]})})};x.memo(O);const ae=p=>{var n,f;const{score:y,pageIndex:m,system:s,systemIndex:o}=p;if(s.staves.length===0)return e.jsx("g",{},o);const i=Q(y.staffLayoutCode);return e.jsxs("g",{className:S("system",{}),transform:`translate(${s.left}, ${s.top})`,children:[s.backgroundImage&&!((n=s.staves[0])!=null&&n.backgroundImage)&&!((f=s.staves[0])!=null&&f.maskImage)&&e.jsx("image",{className:"background",href:s.backgroundImage,...s.imagePosition||{}}),s.staves.length>=2&&e.jsx("line",{className:"connection",x1:0,x2:0,y1:s.connectionLine.top,y2:s.connectionLine.bottom}),s.staves.map((r,c)=>e.jsxs("g",{className:S("staff"),transform:`translate(0, ${r.top})`,children:[!r.maskImage&&r.backgroundImage&&e.jsx("image",{className:"background",href:r.backgroundImage,...r.imagePosition||{}}),r.maskImage&&e.jsx("image",{className:"background",href:r.maskImage,...r.imagePosition||{}})]},"staff-"+c)),s.staves.map((r,c)=>e.jsx(O,{...p,staff:r,staffIndex:c},c)),e.jsx("g",{className:"measure-bars",children:s.measureBars.map((r,c)=>e.jsx("g",{transform:`translate(${r}, 0)`,children:i.mask(s.staffMask).conjunctions.map((t,a)=>{const l=s.staves[a],d=s.staves[a+1];if(l&&d)return e.jsx("g",{transform:`translate(0, ${l.top+l.staffY+2})`,children:e.jsx("line",{className:S("staff-layout-measure-bar",{dashed:t===1,blank:t===0}),x1:"0",x2:"0",y1:0,y2:d.top+d.staffY-(l.top+l.staffY)-4})},a)})},c))}),e.jsx(K,{layout:i.mask(s.staffMask),positions:s.staffPositions,nameDict:(!s.prev||s.staffMask!==s.prev.staffMask)&&y.instrumentDict})]},o)},oe=x.memo(ae),ie=({score:p,pageIndex:y,cursorPosition:m,onSeekPosition:s})=>{var f,r,c;const o=p.pages[y],i=x.useRef(null);if(!o)return null;const n=x.useMemo(()=>{let t=0;if(m){let a=0;for(const[l,d]of p.pages.entries()){if(m.system>=a-1&&m.system{i.current&&i.current.scrollIntoView({block:"center",behavior:"smooth"})},[i.current,n]),e.jsx("div",{children:e.jsxs("svg",{className:S("graph",{}),style:{objectFit:"contain"},viewBox:`0 0 ${o.width} ${o.height}`,children:[e.jsx(Z,{}),(f=o==null?void 0:o.systems)==null?void 0:f.map((t,a)=>e.jsx(oe,{score:p,page:o,pageIndex:y,system:t,systemIndex:a},a)),(o==null?void 0:o.semantics)&&e.jsx("g",{children:(r=o==null?void 0:o.semantics)==null?void 0:r.map((t,a)=>{var l,d,b,v,k,w;if(t.semantic===V.rect_Text)return e.jsx("g",{transform:`translate(${t.x}, ${t.y}) ${(l=t.extension)!=null&&l.theta?`rotate(${((d=t.extension)==null?void 0:d.theta)*180/Math.PI})`:""}`,color:"rgba(25, 175, 230, 0.6)",children:e.jsxs("text",{dominantBaseline:"hanging",x:0,y:-((b=t.extension)==null?void 0:b.height)/2,textAnchor:"middle",style:{fontSize:(v=t.extension)==null?void 0:v.height},children:[(k=t.extension)==null?void 0:k.text,e.jsx("title",{children:((w=t.extension)==null?void 0:w.type)||t.semantic})]})},a)})}),(o==null?void 0:o.tokens)&&e.jsx("g",{children:(c=o==null?void 0:o.tokens)==null?void 0:c.map((t,a)=>{if(t.type===W.Text)return e.jsx("g",{transform:`translate(${t.x}, ${t.y})`,color:"rgba(25, 175, 230, 0.6)",className:"token",children:e.jsxs("text",{dominantBaseline:"hanging",x:0,y:-t.fontSize/2,textAnchor:"middle",style:{fontSize:t.fontSize},className:S(t.textType),children:[t.text,e.jsx("title",{children:t.textType})]})},a)})}),o.systems.map((t,a)=>{const l=p.pages.slice(0,y).reduce((d,b)=>d+b.systems.length,0)+a;return e.jsxs("g",{className:S("system"),transform:`translate(${t.left}, ${t.top})`,children:[e.jsx("rect",{style:{opacity:0},x:0,y:t.noteRange.top,width:t.width,height:t.noteRange.bottom-t.noteRange.top,onClick:d=>{const b=d.target,v=b.getBoundingClientRect(),k=d.clientX-v.left,w=b.getBBox(),g=k/v.width*w.width;s({system:l,x:g})}}),(m==null?void 0:m.system)===l?e.jsx("line",{ref:i,transform:`translate(${m.x}, 0)`,x1:0,x2:0,y1:t.noteRange.top,y2:t.noteRange.bottom,style:{stroke:"lightblue",strokeWidth:1}}):null]},a)})]})})},le=x.memo(ie),ce=p=>{var w;const y=_(),m=E(),s=x.useRef(new J(performance)),[o,i]=x.useState(),n=x.useRef(null),f=x.useRef(null),[r,c]=x.useState(!1),[t,a]=x.useState(!1),l=ee(async()=>{var j,$,N,M;const g=(m==null?void 0:m.id)||(($=(j=p==null?void 0:p.match)==null?void 0:j.params)==null?void 0:$.id),u=await G.get(`/api/musicSets/${g}`);if((N=u==null?void 0:u.content)!=null&&N.scoreURL){const B=await(await fetch(H(u.content.scoreURL))).json(),T=Y(B,z);return T.assemble(((M=T.settings)==null?void 0:M.semanticConfidenceThreshold)??1),T}return u},[]);x.useEffect(()=>{I.WebAudio.empty()&&I.loadPlugin({soundfontUrl:"/soundfont/",api:"webaudio"}).then(()=>{a(!0),console.debug("Soundfont loaded.")}),k()},[]);const d=x.useCallback(async g=>{if(!n.current){console.log("please create midi player first");return}const u=n.current.isPlaying;u&&(n.current.pause(),await new Promise(j=>setTimeout(j,0)),document.querySelectorAll(".notePlayOn").forEach(j=>j.classList.remove("notePlayOn"))),n.current.progressTicks=f.current.lookupTick(g),u&&v()},[]),b=async()=>{var g,u,j,$;(u=(g=I.WebAudio).needsWarmup)!=null&&u.call(g)&&await(($=(j=I.WebAudio).awaitWarmup)==null?void 0:$.call(j))},v=async()=>{var g;(g=n.current)!=null&&g.isPlaying?(n.current.pause(),c(!1)):(await b(),k(),n.current.play({nextFrame:()=>(f.current&&i(f.current.lookupPosition(n.current.progressTicks)),new Promise(u=>requestAnimationFrame(()=>u())))}),c(!0))},k=()=>{var B,T;if(!((T=(B=l.value)==null?void 0:B.systems)!=null&&T.length))return;const{notation:g,tokenMap:u}=l.value.spartito.perform(),j=l.value.getMeasureLayout(),$=j?j.serialize(U.Full):Array(g.measures.length).fill(null).map((h,L)=>L+1),N=g.toPerformingNotationWithEvents($);Math.round(6e7/N.tempos[0].tempo),f.current=D.createFromNotation(N,u);const M=n.current?n.current.progressTicks:0;n.current&&n.current.dispose(),n.current=new q(N,{cacheSpan:200,onMidi:(h,L)=>{let A=null;switch(h.subtype){case"noteOn":I.noteOn(h.channel,h.noteNumber,h.velocity,L),A=()=>{var P;return(P=h==null?void 0:h.ids)==null?void 0:P.map(C=>{const R=document.getElementById(C);R&&R.classList.add("notePlayOn")})};break;case"noteOff":I.noteOff(h.channel,h.noteNumber,L),A=()=>{var P;return(P=h==null?void 0:h.ids)==null?void 0:P.map(C=>{const R=document.getElementById(C);R&&R.classList.remove("notePlayOn")})};break}A&&s.current.appendTask(L,A)},onPlayFinish(){n.current&&(n.current.progressTicks=0),c(!1)},onTurnCursor(){n.current&&f.current&&i(f.current.lookupPosition(n.current.progressTicks))}}),n.current.progressTicks=M};return e.jsxs("div",{className:"viewer",children:[e.jsx(X,{style:{position:"fixed",top:"10px",left:"10px"},icon:r?e.jsx(te,{}):e.jsx(se,{}),onClick:v,disabled:!((w=l.value)!=null&&w.spartito)||!t,children:r?y.formatMessage({id:"common.pause"}):y.formatMessage({id:"common.play"})}),!l.loading&&l.value.pages.map((g,u)=>e.jsx(le,{score:l.value,pageIndex:u,cursorPosition:o,onSeekPosition:d},u))]})},Ne=x.memo(ce);export{Ne as default}; diff --git a/dist/assets/index-1b65ca98.js b/dist/assets/index-40bfaf7c.js similarity index 96% rename from dist/assets/index-1b65ca98.js rename to dist/assets/index-40bfaf7c.js index 2636b69e3aa4207f8f4b6639adb923bcf05d278e..599513dc12ff9e4fa782e3845a54848d9409dea0 100644 --- a/dist/assets/index-1b65ca98.js +++ b/dist/assets/index-40bfaf7c.js @@ -1 +1 @@ -import{bn as D,a8 as L,g as M,r as c,C as H,d as _,a as U,B as V,c as E,b as x}from"./umi-9940633e.js";import{n as A,t as X,o as q,i as k,c as w}from"./_setToString-98c064b8.js";var G=/\s/;function J(e){for(var n=e.length;n--&&G.test(e.charAt(n)););return n}var K=J,Q=K,Y=/^\s+/;function Z(e){return e&&e.slice(0,Q(e)+1).replace(Y,"")}var ee=Z,ne=ee,R=A,te=D,W=0/0,re=/^[-+]0x[0-9a-f]+$/i,ae=/^0b[01]+$/i,ie=/^0o[0-7]+$/i,se=parseInt;function ce(e){if(typeof e=="number")return e;if(te(e))return W;if(R(e)){var n=typeof e.valueOf=="function"?e.valueOf():e;e=R(n)?n+"":n}if(typeof e!="string")return e===0?e:+e;e=ne(e);var t=ae.test(e);return t||ie.test(e)?se(e.slice(2),t?2:8):re.test(e)?W:+e}var oe=ce,le=L,ue=function(){return le.Date.now()},de=ue,me=A,j=de,z=oe,fe="Expected a function",ve=Math.max,pe=Math.min;function ge(e,n,t){var r,i,o,l,s,u,m=0,h=!1,g=!1,y=!0;if(typeof e!="function")throw new TypeError(fe);n=z(n)||0,me(t)&&(h=!!t.leading,g="maxWait"in t,o=g?ve(z(t.maxWait)||0,n):o,y="trailing"in t?!!t.trailing:y);function C(a){var d=r,p=i;return r=i=void 0,m=a,l=e.apply(p,d),l}function O(a){return m=a,s=setTimeout(b,n),h?C(a):l}function T(a){var d=a-u,p=a-m,S=n-d;return g?pe(S,o-p):S}function N(a){var d=a-u,p=a-m;return u===void 0||d>=n||d<0||g&&p>=o}function b(){var a=j();if(N(a))return I(a);s=setTimeout(b,T(a))}function I(a){return s=void 0,y&&r?C(a):(r=i=void 0,l)}function $(){s!==void 0&&clearTimeout(s),m=0,r=u=i=s=void 0}function f(){return s===void 0?l:I(j())}function v(){var a=j(),d=N(a);if(r=arguments,i=this,u=a,d){if(s===void 0)return O(u);if(g)return clearTimeout(s),s=setTimeout(b,n),C(u)}return s===void 0&&(s=setTimeout(b,n)),l}return v.cancel=$,v.flush=f,v}var Ne=ge;const ye=M(Ne);var be=globalThis&&globalThis.__rest||function(e,n){var t={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&n.indexOf(r)<0&&(t[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(e);i=n||d<0||g&&p>=o}function b(){var a=j();if(N(a))return I(a);s=setTimeout(b,T(a))}function I(a){return s=void 0,y&&r?C(a):(r=i=void 0,l)}function $(){s!==void 0&&clearTimeout(s),m=0,r=u=i=s=void 0}function f(){return s===void 0?l:I(j())}function v(){var a=j(),d=N(a);if(r=arguments,i=this,u=a,d){if(s===void 0)return O(u);if(g)return clearTimeout(s),s=setTimeout(b,n),C(u)}return s===void 0&&(s=setTimeout(b,n)),l}return v.cancel=$,v.flush=f,v}var Ne=ge;const ye=M(Ne);var be=globalThis&&globalThis.__rest||function(e,n){var t={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&n.indexOf(r)<0&&(t[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(e);i{const o=e[a],c=e[a+1]?e[a+1]-o:0,d=t.filter(l=>l.measure===a+1).map(l=>({tick:l.startTick-o,duration:l.endTick-l.startTick,...pick(l,COMMON_NOTE_FIELDS),subNotes:[]}));return d.forEach(l=>["rest","tied","implicitType","afterGrace"].forEach(u=>{l[u]||delete l[u]})),{tick:o,duration:c,notes:d}}),n.idTrackMap=t.reduce((r,a)=>(a.id&&(r[a.id]=a.track),r),{}),n}static performAbsoluteNotes(t,{withRestTied:e=!1}={}){const n=t.filter(r=>(e||!r.rest&&!r.tied)&&!r.overlapped).map(r=>({measure:r.measure,channel:r.channel,track:r.track,start:r.start,startTick:r.startTick,endTick:r.endTick,pitch:r.pitch,duration:r.duration,velocity:r.velocity||127,id:r.id,ids:r.ids,staffTrack:r.staffTrack,contextIndex:r.contextIndex,implicitType:r.implicitType,chordPosition:r.chordPosition})).reduce((r,a)=>{const o=`${a.channel}|${a.start}|${a.pitch}`,c=r[o];return c?c.ids.push(...a.ids):r[o]=a,r},{});return Object.values(n)}constructor(t){t&&Object.assign(this,t)}get trackTickBias(){const t=this.measures[0];return this.trackNames.reduce((e,i,n)=>{if(e[i]=0,t){const r=t.notes.find(a=>a.track===n);r&&(e[i]=Math.min(r.tick,0))}return e},{})}get idSet(){return this.measures.reduce((t,e)=>(e.notes.filter(i=>!i.rest).forEach(i=>i.ids.forEach(n=>t.add(n))),t),new Set)}toJSON(){return{__prototype:"LilyNotation",measures:this.measures,idTrackMap:this.idTrackMap,trackNames:this.trackNames,ripe:this.ripe}}toAbsoluteNotes(t){let e=0;const i=t.map(n=>{const r=this.measures[n-1];console.assert(!!r,"invalid measure index:",n,this.measures.length);const a=r.notes.map(o=>({startTick:e+o.tick,endTick:e+o.tick+o.duration,start:e+o.tick,duration:o.duration,measure:n,...pick(o,COMMON_NOTE_FIELDS)}));return e+=r.duration,a});return[].concat(...i)}toPerformingNotation(t,e={}){const i=this.toAbsoluteNotes(t),n=MetaNotation.performAbsoluteNotes(i,e),r=Math.max(...n.map(c=>c.start+c.duration)),a=t.reduce((c,d)=>c+this.measures[d-1].duration,0);return new xt.Notation({ticksPerBeat:TICKS_PER_BEAT,meta:{},tempos:[],channels:[n],endTime:r,endTick:a})}toPerformingMIDI(t,{trackList:e}={}){var d,l;if(!t.length)return null;const i=-Math.min(0,...((d=this.measures[0])==null?void 0:d.events.map(u=>u.ticks))||[],...((l=this.measures[0])==null?void 0:l.notes.map(u=>u.tick))||[]);let n=i;const r=t.map(u=>{const h=this.measures[u-1];console.assert(!!h,"invalid measure index:",u,this.measures.length);const y=h.events.map(f=>({ticks:n+f.ticks,track:f.track,data:{...f.data,measure:u}}));return n+=h.duration,y}),a=u=>u.ticks+(u.subtype==="noteOff"?-1e-8:0),o=[].concat(...r).reduce((u,h)=>(u[h.track]=u[h.track]||[],u[h.track].push({ticks:h.ticks,...h.data}),u),[]);o[0]=o[0]||[],n=i,t.map(u=>{const h=this.measures[u-1];console.assert(!!h,"invalid measure index:",u,this.measures.length),Number.isFinite(h.duration)&&(h.notes.forEach(y=>{if(e&&!e[y.track]||y.rest)return;const f=n+y.tick,p=o[y.track]=o[y.track]||[];y.subNotes.forEach(m=>{p.push({ticks:f+m.startTick,measure:u,ids:y.ids,type:"channel",subtype:"noteOn",channel:y.channel,noteNumber:m.pitch,velocity:m.velocity,staffTrack:y.staffTrack,staff:y.staff}),p.push({ticks:f+m.endTick,measure:u,ids:y.ids,type:"channel",subtype:"noteOff",channel:y.channel,noteNumber:m.pitch,velocity:0,staffTrack:y.staffTrack,staff:y.staff})})}),n+=h.duration)});const c=n;for(let u=0;u{u.sort((y,f)=>a(y)-a(f));let h=0;u.forEach(y=>{y.deltaTime=y.ticks-h,Number.isFinite(y.deltaTime)?h=y.ticks:y.deltaTime=0}),u.push({deltaTime:Math.max(c-h,0),type:"meta",subtype:"endOfTrack"})}),{header:{formatType:0,ticksPerBeat:TICKS_PER_BEAT},tracks:o,zeroTick:i}}toPerformingNotationWithEvents(t,e={}){if(!t.length)return null;const{zeroTick:i,...n}=this.toPerformingMIDI(t,e),r=xt.Notation.parseMidi(n);assignNotationNoteDataFromEvents(r);let a=i;return r.measures=t.map(o=>{const c=a;return a+=this.measures[o-1].duration,{index:o,startTick:c,endTick:a}}),r}setTempo(t){let e=!1;for(const i of this.measures)for(const n of i.events)n.data.subtype==="setTempo"&&(n.data.microsecondsPerBeat=6e7/t,e=!0);return e}}const assignNotationNoteDataFromEvents=(s,t=["ids","measure","staffTrack"])=>{const e=(n,r,a)=>`${n}|${r}|${a}`,i=s.notes.reduce((n,r)=>(n[e(r.channel,r.pitch,r.startTick)]=r,n),{});s.events.forEach(n=>{if(n.data.subtype==="noteOn"){const r=e(n.data.channel,n.data.noteNumber,n.ticks),a=i[r];console.assert(!!a,"cannot find note of",r),a&&Object.assign(a,pick(n.data,t))}})},recoverJSON=(s,t)=>(typeof s=="object"&&(s=JSON.stringify(s)),JSON.parse(s,(e,i)=>{if(i&&typeof i=="object"&&i.__prototype){const n=t[i.__prototype];if(n){const{__prototype:r,...a}=i;return new n(a)}}return i})),deepCopy=(s,t=null)=>{if(t=t||new Map,t.get(s))return t.get(s);if(Array.isArray(s)){const e=[];return t.set(s,e),s.forEach(i=>e.push(deepCopy(i,t))),e}else if(s&&typeof s=="object"){const e={};return t.set(s,e),Object.entries(s).forEach(([i,n])=>e[i]=deepCopy(n,t)),Object.setPrototypeOf(e,s.__proto__),e}return s};class SimpleClass{assign(t){t&&Object.assign(this,t)}toJSON(){const t=this.constructor,e=t.serializedKeys||t.blackKeys&&Object.keys(this).filter(n=>!t.blackKeys.includes(n)),i=e?pick(this,e):this;return{__prototype:t.className,...i}}deepCopy(){return deepCopy(this)}}var LayoutType=(s=>(s.Ordinary="ordinary",s.Full="full",s.Conservative="conservative",s.Once="once",s))(LayoutType||{});const spreadMeasureSeq=(s,t="ordinary")=>[].concat(...s.map(e=>e.serialize(t))),seqToCode=(s,{withBrackets:t=!1}={})=>{let e="",i=!1;for(let n=0;n0&&!i&&(e+=", "),i=!1,e+=s[n].code);return t?`[${e}]`:e};class SingleMLayout extends SimpleClass{static className="SingleMLayout";measure;static from(t){const e=new SingleMLayout;return e.measure=t,e}constructor(t=void 0){super(),this.assign(t)}serialize(){return[this.measure]}get seq(){return[this]}get code(){return this.measure.toString()}}class BlockMLayout extends SimpleClass{static className="BlockMLayout";seq;static trimSeq(t){const e=[];for(const r of t)if(r instanceof BlockMLayout)for(const a of r.seq)e.push(a);else e.push(r);const i=[];let n=null;for(const r of e)r instanceof SingleMLayout?r.measure>n&&(i.push(r),n=r.measure):i.push(r);return i}static fromSeq(t){const e=new BlockMLayout;return e.seq=BlockMLayout.trimSeq(t),e}constructor(t=void 0){super(),this.assign(t)}serialize(t){return spreadMeasureSeq(this.seq,t)}get code(){return seqToCode(this.seq,{withBrackets:!0})}}class VoltaMLayout extends SimpleClass{static className="VoltaMLayout";times;body;alternates;constructor(t=void 0){super(),this.assign(t)}serialize(t){const e=spreadMeasureSeq(this.body);if(this.alternates){const i=this.alternates.map(r=>spreadMeasureSeq(r)),n=i[i.length-1];switch(t){case"ordinary":return e.concat(...i);case"conservative":case"full":return[...[].concat(...Array(this.times-1).fill(null).map((a,o)=>[...e,...i[o%(this.times-1)]])),...e,...n];case"once":return[...e,...n]}}else switch(t){case"ordinary":case"conservative":case"once":return e;case"full":return[].concat(...Array(this.times).fill(null).map(()=>e))}console.warn("the current case not handled:",t,this)}get seq(){const t=this.alternates?this.alternates[this.alternates.length-1]:[];return[...this.body,...t]}get code(){const t=seqToCode(this.body,{withBrackets:!0});let e=`${this.times}*${t}`;return this.alternates&&(e+="{"+this.alternates.map(i=>seqToCode(i,{withBrackets:i.length>1})).join(", ")+"}"),e}}class ABAMLayout extends SimpleClass{static className="ABAMLayout";main;rest;constructor(t=void 0){super(),this.assign(t)}serialize(t){const e=this.main.serialize(t),i=spreadMeasureSeq(this.main.seq,"once"),n=spreadMeasureSeq(this.rest,t);switch(t){case"ordinary":return[...e,...n];case"once":return[...n,...i];case"conservative":case"full":return[...e,...n,...i];default:console.warn("the current case not handled:",t,this)}}get seq(){return[this.main,...this.rest]}get code(){return"<"+this.main.code+", "+seqToCode(this.rest)+">"}}const measureLayout=Object.freeze(Object.defineProperty({__proto__:null,ABAMLayout,BlockMLayout,LayoutType,SingleMLayout,VoltaMLayout},Symbol.toStringTag,{value:"Module"}));var parser=function(){var s=function(M,b,_,R){for(_=_||{},R=M.length;R--;_[M[R]]=b);return _},t=[1,13],e=[1,16],i=[1,15],n=[1,26],r=[1,29],a=[1,28],o=[1,30],c=[5,13,22,27,29],d=[2,15],l=[1,32],u=[5,14,21,22,27,28,29],h={trace:function(){},yy:{},symbols_:{error:2,start_symbol:3,measure_layout:4,EOF:5,index_wise_measure_layout:6,"i:":7,"s:":8,segment_wise_measure_layout:9,iw_sequence:10,iw_item:11,range:12,",":13,UNSIGNED:14,"..":15,single:16,iw_block_item:17,iw_volta:18,iw_aba:19,iw_block:20,"[":21,"]":22,"*":23,iw_optional_alternates:24,iw_alternates:25,"{":26,"}":27,"<":28,">":29,sw_sequence:30,sw_item:31,segment:32,sw_block_item:33,sw_volta:34,sw_aba:35,sw_block:36,sw_optional_alternates:37,sw_alternates:38,$accept:0,$end:1},terminals_:{2:"error",5:"EOF",7:"i:",8:"s:",13:",",14:"UNSIGNED",15:"..",21:"[",22:"]",23:"*",26:"{",27:"}",28:"<",29:">"},productions_:[0,[3,2],[4,1],[4,2],[4,2],[6,1],[10,1],[10,1],[10,3],[10,3],[12,3],[11,1],[11,1],[11,1],[11,1],[16,1],[17,1],[20,3],[18,4],[24,0],[24,1],[25,3],[19,5],[9,1],[30,1],[30,2],[31,1],[31,1],[31,1],[31,1],[32,1],[33,1],[36,3],[34,4],[37,0],[37,1],[38,3],[35,4]],performAction:function(b,_,R,I,D,w,B){var C=w.length-1;switch(D){case 1:return w[C-1];case 2:this.$=y(null,w[C]);break;case 3:this.$=y("index-wise",w[C]);break;case 4:this.$=y("segment-wise",E(w[C]));break;case 5:case 23:w[C].length===1&&w[C][0].__prototype==="BlockMLayout"?this.$=w[C][0]:this.$=p(w[C]);break;case 6:case 24:this.$=[w[C]];break;case 7:case 11:case 12:case 13:case 14:case 20:case 27:case 28:case 29:case 35:this.$=w[C];break;case 8:this.$=[...w[C-2],w[C]];break;case 9:this.$=[...w[C-2],...w[C]];break;case 10:this.$=v(w[C-2],w[C]);break;case 15:this.$=f(w[C]);break;case 16:case 31:this.$=p(w[C]);break;case 17:case 32:this.$=w[C-1];break;case 18:case 33:this.$=m(w[C-3],w[C-1],w[C]);break;case 19:case 34:this.$=null;break;case 21:case 36:this.$=g(w[C-1]);break;case 22:this.$=T(w[C-3],w[C-1]);break;case 25:this.$=[...w[C-1],w[C]];break;case 26:this.$=p([w[C]]);break;case 30:this.$=x(w[C]);break;case 37:this.$=T(w[C-2],w[C-1]);break}},table:[{3:1,4:2,6:3,7:[1,4],8:[1,5],10:6,11:7,12:8,14:t,16:9,17:10,18:11,19:12,20:14,21:e,28:i},{1:[3]},{5:[1,17]},{5:[2,2]},{6:18,10:6,11:7,12:8,14:t,16:9,17:10,18:11,19:12,20:14,21:e,28:i},{9:19,14:n,21:r,28:a,30:20,31:21,32:22,33:23,34:24,35:25,36:27},{5:[2,5],13:o},s(c,[2,6]),s(c,[2,7]),s(c,[2,11]),s(c,[2,12]),s(c,[2,13]),s(c,[2,14]),s(c,d,{15:[1,31],23:l}),s(c,[2,16]),{11:33,14:[1,34],16:9,17:10,18:11,19:12,20:14,21:e,28:i},{10:35,11:7,12:8,14:t,16:9,17:10,18:11,19:12,20:14,21:e,28:i},{1:[2,1]},{5:[2,3]},{5:[2,4]},{5:[2,23],14:n,21:r,28:a,31:36,32:22,33:23,34:24,35:25,36:27},s(u,[2,24]),s(u,[2,26]),s(u,[2,27]),s(u,[2,28]),s(u,[2,29]),s(u,[2,30],{23:[1,37]}),s(u,[2,31]),{14:n,21:r,28:a,31:38,32:22,33:23,34:24,35:25,36:27},{14:n,21:r,28:a,30:39,31:21,32:22,33:23,34:24,35:25,36:27},{11:40,12:41,14:t,16:9,17:10,18:11,19:12,20:14,21:e,28:i},{14:[1,42]},{20:43,21:e},{13:[1,44]},{13:d,23:l},{13:o,22:[1,45]},s(u,[2,25]),{21:r,36:46},{14:n,21:r,28:a,30:47,31:21,32:22,33:23,34:24,35:25,36:27},{14:n,21:r,22:[1,48],28:a,31:36,32:22,33:23,34:24,35:25,36:27},s(c,[2,8]),s(c,[2,9]),s(c,[2,10]),s(c,[2,19],{24:49,25:50,26:[1,51]}),{10:52,11:7,12:8,14:t,16:9,17:10,18:11,19:12,20:14,21:e,28:i},s([5,13,22,26,27,29],[2,17]),s(u,[2,34],{37:53,38:54,26:[1,55]}),{14:n,21:r,28:a,29:[1,56],31:36,32:22,33:23,34:24,35:25,36:27},s([5,14,21,22,26,27,28,29],[2,32]),s(c,[2,18]),s(c,[2,20]),{10:57,11:7,12:8,14:t,16:9,17:10,18:11,19:12,20:14,21:e,28:i},{13:o,29:[1,58]},s(u,[2,33]),s(u,[2,35]),{14:n,21:r,28:a,30:59,31:21,32:22,33:23,34:24,35:25,36:27},s(u,[2,37]),{13:o,27:[1,60]},s(c,[2,22]),{14:n,21:r,27:[1,61],28:a,31:36,32:22,33:23,34:24,35:25,36:27},s(c,[2,21]),s(u,[2,36])],defaultActions:{3:[2,2],17:[2,1],18:[2,3],19:[2,4]},parseError:function(b,_){if(_.recoverable)this.trace(b);else{var R=new Error(b);throw R.hash=_,R}},parse:function(b){var _=this,R=[0],I=[null],D=[],w=this.table,B="",C=0,A=0,N=2,F=1,L=D.slice.call(arguments,1),H=Object.create(this.lexer),W={yy:{}};for(var P in this.yy)Object.prototype.hasOwnProperty.call(this.yy,P)&&(W.yy[P]=this.yy[P]);H.setInput(b,W.yy),W.yy.lexer=H,W.yy.parser=this,typeof H.yylloc>"u"&&(H.yylloc={});var j=H.yylloc;D.push(j);var z=H.options&&H.options.ranges;typeof W.yy.parseError=="function"?this.parseError=W.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;for(var it=function(){var $;return $=H.lex()||F,typeof $!="number"&&($=_.symbols_[$]||$),$},G,X,V,J,Y={},q,U,Z,K;;){if(X=R[R.length-1],this.defaultActions[X]?V=this.defaultActions[X]:((G===null||typeof G>"u")&&(G=it()),V=w[X]&&w[X][G]),typeof V>"u"||!V.length||!V[0]){var Q="";K=[];for(q in w[X])this.terminals_[q]&&q>N&&K.push("'"+this.terminals_[q]+"'");H.showPosition?Q="Parse error on line "+(C+1)+`: +import{c as pick,x as xt,p as parseCode$1}from"./parser-b66b074b.js";import{k as commonjsGlobal,g as getDefaultExportFromCjs,D as commonjsRequire}from"./umi-a12c8253.js";import{z as require$$5}from"./index-5722ce0d.js";const WHOLE_DURATION_MAGNITUDE=1920,TICKS_PER_BEAT=WHOLE_DURATION_MAGNITUDE/4,EXTRA_NOTE_FIELDS=["rest","tied","overlapped","implicitType","afterGrace","contextIndex","staffTrack","chordPosition","division"],COMMON_NOTE_FIELDS=["id","ids","pitch","velocity","track","channel",...EXTRA_NOTE_FIELDS];class MetaNotation{measures;trackNames;idTrackMap;ripe=!1;static fromAbsoluteNotes(t,e,i){const n=new MetaNotation(i);return n.measures=Array(e.length).fill(null).map((r,a)=>{const o=e[a],c=e[a+1]?e[a+1]-o:0,d=t.filter(l=>l.measure===a+1).map(l=>({tick:l.startTick-o,duration:l.endTick-l.startTick,...pick(l,COMMON_NOTE_FIELDS),subNotes:[]}));return d.forEach(l=>["rest","tied","implicitType","afterGrace"].forEach(u=>{l[u]||delete l[u]})),{tick:o,duration:c,notes:d}}),n.idTrackMap=t.reduce((r,a)=>(a.id&&(r[a.id]=a.track),r),{}),n}static performAbsoluteNotes(t,{withRestTied:e=!1}={}){const n=t.filter(r=>(e||!r.rest&&!r.tied)&&!r.overlapped).map(r=>({measure:r.measure,channel:r.channel,track:r.track,start:r.start,startTick:r.startTick,endTick:r.endTick,pitch:r.pitch,duration:r.duration,velocity:r.velocity||127,id:r.id,ids:r.ids,staffTrack:r.staffTrack,contextIndex:r.contextIndex,implicitType:r.implicitType,chordPosition:r.chordPosition})).reduce((r,a)=>{const o=`${a.channel}|${a.start}|${a.pitch}`,c=r[o];return c?c.ids.push(...a.ids):r[o]=a,r},{});return Object.values(n)}constructor(t){t&&Object.assign(this,t)}get trackTickBias(){const t=this.measures[0];return this.trackNames.reduce((e,i,n)=>{if(e[i]=0,t){const r=t.notes.find(a=>a.track===n);r&&(e[i]=Math.min(r.tick,0))}return e},{})}get idSet(){return this.measures.reduce((t,e)=>(e.notes.filter(i=>!i.rest).forEach(i=>i.ids.forEach(n=>t.add(n))),t),new Set)}toJSON(){return{__prototype:"LilyNotation",measures:this.measures,idTrackMap:this.idTrackMap,trackNames:this.trackNames,ripe:this.ripe}}toAbsoluteNotes(t){let e=0;const i=t.map(n=>{const r=this.measures[n-1];console.assert(!!r,"invalid measure index:",n,this.measures.length);const a=r.notes.map(o=>({startTick:e+o.tick,endTick:e+o.tick+o.duration,start:e+o.tick,duration:o.duration,measure:n,...pick(o,COMMON_NOTE_FIELDS)}));return e+=r.duration,a});return[].concat(...i)}toPerformingNotation(t,e={}){const i=this.toAbsoluteNotes(t),n=MetaNotation.performAbsoluteNotes(i,e),r=Math.max(...n.map(c=>c.start+c.duration)),a=t.reduce((c,d)=>c+this.measures[d-1].duration,0);return new xt.Notation({ticksPerBeat:TICKS_PER_BEAT,meta:{},tempos:[],channels:[n],endTime:r,endTick:a})}toPerformingMIDI(t,{trackList:e}={}){var d,l;if(!t.length)return null;const i=-Math.min(0,...((d=this.measures[0])==null?void 0:d.events.map(u=>u.ticks))||[],...((l=this.measures[0])==null?void 0:l.notes.map(u=>u.tick))||[]);let n=i;const r=t.map(u=>{const h=this.measures[u-1];console.assert(!!h,"invalid measure index:",u,this.measures.length);const y=h.events.map(f=>({ticks:n+f.ticks,track:f.track,data:{...f.data,measure:u}}));return n+=h.duration,y}),a=u=>u.ticks+(u.subtype==="noteOff"?-1e-8:0),o=[].concat(...r).reduce((u,h)=>(u[h.track]=u[h.track]||[],u[h.track].push({ticks:h.ticks,...h.data}),u),[]);o[0]=o[0]||[],n=i,t.map(u=>{const h=this.measures[u-1];console.assert(!!h,"invalid measure index:",u,this.measures.length),Number.isFinite(h.duration)&&(h.notes.forEach(y=>{if(e&&!e[y.track]||y.rest)return;const f=n+y.tick,p=o[y.track]=o[y.track]||[];y.subNotes.forEach(m=>{p.push({ticks:f+m.startTick,measure:u,ids:y.ids,type:"channel",subtype:"noteOn",channel:y.channel,noteNumber:m.pitch,velocity:m.velocity,staffTrack:y.staffTrack,staff:y.staff}),p.push({ticks:f+m.endTick,measure:u,ids:y.ids,type:"channel",subtype:"noteOff",channel:y.channel,noteNumber:m.pitch,velocity:0,staffTrack:y.staffTrack,staff:y.staff})})}),n+=h.duration)});const c=n;for(let u=0;u{u.sort((y,f)=>a(y)-a(f));let h=0;u.forEach(y=>{y.deltaTime=y.ticks-h,Number.isFinite(y.deltaTime)?h=y.ticks:y.deltaTime=0}),u.push({deltaTime:Math.max(c-h,0),type:"meta",subtype:"endOfTrack"})}),{header:{formatType:0,ticksPerBeat:TICKS_PER_BEAT},tracks:o,zeroTick:i}}toPerformingNotationWithEvents(t,e={}){if(!t.length)return null;const{zeroTick:i,...n}=this.toPerformingMIDI(t,e),r=xt.Notation.parseMidi(n);assignNotationNoteDataFromEvents(r);let a=i;return r.measures=t.map(o=>{const c=a;return a+=this.measures[o-1].duration,{index:o,startTick:c,endTick:a}}),r}setTempo(t){let e=!1;for(const i of this.measures)for(const n of i.events)n.data.subtype==="setTempo"&&(n.data.microsecondsPerBeat=6e7/t,e=!0);return e}}const assignNotationNoteDataFromEvents=(s,t=["ids","measure","staffTrack"])=>{const e=(n,r,a)=>`${n}|${r}|${a}`,i=s.notes.reduce((n,r)=>(n[e(r.channel,r.pitch,r.startTick)]=r,n),{});s.events.forEach(n=>{if(n.data.subtype==="noteOn"){const r=e(n.data.channel,n.data.noteNumber,n.ticks),a=i[r];console.assert(!!a,"cannot find note of",r),a&&Object.assign(a,pick(n.data,t))}})},recoverJSON=(s,t)=>(typeof s=="object"&&(s=JSON.stringify(s)),JSON.parse(s,(e,i)=>{if(i&&typeof i=="object"&&i.__prototype){const n=t[i.__prototype];if(n){const{__prototype:r,...a}=i;return new n(a)}}return i})),deepCopy=(s,t=null)=>{if(t=t||new Map,t.get(s))return t.get(s);if(Array.isArray(s)){const e=[];return t.set(s,e),s.forEach(i=>e.push(deepCopy(i,t))),e}else if(s&&typeof s=="object"){const e={};return t.set(s,e),Object.entries(s).forEach(([i,n])=>e[i]=deepCopy(n,t)),Object.setPrototypeOf(e,s.__proto__),e}return s};class SimpleClass{assign(t){t&&Object.assign(this,t)}toJSON(){const t=this.constructor,e=t.serializedKeys||t.blackKeys&&Object.keys(this).filter(n=>!t.blackKeys.includes(n)),i=e?pick(this,e):this;return{__prototype:t.className,...i}}deepCopy(){return deepCopy(this)}}var LayoutType=(s=>(s.Ordinary="ordinary",s.Full="full",s.Conservative="conservative",s.Once="once",s))(LayoutType||{});const spreadMeasureSeq=(s,t="ordinary")=>[].concat(...s.map(e=>e.serialize(t))),seqToCode=(s,{withBrackets:t=!1}={})=>{let e="",i=!1;for(let n=0;n0&&!i&&(e+=", "),i=!1,e+=s[n].code);return t?`[${e}]`:e};class SingleMLayout extends SimpleClass{static className="SingleMLayout";measure;static from(t){const e=new SingleMLayout;return e.measure=t,e}constructor(t=void 0){super(),this.assign(t)}serialize(){return[this.measure]}get seq(){return[this]}get code(){return this.measure.toString()}}class BlockMLayout extends SimpleClass{static className="BlockMLayout";seq;static trimSeq(t){const e=[];for(const r of t)if(r instanceof BlockMLayout)for(const a of r.seq)e.push(a);else e.push(r);const i=[];let n=null;for(const r of e)r instanceof SingleMLayout?r.measure>n&&(i.push(r),n=r.measure):i.push(r);return i}static fromSeq(t){const e=new BlockMLayout;return e.seq=BlockMLayout.trimSeq(t),e}constructor(t=void 0){super(),this.assign(t)}serialize(t){return spreadMeasureSeq(this.seq,t)}get code(){return seqToCode(this.seq,{withBrackets:!0})}}class VoltaMLayout extends SimpleClass{static className="VoltaMLayout";times;body;alternates;constructor(t=void 0){super(),this.assign(t)}serialize(t){const e=spreadMeasureSeq(this.body);if(this.alternates){const i=this.alternates.map(r=>spreadMeasureSeq(r)),n=i[i.length-1];switch(t){case"ordinary":return e.concat(...i);case"conservative":case"full":return[...[].concat(...Array(this.times-1).fill(null).map((a,o)=>[...e,...i[o%(this.times-1)]])),...e,...n];case"once":return[...e,...n]}}else switch(t){case"ordinary":case"conservative":case"once":return e;case"full":return[].concat(...Array(this.times).fill(null).map(()=>e))}console.warn("the current case not handled:",t,this)}get seq(){const t=this.alternates?this.alternates[this.alternates.length-1]:[];return[...this.body,...t]}get code(){const t=seqToCode(this.body,{withBrackets:!0});let e=`${this.times}*${t}`;return this.alternates&&(e+="{"+this.alternates.map(i=>seqToCode(i,{withBrackets:i.length>1})).join(", ")+"}"),e}}class ABAMLayout extends SimpleClass{static className="ABAMLayout";main;rest;constructor(t=void 0){super(),this.assign(t)}serialize(t){const e=this.main.serialize(t),i=spreadMeasureSeq(this.main.seq,"once"),n=spreadMeasureSeq(this.rest,t);switch(t){case"ordinary":return[...e,...n];case"once":return[...n,...i];case"conservative":case"full":return[...e,...n,...i];default:console.warn("the current case not handled:",t,this)}}get seq(){return[this.main,...this.rest]}get code(){return"<"+this.main.code+", "+seqToCode(this.rest)+">"}}const measureLayout=Object.freeze(Object.defineProperty({__proto__:null,ABAMLayout,BlockMLayout,LayoutType,SingleMLayout,VoltaMLayout},Symbol.toStringTag,{value:"Module"}));var parser=function(){var s=function(M,b,_,R){for(_=_||{},R=M.length;R--;_[M[R]]=b);return _},t=[1,13],e=[1,16],i=[1,15],n=[1,26],r=[1,29],a=[1,28],o=[1,30],c=[5,13,22,27,29],d=[2,15],l=[1,32],u=[5,14,21,22,27,28,29],h={trace:function(){},yy:{},symbols_:{error:2,start_symbol:3,measure_layout:4,EOF:5,index_wise_measure_layout:6,"i:":7,"s:":8,segment_wise_measure_layout:9,iw_sequence:10,iw_item:11,range:12,",":13,UNSIGNED:14,"..":15,single:16,iw_block_item:17,iw_volta:18,iw_aba:19,iw_block:20,"[":21,"]":22,"*":23,iw_optional_alternates:24,iw_alternates:25,"{":26,"}":27,"<":28,">":29,sw_sequence:30,sw_item:31,segment:32,sw_block_item:33,sw_volta:34,sw_aba:35,sw_block:36,sw_optional_alternates:37,sw_alternates:38,$accept:0,$end:1},terminals_:{2:"error",5:"EOF",7:"i:",8:"s:",13:",",14:"UNSIGNED",15:"..",21:"[",22:"]",23:"*",26:"{",27:"}",28:"<",29:">"},productions_:[0,[3,2],[4,1],[4,2],[4,2],[6,1],[10,1],[10,1],[10,3],[10,3],[12,3],[11,1],[11,1],[11,1],[11,1],[16,1],[17,1],[20,3],[18,4],[24,0],[24,1],[25,3],[19,5],[9,1],[30,1],[30,2],[31,1],[31,1],[31,1],[31,1],[32,1],[33,1],[36,3],[34,4],[37,0],[37,1],[38,3],[35,4]],performAction:function(b,_,R,I,D,w,B){var C=w.length-1;switch(D){case 1:return w[C-1];case 2:this.$=y(null,w[C]);break;case 3:this.$=y("index-wise",w[C]);break;case 4:this.$=y("segment-wise",E(w[C]));break;case 5:case 23:w[C].length===1&&w[C][0].__prototype==="BlockMLayout"?this.$=w[C][0]:this.$=p(w[C]);break;case 6:case 24:this.$=[w[C]];break;case 7:case 11:case 12:case 13:case 14:case 20:case 27:case 28:case 29:case 35:this.$=w[C];break;case 8:this.$=[...w[C-2],w[C]];break;case 9:this.$=[...w[C-2],...w[C]];break;case 10:this.$=v(w[C-2],w[C]);break;case 15:this.$=f(w[C]);break;case 16:case 31:this.$=p(w[C]);break;case 17:case 32:this.$=w[C-1];break;case 18:case 33:this.$=m(w[C-3],w[C-1],w[C]);break;case 19:case 34:this.$=null;break;case 21:case 36:this.$=g(w[C-1]);break;case 22:this.$=T(w[C-3],w[C-1]);break;case 25:this.$=[...w[C-1],w[C]];break;case 26:this.$=p([w[C]]);break;case 30:this.$=x(w[C]);break;case 37:this.$=T(w[C-2],w[C-1]);break}},table:[{3:1,4:2,6:3,7:[1,4],8:[1,5],10:6,11:7,12:8,14:t,16:9,17:10,18:11,19:12,20:14,21:e,28:i},{1:[3]},{5:[1,17]},{5:[2,2]},{6:18,10:6,11:7,12:8,14:t,16:9,17:10,18:11,19:12,20:14,21:e,28:i},{9:19,14:n,21:r,28:a,30:20,31:21,32:22,33:23,34:24,35:25,36:27},{5:[2,5],13:o},s(c,[2,6]),s(c,[2,7]),s(c,[2,11]),s(c,[2,12]),s(c,[2,13]),s(c,[2,14]),s(c,d,{15:[1,31],23:l}),s(c,[2,16]),{11:33,14:[1,34],16:9,17:10,18:11,19:12,20:14,21:e,28:i},{10:35,11:7,12:8,14:t,16:9,17:10,18:11,19:12,20:14,21:e,28:i},{1:[2,1]},{5:[2,3]},{5:[2,4]},{5:[2,23],14:n,21:r,28:a,31:36,32:22,33:23,34:24,35:25,36:27},s(u,[2,24]),s(u,[2,26]),s(u,[2,27]),s(u,[2,28]),s(u,[2,29]),s(u,[2,30],{23:[1,37]}),s(u,[2,31]),{14:n,21:r,28:a,31:38,32:22,33:23,34:24,35:25,36:27},{14:n,21:r,28:a,30:39,31:21,32:22,33:23,34:24,35:25,36:27},{11:40,12:41,14:t,16:9,17:10,18:11,19:12,20:14,21:e,28:i},{14:[1,42]},{20:43,21:e},{13:[1,44]},{13:d,23:l},{13:o,22:[1,45]},s(u,[2,25]),{21:r,36:46},{14:n,21:r,28:a,30:47,31:21,32:22,33:23,34:24,35:25,36:27},{14:n,21:r,22:[1,48],28:a,31:36,32:22,33:23,34:24,35:25,36:27},s(c,[2,8]),s(c,[2,9]),s(c,[2,10]),s(c,[2,19],{24:49,25:50,26:[1,51]}),{10:52,11:7,12:8,14:t,16:9,17:10,18:11,19:12,20:14,21:e,28:i},s([5,13,22,26,27,29],[2,17]),s(u,[2,34],{37:53,38:54,26:[1,55]}),{14:n,21:r,28:a,29:[1,56],31:36,32:22,33:23,34:24,35:25,36:27},s([5,14,21,22,26,27,28,29],[2,32]),s(c,[2,18]),s(c,[2,20]),{10:57,11:7,12:8,14:t,16:9,17:10,18:11,19:12,20:14,21:e,28:i},{13:o,29:[1,58]},s(u,[2,33]),s(u,[2,35]),{14:n,21:r,28:a,30:59,31:21,32:22,33:23,34:24,35:25,36:27},s(u,[2,37]),{13:o,27:[1,60]},s(c,[2,22]),{14:n,21:r,27:[1,61],28:a,31:36,32:22,33:23,34:24,35:25,36:27},s(c,[2,21]),s(u,[2,36])],defaultActions:{3:[2,2],17:[2,1],18:[2,3],19:[2,4]},parseError:function(b,_){if(_.recoverable)this.trace(b);else{var R=new Error(b);throw R.hash=_,R}},parse:function(b){var _=this,R=[0],I=[null],D=[],w=this.table,B="",C=0,A=0,N=2,F=1,L=D.slice.call(arguments,1),H=Object.create(this.lexer),W={yy:{}};for(var P in this.yy)Object.prototype.hasOwnProperty.call(this.yy,P)&&(W.yy[P]=this.yy[P]);H.setInput(b,W.yy),W.yy.lexer=H,W.yy.parser=this,typeof H.yylloc>"u"&&(H.yylloc={});var j=H.yylloc;D.push(j);var z=H.options&&H.options.ranges;typeof W.yy.parseError=="function"?this.parseError=W.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;for(var it=function(){var $;return $=H.lex()||F,typeof $!="number"&&($=_.symbols_[$]||$),$},G,X,V,J,Y={},q,U,Z,K;;){if(X=R[R.length-1],this.defaultActions[X]?V=this.defaultActions[X]:((G===null||typeof G>"u")&&(G=it()),V=w[X]&&w[X][G]),typeof V>"u"||!V.length||!V[0]){var Q="";K=[];for(q in w[X])this.terminals_[q]&&q>N&&K.push("'"+this.terminals_[q]+"'");H.showPosition?Q="Parse error on line "+(C+1)+`: `+H.showPosition()+` Expecting `+K.join(", ")+", got '"+(this.terminals_[G]||G)+"'":Q="Parse error on line "+(C+1)+": Unexpected "+(G==F?"end of input":"'"+(this.terminals_[G]||G)+"'"),this.parseError(Q,{text:H.match,token:this.terminals_[G]||G,line:H.yylineno,loc:j,expected:K})}if(V[0]instanceof Array&&V.length>1)throw new Error("Parse Error: multiple actions possible at state: "+X+", token: "+G);switch(V[0]){case 1:R.push(G),I.push(H.yytext),D.push(H.yylloc),R.push(V[1]),G=null,A=H.yyleng,B=H.yytext,C=H.yylineno,j=H.yylloc;break;case 2:if(U=this.productions_[V[1]][1],Y.$=I[I.length-U],Y._$={first_line:D[D.length-(U||1)].first_line,last_line:D[D.length-1].last_line,first_column:D[D.length-(U||1)].first_column,last_column:D[D.length-1].last_column},z&&(Y._$.range=[D[D.length-(U||1)].range[0],D[D.length-1].range[1]]),J=this.performAction.apply(Y,[B,A,C,W.yy,V[1],I,D].concat(L)),typeof J<"u")return J;U&&(R=R.slice(0,-1*U*2),I=I.slice(0,-1*U),D=D.slice(0,-1*U)),R.push(this.productions_[V[1]][0]),I.push(Y.$),D.push(Y._$),Z=w[R[R.length-2]][R[R.length-1]],R.push(Z);break;case 3:return!0}}return!0}};const y=(M,b)=>({__prototype:"MesaureLayout",type:M,data:b}),f=M=>({__prototype:"SingleMLayout",measure:Number(M)}),p=M=>({__prototype:"BlockMLayout",seq:M}),m=(M,b,_)=>({__prototype:"VoltaMLayout",times:Number(M),body:b,alternates:_}),T=(M,b)=>({__prototype:"ABAMLayout",main:M,rest:b}),x=M=>({segment:!0,length:Number(M)}),g=M=>M.map(b=>b.__prototype==="BlockMLayout"?b.seq:[b]),v=(M,b)=>{if(M=Number(M),b=Number(b),!(b>=M))throw new Error(`invalid measure range: ${M}..${b}`);return Array(b+1-M).fill(0).map((_,R)=>f(M+R))},S=(M,b)=>{if(M.segment){const _=b.index;return b.index+=M.length,Array(M.length).fill(0).map((R,I)=>f(_+I))}return[E(M,b)]},E=(M,b={index:1})=>{const _=R=>[].concat(...R.map(I=>S(I,b)));switch(M.__prototype){case"BlockMLayout":M.seq=_(M.seq);break;case"VoltaMLayout":M.body=_(M.body),M.alternates=M.alternates&&M.alternates.map(_);break;case"ABAMLayout":M.main=E(M.main,b),M.rest=_(M.rest);break}return M};var k=function(){var M={EOF:1,parseError:function(_,R){if(this.yy.parser)this.yy.parser.parseError(_,R);else throw new Error(_)},setInput:function(b,_){return this.yy=_||this.yy||{},this._input=b,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var b=this._input[0];this.yytext+=b,this.yyleng++,this.offset++,this.match+=b,this.matched+=b;var _=b.match(/(?:\r\n?|\n).*/g);return _?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),b},unput:function(b){var _=b.length,R=b.split(/(?:\r\n?|\n)/g);this._input=b+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-_),this.offset-=_;var I=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),R.length-1&&(this.yylineno-=R.length-1);var D=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:R?(R.length===I.length?this.yylloc.first_column:0)+I[I.length-R.length].length-R[0].length:this.yylloc.first_column-_},this.options.ranges&&(this.yylloc.range=[D[0],D[0]+this.yyleng-_]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){if(this.options.backtrack_lexer)this._backtrack=!0;else return this.parseError("Lexical error on line "+(this.yylineno+1)+`. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true). `+this.showPosition(),{text:"",token:null,line:this.yylineno});return this},less:function(b){this.unput(this.match.slice(b))},pastInput:function(){var b=this.matched.substr(0,this.matched.length-this.match.length);return(b.length>20?"...":"")+b.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var b=this.match;return b.length<20&&(b+=this._input.substr(0,20-b.length)),(b.substr(0,20)+(b.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var b=this.pastInput(),_=new Array(b.length+1).join("-");return b+this.upcomingInput()+` @@ -11,4 +11,4 @@ Expecting `+K.join(", ")+", got '"+(this.terminals_[G]||G)+"'":Q="Parse error on * @copyright Chen, Yi-Cyuan 2014-2017 * @license MIT */(function(module){(function(){var root=typeof window=="object"?window:{},NODE_JS=!root.JS_SHA1_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;NODE_JS&&(root=commonjsGlobal);var COMMON_JS=!root.JS_SHA1_NO_COMMON_JS&&!0&&module.exports,HEX_CHARS="0123456789abcdef".split(""),EXTRA=[-2147483648,8388608,32768,128],SHIFT=[24,16,8,0],OUTPUT_TYPES=["hex","array","digest","arrayBuffer"],blocks=[],createOutputMethod=function(s){return function(t){return new Sha1(!0).update(t)[s]()}},createMethod=function(){var s=createOutputMethod("hex");NODE_JS&&(s=nodeWrap(s)),s.create=function(){return new Sha1},s.update=function(i){return s.create().update(i)};for(var t=0;t>2]|=s[i]<>2]|=e<>2]|=(192|e>>6)<>2]|=(128|e&63)<=57344?(a[n>>2]|=(224|e>>12)<>2]|=(128|e>>6&63)<>2]|=(128|e&63)<>2]|=(240|e>>18)<>2]|=(128|e>>12&63)<>2]|=(128|e>>6&63)<>2]|=(128|e&63)<=64?(this.block=a[16],this.start=n-64,this.hash(),this.hashed=!0):this.start=n}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this}},Sha1.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var s=this.blocks,t=this.lastByteIndex;s[16]=this.block,s[t>>2]|=EXTRA[t&3],this.block=s[16],t>=56&&(this.hashed||this.hash(),s[0]=this.block,s[16]=s[1]=s[2]=s[3]=s[4]=s[5]=s[6]=s[7]=s[8]=s[9]=s[10]=s[11]=s[12]=s[13]=s[14]=s[15]=0),s[14]=this.hBytes<<3|this.bytes>>>29,s[15]=this.bytes<<3,this.hash()}},Sha1.prototype.hash=function(){var s=this.h0,t=this.h1,e=this.h2,i=this.h3,n=this.h4,r,a,o,c=this.blocks;for(a=16;a<80;++a)o=c[a-3]^c[a-8]^c[a-14]^c[a-16],c[a]=o<<1|o>>>31;for(a=0;a<20;a+=5)r=t&e|~t&i,o=s<<5|s>>>27,n=o+r+n+1518500249+c[a]<<0,t=t<<30|t>>>2,r=s&t|~s&e,o=n<<5|n>>>27,i=o+r+i+1518500249+c[a+1]<<0,s=s<<30|s>>>2,r=n&s|~n&t,o=i<<5|i>>>27,e=o+r+e+1518500249+c[a+2]<<0,n=n<<30|n>>>2,r=i&n|~i&s,o=e<<5|e>>>27,t=o+r+t+1518500249+c[a+3]<<0,i=i<<30|i>>>2,r=e&i|~e&n,o=t<<5|t>>>27,s=o+r+s+1518500249+c[a+4]<<0,e=e<<30|e>>>2;for(;a<40;a+=5)r=t^e^i,o=s<<5|s>>>27,n=o+r+n+1859775393+c[a]<<0,t=t<<30|t>>>2,r=s^t^e,o=n<<5|n>>>27,i=o+r+i+1859775393+c[a+1]<<0,s=s<<30|s>>>2,r=n^s^t,o=i<<5|i>>>27,e=o+r+e+1859775393+c[a+2]<<0,n=n<<30|n>>>2,r=i^n^s,o=e<<5|e>>>27,t=o+r+t+1859775393+c[a+3]<<0,i=i<<30|i>>>2,r=e^i^n,o=t<<5|t>>>27,s=o+r+s+1859775393+c[a+4]<<0,e=e<<30|e>>>2;for(;a<60;a+=5)r=t&e|t&i|e&i,o=s<<5|s>>>27,n=o+r+n-1894007588+c[a]<<0,t=t<<30|t>>>2,r=s&t|s&e|t&e,o=n<<5|n>>>27,i=o+r+i-1894007588+c[a+1]<<0,s=s<<30|s>>>2,r=n&s|n&t|s&t,o=i<<5|i>>>27,e=o+r+e-1894007588+c[a+2]<<0,n=n<<30|n>>>2,r=i&n|i&s|n&s,o=e<<5|e>>>27,t=o+r+t-1894007588+c[a+3]<<0,i=i<<30|i>>>2,r=e&i|e&n|i&n,o=t<<5|t>>>27,s=o+r+s-1894007588+c[a+4]<<0,e=e<<30|e>>>2;for(;a<80;a+=5)r=t^e^i,o=s<<5|s>>>27,n=o+r+n-899497514+c[a]<<0,t=t<<30|t>>>2,r=s^t^e,o=n<<5|n>>>27,i=o+r+i-899497514+c[a+1]<<0,s=s<<30|s>>>2,r=n^s^t,o=i<<5|i>>>27,e=o+r+e-899497514+c[a+2]<<0,n=n<<30|n>>>2,r=i^n^s,o=e<<5|e>>>27,t=o+r+t-899497514+c[a+3]<<0,i=i<<30|i>>>2,r=e^i^n,o=t<<5|t>>>27,s=o+r+s-899497514+c[a+4]<<0,e=e<<30|e>>>2;this.h0=this.h0+s<<0,this.h1=this.h1+t<<0,this.h2=this.h2+e<<0,this.h3=this.h3+i<<0,this.h4=this.h4+n<<0},Sha1.prototype.hex=function(){this.finalize();var s=this.h0,t=this.h1,e=this.h2,i=this.h3,n=this.h4;return HEX_CHARS[s>>28&15]+HEX_CHARS[s>>24&15]+HEX_CHARS[s>>20&15]+HEX_CHARS[s>>16&15]+HEX_CHARS[s>>12&15]+HEX_CHARS[s>>8&15]+HEX_CHARS[s>>4&15]+HEX_CHARS[s&15]+HEX_CHARS[t>>28&15]+HEX_CHARS[t>>24&15]+HEX_CHARS[t>>20&15]+HEX_CHARS[t>>16&15]+HEX_CHARS[t>>12&15]+HEX_CHARS[t>>8&15]+HEX_CHARS[t>>4&15]+HEX_CHARS[t&15]+HEX_CHARS[e>>28&15]+HEX_CHARS[e>>24&15]+HEX_CHARS[e>>20&15]+HEX_CHARS[e>>16&15]+HEX_CHARS[e>>12&15]+HEX_CHARS[e>>8&15]+HEX_CHARS[e>>4&15]+HEX_CHARS[e&15]+HEX_CHARS[i>>28&15]+HEX_CHARS[i>>24&15]+HEX_CHARS[i>>20&15]+HEX_CHARS[i>>16&15]+HEX_CHARS[i>>12&15]+HEX_CHARS[i>>8&15]+HEX_CHARS[i>>4&15]+HEX_CHARS[i&15]+HEX_CHARS[n>>28&15]+HEX_CHARS[n>>24&15]+HEX_CHARS[n>>20&15]+HEX_CHARS[n>>16&15]+HEX_CHARS[n>>12&15]+HEX_CHARS[n>>8&15]+HEX_CHARS[n>>4&15]+HEX_CHARS[n&15]},Sha1.prototype.toString=Sha1.prototype.hex,Sha1.prototype.digest=function(){this.finalize();var s=this.h0,t=this.h1,e=this.h2,i=this.h3,n=this.h4;return[s>>24&255,s>>16&255,s>>8&255,s&255,t>>24&255,t>>16&255,t>>8&255,t&255,e>>24&255,e>>16&255,e>>8&255,e&255,i>>24&255,i>>16&255,i>>8&255,i&255,n>>24&255,n>>16&255,n>>8&255,n&255]},Sha1.prototype.array=Sha1.prototype.digest,Sha1.prototype.arrayBuffer=function(){this.finalize();var s=new ArrayBuffer(20),t=new DataView(s);return t.setUint32(0,this.h0),t.setUint32(4,this.h1),t.setUint32(8,this.h2),t.setUint32(12,this.h3),t.setUint32(16,this.h4),s};var exports=createMethod();COMMON_JS?module.exports=exports:root.sha1=exports})()})(sha1$1);var sha1Exports=sha1$1.exports;const sha1=getDefaultExportFromCjs(sha1Exports);var lib$6={exports:{}};function evalpoly$1(s,t){var e,i;if(i=s.length,i<2||t===0)return i===0?0:s[0];for(i-=1,e=s[i]*t+s[i-1],i-=2;i>=0;)e=e*t+s[i],i-=1;return e}var evalpoly_1=evalpoly$1;function factory(s){var t,e,i,n;if(t="return function evalpoly(x){",e=s.length,e===0)t+="return 0;";else if(e===1)t+="return "+s[0]+";";else{for(t+="if(x===0){return "+s[0]+";}",t+="return "+s[0],i=e-1,n=1;n>>0,FLOAT64_VIEW[0]}var lib$3=setLowWord$1,lib$2=Number.POSITIVE_INFINITY,lib$1=Number.NEGATIVE_INFINITY,evalpoly=libExports.factory,exp=lib$5,setLowWord=lib$3,PINF=lib$2,NINF=lib$1,TINY=1e-300,VERY_TINY=2848094538889218e-321,SMALL=3725290298461914e-24,ERX=.8450629115104675,EFX=.1283791670955126,EFX8=1.0270333367641007,PPC=.12837916709551256,PP=[-.3250421072470015,-.02848174957559851,-.005770270296489442,-23763016656650163e-21],QQC=1,QQ=[.39791722395915535,.0650222499887673,.005081306281875766,.00013249473800432164,-3960228278775368e-21],PAC=-.0023621185607526594,PA=[.41485611868374833,-.3722078760357013,.31834661990116175,-.11089469428239668,.035478304325618236,-.002166375594868791],QAC=1,QA=[.10642088040084423,.540397917702171,.07182865441419627,.12617121980876164,.01363708391202905,.011984499846799107],RAC=-.009864944034847148,RA=[-.6938585727071818,-10.558626225323291,-62.375332450326006,-162.39666946257347,-184.60509290671104,-81.2874355063066,-9.814329344169145],SAC=1,SA=[19.651271667439257,137.65775414351904,434.56587747522923,645.3872717332679,429.00814002756783,108.63500554177944,6.570249770319282,-.0604244152148581],RBC=-.0098649429247001,RB=[-.799283237680523,-17.757954917754752,-160.63638485582192,-637.5664433683896,-1025.0951316110772,-483.5191916086514],SBC=1,SB=[30.33806074348246,325.7925129965739,1536.729586084437,3199.8582195085955,2553.0504064331644,474.52854120695537,-22.44095244658582],polyvalPP=evalpoly(PP),polyvalQQ=evalpoly(QQ),polyvalPA=evalpoly(PA),polyvalQA=evalpoly(QA),polyvalRA=evalpoly(RA),polyvalSA=evalpoly(SA),polyvalRB=evalpoly(RB),polyvalSB=evalpoly(SB);function erf(s){var t,e,i,n,r,a,o,c;return s!==s?NaN:s===PINF?1:s===NINF?-1:s===0?s:(s<0?(t=!0,e=-s):(t=!1,e=s),e<.84375?e=6?t?TINY-1:1-TINY:(r=1/(e*e),e<2.857142857142857?(n=RAC+r*polyvalRA(r),r=SAC+r*polyvalSA(r)):(n=RBC+r*polyvalRB(r),r=SBC+r*polyvalSB(r)),i=setLowWord(e,0),n=exp(-i*i-.5625)*exp((i-e)*(i+e)+n/r),t?n/e-1:1-n/e))}var lib=erf;const erf$1=getDefaultExportFromCjs(lib);var Sylvester={};Sylvester.Matrix=function(){};Sylvester.Matrix.create=function(s){var t=new Sylvester.Matrix;return t.setElements(s)};Sylvester.Matrix.I=function(s){for(var t=[],e=s,i;e--;)for(i=s,t[e]=[];i--;)t[e][i]=e===i?1:0;return Sylvester.Matrix.create(t)};Sylvester.Matrix.prototype={dup:function(){return Sylvester.Matrix.create(this.elements)},isSquare:function(){var s=this.elements.length===0?0:this.elements[0].length;return this.elements.length===s},toRightTriangular:function(){if(this.elements.length===0)return Sylvester.Matrix.create([]);var s=this.dup(),t,e=this.elements.length,i,n,r=this.elements[0].length,a;for(i=0;i"u"&&(t=Sylvester.Matrix.create(t).elements);var e=this.dup(),i=e.elements[0].length,n=e.elements.length,r=t[0].length,a;if(n!==t.length)return null;for(;n--;)for(a=r;a--;)e.elements[n][i+a]=t[n][a];return e},inverse:function(){if(this.elements.length===0||!this.isSquare()||this.isSingular())return null;for(var s=this.elements.length,t=s,e,i=this.augment(Sylvester.Matrix.I(s)).toRightTriangular(),n=i.elements[0].length,r,a,o,c=[],d;t--;){for(a=[],c[t]=[],o=i.elements[t][t],r=0;r=s&&c[t].push(d);for(i.elements[t]=a,e=t;e--;){for(a=[],r=0;r(s.ClefG="ClefG",s.ClefF="ClefF",s.ClefC="ClefC",s.NoteheadS0="NoteheadS0",s.NoteheadS1="NoteheadS1",s.NoteheadS2="NoteheadS2",s.NoteheadS1stemU="NoteheadS1stemU",s.NoteheadS1stemD="NoteheadS1stemD",s.NoteheadS2stemU="NoteheadS2stemU",s.NoteheadS2stemD="NoteheadS2stemD",s.vline_Stem="vline_Stem",s.Flag3="Flag3",s.BeamLeft="BeamLeft",s.BeamContinue="BeamContinue",s.BeamRight="BeamRight",s.TremoloLeft="TremoloLeft",s.TremoloRight="TremoloRight",s.TremoloMiddle="TremoloMiddle",s.Dot="Dot",s.Rest0="Rest0",s.Rest1="Rest1",s.Rest2="Rest2",s.Rest3="Rest3",s.Rest4="Rest4",s.Rest5="Rest5",s.Rest6="Rest6",s.Rest0W="Rest0W",s.RestM1="RestM1",s.AccNatural="AccNatural",s.AccSharp="AccSharp",s.AccDoublesharp="AccDoublesharp",s.AccFlat="AccFlat",s.AccFlatflat="AccFlatflat",s.vline_VoltaLeft="vline_VoltaLeft",s.vline_VoltaRight="vline_VoltaRight",s.VoltaLeft="VoltaLeft",s.VoltaRight="VoltaRight",s.VoltaAlternativeBegin="VoltaAlternativeBegin",s.BarMeasure="BarMeasure",s.vline_BarMeasure="vline_BarMeasure",s.vline_BarTerminal="vline_BarTerminal",s.vline_BarSegment="vline_BarSegment",s.SlurBegin="SlurBegin",s.SlurEnd="SlurEnd",s.TimesigC44="TimesigC44",s.TimesigC22="TimesigC22",s.TimesigZero="TimesigZero",s.TimesigOne="TimesigOne",s.TimesigTwo="TimesigTwo",s.TimesigThree="TimesigThree",s.TimesigFour="TimesigFour",s.TimesigFive="TimesigFive",s.TimesigSix="TimesigSix",s.TimesigSeven="TimesigSeven",s.TimesigEight="TimesigEight",s.TimesigNine="TimesigNine",s.OctaveShift8va="OctaveShift8va",s.OctaveShift8vb="OctaveShift8vb",s.OctaveShift8="OctaveShift8",s.OctaveShift0="OctaveShift0",s.Zero="Zero",s.One="One",s.Two="Two",s.Three="Three",s.Four="Four",s.Five="Five",s.Six="Six",s.Seven="Seven",s.Eight="Eight",s.Nine="Nine",s.f="f",s.p="p",s.m="m",s.n="n",s.r="r",s.s="s",s.z="z",s.CrescendoBegin="CrescendoBegin",s.CrescendoEnd="CrescendoEnd",s.DecrescendoBegin="DecrescendoBegin",s.DecrescendoEnd="DecrescendoEnd",s.ScriptFermata="ScriptFermata",s.ScriptShortFermata="ScriptShortFermata",s.ScriptSforzato="ScriptSforzato",s.ScriptStaccato="ScriptStaccato",s.ScriptStaccatissimo="ScriptStaccatissimo",s.ScriptTurn="ScriptTurn",s.ScriptTrill="ScriptTrill",s.ScriptSegno="ScriptSegno",s.ScriptCoda="ScriptCoda",s.ScriptArpeggio="ScriptArpeggio",s.ScriptPrall="ScriptPrall",s.ScriptMordent="ScriptMordent",s.ScriptMarcato="ScriptMarcato",s.ScriptTenuto="ScriptTenuto",s.ScriptPortato="ScriptPortato",s.PedalStar="PedalStar",s.PedalPed="PedalPed",s.KeyAcc="KeyAcc",s.TempoNotehead="TempoNotehead",s.GraceNotehead="GraceNotehead",s.SignLined="SignLined",s.SignInterval="SignInterval",s.rect_Text="rect_Text",s.rect_Lyric="rect_Lyric",s))(SemanticType||{});const glyphSemanticMapping={"rests.1":"Rest1","rests.0o":"Rest0","rests.1o":"Rest1","rests.M1":"RestM1","rests.2":"Rest2","rests.3":"Rest3","rests.4":"Rest4","rests.5":"Rest5","rests.6":"Rest6","accidentals.sharp":"AccSharp","accidentals.doublesharp":"AccDoublesharp","accidentals.natural":"AccNatural","accidentals.flat":"AccFlat","accidentals.flatflat":"AccFlatflat","dots.dot":"Dot","scripts.ufermata":"ScriptFermata","scripts.dfermata":"ScriptFermata","scripts.ushortfermata":"ScriptShortFermata","scripts.dshortfermata":"ScriptShortFermata","scripts.staccato":"ScriptStaccato","scripts.ustaccatissimo":"ScriptStaccatissimo","scripts.dstaccatissimo":"ScriptStaccatissimo","scripts.turn":"ScriptTurn","scripts.trill":"ScriptTrill","scripts.segno":"ScriptSegno","scripts.coda":"ScriptCoda","scripts.arpeggio":"ScriptArpeggio","scripts.prall":"ScriptPrall","scripts.mordent":"ScriptMordent","scripts.umarcato":"ScriptMarcato","scripts.dmarcato":"ScriptMarcato","scripts.uportato":"ScriptPortato","scripts.dportato":"ScriptPortato","scripts.tenuto":"ScriptTenuto","scripts.sforzato":"ScriptSforzato","clefs.C":"ClefC","clefs.F":"ClefF","clefs.G":"ClefG","clefs.F_change":"ClefF","clefs.G_change":"ClefG","timesig.C44":"TimesigC44","timesig.C22":"TimesigC22","pedal.*":"PedalStar","pedal.Ped":"PedalPed","noteheads.s0":"NoteheadS0","noteheads.s1":"NoteheadS1","noteheads.s2":"NoteheadS2",f:"f",m:"m",p:"p",r:"r",s:"s",z:"z"},semanticPriorities={ClefG:0,ClefF:0,TimesigFour:0,TimesigThree:0,TimesigTwo:0,NoteheadS0:0,NoteheadS1:0,NoteheadS2:0,Dot:0,vline_BarMeasure:0,vline_Stem:0,Flag3:0,TimesigC44:1,TimesigC22:1,TimesigEight:1,TimesigSix:1,AccNatural:1,AccSharp:1,AccFlat:1,KeyAcc:1,Rest0:1,Rest1:1,Rest2:1,Rest3:1,Rest4:1,OctaveShift8:1,OctaveShift0:1,AccDoublesharp:2,AccFlatflat:2,TimesigOne:2,TimesigNine:2,Rest5:2,Rest6:2,SlurBegin:2,SlurEnd:2,VoltaLeft:2,VoltaRight:2,vline_BarTerminal:2,vline_BarSegment:2,TempoNotehead:2,GraceNotehead:2,SignLined:2,SignInterval:2,BeamLeft:2,BeamRight:2,BeamContinue:2,TremoloLeft:2,TremoloRight:2,TremoloMiddle:2,StemTip:2,StemHead:2,f:3,p:3,m:3,ScriptFermata:3,ScriptSforzato:3,ScriptStaccato:3,ScriptStaccatissimo:3,ScriptTurn:3,ScriptTrill:3,ScriptSegno:3,ScriptCoda:3,ScriptArpeggio:3,ScriptPrall:3,ScriptMordent:3,ScriptTenuto:3,PedalStar:3,PedalPed:3,TimesigFive:3,TimesigSeven:3,TimesigZero:3,One:3,Two:3,Three:3,Four:3,Five:3,rect_Text:3,rect_Lyric:3,CrescendoBegin:3,CrescendoEnd:3,DecrescendoBegin:3,DecrescendoEnd:3,RestM1:4,ClefC:4,ScriptShortFermata:4,ScriptMarcato:4,ScriptPortato:4,s:4,r:4,z:4,Zero:4,Six:4,Seven:4,Eight:4,Nine:4},NOTEHEAD_WIDTHS={NoteheadS0:.913*2,NoteheadS1:.632*2,NoteheadS2:.599*2},glyphCenters={"clefs.F":{x:1.06},"clefs.G":{x:1.3},"clefs.F_change":{x:.87},"clefs.G_change":{x:1.07},"timesig.C44":{x:.9},"timesig.C22":{x:.9},zero:{x:.7,y:-1},one:{x:.7,y:-1},two:{x:.7,y:-1},three:{x:.7,y:-1},four:{x:.7,y:-1},five:{x:.7,y:-1},six:{x:.7,y:-1},seven:{x:.7,y:-1},eight:{x:.7,y:-1},nine:{x:.7,y:-1},"accidentals.sharp":{x:.55},"accidentals.doublesharp":{x:.5},"accidentals.natural":{x:.3},"accidentals.flat":{x:.3},"accidentals.flatflat":{x:.5},"noteheads.s0":{x:NOTEHEAD_WIDTHS.NoteheadS0/2},"noteheads.s1":{x:NOTEHEAD_WIDTHS.NoteheadS1/2},"noteheads.s2":{x:NOTEHEAD_WIDTHS.NoteheadS2/2},"rests.0":{x:.75,y:1},"rests.1":{x:.75},"rests.0o":{x:.75,y:1},"rests.1o":{x:.75},"rests.M1":{x:.75,y:1},"rests.2":{x:.5},"rests.3":{x:.5},"rests.4":{x:.5},"rests.5":{x:.5},"rests.6":{x:.5},f:{x:.6,y:-.5},m:{x:.9,y:-.5},p:{x:.5,y:-.5},r:{x:.5,y:-.5},s:{x:.5,y:-.5},z:{x:.5,y:-.5},"scripts.trill":{y:-.5},"scripts.segno":{x:0,y:0},"scripts.coda":{x:0,y:0},"scripts.arpeggio":{x:.5,y:-.5},"pedal.*":{x:.78,y:-.78},"pedal.Ped":{x:1.6,y:-.7}},ONE_D_SEMANTICS=["OctaveShift8va","OctaveShift8vb","OctaveShift8","OctaveShift0","vline_VoltaLeft","vline_VoltaRight","VoltaAlternativeBegin","vline_BarMeasure","vline_BarTerminal","vline_BarSegment"],SYSTEM_SEMANTIC_TYPES=["BarMeasure","vline_BarMeasure","vline_BarTerminal","vline_BarSegment","vline_VoltaLeft","vline_VoltaRight","VoltaAlternativeBegin"],st=SemanticType,CONFLICTION_GROUPS=[[st.NoteheadS0,st.NoteheadS1,st.NoteheadS2],[st.Zero,st.One,st.Two,st.Three,st.Four,st.Five,st.Six,st.Seven,st.Eight,st.Nine,st.ScriptStaccatissimo],[st.TimesigZero,st.TimesigOne,st.TimesigTwo,st.TimesigThree,st.TimesigFour,st.TimesigFive,st.TimesigSix,st.TimesigSeven,st.TimesigEight,st.TimesigNine],[st.Rest0,st.Rest1,st.Rest2,st.Rest3,st.Rest4,st.Rest5,st.Rest6,st.Rest0W,st.RestM1],[st.SignInterval,st.SignLined],[st.BeamLeft,st.BeamContinue,st.BeamRight]],STAMP_SEMANTICS=[st.ClefG,st.ClefF,st.ClefC,st.NoteheadS0,st.NoteheadS1,st.NoteheadS2,st.Dot,st.Rest0,st.Rest1,st.Rest2,st.Rest3,st.Rest4,st.Rest5,st.Rest6,st.RestM1,st.AccNatural,st.AccSharp,st.AccDoublesharp,st.AccFlat,st.AccFlatflat,st.TimesigC44,st.TimesigC22,st.TimesigZero,st.TimesigOne,st.TimesigTwo,st.TimesigThree,st.TimesigFour,st.TimesigFive,st.TimesigSix,st.TimesigSeven,st.TimesigEight,st.TimesigNine,st.One,st.Two,st.Three,st.Four,st.Five,st.OctaveShift8,st.OctaveShift0,st.f,st.p,st.m,st.n,st.r,st.s,st.z,st.ScriptFermata,st.ScriptShortFermata,st.ScriptSforzato,st.ScriptStaccato,st.ScriptStaccatissimo,st.ScriptTurn,st.ScriptTrill,st.ScriptSegno,st.ScriptCoda,st.ScriptArpeggio,st.ScriptPrall,st.ScriptMordent,st.ScriptMarcato,st.ScriptTenuto,st.ScriptPortato,st.PedalStar,st.PedalPed],STAMP_RECTS={ClefG:[-.0625,-1.125,3.6,8.6],ClefF:[.25,.5625,3.6,3.8],ClefC:[.25,0,3.25,4.5],NoteheadS0:[.0625,0,2.55,1.4],NoteheadS1:[.0625,0,1.8,1.4],NoteheadS2:[.0625,-.0625,1.65,1.35],Dot:[.25,0,.6,.6],Rest0:[0,-.75,3.25,.9],Rest1:[0,-.25,3.25,.9],Rest2:[-.0625,-.1875,1.6,3.375],Rest3:[0,.0625,1.2,2.25],Rest4:[.0625,.5625,1.65,3.375],Rest5:[.0625,.0625,1.95,4.375],Rest6:[.0625,.5625,1.95,5.375],RestM1:[-.4375,-1.5,.75,1.2],AccNatural:[0,0,.9,3.5],AccSharp:[0,0,1.5,3.5],AccDoublesharp:[0,0,1.5,1.5],AccFlat:[0,-.5625,1.2,3.125],AccFlatflat:[.1875,-.5625,1.95,3.125],TimesigC44:[-.0625,0,2.25,2.3],TimesigC22:[-.0625,0,2.25,3.2],TimesigZero:[0,0,1.8,2.2],TimesigOne:[-.125,0,1.5,2.2],TimesigTwo:[0,0,2.2,2.2],TimesigThree:[-.0625,0,1.9,2.4],TimesigFour:[.0625,0,1.95,2.2],TimesigFive:[0,0,1.8,2.3],TimesigSix:[0,0,2,2.4],TimesigSeven:[0,0,1.8,2.2],TimesigEight:[0,0,1.9,2.2],TimesigNine:[0,0,1.9,2.2],One:[-.0625,0,.75,1.6],Two:[0,0,1.2,1.6],Three:[0,0,1.2,1.6],Four:[0,0,1.2,1.6],Five:[0,0,1.2,1.6],OctaveShift8:[2.125,-.1875,4.75,3.6],OctaveShift0:[-.4,0,1.8,4.2],f:[.0625,-.125,2.55,3],p:[-.0625,.25,2.55,2.1],m:[-.125,-.0625,2.4,1.35],n:[-.3125,-.0625,1.95,1.35],r:[0,-.125,1.5,1.5],s:[0,-.0625,1.2,1.35],z:[.0625,0,1.35,1.5],ScriptFermata:[0,0,3.25,3.9],ScriptShortFermata:[0,0,2.4,4.95],ScriptSforzato:[-.0625,0,2.5,1.2],ScriptStaccato:[0,-.0625,.6,.45],ScriptStaccatissimo:[0,0,1.2,2.6],ScriptTurn:[0,0,2.7,1.5],ScriptTrill:[-.125,-.5,3,2.7],ScriptSegno:[0,0,2.4,3.5],ScriptCoda:[0,0,2.7,3.25],ScriptArpeggio:[-.0625,0,1.05,1.8],ScriptPrall:[0,0,2.4,1.2],ScriptMordent:[0,0,2.4,1.5],ScriptMarcato:[0,0,1.2,2.475],ScriptTenuto:[0,-.0625,1.5,.15],ScriptPortato:[0,0,1.5,1.65],PedalStar:[0,0,3.2,3.2],PedalPed:[0,-.25,4.7,2.4]},hashSemanticPoint=(s,t,e)=>{const i=Math.round(e.x*10),n=Math.round(e.y*10),r=`${s}|${t}|${e.semantic}|${i}|${n}`,a=sha1.array(r).slice(12),o=globalThis.btoa(String.fromCharCode(...a)).substring(0,11);return e.id=o,o},hashPageSemanticPoint=(s,t)=>{const e=Math.round(t.x),i=Math.round(t.y),n=`p-${s}|${t.semantic}|${e}|${i}`,r=sha1.array(n).slice(12),a=globalThis.btoa(String.fromCharCode(...r)).substring(0,11);return t.id=a,a},POINT_CONFLICTION_DISTANCE=.4,roundNumber=(s,t,e=-1/0)=>Math.max(Math.round(s/t)*t,e),distance2D=(s,t)=>{const e=s.x-t.x,i=s.y-t.y;return Math.sqrt(e*e+i*i)},trans23=(s,t)=>({x:t[0]*s.x+t[2]*s.y+t[4],y:t[1]*s.x+t[3]*s.y+t[5]}),gcd=(s,t)=>Number.isInteger(s)&&Number.isInteger(t)?t===0?s:gcd(t,s%t):(console.error("non-integer gcd:",s,t),1),frac=(s,t)=>({numerator:s,denominator:t}),reducedFraction=(s,t)=>{s=Math.round(s),t=Math.round(t);const e=s!==0?gcd(s,t):t;return frac(s/e,t/e)},printFraction=s=>`${s.numerator}/${s.denominator}`,fractionMul=(s,t)=>t?s*t.numerator/t.denominator:s,segmentPoints=(s,t)=>{const e=[...s].sort((r,a)=>r[t]-a[t]);let i=null,n=null;return e.reduce((r,a,o)=>(n?a[t]-n[t]1&&r.push(i),n=a,i=[a]):(n=a,i=[a]),i.length>1&&o===e.length-1&&r.push(i),r),[])},filterWeekPoints=s=>{if(s.length<=1)return[];let t=s.slice(1);const e=CONFLICTION_GROUPS.find(n=>n.includes(s[0].semantic));if(!e)return filterWeekPoints(t);const i=t.filter(n=>e.includes(n.semantic));return t=t.filter(n=>!e.includes(n.semantic)),[...i,...filterWeekPoints(t)]},solveOverlapping=s=>{const t=new Set(s),e=segmentPoints(s,"x"),i=[].concat(...e.map(n=>segmentPoints(n,"y")));return i.forEach(n=>n.sort((r,a)=>a.confidence-r.confidence)),i.forEach(n=>{filterWeekPoints(n).forEach(r=>t.delete(r))}),Array.from(t)},GROUP_N_TO_PITCH$1=[0,2,4,5,7,9,11],MIDDLE_C$1=60,mod7$1=s=>{let t=s%7;for(;t<0;)t+=7;return t},noteToPitch=({note:s,alter:t})=>{const e=Math.floor(s/7),i=mod7$1(s);return MIDDLE_C$1+e*12+GROUP_N_TO_PITCH$1[i]+t},argmax$1=s=>{const t=Math.max(...s);return s.indexOf(t)};class DummyLogger{debug(...t){}group(...t){}groupCollapsed(...t){}groupEnd(){}info(...t){}warn(...t){}assert(...t){}}const EOM=-1,GREAT_NUMBER=1920,DURATION_MULTIPLIER=128*3*5*7*11*13,floatToFrac=s=>{const t=Math.round(s*GREAT_NUMBER);return reducedFraction(t,GREAT_NUMBER)},floatToTimeWarp=s=>s===1?null:floatToFrac(s);class Action{type;e1;e2;constructor(t){Object.assign(this,t)}static P(t){return new Action({type:0,e1:t})}static V(t,e,i=1){return new Action({type:1,e1:i>0?t:e,e2:i>0?e:t})}static H(t,e){return new Action({type:2,e1:t,e2:e})}get id(){switch(this.type){case 0:return this.e1.toString();case 1:return`${this.e1}|${this.e2}`;case 2:return`${this.e1}-${this.e2>=0?this.e2:"."}`}}get events(){return[this.e1,this.e2].filter(Number.isFinite)}}class StageMatrix{matrix;static fromNode(t,e){const i=Array(t.stages.length).fill(null).map(()=>Array(t.stages.length).fill(null).map(()=>new Set));t.actions.filter(d=>d.type===2).forEach(d=>{const l=t.stages.findIndex(h=>h.events.includes(d.e1)),u=t.stages.findIndex(h=>h.events.includes(d.e2));console.assert(l>=0&&u>=0,"invalid stages for H action:",t.id,t.stages,d),i[l][u].add(d.e1)}),i[0][t.stages.length-1].add(0);const n=t.stagedEvents,r=e.matrixH[e.matrixH.length-1].filter((d,l)=>!n.has(l)),a=Math.max(0,Math.max(...r)-.01),o=t.actions.filter(d=>d.type===2),c=Object.keys(e.eventMap).map(Number).filter(d=>!o.find(l=>l.e2===d));return t.stages.forEach(d=>{d.events.forEach(l=>{l>0&&!o.find(h=>h.e1===l)&&e.matrixH[e.matrixH.length-1][l]>=a&&(c.some(h=>e.matrixH[h][l]>0)||i[d.index][t.stages.length-1].add(l))})}),new StageMatrix({matrix:i})}constructor(t){Object.assign(this,t)}pathOf(t,e,i,n=0){if(this.matrix[t][e].size){const r=[...this.matrix[t][e]][n];if(e===i)return[r];for(let a=e+1;a<=i;++a){const o=this.pathOf(e,a,i);if(o)return[r,...o]}}return null}findDoublePath(t,e){const i=[];for(let n=e;n>=t+1;--n)for(let r=0;re.forEach(i=>t.forEach(n=>i.delete(n))))}toEquations(t){const e=[];for(let i=1;id[l]=1),c.forEach(l=>d[l]=-1),e.push(d),this.reducePath(o.length>c.length?o:c)}else break}}return e}}class PathNode{logger;parent;action;possibility;children;stages;constraints;constructor(t){Object.assign(this,t),console.assert(this.logger,"logger is null:",t)}get actions(){const t=this.parent?this.parent.actions:[];return this.action?[...t,this.action]:t}get id(){return this.actions.map(e=>e.id).sort().join(" ")}get stagedEvents(){const t=new Set;return this.stages&&this.stages.forEach(e=>e.events.forEach(i=>i>=0&&t.add(i))),t}like(t){return t.split(" ").sort().join(" ")===this.id}constructStages(t){this.stages=[{events:[EOM]}];for(const e of this.actions)switch(e.type){case 0:this.stages.unshift({events:[e.e1]});break;case 1:{const i=this.stages.find(r=>r.events.includes(e.e1)),n=this.stages.find(r=>r.events.includes(e.e2));console.assert(i||n,"invalid V action:",this.stages,e),i&&n?(i.events.push(...n.events),n.events=null,this.stages=this.stages.filter(r=>r.events)):i?n||i.events.push(e.e2):n.events.unshift(e.e1)}break;case 2:{const i=this.stages.find(a=>a.events.includes(e.e1)),n=this.stages.find(a=>a.events.includes(e.e2));console.assert(i||n,"invalid H action:",this.stages,e);const r=a=>{console.assert(t.eventMap[a],"invalid event id:",e.id,a,t.eventMap);const o=t.eventMap[a].x,c=this.stages.find(d=>d.events.some(l=>l>0&&t.eventMap[l].x<=o)&&d.events.some(l=>l>0&&t.eventMap[l].x>=o));if(c)c.events.push(a);else{const d={events:[a]},l=this.stages.findIndex(u=>u.events[0]===EOM||t.eventMap[u.events[0]].x>=o);this.stages.splice(l,0,d)}};i||r(e.e1),n||r(e.e2)}break}this.stages.forEach((e,i)=>e.index=i)}constructConstraints(t){const e=Object.keys(t.eventMap).length,n=StageMatrix.fromNode(this,t).toEquations(e),r=Array(e).fill(null).map((a,o)=>t.eventMap[o].duration);this.constraints=n.map(a=>a.map((o,c)=>o*r[c]))}inbalancesConstraints(t){console.assert(this.constraints,"constraints not constructed.");const e=Object.keys(t.eventMap).length,i=Array(e).fill(!0),n=Array(e).fill(!1),r=[];for(const a of this.constraints){const o=a.reduce((c,d)=>c+d,0);if(o!==0){const c=o<0?a.map(d=>-d):a;if(c[0]>0)continue;r.push(c),c.forEach((d,l)=>{n[l]=n[l]||d<0,d&&(i[l]=d<0||n[l])})}}return this.constraints.forEach(a=>{a.reduce((c,d)=>c+d,0)===0&&!a[0]&&a.some((c,d)=>c&&!i[d])&&(a.forEach((c,d)=>c&&(i[d]=!1)),r.push(a))}),{ones:i,inbalances:r}}solveEquations({ones:t,inbalances:e}){if(!e.length)return t.map(()=>1);const i=t.map((p,m)=>({fixed:p,i:m})).filter(({fixed:p})=>!p).map(({i:p})=>p).filter(p=>e.some(m=>m[p]!==0));if(!i.length)return t.map(()=>1);const n=i.map(p=>Math.abs(e.find(m=>m[p]!==0)[p])),r=new Map;let a=!1;const o=e.map(p=>{const m=p.filter((x,g)=>i.includes(g)),T=-p.reduce((x,g,v)=>x+(i.includes(v)?0:g),0);return{line:m,bias:T}}).filter(({line:p,bias:m})=>{if(p.every(x=>x===0))return!1;const T=p.join(",");return r.has(T)?(a=r.get(T)!==m,!1):(r.set(T,m),!0)});if(a)return null;const c=o.slice(0,i.length),d=o.slice(i.length);if(c.lengthv===m?1:v===T?-1:0),bias:0,prior:(n[m]+n[T])/DURATION_MULTIPLIER};c.some(g=>g.line[m]&&g.line[T])&&(x.prior-=10),c.some(g=>g.line.filter(Number).length===1&&(g.line[m]||g.line[T]))&&(x.prior+=1),p.push(x)}p.sort((m,T)=>m.prior-T.prior),c.push(...p.slice(0,i.length-c.length))}const l=c.map(({line:p})=>p),u=c.map(({bias:p})=>p),h=matrixInverse$1(l);if(!h)return this.logger.warn("null invert:",l),null;const y=h.map(p=>p.reduce((m,T,x)=>m+T*u[x],0));if(d.length&&d.some(p=>Math.abs(p.line.reduce((m,T,x)=>m+T*y[x],0))>.001))return null;const f=t.map(()=>1);return i.forEach((p,m)=>f[p]=y[m]),f}optimallySolve(t){const{ones:e,inbalances:i}=this.inbalancesConstraints(t),r=e.map((o,c)=>o?-1:roundNumber(t.eventMap[c].shrinkness,.01)).reduce((o,c,d)=>(c>=0&&(o[c]=o[c]||[],o[c].push(d)),o),{}),a=Object.entries(r).sort((o,c)=>Number(c[0])-Number(o[0])).map(o=>o[1]);for(let o=1;o!c.includes(h)),l=this.solveEquations({ones:d,inbalances:i});if(l&&l.every((u,h)=>u<=1&&u>t.eventMap[h].lowWarp))return l}return this.solveEquations({ones:e,inbalances:i})}isConflicted(t){const{ones:e,inbalances:i}=this.inbalancesConstraints(t);for(const r of i)if(r.reduce((o,c,d)=>o+c*(e[d]||c<=0?1:t.eventMap[d].lowWarp),0)>=0)return r.forEach((o,c)=>{o&&(t.eventTendencies[c]+=o>0?1:-1)}),!0;if(!i.length)return!1;const n=this.solveEquations({ones:e,inbalances:i});return n?!n.every((r,a)=>r>t.eventMap[a].lowWarp&&r<=1):!0}getSolution(t){const e=f=>t.eventMap[f.e2]?t.eventMap[f.e2].x+Math.abs(t.eventMap[f.e2].x-t.eventMap[f.e1].x)*.06:t.eventMap[f.e1].x+1e4,i=this.actions.filter(f=>f.type===2).sort((f,p)=>e(f)-e(p)),n=i.reduce((f,p)=>({...f,[p.e1]:p.e2}),{}),r=new Set([...Object.keys(n)].map(Number));i.forEach(f=>r.delete(f.e2)),this.stages[0].events.forEach(f=>f>0&&r.add(f));let a=[...r].map(f=>{const p=[f];let m=f;for(;n[m]&&(m=n[m],!(m<0||p.includes(m)));)p.push(m);return p});const o=Object.values(t.eventMap).filter(f=>f.id>0).map(f=>({id:f.id,tick:null,endTick:null,tickGroup:null,timeWarp:null})),c=o.filter(f=>a.some(p=>p.includes(f.id))||i.some(p=>[p.e1,p.e2].includes(f.id))).reduce((f,p)=>({...f,[p.id]:p}),{});this.stages.forEach((f,p)=>f.events.forEach(m=>c[m]&&(c[m].tickGroup=p))),this.stages[0].tick=0,this.stages[0].events.forEach(f=>c[f]&&(c[f].tick=0));const d=this.optimallySolve(t);o.forEach(f=>f.timeWarp=floatToTimeWarp(d[f.id]));const l=this.stages.slice(0,this.stages.length-1),u=()=>{if(l.every(p=>Number.isFinite(p.tick)))return!1;let f=!1;return i.forEach(p=>{const m=this.stages.find(x=>x.events.includes(p.e1)),T=this.stages.find(x=>x.events.includes(p.e2));Number.isFinite(m.tick)&&!Number.isFinite(T.tick)&&(T.tick=m.tick+fractionMul(t.eventMap[p.e1].duration,c[p.e1].timeWarp),T.events.forEach(x=>c[x]&&(c[x].tick=T.tick)),f=!0)}),[...i].reverse().forEach(p=>{const m=this.stages.find(x=>x.events.includes(p.e1)),T=this.stages.find(x=>x.events.includes(p.e2));!Number.isFinite(m.tick)&&Number.isFinite(T.tick)&&(m.tick=T.tick-fractionMul(t.eventMap[p.e1].duration,c[p.e1].timeWarp),m.events.forEach(x=>c[x]&&(c[x].tick=m.tick)),f=!0)}),f};for(;u(););console.assert(l.every(f=>Number.isFinite(f.tick)),"stage ticks not all solved:",this.stages,this.id),o.filter(f=>Number.isFinite(f.tick)).forEach(f=>f.endTick=f.tick+fractionMul(t.eventMap[f.id].duration,f.timeWarp));const h=t.eventMap[0].duration;a.forEach(f=>{const p=f.findIndex(m=>c[m].endTick>h);p>=0&&f.splice(p,f.length-p).forEach(T=>{c[T].tick=null,c[T].endTick=null})}),a=a.filter(f=>f.length);const y=Math.max(0,...o.map(f=>f.endTick).filter(Number.isFinite));return this.logger.debug(String.fromCodePoint(127822),this.id,d),{voices:a,events:o,duration:y,actions:this.actions.map(f=>f.id).join(" ")}}deduce(t,e){this.stages||this.constructStages(t);const i=t.actionAccessing.get(this.id)||{times:0};if(++i.times,t.actionAccessing.set(this.id,i),this.constructConstraints(t),this.isConflicted(t))return i.closed=!0,this.logger.info(this.action.id,"❌"),null;if(this.logger.group(this.action&&this.action.id),e.credits>0){if(--e.credits,this.children||this.expand(t),this.children=this.children.filter(n=>!t.actionAccessing.get(n.id)||!t.actionAccessing.get(n.id).closed),this.children.length){const n=r=>r.possibility/((t.actionAccessing.get(r.id)||{times:0}).times+1);this.children.sort((r,a)=>n(a)-n(r));for(const r of this.children){const a=r.deduce(t,e);if(a)return this.logger.groupEnd(),a;if(e.credits<=0)break}}}else this.logger.debug("quota exhausted.");return this.logger.groupEnd(),i.closed=!0,this.getSolution(t)}expand(t){this.constructStages(t);const{eventMap:e,matrixV:i,matrixH:n}=t,r=this.stagedEvents,a=[],o=c=>{if(!this.actions.some(d=>d.id===c.action.id)&&!a.some(d=>d.action.id===c.action.id)){const d=this.stages.find(u=>u.events.includes(c.action.e1)),l=this.stages.find(u=>u.events.includes(c.action.e2));if(d===l||d&&l&&d.index>=l.index)return;if(d&&l){if(c.action.type===1){if(l.index-d.index>1||this.actions.some(u=>d.events.includes(u.e1)&&l.events.includes(u.e2)))return}else if(c.action.type===2&&d.index>l.index)return}if(c.action.type===2&&this.actions.some(u=>u.type===2&&(u.e1===c.action.e1||u.e2===c.action.e2||u.e1===c.action.e2&&u.e2===c.action.e1))||c.action.type===1&&(d&&(c.possibility=Math.min(c.possibility,...d.events.map(u=>i[c.action.e2][u])),c.possibility<=0)||l&&(c.possibility=Math.min(c.possibility,...l.events.map(u=>i[u][c.action.e1])),c.possibility<=0)))return;a.push(c)}};for(const c of r)c<0||(i[c].forEach((d,l)=>{d>0&&c!==l&&o({action:Action.V(l,c),possibility:d})}),i.forEach((d,l)=>{const u=d[c];u>0&&o({action:Action.V(c,l),possibility:u})}),n[c].forEach((d,l)=>{d>0&&o({action:Action.H(l,c),possibility:d})}),n.forEach((d,l)=>{l=l>=Object.keys(e).length?-1:l;const u=d[c];u>0&&o({action:Action.H(c,l),possibility:u})}));if(!a.some(c=>[2,0].includes(c.action.type)||!r.has(c.action.e1)||!r.has(c.action.e2))){this.children=[];return}this.children=a.map(c=>new PathNode({logger:this.logger,parent:this,...c}))}}class Solver{quota;logger;events;matrixH;matrixV;xSpan;eventMap;actionAccessing;pathRoot;constructor(t,{quota:e=1e3,logger:i=new DummyLogger}={}){this.quota=e,this.logger=i;const n={id:0,x:0,confidence:1,shrinkness:t.measureShrinkness,duration:t.expectedDuration,lowWarp:0};this.events=[n,...t.events.map(r=>({id:r.id,x:r.x,confidence:r.confidence,shrinkness:r.shrinkness,staff:r.staff,duration:r.duration,lowWarp:.5}))],this.eventMap=this.events.reduce((r,a)=>({...r,[a.id]:a}),{}),this.matrixH=t.matrixH,this.matrixV=t.matrixV,this.xSpan=t.endX-Math.min(t.endX-1,...t.events.map(r=>r.x)),this.actionAccessing=new Map}solve(){this.pathRoot=new PathNode({logger:this.logger,action:null}),this.pathRoot.children=this.events.slice(1).map(n=>new PathNode({logger:this.logger,parent:this.pathRoot,action:Action.P(n.id),possibility:this.matrixV[n.id].reduce((r,a)=>r+a,0)}));let t=null;this.logger.groupCollapsed("solve");const e=Array(this.events.length).fill(0),i={credits:this.quota,times:0};for(;i.credits>0;){++i.times;const n={eventMap:this.eventMap,matrixH:this.matrixH,matrixV:this.matrixV,actionAccessing:this.actionAccessing,eventTendencies:e},r=this.pathRoot.deduce(n,i);if(r.credits=this.quota-i.credits,r.times=i.times,this.evaluateSolution(r),this.logger.debug("loss:",r.loss),t=!t||r.lossn/i.times)),t}evaluateSolution(t){t.loss=0;const e=t.events.reduce((h,y)=>({...h,[y.id]:{...y,...this.eventMap[y.id]}}),{}),i=t.events.filter(h=>Number.isFinite(h.tick)).map(h=>e[h.id]),n=i.reduce((h,y)=>(h[y.staff]=h[y.staff]||[],h[y.staff].push(y),h),{});Object.values(n).forEach(h=>{h.sort((f,p)=>f.x-p.x).slice(0,h.length-1).forEach((f,p)=>{h[p+1].tick{if((!Number.isFinite(h.tick)||t.voices.every(y=>!y.includes(h.id)))&&(t.loss+=100*e[h.id].confidence),h.timeWarp){const{numerator:y,denominator:f}=h.timeWarp,p=e[h.id].shrinkness;r.set(y,Math.max(r.get(y)||0,1-p)),r.set(f,Math.max(r.get(f)||0,1-p))}});const a=reducedFraction(t.duration,this.eventMap[0].duration);r.set(a.numerator,Math.max(r.get(a.numerator)||0,1-this.eventMap[0].shrinkness)),r.set(a.denominator,Math.max(r.get(a.denominator)||0,1-this.eventMap[0].shrinkness));for(const[h,y]of r.entries())h>1&&(t.loss+=Math.log(h)*y);let o=0,c=0;t.voices.forEach(h=>{console.assert(e[h[0]],"invalid voice:",h,Object.keys(e));const y=Math.abs(e[h[0]].tick),f=e[h[h.length-1]].endTick;o+=Math.max(0,y+t.duration-f);let p=null;h.forEach(m=>{const T=e[m];T.staff!==p&&(p!==null&&++c,p=T.staff)})}),t.loss+=o*10/DURATION_MULTIPLIER,t.loss+=5**c-1;const d=[...i].sort((h,y)=>h.x-y.x),l=d.slice(1).map((h,y)=>{const f=d[y],p=h.x-f.x,m=h.tick-f.tick;return m?(Math.atan2(m/t.duration,p/this.xSpan)*4/Math.PI-1)**2:p/this.xSpan}),u=Math.max(...l,0);t.loss+=u**2,console.assert(t.loss>=0,"Invalid solution loss!!!",t.loss,r,o,c),t.loss<0&&(t.loss=1/0)}}var EventElementType=(s=>(s[s.PAD=0]="PAD",s[s.BOS=1]="BOS",s[s.EOS=2]="EOS",s[s.CHORD=3]="CHORD",s[s.REST=4]="REST",s))(EventElementType||{});class EventCluster extends SimpleClass{static className="EventCluster";static blackKeys=["id"];id;index;duration;staffY0;signatureDuration;elements;matrixH;backgroundImages;annotation;constructor(t){super(),super.assign(t)}get regular(){return this.elements.some(t=>[3,4].includes(t.type)&&!t.fake)&&this.elements.every(t=>[t.x,t.y1,t.y2,t.tick].every(Number.isFinite))&&this.elements.slice(1).every((t,e)=>t.fake||this.elements[e].fake||t.grace||this.elements[e].grace||t.fullMeasure||this.elements[e].fullMeasure||t.tick<=this.elements[e].tick||t.x>this.elements[e].x)}get grant(){return this.annotation&&this.annotation.grant}get feature(){return{index:this.index,elements:this.elements}}get estimatedDuration(){var i;const t=this.elements.find(n=>n.type===2),e=t!=null&&t.predisposition?(i=t.predisposition)==null?void 0:i.tick:t==null?void 0:t.tick;return Number.isFinite(e)?e:this.duration}assignPrediction(t){console.assert(t.index===this.index,"index mismatch:",t.index,this.index),this.matrixH=t.matrixH,t.elements.forEach(e=>{const{index:i,...n}=e,r=this.elements.find(a=>a.index===i);console.assert(r,"element not found:",i),r&&(r.predisposition=n)})}}class EventClusterSet extends SimpleClass{static className="EventClusterSet";name;clusters;constructor(t){super(),super.assign(t)}trimIrregular(){let t=0;return this.clusters=this.clusters.filter(e=>{const i=e.regular;return i||(console.debug("irregular cluster:",e),++t),i}),t?console.debug("Irregular clusters trimmed:",`${t}/${this.clusters.length+t}`):console.debug(`The EventClusterSet (${this.clusters.length}) is fine.`),t}}class PatchMeasure extends SimpleClass{static className="PatchMeasure";measureIndex;staffMask;basic;events;contexts;marks;voices;constructor(t){super(),Object.assign(this,t)}get staffN(){return Math.floor(Math.log2(this.staffMask))+1}get basics(){return Array(this.staffN).fill(this.basic)}get duration(){return Math.max(0,...(this.voices||[]).map(t=>t.map(i=>this.events.find(n=>n.id===i)).reduce((i,n)=>i+n.duration,0)))}}var TokenType=(s=>(s.ClefG="clefs-G",s.ClefF="clefs-F",s.ClefC="clefs-C",s.TimesigC44="timesig-C44",s.TimesigC22="timesig-C22",s.TimesigZero="zero|timesig0",s.TimesigOne="one|timesig1",s.TimesigTwo="two|timesig2",s.TimesigThree="three|timesig3",s.TimesigFour="four|timesig4",s.TimesigFive="five|timesig5",s.TimesigSix="six|timesig6",s.TimesigSeven="seven|timesig7",s.TimesigEight="eight|timesig8",s.TimesigNine="nine|timesig9",s.OctaveShift8va="octave-a",s.OctaveShift8vb="octave-b",s.OctaveShift0="octave-0",s.Zero="zero|n0",s.One="one|n1",s.Two="two|n2",s.Three="three|n3",s.Four="four|n4",s.Five="five|n5",s.Six="six|n6",s.Seven="seven|n7",s.Eight="eight|n8",s.Nine="nine|n9",s.AccNatural="accidentals-natural",s.AccSharp="accidentals-sharp",s.AccDoublesharp="accidentals-doublesharp",s.AccFlat="accidentals-flat",s.AccFlatflat="accidentals-flatflat",s.KeyNatural="accidentals-natural|key-natural",s.KeySharp="accidentals-sharp|key-sharp",s.KeyFlat="accidentals-flat|key-flat",s.NoteheadS0="noteheads-s0",s.NoteheadS1="noteheads-s1",s.NoteheadS2="noteheads-s2",s.NoteheadS1stemU="noteheads-s1|noteheads-s1-u",s.NoteheadS1stemD="noteheads-s1|noteheads-s1-d",s.NoteheadS2stemU="noteheads-s2|noteheads-s2-u",s.NoteheadS2stemD="noteheads-s2|noteheads-s2-d",s.Rest0="rests-0o",s.Rest1="rests-1o",s.Rest2="rests-2",s.Rest3="rests-3",s.Rest4="rests-4",s.Rest5="rests-5",s.Rest6="rests-6",s.Rest0W="rests-0",s.RestM1="rests-M1",s.Flag3="flags-u3",s.Flag4="flags-u4",s.Flag5="flags-u5",s.Flag6="flags-u6",s.Flag7="flags-u7",s.Flag8="flags-u8",s.BeamLeft="|beam-left",s.BeamRight="|beam-right",s.BeamContinue="|beam-continue",s.TremoloLeft="|tremolo-left",s.TremoloRight="|tremolo-right",s.TremoloMiddle="|tremolo-middle",s.SlurBegin="|slur-begin",s.SlurEnd="|slur-end",s.TieBegin="|tie-begin",s.TieEnd="|tie-end",s.VoltaLeft="|volta-left",s.VoltaRight="|volta-right",s.VoltaAlternativeBegin="|volta-alter-begin",s.BarTerminal="|bar-terminal",s.BarSegment="|bar-segment",s.Dot="|dot",s.DotDot="|dotdot",s.f="f",s.p="p",s.m="m",s.r="r",s.s="s",s.z="z",s.WedgeCrescendo="|wedge-crescendo",s.WedgeDiminuendo="|wedge-diminuendo",s.WedgeClose="|wedge-close",s.CrescendoBegin="|wedge-crescendo",s.DecrescendoBegin="|wedge-diminuendo",s.CrescendoEnd="|wedge-close",s.DecrescendoEnd="|wedge-close",s.ScriptFermata="scripts-ufermata",s.ScriptShortFermata="scripts-ushortfermata",s.ScriptSforzato="scripts-sforzato",s.ScriptStaccato="scripts-staccato",s.ScriptStaccatissimo="scripts-ustaccatissimo",s.ScriptTurn="scripts-turn",s.ScriptTrill="scripts-trill",s.ScriptSegno="scripts-segno",s.ScriptCoda="scripts-coda",s.ScriptArpeggio="scripts-arpeggio",s.ScriptPrall="scripts-prall",s.ScriptMordent="scripts-mordent",s.ScriptMarcato="scripts-umarcato",s.ScriptTenuto="scripts-tenuto",s.ScriptPortato="scripts-uportato",s.PedalStar="pedal-star",s.PedalPed="pedal-Ped",s.Text="|text",s.GraceNotehead="|grace-notehead",s))(TokenType||{});const tt=TokenType,TokenTypes=Object.values(TokenType),TokenClefs=TokenTypes.filter(s=>/clefs-/.test(s)),TokenTimesigs=TokenTypes.filter(s=>/timesig/.test(s)),TokenTimesigsC=TokenTypes.filter(s=>/timesig-/.test(s)),TokenTimesigsN=TokenTypes.filter(s=>/timesig\d/.test(s)),TokenOctshifts=TokenTypes.filter(s=>/octave-/.test(s)),TokenNumbers=TokenTypes.filter(s=>/n\d/.test(s)),TokenAccidentals=TokenTypes.filter(s=>/accidentals-/.test(s)),TokenNoteheads=TokenTypes.filter(s=>/noteheads-/.test(s)),TokenBareNoteheads=[tt.NoteheadS0,tt.NoteheadS1,tt.NoteheadS2],TokenDirectionalNoteheads=TokenTypes.filter(s=>/noteheads-.+-[ud]/.test(s)),TokenRests=TokenTypes.filter(s=>/rests-/.test(s)),TokenFlags=TokenTypes.filter(s=>/flags-/.test(s)),TokenVolta=TokenTypes.filter(s=>/volta-/.test(s)),TokenDynamics=TokenTypes.filter(s=>/^[a-z]$/.test(s)),TokenScripts=TokenTypes.filter(s=>/scripts-/.test(s)),TokenPedals=TokenTypes.filter(s=>/pedal-/.test(s)),TokenDots=[tt.Dot,tt.DotDot],TokenArcs=[tt.SlurBegin,tt.SlurEnd,tt.TieBegin,tt.TieEnd],TokenBeams=TokenTypes.filter(s=>/beam-/.test(s)),TokenWedges=TokenTypes.filter(s=>/wedge-/.test(s)),TokenAccessories=[...TokenNumbers,...TokenDynamics,...TokenWedges,...TokenPedals,...TokenArcs,tt.ScriptFermata,tt.ScriptShortFermata,tt.ScriptSforzato,tt.ScriptStaccato,tt.ScriptStaccatissimo,tt.ScriptTurn,tt.ScriptTrill,tt.ScriptPrall,tt.ScriptMordent,tt.ScriptMarcato,tt.ScriptTenuto,tt.ScriptPortato],TokenDirectionless=[...TokenPedals],TokenGlyphs=[...TokenClefs,...TokenTimesigs,...TokenNumbers,...TokenAccidentals,tt.NoteheadS0,tt.NoteheadS1,tt.NoteheadS2,...TokenRests,...TokenDynamics,...TokenScripts,...TokenPedals,...TokenDots],TOKEN_Y_ROUND={};TokenClefs.forEach(s=>TOKEN_Y_ROUND[s]=1);TokenTimesigsN.forEach(s=>TOKEN_Y_ROUND[s]=1);TokenAccidentals.forEach(s=>TOKEN_Y_ROUND[s]=.5);TokenNoteheads.forEach(s=>TOKEN_Y_ROUND[s]=.5);TokenRests.forEach(s=>TOKEN_Y_ROUND[s]=.5);TokenDots.forEach(s=>TOKEN_Y_ROUND[s]=.5);const TOKEN_Y_FIXED={};TokenTimesigsC.forEach(s=>TOKEN_Y_FIXED[s]=0);TokenVolta.forEach(s=>TOKEN_Y_FIXED[s]=0);class Token{static className="Token";id;type;x;y;pivotX;confidence;tip;voice;timeWarped;constructor(t){Object.assign(this,t)}get typeId(){return this.type.split("|").reverse()[0]}get isPredicted(){return Number.isFinite(this.confidence)}get isNotehead(){return TokenDirectionalNoteheads.includes(this.type)||this.type==="noteheads-s0"}get isContexted(){return TokenClefs.includes(this.type)||TokenTimesigs.includes(this.type)||TokenOctshifts.includes(this.type)||TokenAccidentals.includes(this.type)}get isAccessory(){return TokenNumbers.includes(this.type)||TokenDynamics.includes(this.type)||TokenScripts.includes(this.type)||TokenPedals.includes(this.type)}get division(){switch(this.type){case tt.NoteheadS0:return 0;case tt.NoteheadS1stemU:case tt.NoteheadS1stemD:return 1;case tt.NoteheadS2stemU:case tt.NoteheadS2stemD:return 2;case tt.Flag3:return 3;case tt.Flag4:return 4;case tt.Flag5:return 5;case tt.Flag6:return 6;case tt.Flag7:return 7;case tt.Flag8:return 8;case tt.RestM1:return-1;case tt.Rest0:return 0;case tt.Rest1:return 1;case tt.Rest2:return 2;case tt.Rest3:return 3;case tt.Rest4:return 4;case tt.Rest5:return 5;case tt.Rest6:return 6}return null}get dots(){switch(this.type){case tt.Dot:return 1;case tt.DotDot:return 2}return null}get direction(){switch(this.type){case tt.NoteheadS1stemU:case tt.NoteheadS2stemU:return"u";case tt.NoteheadS1stemD:case tt.NoteheadS2stemD:return"d"}return null}get width(){switch(this.type){case tt.NoteheadS0:return NOTEHEAD_WIDTHS.NoteheadS0;case tt.NoteheadS1stemU:case tt.NoteheadS1stemD:return NOTEHEAD_WIDTHS.NoteheadS1;case tt.NoteheadS2stemU:case tt.NoteheadS2stemD:return NOTEHEAD_WIDTHS.NoteheadS2}}get left(){switch(this.type){case tt.NoteheadS0:return this.x-this.width/2;case tt.NoteheadS1stemU:case tt.NoteheadS2stemU:return this.x-this.width;case tt.NoteheadS1stemD:case tt.NoteheadS2stemD:return this.x}return this.x}get right(){switch(this.type){case tt.NoteheadS0:return this.x+this.width/2;case tt.NoteheadS1stemU:case tt.NoteheadS2stemU:return this.x;case tt.NoteheadS1stemD:case tt.NoteheadS2stemD:return this.x+this.width}return this.x}get voiceIndices(){return!this.voice||this.voice<0?[]:Array(Math.floor(Math.log2(this.voice))+1).fill(null).reduce((t,e,i)=>this.voice&1<(s.Up="^",s.Down="_",s.Middle="-",s))(AccessoryDirection||{}),GraceType=(s=>(s.Grace="grace",s.AfterGrace="afterGrace",s.Acciaccatura="acciaccatura",s.Appoggiatura="appoggiatura",s.SlashedGrace="slashedGrace",s))(GraceType||{}),StemBeam=(s=>(s.Open="Open",s.Close="Close",s.Continue="Continue",s))(StemBeam||{}),TremoloLink=(s=>(s.Pitcher="Pitcher",s.Catcher="Catcher",s.Pierced="Pierced",s))(TremoloLink||{}),GlissandoStyle=(s=>(s.Normal="normal",s.DashedLine="dashed-line",s.DottedLine="dotted-line",s.Zigzag="zigzag",s.Trill="trill",s))(GlissandoStyle||{}),ArpeggioStyle=(s=>(s.Normal="Normal",s.Bracket="Bracket",s.Parenthesis="Parenthesis",s.ParenthesisDashed="ParenthesisDashed",s.ArrowDown="ArrowDown",s))(ArpeggioStyle||{});class Term extends SimpleClass{x;staff}const SCALE_NAMES="CDEFGAB";class EventTerm extends Term{static className="EventTerm";left;right;pivotX;system;roundX;intX;intY;ys;pitches;rest;division;dots;accessories;multiplier;stemDirection;tying;tied;repetitionChord;grace;beam;timeWarp;parenthesized;tremolo;tremoloLink;glissando;glissandoStyle;arpeggioStyle;tip;tick;id;prevId;tickGroup;feature;predisposition;graceIds;catcherId;noteIds;static space({tick:t,duration:e}){const i=new EventTerm({rest:"s",tick:t,accessories:[]});return i.duration=Math.round(e),i}constructor(t){super(),super.assign(t),Object.assign(this,t),Number.isFinite(t.left)&&Number.isFinite(t.right)&&(this.x=(this.left+this.right)/2),Number.isFinite(this.pivotX)||(this.pivotX=this.x)}get alignedTick(){return this.grace?this.tick+this.duration:this.tick}get mainDuration(){return WHOLE_DURATION*2**-this.division*(2-2**-this.dots)}get duration(){let t=this.mainDuration;return this.multiplier&&(t*=this.multiplier.numerator/this.multiplier.denominator),this.timeWarp&&(t*=this.timeWarp.numerator/this.timeWarp.denominator),this.grace?t/8:t}set duration(t){console.assert(Number.isFinite(t),"invalid duration value:",t);const e=gcd(t,WHOLE_EXP2),i=Math.log2(WHOLE_EXP2/e),n=reducedFraction(t*2**i,WHOLE_DURATION);this.division=i,this.dots=0,n.numerator!==n.denominator?this.multiplier=n:this.multiplier=void 0}get prior(){return this.tick}get times(){return this.timeWarp?`${this.timeWarp.numerator}/${this.timeWarp.denominator}`:null}get fullMeasureRest(){return this.rest==="R"}get tipX(){return this.tip?this.tip.x:this.x}get tipY(){return this.tip?this.tip.y:this.ys?this.ys[0]:0}get tremoloCatcher(){return this.tremoloLink==="Catcher"}get scaleChord(){return this.pitches.map(t=>SCALE_NAMES[(t.note+700)%7]).join("")}get zeroHolder(){return!!this.grace||this.tremoloCatcher}}var ContextType=(s=>(s[s.Clef=0]="Clef",s[s.KeyAcc=1]="KeyAcc",s[s.Acc=2]="Acc",s[s.OctaveShift=3]="OctaveShift",s[s.TimeSignatureC=4]="TimeSignatureC",s[s.TimeSignatureN=5]="TimeSignatureN",s))(ContextType||{});class ContextedTerm extends Term{static className="ContextedTerm";y;tokenType;tick;constructor(t){super(),Object.assign(this,t)}get type(){return TokenClefs.includes(this.tokenType)?0:/\|key-/.test(this.tokenType)?1:/accidentals-/.test(this.tokenType)?2:TokenOctshifts.includes(this.tokenType)?3:TokenTimesigsC.includes(this.tokenType)?4:TokenTimesigsN.includes(this.tokenType)?5:null}get staffLevel(){return[3,0,1].includes(this.type)}get prior(){return this.tick-.1}get clef(){switch(this.tokenType){case TokenType.ClefG:return-this.y-2;case TokenType.ClefF:return-this.y+2;case TokenType.ClefC:return-this.y}return null}get alter(){switch(this.tokenType){case TokenType.AccNatural:case TokenType.KeyNatural:return 0;case TokenType.AccSharp:case TokenType.KeySharp:return 1;case TokenType.AccFlat:case TokenType.KeyFlat:return-1;case TokenType.AccDoublesharp:return 2;case TokenType.AccFlatflat:return-2}return null}get octaveShift(){switch(this.tokenType){case TokenType.OctaveShift8va:return-1;case TokenType.OctaveShift0:return 0;case TokenType.OctaveShift8vb:return 1}return null}get number(){switch(this.tokenType){case TokenType.TimesigZero:return 0;case TokenType.TimesigOne:return 1;case TokenType.TimesigTwo:return 2;case TokenType.TimesigThree:return 3;case TokenType.TimesigFour:return 4;case TokenType.TimesigFive:return 5;case TokenType.TimesigSix:return 6;case TokenType.TimesigSeven:return 7;case TokenType.TimesigEight:return 8;case TokenType.TimesigNine:return 9}return null}}class MarkTerm extends Term{static className="MarkTerm";tick;get prior(){return this.tick+.01}}const MUSIC_NOTES=Array(7).fill(0).map((s,t)=>String.fromCodePoint(119133+t));class TempoTerm extends MarkTerm{static className="TempoTerm";duration;beats;static fromNumeralText(t){if(/.+=.*\d+/.test(t)){const[e,i]=t.split("=");let n=MUSIC_NOTES.findIndex(a=>e.includes(a));n=n>=0?n:2;let r=(2**n).toString();return e.includes(".")&&(r+="."),new TempoTerm({tick:0,duration:r,beats:i})}return null}constructor(t){super(),Object.assign(this,t)}get prior(){return this.tick-.01}get durationMagnitude(){const[t,e,i]=this.duration.match(/^(\d+)(\.)?$/);return WHOLE_DURATION/Number(e)*(i?1.5:1)}get bpm(){const[t]=this.beats.match(/\d+/)||[90];return Number(t)*this.durationMagnitude*4/WHOLE_DURATION}isValid(t=[10,400]){const e=this.bpm;return Number.isFinite(this.bpm)&&e>=t[0]&&e{const t=e=>{const i=new Map;return e.rows.forEach(n=>{if(n.events.length===1){const r=n.events[0];r.rest&&r.division===0&&(r.rest="R")}}),e.events.forEach(n=>{const r=Math.round(n.pivotX*10)/10;let a=0;n.fullMeasureRest?a=Math.min(r,...i.keys()):a=[...i.keys()].find(c=>{const d=i.get(c),l=Math.min(...d.map(y=>y.left)),u=Math.max(...d.map(y=>y.right));return Math.min(u,n.right)-Math.max(l,n.left)>NOTEHEAD_WIDTHS.NoteheadS1*.62})||r,n.roundX=a;const o=i.get(a)||[];i.set(a,o),o.push(n)}),i};s.computeMeasureTicks=e=>{const i=t(e);let n=0;const r=new Set([n]),a=[...i.entries()].sort(([o],[c])=>o-c);for(const[o,c]of a)c.forEach(d=>{d.predisposition&&(d.rest=d.rest&&d.predisposition.fullMeasure>.5?"R":d.rest,d.grace=d.predisposition.grace?GraceType.Grace:null,d.division=argmax$1(d.predisposition.divisionVector),d.dots=argmax$1(d.predisposition.dotsVector),d.predisposition.timeWarped>.5&&(d.timeWarp=frac(2,3))),d.fullMeasureRest?d.tick=0:(d.zeroHolder&&(n-=d.duration),!d.zeroHolder&&d.predisposition&&Number.isInteger(d.predisposition.tick)?d.tick=d.predisposition.tick:d.tick=n,r.add(d.tick+d.duration))}),r.delete(n),r.size&&(n=Math.min(...r));Number.isInteger(e.estimatedDuration)?e.duration=e.estimatedDuration:e.duration=Math.max(...r,0)},s.computeMeasureVoices=e=>{e.voices=[];for(const i of e.rows){const n=i.events.filter(a=>!a.grace&&!a.tremoloCatcher&&!a.fullMeasureRest&&!(a.predisposition&&a.predisposition.fake>.5)),r=new Set(n);for(;r.size;){let a=0;const o=[],c=l=>{o.push(l.id),l.zeroHolder||(a+=l.duration),r.delete(l)},d=n.find(l=>r.has(l));for(d.alignedTick>0&&(a=d.alignedTick),c(d);;){const l=n.find(u=>r.has(u)&&u.alignedTick===a);if(!l)break;c(l)}e.voices.push(o)}}}})(SimplePolicy||(SimplePolicy={}));const solveGraceEvents=s=>{const t=s.events.filter(r=>r.grace);if(!t.length)return;const i=[...s.tickMap.entries()].reduce((r,[a,o])=>(o.forEach(c=>{if(!c.grace){r[c.staff]=r[c.staff]||{};const d=r[c.staff][a];r[c.staff][a]=!d||d.x>c.x?c:d}}),r),{}),n=Object.entries(i).reduce((r,[a,o])=>{r[a]=Object.entries(o).map(([d,l])=>({event:l,tick:Number(d),preTick:-240,graces:[]})).sort((d,l)=>d.event.x-l.event.x),r[a].push({tick:s.duration,event:s.endEvent,preTick:0,graces:[]});let c=0;return r[a].forEach(d=>{d.tick>c&&(d.preTick=c,c=d.tick)}),r},{});t.forEach(r=>{const a=n[r.staff];if(a){const o=a.find(c=>c.event.x>r.x);o&&o.graces.push(r),r.roundX=r.x}}),Object.values(n).forEach(r=>r.forEach(a=>{if(a.graces.length){a.event.graceIds=a.graces.map(u=>u.id);const o=a.graces.reduce((u,h)=>u+h.duration,0),d=Math.min(o,a.tick-a.preTick)/o;let l=a.tick;[...a.graces].reverse().forEach(u=>{u.tick=Math.round(l-u.duration*d),l=u.tick})}}))},solveTremoloPairs=s=>{const t=s.events.filter(i=>i.tremoloCatcher&&!i.grace),e=s.events.filter(i=>i.tremoloLink===TremoloLink.Pitcher&&!i.grace);t.forEach(i=>{let n=e.filter(r=>r.division===i.division&&r.xNumber.isFinite(r.tick)&&!r.grace&&!r.rest&&r.division===i.division&&r.dots===i.dots&&r.xa.x-r.x),n.length){const r=n[0];r.catcherId=i.id;const a=Math.max(r.tremolo||3,i.tremolo||3);r.tremolo=a,i.tremolo=a,i.tick||(i.tick=r.tick+r.duration/2);const o=e.indexOf(r);o>=0&&e.splice(o,1)}})};var EquationPolicy;(s=>{const c=.7071067811865475,d=3,l=[[null,null],[null,StemBeam.Open],[StemBeam.Open,StemBeam.Continue],[StemBeam.Open,StemBeam.Close],[StemBeam.Continue,StemBeam.Continue],[StemBeam.Continue,StemBeam.Close],[StemBeam.Close,null],[StemBeam.Close,StemBeam.Open]].map(h=>h.join("-")),u=(h,y)=>h.events.length?new Solver(h,y).solve():{events:[],voices:[],duration:0};s.estiamteMeasure=h=>{const y=h.events.filter(S=>!S.zeroHolder).map(S=>({id:S.id,staff:S.staff,x:S.x,tickEstimated:S.predisposition&&Number.isFinite(S.predisposition.tick)?S.predisposition.tick:S.x,tipX:S.tipX,y:S.tipY+S.staff*100,duration:S.mainDuration*1921920/WHOLE_DURATION,division:S.division,dots:S.dots,stemDirection:S.stemDirection,beam:S.beam,rest:S.rest,pR:S.rest==="R"?1:S.rest==="r"&&S.division===0?Math.tanh(S.x-h.eventStartX):0,fakeP:S.predisposition&&S.predisposition.fakeP||0,shrinkness:S.predisposition?S.predisposition.timeWarped:null}));let f=1921920*h.timeSignature.numerator/h.timeSignature.denominator;Number.isFinite(h.estimatedDuration)&&(f=Math.max(f,roundNumber(h.estimatedDuration,1921920/4)));const p=h.staffGroups.reduce((S,E,k)=>(E.forEach(O=>S[O]=k),S),{}),m=[0,...y.map(S=>S.id)],T=y.map(S=>({...S,id:m.indexOf(S.id),x:S.x-h.startX,confidence:(1-S.pR)*(1-S.fakeP),shrinkness:Number.isFinite(S.shrinkness)?S.shrinkness:Math.tanh((S.division-S.dots*.1)/4),staffGroup:p[S.staff]})),x=Array(m.length+1).fill(null).map(()=>Array(m.length).fill(0)),g=Array(m.length).fill(null).map(()=>Array(m.length).fill(0)),v=S=>erf$1(S/1.6)*erf$1(1.6/S);for(const S of T){for(const E of T){if(g[S.id][E.id]=S!==E&&S.tickEstimated>=E.tickEstimated?1-erf$1((S.tickEstimated-E.tickEstimated)*c/.6):0,S.staffGroup!==E.staffGroup)x[S.id][E.id]=0;else if(S.x<=E.x)x[S.id][E.id]=0;else{const O=Math.exp(-Math.abs(S.staff-E.staff)*2),M=S.staff===E.staff?Math.exp(-Math.abs(S.y-E.y)/16):1,b=S.x-E.x,_=S.tipX-E.tipX;x[S.id][E.id]=(O*M*Math.min(v(b),v(_)))**(1/d)}const k=(1-S.pR)*(1-E.pR);g[S.id][E.id]*=k,x[S.id][E.id]*=k,g[S.id][E.id]<.01&&(g[S.id][E.id]=0),S.stemDirection&&E.stemDirection&&S.stemDirection!==E.stemDirection&&(x[S.id][E.id]*=.9),!S.rest&&!E.rest&&!l.includes([E.beam,S.beam].join("-"))&&(x[S.id][E.id]*=.2)}x[m.length][S.id]=v(h.width-S.x)**(1/d)}return{ids:m,events:T,expectedDuration:f,measureShrinkness:0,endX:h.position.right,matrixH:x,matrixV:g}},s.regulateMeasure=async(h,{solver:y=null,...f})=>{const p=(0,s.estiamteMeasure)(h),{ids:m,matrixH:T,matrixV:x}=p;if(h.matrixH){console.assert(h.matrixH.length>m[m.length-1]&&h.matrixH[0].length>m[m.length-1],"matrix shape mismatch:",m.length,`${h.matrixH.length}x${h.matrixH[0].length}`,`${T.length}x${T[0].length}`);for(let S=0;SS.forEach((k,O)=>{const M=h.matrixV[m[E]][m[O]];Number.isFinite(M)&&(x[E][O]=M)})),Number.isFinite(h.estimatedDuration)&&(p.measureShrinkness=Math.tanh(Math.log(Math.min(1,h.estimatedDuration/h.duration))*-3)),f.logger&&f.logger.info("--- MEASURE",h.measureIndex,"---",p);const g=y?await y(p,f):u(p,f),v=g.events.map(S=>({...S,id:p.ids[S.id]}));v.forEach(S=>{const E=h.events.find(k=>k.id===S.id);E.tick=Number.isFinite(S.tick)?Math.round(S.tick*WHOLE_DURATION/1921920):null,E.tickGroup=S.tickGroup,E.timeWarp=S.timeWarp}),h.duration=Math.round(g.duration*WHOLE_DURATION/1921920),h.voices=g.voices.map(S=>S.map(E=>p.ids[E])),h.solutionStat={loss:g.loss,solverCredits:g.credits,solverTimes:g.times},h.events.forEach(S=>{const E=v.find(k=>k.id===S.id);if(E)!Number.isFinite(E.tick)&&S.rest==="r"&&S.division===0?(S.tick=0,S.tickGroup=0,S.rest="R",S.duration=h.duration,h.voices.push([S.id])):S.rest==="R"&&(S.tick=0,S.tickGroup=0,S.duration=h.duration,h.voices.push([S.id]));else return})},s.regulateMeasureWithRectification=async(h,y,{solver:f=null,...p})=>{const m=h.events.filter(I=>!I.zeroHolder).map(I=>{var A,N;const D=y.events.find(F=>F&&F.id===I.id),w=Number.isFinite(D==null?void 0:D.division)?D.division:I.division,B=Number.isFinite(D==null?void 0:D.dots)?D.dots:I.dots,C=1921920*2**-w*(2-2**-B);return{id:I.id,staff:I.staff,x:I.x,tickEstimated:(A=I.predisposition)==null?void 0:A.tick,y:I.tipY+I.staff*100,duration:C,pR:I.rest==="R"?1:I.rest==="r"&&I.division===0?Math.tanh(I.x-h.eventStartX):0,fakeP:I.predisposition&&I.predisposition.fakeP||0,shrinkness:((N=I.predisposition)==null?void 0:N.timeWarped)||0}});let T=1921920*h.timeSignature.numerator/h.timeSignature.denominator;Number.isFinite(h.estimatedDuration)&&(T=Math.max(T,roundNumber(h.estimatedDuration,1921920/4)));const x=h.staffGroups.reduce((I,D,w)=>(D.forEach(B=>I[B]=w),I),{}),g=[0,...m.map(I=>I.id)],v=m.map(I=>({...I,id:g.indexOf(I.id),x:I.x-h.startX,confidence:(1-I.pR)*(1-I.fakeP),shrinkness:I.shrinkness,staffGroup:x[I.staff]})),S=Array(g.length+1).fill(null).map(()=>Array(g.length).fill(0)),E=Array(g.length).fill(null).map(()=>Array(g.length).fill(0));for(const I of v)for(const D of v){E[I.id][D.id]=I!==D&&I.tickEstimated>=D.tickEstimated?1-erf$1((I.tickEstimated-D.tickEstimated)*c/.6):0;const w=(1-I.pR)*(1-D.pR);E[I.id][D.id]*=w,E[I.id][D.id]<.01&&(E[I.id][D.id]=0)}console.assert(h.matrixH&&h.matrixH.length>g[g.length-1]&&h.matrixH[0].length>g[g.length-1],"matrix shape mismatch:",g.length,`${h.matrixH.length}x${h.matrixH[0].length}`,`${S.length}x${S[0].length}`);for(let I=0;I{const C=y.events.find(N=>N&&N.id===I),A=Number.isFinite(D)?Math.round(D*WHOLE_DURATION/1921920):D;return{id:I,tick:A,tickGroup:w,timeWarp:B,division:C==null?void 0:C.division,dots:C==null?void 0:C.dots}}),R=Math.round(M.duration*WHOLE_DURATION/1921920);return{events:_,voices:M.voices,duration:R,priority:b}}})(EquationPolicy||(EquationPolicy={}));class SpartitoMeasure extends SimpleClass{static className="SpartitoMeasure";static blackKeys=["staffGroups","solutionStat","measureNumber","deposit"];measureIndex;staffMask;staffGroups;originalRegulationHash;measureNumber;patched;discard;position;backgroundImages;events;endEvent;contexts;marks;duration;voices;break;pageBreak;basics;voltaBegin;voltaEnd;alternative;barTypes;indent;solutionStat;matrixH;matrixV;estimatedDuration;graph;deposit;static reorderEvents(t,e){const n=[],r=t.map(d=>({id:d.id,staff:d.staff,x:d.x/.7,rx:0,ry:e[d.staff]+d.tipY,tipY:d.tipY,prior:0}));r.sort((d,l)=>d.x-l.x),r.slice(1).forEach((d,l)=>{const u=Math.min(Math.round(d.x-r[l].x),2);d.rx=r[l].rx+u}),r.forEach(d=>{d.prior=d.staff*1e4+d.rx+d.tipY*.01,n.includes(d.ry)||n.push(d.ry)}),r.sort((d,l)=>d.prior-l.prior),n.sort((d,l)=>d-l);let a=0;const o=n.map((d,l)=>(!l||n[l]-n[l-1]<.5||++a,a)),c=r.map(d=>new EventTerm({...t.find(l=>l.id===d.id),intX:d.rx,intY:o[n.indexOf(d.ry)]}));return c.forEach((d,l)=>d.id=l+1),c}constructor(t){super(),super.assign(t),!this.originalRegulationHash&&!this.regulated&&(this.originalRegulationHash=this.regulationHash),this.barTypes=this.barTypes||{},this.regulated&&this.position&&this.postRegulate()}get timeSignature(){return this.basics&&this.basics[0].timeSignature}get keySignature(){return this.basics&&this.basics[0].keySignature}get timeSignatureChanged(){return this.contexts.filter(Boolean)[0].some(t=>[ContextType.TimeSignatureC,ContextType.TimeSignatureN].includes(t.type))}get doubtfulTimesig(){return this.basics&&this.basics[0].doubtfulTimesig}get regulated(){return!!this.voices}get validRegulated(){return this.voices?this.voices.flat(1).every(t=>{var e;return Number.isFinite((e=this.events.find(i=>i.id===t))==null?void 0:e.tick)}):!1}get rows(){return this.contexts.map((t,e)=>({events:this.events.filter(n=>n.staff===e),contexts:t}))}get eventStartX(){return this.events.length?Math.min(...this.events.map(t=>t.x)):this.startX}get startX(){return this.position.left}get width(){return this.position.right-this.position.left}get tickMap(){return this.events.concat([this.endEvent]).filter(Boolean).reduce((t,e)=>(Number.isFinite(e.tick)&&(t.has(e.tick)||t.set(e.tick,[]),t.get(e.tick).push(e)),t),new Map)}get tickToX(){return[...this.tickMap.entries()].reduce((t,[e,i])=>{if(i=i.filter(n=>!n.fullMeasureRest&&!n.grace),i.length){const n=Math.min(...i.map(r=>r.x));t[e]=n}return t},{})}get tickRates(){const t=this.events.filter(e=>Number.isFinite(e.tick)&&!e.fullMeasureRest);return t.sort((e,i)=>e.x-i.x),t.slice(0,t.length-1).map((e,i)=>{const n=t[i+1];return(n.tick-e.tick)/Math.max(n.x-e.x,.001)})}get tickRatesInStaves(){const e=this.events.filter(n=>Number.isFinite(n.tick)&&!n.fullMeasureRest&&!n.grace).reduce((n,r)=>(n[r.staff]=n[r.staff]||[],n[r.staff].push(r),n),{}),i=Object.values(e).map(n=>n.sort((r,a)=>r.x-a.x).slice(0,n.length-1).map((r,a)=>{const o=n[a+1];return(o.tick-r.tick)/Math.max(o.x-r.x,.001)}));return[].concat(...i)}get tickRatesInGroups(){const e=this.events.filter(n=>Number.isFinite(n.tick)&&!n.fullMeasureRest).reduce((n,r)=>{const a=this.staffGroups.findIndex(o=>o.includes(r.staff));return n[a]=n[a]||[],n[a].push(r),n},{}),i=Object.values(e).map(n=>n.sort((r,a)=>r.x-a.x).slice(0,n.length-1).map((r,a)=>{const o=n[a+1];return(o.tick-r.tick)/Math.max(o.x-r.x,.001)}));return[].concat(...i)}get tickTwist(){if(!this.duration||!this.staffGroups)return;const e=this.events.filter(n=>Number.isFinite(n.tick)&&!n.fullMeasureRest&&!n.grace&&!n.tremoloCatcher&&!(n.rest&&n.division===0)).reduce((n,r)=>{const a=this.staffGroups.findIndex(o=>o.includes(r.staff));return n[a]=n[a]||[],n[a].push(r),n},{}),i=Object.values(e).map(n=>{const r=[...n].sort((c,d)=>c.pivotX-d.pivotX),a=this.position.right-r[0].x,o=r.slice(1).map((c,d)=>{const l=r[d],u=c.pivotX-l.pivotX,h=c.tick-l.tick;return h?(Math.atan2(h/this.duration,u/a)*4/Math.PI-1)**2:u/a});return Math.max(0,...o)});return Math.max(0,...i)}get eventMap(){return this.events.reduce((t,e)=>(t[e.id]=e,t),{})}get empty(){var t,e;return!((t=this.events)!=null&&t.length)||!((e=this.voices)!=null&&e.length)}get hasIllEvent(){const t=this.voices.flat(1),e=this.eventMap;return this.regulated&&t.some(i=>{const n=e[i];return!n.zeroHolder&&!Number.isFinite(n.tick)&&!n.fullMeasureRest})}get brief(){const t=`${this.timeSignature.numerator}/${this.timeSignature.denominator}`,e=this.events.map(i=>{var n;return[i.staff,i.intX,Math.round(i.tip?i.tip.y:((n=i.ys)==null?void 0:n[0])??0),i.fullMeasureRest?0:i.division,i.fullMeasureRest?0:i.dots,i.rest?"r":"",i.grace||"",i.stemDirection,i.beam||""].join("|")});return[t,...e].join(` -`)}get regulationHash(){return sha1(this.brief)}get regulationHash0(){return this.originalRegulationHash||this.regulationHash}get regulationHashes(){return Array.from(new Set([this.originalRegulationHash,this.regulationHash].filter(Boolean)))}get featureWords(){if(!this.regulated||!this.voices||!this.voices.length)return null;const t=this.tickRatesInStaves.some(c=>c<0),i=this.events.filter(c=>!c.zeroHolder&&!c.rest).map(c=>c.ys).flat(1).map(c=>`Y${-c*2}`),n=Array.from(new Set(i));this.keySignature&&n.push(`K${this.keySignature}`);const r=this.voices.map(c=>c.map(d=>this.events.find(l=>l.id===d)).filter(d=>!d.zeroHolder&&!d.rest)).filter(c=>c.length),a=t?[]:r.map(c=>c.map(d=>d.scaleChord).join("-")),o=t?[]:r.map(c=>c.map(d=>d.division).join(""));return this.timeSignature&&o.push(`T${this.timeSignature.numerator}/${this.timeSignature.denominator}`),[n,a,o]}get barType(){if(this.voltaEnd)return"VoltaRight";const t=Object.entries(this.barTypes).sort((e,i)=>i[1]-e[1]);return t[0]&&t[0][1]>=1?t[0][0]:null}get partialDuration(){if(!Number.isFinite(this.duration))return!1;const t=fractionMul(WHOLE_DURATION,this.timeSignature);return this.duration{const i=t[e.tick];Number.isFinite(i)&&(e.roundX=i)})}updateContextTick(){if(!this.staffGroups)return;const t=this.contexts.flat(1);this.staffGroups.flat(1).forEach(e=>{const i=[...this.events.filter(r=>r.staff===e),...t.filter(r=>r.staff===e)];i.sort((r,a)=>a.x-r.x);let n=this.duration;i.forEach(r=>{r instanceof EventTerm?!r.fullMeasureRest&&!r.zeroHolder&&(n=r.tick):r instanceof ContextedTerm&&(r.tick=n)})})}asSolution(t=void 0){var e;return this.regulated?{events:this.events.map(i=>{const n={id:i.id,tick:i.tick,tickGroup:i.tickGroup,timeWarp:i.timeWarp};if(t){const r=t.events.find(a=>a.id===i.id);r&&(i.division!==r.division&&(n.division=i.division),i.dots!==r.dots&&(n.dots=i.dots),i.grace!==r.grace&&(n.grace=!!i.grace),i.beam!==r.beam&&(n.beam=i.beam),i.fullMeasureRest!==r.fullMeasureRest&&(n.fullMeasure=i.fullMeasureRest))}return n}),voices:this.voices,duration:this.duration,priority:-((e=this.solutionStat)==null?void 0:e.loss)}:null}applySolution(t){t.timeSignature&&this.basics.forEach(e=>{e.timeSignature=t.timeSignature,e.doubtfulTimesig=!1}),this.voices=t.voices,this.duration=t.duration,this.events.forEach(e=>{var n;e.timeWarp=null,e.tick=null,e.tickGroup=null;const i=(n=t.events)==null?void 0:n.find(r=>r.id===e.id);i&&(e.tick=i.tick,e.timeWarp=i.timeWarp,e.tickGroup=i.tickGroup,Number.isFinite(i.division)&&(e.division=i.division),Number.isFinite(i.dots)&&(e.dots=i.dots),i.beam!==void 0&&(e.beam=i.beam),i.grace!==void 0&&(e.grace=i.grace?GraceType.Grace:void 0),i.fullMeasure&&(e.rest="R"))}),Number.isFinite(t.priority)&&(this.solutionStat={loss:-t.priority}),this.postRegulate()}cleanupRegulation(){this.voices=null,this.duration=null,this.events.forEach(t=>{t.tick=null,t.tickGroup=null,t.timeWarp=null})}regulateTest(){this.duration=0,this.voices=this.rows.map(t=>t.events.map(e=>e.id)),this.voices.forEach(t=>{let e=0;t.map(n=>this.events.find(r=>r.id===n)).forEach((n,r)=>{n.tickGroup=r,n.tick=e,e+=n.duration}),this.duration=Math.max(this.duration,e)})}regulateSimple(){SimplePolicy.computeMeasureTicks(this),SimplePolicy.computeMeasureVoices(this)}async regulateEquations(t){await EquationPolicy.regulateMeasure(this,t)}async regulate({policy:t="advanced",...e}={}){switch(t){case"test":this.regulateTest();break;case"equations":case"advanced":await this.regulateEquations(e);break;case"simple":default:this.regulateSimple()}this.postRegulate()}createPatch(){return new PatchMeasure({measureIndex:this.measureIndex,staffMask:this.staffMask,basic:this.basics[0],events:this.events,contexts:this.contexts,marks:this.marks,voices:this.voices})}createClusters(){const t=this.voices&&new Set(this.voices.flat(1));return this.staffGroups.filter(e=>e.length).map(e=>{const i=this.position.staffYs[0],n=u=>this.position.staffYs[e.indexOf(u)]-i,r=this.events.filter(u=>e.includes(u.staff));if(!r.length)return null;const a=r.map(u=>({index:u.id,voice:(this.voices||[]).findIndex(h=>h.includes(u.id)),type:u.rest?EventElementType.REST:EventElementType.CHORD,staff:e.indexOf(u.staff),x:u.tipX,pivotX:u.pivotX,y1:n(u.staff)+(u.stemDirection==="u"?u.tipY:u.ys[u.ys.length-1]),y2:n(u.staff)+(u.stemDirection==="u"?u.ys[0]:u.tipY),headY:u.stemDirection==="u"?u.ys[0]:u.ys[u.ys.length-1],feature:u.feature,division:u.division,dots:u.dots,beam:u.beam||null,stemDirection:u.stemDirection,grace:!!u.grace,tremoloCatcher:u.tremoloCatcher,timeWarped:!!u.timeWarp,fullMeasure:u.fullMeasureRest,tick:u.tick||0,fake:!u.fullMeasureRest&&!u.grace&&this.voices&&!t.has(u.id)}));if(!a.some(u=>!u.fake))return null;const o=fractionMul(WHOLE_DURATION,this.timeSignature);a.unshift({index:0,type:EventElementType.BOS,staff:null,division:null,beam:null,dots:null,stemDirection:null,grace:!1,tremoloCatcher:!1,fullMeasure:!1,x:this.position.left,pivotX:this.position.left,y1:0,y2:0,headY:0,feature:null,timeWarped:this.durationa.map(()=>0)),this.voices.forEach(u=>{let h=0;u.forEach(y=>{const f=a.findIndex(p=>p.index===y);f>0&&h>=0&&(c[f][h]=1),h=f}),h>=0&&(c[a.length-1][h]=1)}));const d={...this.solutionStat,patched:this.patched},l=this.backgroundImages&&this.backgroundImages.map(({url:u,position:h})=>({url:u,position:{...h,y:h.y-i}}));return new EventCluster({index:this.measureIndex,duration:this.duration,signatureDuration:o,staffY0:i,elements:a,matrixH:c,annotation:d,backgroundImages:l})}).filter(Boolean)}applyClusters(t){const e=this.events.reduce((i,n)=>Math.max(i,n.id),0)+1;this.matrixH=Array(e+1).fill(null).map(()=>Array(e).fill(0)),t.forEach(i=>{const n=i.elements.map(r=>r.index);console.assert(i.matrixH.length===n.length-1,"unexpected matrixH size:",i.matrixH.length,n.length);for(let r=1;r{const a=this.events.find(o=>o.id===r.index);a&&(a.predisposition=r.predisposition,a.predisposition.grace!==void 0&&(a.grace=a.predisposition.grace?GraceType.Grace:null))})}),this.estimatedDuration=t.reduce((i,n)=>i+n.estimatedDuration,0)/t.length}}class EditableEvent extends EventTerm{voice;constructor(t){super(t)}get agent(){return new Proxy(this,{get(t,e){const i=t;switch(e){case"id":case"tick":case"duration":case"rest":case"division":case"dots":case"stemDirection":case"beam":case"tremolo":case"tremoloLink":case"arpeggioStyle":{const n=i[e];return n===void 0?null:n}case"tying":case"tied":case"glissando":{const n=i[e];return n===void 0?!1:n}case"grace":return!!i.grace;case"timeWarp":return i.timeWarp?`${i.timeWarp.numerator}/${i.timeWarp.denominator}`:null;case"multiplier":return i.multiplier?`${i.multiplier.numerator}/${i.multiplier.denominator}`:null;case"pitches":return i.pitches}},set:(t,e,i)=>{const n=t;switch(e){case"tick":case"duration":case"rest":case"division":case"dots":case"stemDirection":case"tying":case"tied":case"beam":case"tremolo":case"tremoloLink":case"glissando":case"arpeggioStyle":return n[e]=i,!0;case"grace":return n.grace=i?GraceType.Grace:null,!0;case"timeWarp":if(n.timeWarp=null,i&&typeof i=="string"){const r=i.match(/^(\d+)\/(\d+)/);r&&(n.timeWarp={numerator:parseInt(r[1]),denominator:parseInt(r[2])})}return!0;case"multiplier":if(n.multiplier=null,i&&typeof i=="string"){const r=i.match(/^(\d+)\/(\d+)/);r&&(n.multiplier={numerator:parseInt(r[1]),denominator:parseInt(r[2])})}return!0;case"id":case"pitches":return!0}return!1},ownKeys:()=>["id","duration","rest","division","dots","stemDirection","tying","tied","beam","timeWarp","multiplier","tremolo","tremoloLink","glissando","arpeggioStyle","tick","grace","pitches"],getOwnPropertyDescriptor(){return{enumerable:!0,configurable:!0}}})}}class EditableMeasure extends SpartitoMeasure{static className="EditableMeasure";static blackKeys=[];events=null;constructor(t){var e;super(t),this.events=t.events,(e=this.events)!=null&&e.some(i=>!(i instanceof EditableEvent))&&(this.events=this.events.map(i=>new EditableEvent(i))),this.voices&&this.syncVoiceToEvents()}syncVoiceToEvents(){this.events.forEach(t=>t.voice=-1),this.voices.forEach((t,e)=>{t.forEach(i=>{const n=this.events.find(r=>r.id===i);n?n.voice=e:console.warn("no event with id:",i,this.events.length)})})}syncVoiceFromEvents(){const t=[];this.events.forEach(e=>{(e==null?void 0:e.voice)>=0&&(t[e.voice]=t[e.voice]||[],t[e.voice].push(e))}),t.forEach(e=>e.sort((i,n)=>i.tick-n.tick)),this.voices=t.map(e=>e.map(i=>i.id))}get agent(){return new Proxy(this,{get:(t,e)=>{var n;const i=t;switch(e){case"measureIndex":case"duration":return i[e];case"voices":return((n=i.voices)==null?void 0:n.map(r=>r.join(",")))||null;case"timeSignature":case"keySignature":case"doubtfulTimesig":return i.basics[0][e];case"toJSON":return()=>({measureIndex:i.measureIndex,voices:i.voices,duration:i.duration,timeSignature:i.basics[0].timeSignature,keySignature:i.basics[0].keySignature})}},set:(t,e,i)=>{const n=t;switch(e){case"timeSignature":case"keySignature":case"doubtfulTimesig":return n.basics[0][e]=i,n.basics=n.basics.map(()=>n.basics[0]),!0;case"duration":return n.duration=i,!0;case"measureIndex":case"voices":return!0}return!1},ownKeys:()=>["measureIndex","timeSignature","doubtfulTimesig","keySignature","duration","voices"],getOwnPropertyDescriptor(){return{enumerable:!0,configurable:!0}}})}makeMIDI(t=120){if(!this.regulated)return null;const e=6e7/t,i={formatType:0,ticksPerBeat:480},n=this.voices.map((r,a)=>{const o=r.map(l=>{const u=this.events.find(h=>h.id===l);return u?[...u.graceIds?u.graceIds.map(y=>this.events.find(f=>f.id===y)):[],u]:[]}).flat(1),c=0,d=o.filter(l=>!l.rest&&Number.isFinite(l.tick)&&l.tick>=0&&Number.isFinite(l.duration)).map(l=>l.pitches.map(u=>[{id:l.id,time:l.tick,type:"channel",subtype:"noteOn",channel:l.staff,noteNumber:noteToPitch(u),velocity:96},{id:l.id,time:l.tick+l.duration,type:"channel",subtype:"noteOff",channel:l.staff,noteNumber:noteToPitch(u)}])).flat(2);return d.sort(function(l,u){return l.time-u.time}),a===0&&d.unshift({time:c,type:"meta",subtype:"timeSignature",numerator:this.timeSignature.numerator,denominator:this.timeSignature.denominator,thirtyseconds:8},{time:c,type:"meta",subtype:"setTempo",microsecondsPerBeat:e}),d.forEach(l=>{l.ticks=Math.round(l.time-c)}),d.forEach((l,u)=>{l.deltaTime=l.ticks-(u>0?d[u-1].ticks:0)}),d.push({deltaTime:0,type:"meta",subtype:"endOfTrack"}),d});return{header:i,tracks:n}}}var PageLayoutMethod=(s=>(s.ByLines="ByLines",s.ByBlocks="ByBlocks",s))(PageLayoutMethod||{}),TextType=(s=>(s.Title="Title",s.Author="Author",s.TempoText="TempoText",s.TempoNumeral="TempoNumeral",s.TextualMark="TextualMark",s.Lyric="Lyric",s.Instrument="Instrument",s.MeasureNumber="MeasureNumber",s.Times="Times",s.Alternation1="Alternation1",s.Alternation2="Alternation2",s.Chord="Chord",s.PageMargin="PageMargin",s.Other="Other",s))(TextType||{});const BEAM_STATUS={[StemBeam.Open]:1,[StemBeam.Continue]:0,[StemBeam.Close]:-1},evaluateMeasure=s=>{if(!s.regulated)return;const t=s.eventMap,e=s.events.length,i=s.voices.flat(1).length,n=s.events.filter(N=>N.timeWarp).length,r=new Set(s.events.filter(N=>N.timeWarp&&!(N.rest&&N.division===0)).map(N=>`${N.timeWarp.numerator}/${N.timeWarp.denominator}`)),a=new Set(r);a.delete("2/3");const o=s.voices.some(N=>{const F=N.map(P=>t[P]);if(!F.some(P=>P.timeWarp))return!1;let L=0,H=0,W=0;return F.some((P,j)=>{const z=P.timeWarp?P.timeWarp.denominator:0;if(z!==L){if(L>0&&(H%L||W<2))return!0;H=0,W=0}return L=z,H+=P.duration,++W,!!(j===F.length-1&&L>0&&(H%L||W<2))})}),c=s.voices.some(N=>{const F=N.map(H=>t[H]);let L=0;return F.some(H=>H.grace?!1:H.tickN.timeWarp&&N.timeWarp.denominator>3).map(N=>N.duration)).size>1,u=fractionMul(WHOLE_DURATION,s.timeSignature),h=s.doubtfulTimesig?s.duration:u,y=s.voices.flat(1).map(N=>t[N]),f=y.some(N=>!N||!Number.isFinite(N.tick)||!Number.isFinite(N.division)||N.division<0||!Number.isFinite(N.duration)||N.duration<=0),p=y.reduce((N,F)=>N||F.tick<0||F.tick+F.duration>h,!1),m=s.duration>u,T=y.some(N=>N.grace),x=s.events.filter(N=>N.grace).length,g=x>=y.length,v=y.some(N=>{let F=N.tick*2**(N.division+2);return N.timeWarp&&(F*=N.timeWarp.denominator),Number.isFinite(F)?gcd(Math.round(F),WHOLE_DURATION)N.reduce(({status:F,broken:L},H,W)=>{const P=t[H];return P.beam?(W===0&&[StemBeam.Continue,StemBeam.Close].includes(P.beam)&&(F=1),F+=BEAM_STATUS[P.beam],L=L||!(F>=0&&F<=1)):P.rest||(L=L||F!==0),{status:F,broken:L}},{status:0,broken:!1})).some(({broken:N})=>N);let k=0,O=0;s.voices.forEach(N=>{const F=N.reduce((L,H)=>L+t[H].duration,0);k+=Math.max(0,s.duration-F),O+=Math.max(0,F-s.duration)}),k/=WHOLE_DURATION;const M=s.events.filter(N=>!N.grace&&!N.fullMeasureRest&&!N.tremoloCatcher&&(!N.predisposition||N.predisposition.fakeP<.1)&&!Number.isFinite(N.tick)).length,b=s.events.filter(N=>!N.fullMeasureRest&&!N.grace&&!N.tremoloCatcher&&!y.includes(N)).length,{voiceRugged:_}=s.voices.flat(1).reduce((N,F)=>!N.voiceRugged&&N.es.has(F)?{voiceRugged:!0,es:N.es}:(N.es.add(F),N),{voiceRugged:!1,es:new Set}),R=s.tickTwist||0,I=f||R>=1||c||_||s.tickRatesInStaves.some(N=>N<0)||M>2||!s.timeSignature||p||s.duration>h||s.events.some(N=>N.timeWarp&&N.timeWarp.numerator/N.timeWarp.denominator<=.5),D=!I&&!m&&R<.2&&!o&&!a.size&&!v&&!k&&!O&&!!s.voices.length&&!E&&!T&&!g&&(s.duration===h||Number.isFinite(s.estimatedDuration)&&s.estimatedDuration<=h*.75),w=!I&&!m&&R<.3&&!o&&!v&&!O&&!E&&!T;let B=Math.min(h,WHOLE_DURATION*2);Number.isFinite(s.estimatedDuration)&&(B=Math.max(0,Math.min(B,s.estimatedDuration)));const C=s.duration/B;let A=0;if(s.patched&&!f)A=1;else if(!I){const N=Math.tanh(Math.abs(k/Math.max(1,s.voices.length))*1);let F=Math.min(h,WHOLE_DURATION*2);Number.isFinite(s.estimatedDuration)&&(F=Math.max(0,Math.min(F,s.estimatedDuration)));const L=F?Math.max(0,1-C)**2:0,H=Math.tanh(a.size);A=(1-N)*(1-L)*(1-H)*(1-R**2)}return{events:e,validEvents:i,voiceRugged:_,nullEvents:M,fakeEvents:b,warpedEvents:n,complicatedTimewarp:l,spaceTime:k,surplusTime:O,durationRate:C,beamBroken:E,fractionalWarp:o,irregularWarpsN:a.size,irregularTick:v,tickTwist:R,tickOverlapped:c,graceInVoice:T,graceN:x,graceDominant:g,perfect:D,fine:w,error:I,qualityScore:A}};class SemanticGraph extends SimpleClass{static className="SemanticGraph";points;constructor(t){super(),super.assign(t)}static fromPoints(t=[]){const e=new SemanticGraph;return e.points=t,e}getLayer(t){return this.points.filter(e=>e.semantic===t)}getConfidentLayer(t,e){return this.points.filter(i=>i.semantic===t&&(!Number.isFinite(i.confidence)||i.confidence>=e))}getSystemPoints(){return this.points.filter(t=>SYSTEM_SEMANTIC_TYPES.includes(t.semantic))}getStaffPoints(){return this.points.filter(t=>!SYSTEM_SEMANTIC_TYPES.includes(t.semantic))}offset(t,e){this.points.forEach(i=>{i.x+=t,i.y+=e})}scale(t){this.points.forEach(e=>{e.x*=t,e.y*=t})}transform(t){this.points.forEach(e=>{let i=e.x*t[0][0]+e.y*t[1][0]+t[2][0];const n=e.x*t[0][1]+e.y*t[1][1]+t[2][1];if(e.extension){if(Number.isFinite(e.extension.y1)){const r=e.x*t[0][1]+e.extension.y1*t[1][1]+t[2][1],a=e.x*t[0][1]+e.extension.y2*t[1][1]+t[2][1];i=e.x*t[0][0]+(e.extension.y1+e.extension.y2)*.5*t[1][0]+t[2][0],e.extension.y1=r,e.extension.y2=a}if(Number.isFinite(e.extension.width)){const r=Math.sqrt(t[0][0]*t[1][1]-t[0][1]*t[1][0]);e.extension.width*=r,e.extension.height*=r}}e.x=i,e.y=n})}}const CHORD_X_TOLERANCE=.2,STEM_LENGTH_MAX=6,INDENT_THRESHOLD=2,MEASURE_SEMANTICS=[SemanticType.ClefG,SemanticType.ClefF,SemanticType.ClefC,SemanticType.TimesigC44,SemanticType.TimesigC22,SemanticType.TimesigZero,SemanticType.TimesigOne,SemanticType.TimesigTwo,SemanticType.TimesigThree,SemanticType.TimesigFour,SemanticType.TimesigFive,SemanticType.TimesigSix,SemanticType.TimesigSeven,SemanticType.TimesigEight,SemanticType.TimesigNine,SemanticType.OctaveShift8va,SemanticType.OctaveShift8vb,SemanticType.OctaveShift0,SemanticType.Zero,SemanticType.One,SemanticType.Two,SemanticType.Three,SemanticType.Four,SemanticType.Five,SemanticType.Six,SemanticType.Seven,SemanticType.Eight,SemanticType.Nine,SemanticType.AccNatural,SemanticType.AccSharp,SemanticType.AccDoublesharp,SemanticType.AccFlat,SemanticType.AccFlatflat,SemanticType.NoteheadS0,SemanticType.NoteheadS1,SemanticType.NoteheadS2,SemanticType.NoteheadS1stemU,SemanticType.NoteheadS1stemD,SemanticType.NoteheadS2stemU,SemanticType.NoteheadS2stemD,SemanticType.Rest0,SemanticType.Rest1,SemanticType.Rest2,SemanticType.Rest3,SemanticType.Rest4,SemanticType.Rest5,SemanticType.Rest6,SemanticType.Rest0W,SemanticType.RestM1,SemanticType.SlurBegin,SemanticType.SlurEnd,SemanticType.Dot,SemanticType.f,SemanticType.p,SemanticType.m,SemanticType.n,SemanticType.r,SemanticType.s,SemanticType.z,SemanticType.ScriptFermata,SemanticType.ScriptShortFermata,SemanticType.ScriptSforzato,SemanticType.ScriptStaccato,SemanticType.ScriptStaccatissimo,SemanticType.ScriptTurn,SemanticType.ScriptTrill,SemanticType.ScriptSegno,SemanticType.ScriptCoda,SemanticType.ScriptArpeggio,SemanticType.ScriptPrall,SemanticType.ScriptMordent,SemanticType.ScriptMarcato,SemanticType.ScriptTenuto,SemanticType.ScriptPortato,SemanticType.PedalStar,SemanticType.PedalPed,SemanticType.GraceNotehead,SemanticType.BeamLeft,SemanticType.BeamRight,SemanticType.BeamContinue,SemanticType.CrescendoBegin,SemanticType.CrescendoEnd,SemanticType.DecrescendoBegin,SemanticType.DecrescendoEnd,SemanticType.TremoloLeft,SemanticType.TremoloRight,SemanticType.TremoloMiddle],STAFF_LINED_SEMANTICS=[SemanticType.AccNatural,SemanticType.AccSharp,SemanticType.AccDoublesharp,SemanticType.AccFlat,SemanticType.AccFlatflat,SemanticType.NoteheadS0,SemanticType.NoteheadS1,SemanticType.NoteheadS2,SemanticType.NoteheadS1stemU,SemanticType.NoteheadS1stemD,SemanticType.NoteheadS2stemU,SemanticType.NoteheadS2stemD],LINED_INTERVAL_SEMANTICS=[SemanticType.SignLined,SemanticType.SignInterval],NOTEHEAD_FOR_STEM_SEMANTICS=[SemanticType.NoteheadS1,SemanticType.NoteheadS2],KEYACC_CANDIDATE_SEMANTICS={AccSharp:TokenType.KeySharp,AccNatural:TokenType.KeyNatural,AccFlat:TokenType.KeyFlat},NOTEHEAD_TABLE={[SemanticType.NoteheadS1]:{up:SemanticType.NoteheadS1stemU,down:SemanticType.NoteheadS1stemD},[SemanticType.NoteheadS2]:{up:SemanticType.NoteheadS2stemU,down:SemanticType.NoteheadS2stemD}},REST_SEMANTICS=[SemanticType.Rest0,SemanticType.Rest1,SemanticType.Rest2,SemanticType.Rest3,SemanticType.Rest4,SemanticType.Rest5,SemanticType.Rest6],TOKEN_TO_STEMBEAM={[TokenType.BeamLeft]:"Open",[TokenType.BeamRight]:"Close",[TokenType.BeamContinue]:"Continue"},TEXT_TYPE_ALIAS={Alter1:TextType.Alternation1,Alter2:TextType.Alternation2},noteheadsXPivot=(s,t)=>{switch(s.length){case 0:return;case 1:return s[0];case 2:return t==="u"?Math.min(...s):Math.max(...s);default:{const e=s.reduce((i,n)=>i+n,0)/s.length;return s.sort((i,n)=>Math.abs(i-e)-Math.abs(n-e)),noteheadsXPivot(s.slice(0,s.length-1),t)}}},noteheadsPivot=s=>noteheadsXPivot(s.map(t=>Number.isFinite(t.pivotX)?t.pivotX:t.x),s[0].direction);class Measure extends SimpleClass{static className="Measure";static blackKeys=["tokens","antiTokens"];left;width;height;alternative;tokens;antiTokens;barTypes;constructor(t){super(),super.assign(t),this.tokens=this.tokens||[],this.antiTokens=this.antiTokens||[],this.barTypes=this.barTypes||{}}get right(){return this.left+this.width}get noteheads(){return this.tokens.filter(t=>t.isNotehead).sort((t,e)=>t.x-e.x)}get chordRects(){const t=this.noteheads.filter(n=>[TokenType.NoteheadS0,TokenType.NoteheadS1stemU,TokenType.NoteheadS2stemU,TokenType.NoteheadS1stemD,TokenType.NoteheadS2stemD].includes(n.type));let e=0;const i=t.reduce((n,r)=>{const a=r.tip?`${r.tip.x}|${r.tip.y}`:`nul${e}`;let o=`${r.type}|${a}`;return!r.tip&&n[o]&&(n[o].some(c=>Math.abs(c.x-r.x){const r=Math.min(...n.map(f=>f.x)),a=Math.max(...n.map(f=>f.x)),o=Math.min(...n.map(f=>f.y)),c=Math.max(...n.map(f=>f.y)),d=n[0],l=d&&d.tip?d.tip.x:r;let u=r,h=a-r,y=null;switch(d.type){case TokenType.NoteheadS0:u-=NOTEHEAD_WIDTHS.NoteheadS0/2,h+=NOTEHEAD_WIDTHS.NoteheadS0;break;case TokenType.NoteheadS1stemU:case TokenType.NoteheadS2stemU:y="u",u-=NOTEHEAD_WIDTHS.NoteheadS1,h+=NOTEHEAD_WIDTHS.NoteheadS1;break;case TokenType.NoteheadS1stemD:case TokenType.NoteheadS2stemD:y="d",h+=NOTEHEAD_WIDTHS.NoteheadS1;break}return{x:u,width:h,stemX:l,stemDirection:y,top:o,bottom:c,tip:d.tip}})}get timeWarped(){return this.tokens&&this.tokens.some(t=>t.timeWarped)}get additionalLines(){const t=this.getChords(),e=t.filter(n=>n.ys.some(r=>r<=-3)).map(n=>({left:n.left,right:n.right,n:Math.ceil(Math.min(...n.ys))+2})),i=t.filter(n=>n.ys.some(r=>r>=3)).map(n=>({left:n.left,right:n.right,n:Math.floor(Math.max(...n.ys))-2}));return[...e,...i].map(n=>({left:n.left-.28,right:n.right+.28,n:n.n}))}getChords(){const t=this.tokens.filter(o=>TokenFlags.includes(o.type)),e=this.tokens.filter(o=>TokenDots.includes(o.type)),i=this.tokens.filter(o=>TokenBeams.includes(o.type)),n=this.chordRects.map(o=>{const c=this.noteheads.filter(h=>h.direction===o.stemDirection&&h.left>=o.x&&h.right<=o.x+o.width+CHORD_X_TOLERANCE&&h.y>=o.top&&h.y<=o.bottom);c.sort((h,y)=>y.y-h.y);const d=c.map(h=>h.y),l=c.map(h=>h.id),u=c.reduce((h,y)=>Math.max(h,y.division),0);return{rect:o,left:o.x,right:o.x+o.width,pivotX:noteheadsPivot(c),ys:d,tip:o.tip,noteIds:l,division:u,dots:null,rest:!1,stemDirection:o.stemDirection,beam:null}}).sort((o,c)=>c.left-o.left),r=new Set,a=n.map(({rect:o,...c})=>{if(c.division>=1){const l=[o.bottom,o.top];switch(o.stemDirection){case"u":l[0]=o.tip?o.tip.y-.2:o.top-STEM_LENGTH_MAX-.5;break;case"d":l[1]=o.tip?o.tip.y+.2:o.bottom+STEM_LENGTH_MAX+.5;break}const u=t.filter(h=>!r.has(h.id)&&h.x>o.stemX-CHORD_X_TOLERANCE&&h.xl[0]&&h.yMath.max(h,y.division),c.division),u.forEach(h=>r.add(h.id)),c.division>=3){const h=o.tip&&i.find(y=>Math.abs(o.tip.x-y.x)<.3&&Math.abs(o.tip.y-y.y)<.7);h&&(c.beam=TOKEN_TO_STEMBEAM[h.type])}}const d=e.filter(l=>!r.has(l.id)&&l.x>o.x+o.width-.2&&l.xo.top-1&&l.y<=o.bottom+.5);return c.dots=d.reduce((l,u)=>Math.max(l,u.dots),0),d.forEach(l=>r.add(l.id)),c});return a.reverse(),a}getRests(){const t=this.tokens.filter(i=>TokenRests.includes(i.type)),e=this.tokens.filter(i=>TokenDots.includes(i.type));return t.map(i=>{const r=e.filter(a=>a.x>i.x+.5&&a.xi.y-1&&a.yMath.max(a,o.dots),0);return{left:i.x-.75,right:i.x+.75,pivotX:i.x,rest:!0,ys:[i.y],noteIds:[i.id],dots:r,division:i.division,stemDirection:null}})}getEvents(){return[...this.getChords(),...this.getRests()].sort((t,e)=>t.left-e.left)}getContexts(t={}){return this.tokens.filter(e=>e.isContexted).sort((e,i)=>e.x-i.x).map(e=>new ContextedTerm({x:e.x,y:e.y,tokenType:e.type,...t}))}assignAccessoriesOnEvents(t){t.forEach(l=>l.accessories=l.accessories||[]),this.tokens.filter(l=>TokenAccessories.includes(l.type)).forEach(l=>{const u=t.filter(h=>l.x>h.left-1&&l.x0){let h=u[0];u.length>1&&(h=u.map(f=>({event:f,d:Math.min(...f.ys.map(p=>Math.abs(p-l.y)))})).sort(({d:f},{d:p})=>f-p).map(({event:f})=>f)[0]);let y=l.y>Math.max(...h.ys)?AccessoryDirection.Down:AccessoryDirection.Up;TokenDirectionless.includes(l.type)&&(y=null),h.accessories.push({type:l.type,id:l.id,direction:y,x:l.x-h.left})}});const i=[...t];i.sort((l,u)=>l.left-u.left),this.tokens.filter(l=>l.type===TokenType.ScriptArpeggio).forEach(l=>{const u=i.find(h=>l.xyy>l.y));u&&u.accessories.push({type:TokenType.ScriptArpeggio,id:l.id,x:l.x-u.left})}),this.tokens.filter(l=>l.type===TokenType.GraceNotehead).forEach(l=>{const u=t.find(h=>l.x>h.left&&l.xMath.abs(l.y-y)<.4));u&&(u.grace=GraceType.Grace)});const a=this.tokens.filter(l=>l.type===TokenType.TremoloLeft),o=this.tokens.filter(l=>l.type===TokenType.TremoloRight),c=this.tokens.filter(l=>l.type===TokenType.TremoloMiddle),d=t.filter(l=>!l.rest).map(l=>{const u=[...l.ys];l.tip?u.push(l.tip.y):(u.push(l.ys[0]+2),u.push(l.ys[l.ys.length-1]-2));const h=l.tip?l.tip.x:l.left,y=l.tip?l.tip.x:l.right;return{event:l,top:Math.min(...u),bottom:Math.max(...u),stemL:h,stemR:y}});c.forEach(l=>{const u=d.find(h=>h.event.tip?l.y>h.top&&l.y{const u=d.find(h=>l.y>h.top&&l.yh.stemR&&l.x{const u=d.find(h=>l.y>h.top&&l.yh.stemL-1.6);u&&(u.event.tremolo=u.event.tremolo||2,++u.event.tremolo,u.event.tremoloLink=TremoloLink.Catcher)})}assignFeaturesOnEvents(t,e){const i=e.filter(m=>m.x>this.left&&m.xREST_SEMANTICS.includes(m.semantic)),r=i.filter(m=>m.semantic===SemanticType.Flag3),a=i.filter(m=>m.semantic===SemanticType.Dot),o=i.filter(m=>m.semantic===SemanticType.BeamLeft),c=i.filter(m=>m.semantic===SemanticType.BeamContinue),d=i.filter(m=>m.semantic===SemanticType.BeamRight),l=i.filter(m=>m.semantic===SemanticType.GraceNotehead),u=i.filter(m=>m.semantic===SemanticType.TremoloRight),h=i.filter(m=>m.semantic===SemanticType.vline_Stem),y=i.filter(m=>m.semantic===SemanticType.NoteheadS0),f=i.filter(m=>m.semantic===SemanticType.NoteheadS1),p=i.filter(m=>m.semantic===SemanticType.NoteheadS2);t.forEach(m=>{const T=m.tip?m.tip.x:(m.left+m.right)/2,x=m.tip?Math.min(m.tip.y,m.ys[m.ys.length-1]):m.ys[m.ys.length-1],g=m.tip?Math.max(m.tip.y,m.ys[0]):m.ys[0],v=m.tip?m.tip.x:m.left,S=[0,0,0,0,0,0,0];if(m.rest)n.filter(A=>distance2D(A,{x:T,y:m.ys[0]})<.5).forEach(A=>{const N=REST_SEMANTICS.indexOf(A.semantic);S[N]=Math.max(S[N],A.confidence)});else{const C=[y,f,p].map(N=>N.filter(F=>F.x>m.left&&F.xx-.25&&F.yMath.max(0,...N.map(F=>F.confidence))),A=r.filter(N=>N.y>x-.2&&N.yF.confidence-N.confidence),S[0]=C[0],S[1]=C[1],S[2]=C[2],Array(S.length-3).fill(0).forEach((N,F)=>S[3+F]=A[F]?A[F].confidence:0)}const E=a.filter(C=>C.x>T&&C.xE.some(A=>C.x>A.x&&Math.abs(C.y-A.y)<.2)),O=[Math.max(0,...E.map(C=>C.confidence)),Math.max(0,...k.map(C=>C.confidence))],M=[o,c,d].map(C=>C.filter(A=>Math.abs(A.x-T)<.2&&A.y>x-.2&&A.yMath.max(0,...C.map(A=>A.confidence))),b=h.filter(C=>distance2D({x:T,y:m.ys[0]},{x:C.x,y:C.extension.y2})<.5),_=h.filter(C=>distance2D({x:T,y:m.ys[m.ys.length-1]},{x:C.x,y:C.extension.y1})<.5),R=[Math.max(0,...b.map(C=>C.confidence)),Math.max(0,..._.map(C=>C.confidence))],I=l.filter(C=>Math.abs(C.x-T)<.6&&m.ys.some(A=>Math.abs(C.y-A)<.4)),D=Math.max(0,...I.map(C=>C.confidence)),w=m.division===0?u.filter(C=>C.x>m.left-2&&C.xC.y>x-.04&&C.yv-2&&C.xC.confidence));m.feature={divisions:S,dots:O,beams:M,stemDirections:R,grace:D,tremoloCatcher:B}})}}class Staff extends SimpleClass{static className="Staff";static blackKeys=["index","semanticTop","semanticBttom"];index;top;height;staffY;semanticTop;semanticBottom;backgroundImage;maskImage;imagePosition;measures;semantics;constructor({measureCount:t=null,measureBars:e=null,...i}={}){if(super(),super.assign(i),this.height=this.height||10,this.staffY=this.staffY||5,e){let n=0;this.measures=e.map(r=>{const a=new Measure({left:n,width:r-n,height:this.height});return n=r,a})}else t?this.measures=Array(t).fill(null).map(()=>new Measure):this.measures=[]}get noteRange(){const e=[].concat(...this.measures.map(r=>r.noteheads)).map(r=>r.y),i=Math.min(-2,...e),n=Math.max(2,...e);return{top:i,bottom:n}}get additionalLines(){return[].concat(...this.measures.map(t=>t.additionalLines))}rearrangeMeasures(t){var n;if(!t.length){console.warn("rearrangeMeasures error, measureBars are empty.");return}const e=((n=this.measures)==null?void 0:n.map(r=>r.tokens).flat(1))||[];let i=0;this.measures=t.map(r=>{const a=new Measure({left:i,width:r-i,height:this.height});return i=r,a}),this.reassignTokens(e)}reassignTokens(t=null){t||(t=[].concat(...this.measures.map(e=>e.tokens))),this.measures.forEach(e=>e.tokens=[]),t.forEach(e=>{for(const i of this.measures)if(e.xg.semantic===SemanticType.TempoNotehead).forEach(g=>{const v=n.findIndex(S=>/^Notehead/.test(S.semantic)&&distance2D(g,S)<.3);v>=0&&n.splice(v,1)});const a=g=>{var v;return(v=e.displacementSemantics)!=null&&v[g]?this.semantics.find(S=>S.id===g):null};n.filter(g=>MEASURE_SEMANTICS.includes(g.semantic)).forEach(g=>this.appendPoint(g,{points:n}));const o=n.filter(g=>g.semantic===SemanticType.vline_Stem).filter(g=>g.extension.y2-g.extension.y1>1.5).map(g=>({x:g.x,y1:g.extension.y1,y2:g.extension.y2,direction:null})),c=n.filter(g=>NOTEHEAD_FOR_STEM_SEMANTICS.includes(g.semantic)&&g.y>this.semanticTop&&g.y{if((S?1:0)^(g.x{const v=c.filter(S=>Math.abs(S.x-g.x)-NOTEHEAD_WIDTHS[S.semantic]/2<.32&&Math.abs(S.x-g.x)-NOTEHEAD_WIDTHS[S.semantic]/2>-.44&&S.y>g.y1-.5&&S.yg.x&&S.y>g.y2)&&!(S.xb.y-_.y);const S=Math.min(...v.map(b=>b.y-g.y1)),E=Math.min(...v.map(b=>g.y2-b.y));if(Math.min(S,E)>.5)return;const k=S!d.has(g.id)).forEach(g=>{const S=o.filter(E=>Math.abs(E.x-g.x)<2&&g.y>E.y1&&g.yMath.abs(E.x-g.x)-Math.abs(k.x-g.x))[0];if(S){const E=S.direction==="d",k=E?NOTEHEAD_TABLE[g.semantic].down:NOTEHEAD_TABLE[g.semantic].up;this.appendPoint({id:g.id,semantic:k,x:S.x+l(g,S,E),y:g.y,pivotX:g.x,confidence:g.confidence},{tip:{x:S.x,y:E?S.y2:S.y1},antiPoint:a(g.id),points:n})}else i.debug("isolated notehead:",e.index,this.index,g)});const u=n.filter(g=>g.semantic===SemanticType.Flag3);u.sort((g,v)=>g.x-v.x),this.appendFlags(u,o);const y=n.filter(g=>g.semantic===SemanticType.Dot).map(g=>{const v=roundNumber(g.y,.5);return{x:g.x,y:v}}).reduce((g,v)=>(g[v.y]=g[v.y]||[],g[v.y].push(v),g),{});Object.entries(y).forEach(([g,v])=>{const S=Number(g);if(v.length>1){v.sort((E,k)=>E.x-k.x);for(let E=0;EO.x>k.x&&O.x-k.x<1.2)&&this.appendPoint({id:k.id,x:k.x,y:S,confidence:k.confidence},{type:TokenType.DotDot,antiPoint:a(k.id),points:n})}}});const f=n.filter(g=>g.semantic===SemanticType.KeyAcc);n.filter(g=>KEYACC_CANDIDATE_SEMANTICS[g.semantic]).forEach(g=>{f.some(v=>Math.abs(g.x-v.x)<.5&&Math.abs(g.y-v.y)<1)&&this.appendPoint({id:g.id,semantic:g.semantic,x:g.x,y:g.y,confidence:g.confidence},{type:KEYACC_CANDIDATE_SEMANTICS[g.semantic],points:n})}),n.filter(g=>g.semantic===SemanticType.OctaveShift8).forEach(g=>{const v=g.y<0?TokenType.OctaveShift8va:TokenType.OctaveShift8vb;this.appendPoint({id:g.id,x:g.x,y:g.y,confidence:g.confidence},{type:v,points:n})});const T=this.semantics.filter(g=>[SemanticType.VoltaLeft,SemanticType.VoltaRight].includes(g.semantic));T.sort((g,v)=>g.x-v.x);const x=T.reduce((g,v)=>{const S=g[v.semantic],k=Array.from(Object.keys(S)).map(Number).find(O=>v.x{if(S.length>1){const E=S.reduce((k,O)=>k+O.confidence,0);S[0].y*S[1].y<0&&E>=t*2&&this.appendPoint(S[0],{type:TokenType[g]})}})}appendPoint(t,{type:e,points:i=null,antiPoint:n,...r}={}){const a=t.x,o=this.measures.find(f=>aLINED_INTERVAL_SEMANTICS.includes(p.semantic)&&Math.abs(p.y-t.y)<.2&&Math.abs(p.x-t.x)<1.2);f.some(p=>p.semantic===SemanticType.SignLined)?c=!0:f.some(p=>p.semantic===SemanticType.SignInterval)&&(d=!0)}e=e||TokenType[t.semantic];const l=TOKEN_Y_FIXED[e];let u=TOKEN_Y_ROUND[e];(c||d)&&(u=Math.max(u,1));let h=t.y;Number.isFinite(l)?h=l:u&&(d?h=roundNumber(h+.5,u)-.5:h=roundNumber(h,u));const y=o.tokens.find(f=>f.type===e&&Math.abs(f.x-a)<.1&&Math.abs(f.y-h)<.1);if(y){Number.isFinite(y.confidence)&&y.confidence3||(o.tokens.push(new Token({id:t.id,type:e,x:a,y:h,pivotX:t.pivotX,confidence:t.confidence,...r})),n&&o.antiTokens.push(new Token({id:n.id,type:e,x:a,y:n.y,confidence:n.confidence})))}appendFlags(t,e){e.map(n=>({...n,flags:t.filter(r=>Math.abs(r.x-n.x)<.3&&r.y>n.y1-.5&&r.yn.flags.length).forEach(n=>{const r=n.flags.reduce((u,h)=>u&&u.confidence>h.confidence?u:h,null),a=n.direction==="d",o=a?Math.min(n.y2,n.y1+STEM_LENGTH_MAX):Math.max(n.y1,n.y2-STEM_LENGTH_MAX),d=n.flags.map(u=>({tip:(o-u.y)*(a?1:-1),confidence:u.confidence})).filter(u=>u.tip<2||u.confidence>r.confidence*.7).length,l=TokenFlags[d-1];l&&this.appendPoint({id:n.flags[0].id,x:n.x,y:o,confidence:Math.min(...n.flags.map(u=>u.confidence))},{type:l})})}clearTokens(){this.measures.forEach(t=>t.tokens=[]),this.semantics=[]}clearPredictedTokens(){this.measures.forEach(t=>t.tokens=t.tokens.filter(e=>!e.isPredicted))}}class System extends SimpleClass{static className="System";static blackKeys=["index","pageIndex","prev","next","headMeasureIndex","tokens","indent"];index;pageIndex;prev;next;headMeasureIndex;left;top;width;indent;measureCount;staves;measureBars;backgroundImage;imagePosition;semantics;tokens;sidBlackList;sidWhiteList;displacementSemantics;staffMaskChanged;bracketsAppearance;constructor({stavesCount:t,...e}){if(super(),super.assign(e),!this.measureBars){const n=(this.width-5)/this.measureCount;this.measureBars=Array(this.measureCount).fill(0).map((r,a)=>5+n*(a+1))}!e.staves&&t&&(this.staves=Array(t).fill(null).map(()=>new Staff({measureBars:this.measureBars}))),this.arrangePosition(),this.measureCount=this.measureCount||this.measureBars.length,this.sidBlackList=this.sidBlackList||[],this.sidWhiteList=this.sidWhiteList||[]}get noteRange(){if(!this.staves.length)return null;const t=this.staves[0],e=this.staves[this.staves.length-1];return{top:t.top+t.staffY+t.noteRange.top,bottom:e.top+e.staffY+e.noteRange.bottom}}get staffPositions(){return this.staves.map(t=>({y:t.top+t.staffY,radius:2}))}get staffMask(){return this.staffMaskChanged?this.staffMaskChanged:this.prev&&this.staves.length===this.prev.staves.length?this.prev.staffMask:2**this.staves.length-1}get staffTop(){const t=this.staffPositions;return t.length?t[0].y-t[0].radius:0}get staffBottom(){const t=this.staffPositions;return t.length?t[t.length-1].y+t[t.length-1].radius:0}arrangePosition(){let t=0;for(const e of this.staves){if(Number.isFinite(e.top))break;e.top=t,t+=e.height}}tidyMeasureBars(){this.measureBars=this.measureBars.filter(e=>e>1),this.measureBars.sort((e,i)=>e-i);const t=this.width-this.measureBars[this.measureBars.length-1];t>12?this.measureBars.push(this.width):t<2&&(this.measureBars[this.measureBars.length-1]=this.width),this.measureBars=this.measureBars.filter((e,i)=>i<1||e-this.measureBars[i-1]>4)}rearrangeMeasures(){this.measureCount=this.measureBars.length,this.staves.forEach(t=>t.rearrangeMeasures(this.measureBars))}get height(){return this.staves.reduce((t,e)=>t+e.height,0)}get connectionLine(){const t=this.staves[0],e=this.staves[this.staves.length-1];return t&&{top:t.top+t.staffY-2,bottom:e.top+e.staffY+2}}get middleY(){return this.staves.length?this.staves.reduce((e,i)=>e+i.top+i.staffY,0)/this.staves.length:0}get timeSignatureOnHead(){return this.staves.some(t=>{var e;return(e=t.measures[0])==null?void 0:e.tokens.some(i=>TokenTimesigs.includes(i.type))})}getStaffArray(t){let e=0;return Array(t).fill(null).map((i,n)=>{const r=this.staffMask&1<0?this.measureBars[t-1]:0,i=this.measureBars[t];return[...(this.tokens??[]).filter(r=>r.x>=e&&r.xTempoTerm.fromNumeralText(r.text)).filter(Boolean)]}getEvents(t){var a;if(console.assert(Number.isInteger(this.headMeasureIndex),"invalid headMeasureIndex:",this.headMeasureIndex),!((a=this.measureBars)!=null&&a.length)&&this.staves.every(o=>{var c;return!((c=o.measures)!=null&&c.length)}))return{staffMask:this.staffMask,columns:[]};const i=this.getStaffArray(t).map(o=>o?o.measures.map(c=>{const d=c.getEvents();return c.assignAccessoriesOnEvents(d),c.assignFeaturesOnEvents(d,o.semantics),{events:d.map(l=>new EventTerm({staff:o.index,system:this.index,...l,rest:l.rest?"r":null})),contexts:c.getContexts({staff:o.index}),voltaBegin:c.tokens.some(l=>l.type===TokenType.VoltaLeft),voltaEnd:c.tokens.some(l=>l.type===TokenType.VoltaRight),alternative:c.alternative,barTypes:c.barTypes}}):Array(this.measureCount).fill(null).map(()=>({events:[],contexts:[],voltaBegin:!1,voltaEnd:!1,alternative:!1,barTypes:{}})));for(let o=0;o{var u,h;return(h=(u=l[o])==null?void 0:u.contexts)==null?void 0:h.filter(y=>[ContextType.TimeSignatureC,ContextType.TimeSignatureN].includes(y.type))}).find(l=>l==null?void 0:l.length);d&&i.forEach(l=>{l[o]&&!l[o].contexts.length&&!l[o].events.length&&l[o].contexts.push(...d)})}const n=Array(this.measureCount).fill(null).map((o,c)=>({measureIndex:this.headMeasureIndex+c,rows:i.map(d=>d[c]),marks:this.getMarksInMeasure(c),duration:0,voltaBegin:i.some(d=>{var l;return(l=d[c])==null?void 0:l.voltaBegin}),voltaEnd:i.some(d=>{var l;return(l=d[c])==null?void 0:l.voltaEnd}),alternative:i.some(d=>{var l;return(l=d[c])==null?void 0:l.alternative}),barTypes:i.reduce((d,l)=>{var u;return{...d,...(u=l[c])==null?void 0:u.barTypes}},{})}));n.forEach(o=>{[].concat(...o.rows.filter(Boolean).map(d=>d.events)).forEach((d,l)=>d.id=l+1)});const r=n[n.length-1];return r&&(r.break=!0),{staffMask:this.staffMask,columns:n}}getEventsFunctional(t,e,i=[],{useXMap:n=!1}={}){const a=this.getStaffArray(t).map((c,d)=>c?c.measures.map((l,u)=>{const h=e(d,u);return h&&{events:h.map(y=>new EventTerm({system:this.index,...y,rest:y.rest?"r":null})),contexts:l.getContexts({staff:d}),voltaBegin:l.tokens.some(y=>y.type===TokenType.VoltaLeft),voltaEnd:l.tokens.some(y=>y.type===TokenType.VoltaRight),alternative:l.alternative,barTypes:l.barTypes}}):Array(this.measureCount).fill(null).map(()=>({events:[],contexts:[],voltaBegin:!1,voltaEnd:!1,alternative:!1,barTypes:{}}))),o=Array(this.measureCount).fill(null).map((c,d)=>{const l=a.map(h=>h[d]);if(l.some(h=>!h))return null;let u=null;if(n){const y=[].concat(...l.map(f=>f.events)).reduce((f,p)=>(Number.isFinite(p.tickGroup)&&(f[p.tickGroup]=f[p.tickGroup]||[]),f[p.tickGroup].push(p),f),{});u=Object.values(y).reduce((f,p)=>{const m=Math.min(...p.map(T=>(T.left+T.right)/2));return f.set(m,p),f},new Map)}return{measureIndex:this.headMeasureIndex+d,rows:l,marks:this.getMarksInMeasure(d),duration:0,xMap:u,voltaBegin:l.some(h=>h.voltaBegin),voltaEnd:l.some(h=>h.voltaEnd),alternative:l.some(h=>h.alternative),barTypes:l.reduce((h,y)=>({...h,...y.barTypes}),{})}});return i.forEach(c=>o.forEach(c)),{staffMask:this.staffMask,columns:o}}getContexts(t){const i=this.getStaffArray(t).map(r=>r?r.measures.map(a=>({events:null,contexts:a.getContexts(),voltaBegin:a.tokens.some(o=>o.type===TokenType.VoltaLeft),voltaEnd:a.tokens.some(o=>o.type===TokenType.VoltaRight),alternative:i.some(o=>o.alternative),barTypes:a.barTypes})):Array(this.measureCount).fill(null).map(()=>({events:null,contexts:[],voltaBegin:!1,voltaEnd:!1,alternative:!1,barTypes:{}})));for(let r=0;r{var d;return(d=c[r])==null?void 0:d.contexts.filter(l=>[ContextType.TimeSignatureC,ContextType.TimeSignatureN].includes(l.type))}).find(c=>c==null?void 0:c.length);o&&i.forEach(c=>{c[r].contexts.length||c[r].contexts.push(...o)})}const n=Array(this.measureCount).fill(null).map((r,a)=>({measureIndex:this.headMeasureIndex+a,rows:i.map(o=>o[a]),marks:[],duration:0,voltaBegin:i.some(o=>o[a].voltaBegin),voltaEnd:i.some(o=>o[a].voltaEnd),alternative:i.some(o=>o.alternative),barTypes:i.reduce((o,c)=>({...o,...c[a].barTypes}),{})}));return{staffMask:this.staffMask,columns:n}}assignSemantics(t,e){const i=this.staves[t];console.assert(i,"staff is null:",t,this.staves);const n=i.top+i.staffY;e.getSystemPoints().forEach(r=>{const a={...r};a.y+=n,a.extension&&(a.extension={...a.extension},Number.isFinite(a.extension.y1)&&(a.extension.y1+=n,a.extension.y2+=n)),this.semantics.push(a)})}assemble(t,e=new DummyLogger){if(this.measureBars=[],!this.semantics)return;const n=SemanticGraph.fromPoints(this.semantics).getConfidentLayer(SemanticType.vline_BarMeasure,t);n.sort((f,p)=>f.x-p.x);const r=this.staffTop,a=this.staffBottom,o=.4;let c=0;const d=n.reduce((f,p)=>{const m=Number.isFinite(p.confidence)?Math.tanh(p.confidence):1,T=p.x-c>o?p.x:c;c=p.x;let x=f[T]||0;return x+=(Math.min(p.extension.y2,a)-Math.max(p.extension.y1,r))*m,p.x!==T&&delete f[T],f[p.x]=x,f},{}),l=Object.entries(d).filter(([f,p])=>p>3*this.staves.length).map(([f])=>Number(f));if(this.sidWhiteList.length)for(const f of n)this.sidWhiteList.includes(f.id)&&!l.some(p=>Math.abs(p-f.x)<=2)&&l.push(f.x);l.sort((f,p)=>f-p),l.forEach((f,p)=>{(p<=0||f-l[p-1]>2)&&this.measureBars.push(f)}),this.measureBars.length||this.measureBars.push(this.width),this.tidyMeasureBars(),this.rearrangeMeasures(),this.semantics.filter(f=>[SemanticType.vline_BarTerminal,SemanticType.vline_BarSegment].includes(f.semantic)).forEach(f=>{const p=this.staves[0].measures.find(m=>f.x>m.right-2&&f.x{for(;!(y&1<hashSemanticPoint(this.index,p,m)),f.clearPredictedTokens(),f.assemble(t,this,e))})}qualifiedSemantics(t,e=1){return t.filter(i=>this.sidWhiteList.includes(i.id)||!this.sidBlackList.includes(i.id)&&(i.confidence>=e||!Number.isFinite(i.confidence))).map(i=>this.displacementSemantics&&this.displacementSemantics[i.id]?{...i,...this.displacementSemantics[i.id]}:i)}clearTokens(){this.staves.forEach(t=>t.clearTokens()),this.semantics=[]}newPoint(t,e,i=1){const n=this.staves[t];console.assert(n,"staff index out of bound:",t,this.staves.length);const{semantic:r,x:a,y:o,confidence:c=0,extension:d=null}=e,l={semantic:r,x:a,y:o,confidence:c,extension:d};return l.extension||delete l.extension,hashSemanticPoint(this.index,t,l),n.semantics.push(l),n.clearPredictedTokens(),n.assemble(i,this),l}appendToken(t){switch(this.tokens.push(t),t.textType){case TextType.TempoNumeral:{const e=this.staves[0];if(e){const i=e.top+e.staffY;e.measures.forEach(n=>{n.tokens=n.tokens.filter(r=>!TokenNoteheads.includes(r.type)||Math.abs(r.x-t.x)>t.width/2||Math.abs(i+r.y-t.y)>t.fontSize/2)})}}break;case TextType.Alternation1:case TextType.Alternation2:this.staves[0].measures.forEach(e=>{const i=Math.min(e.left+e.width,t.x+t.width/2)-Math.max(e.left,t.x-t.width/2);e.alternative=e.alternative||i/e.width>.5});break}}}class Page extends SimpleClass{static className="Page";static blackKeys=["index","tokens"];index;width;height;systems;source;layout;semantics;tokens;lyricTokens;constructor(t){super(),super.assign(t),this.systems=this.systems||[],this.source&&(this.source.matrix=this.source.matrix||[1,0,0,1,0,0])}get sidBlackList(){const t=[].concat(...this.systems.map(e=>e.sidBlackList));return new Set(t)}get sidWhiteList(){const t=[].concat(...this.systems.map(e=>e.sidWhiteList));return new Set(t)}clearTokens(){this.semantics=null,this.tokens=null,this.lyricTokens=null,this.systems.forEach(t=>t.tokens=null)}assignTexts(t,[e,i]){const n=this.source&&this.source.interval?this.source.interval*(e/this.source.dimensions.height):e/this.height;this.semantics=t.map(r=>{const a={x:(r.cx-i/2)/n,y:(r.cy-e/2)/n},o=this.source&&this.source.matrix?trans23(a,this.source.matrix):a;return this.createTextSemantic(r,o.x+this.width/2,o.y+this.height/2,n)})}assignPageTexts(t,[e,i]){const n=i/this.width,r=e/this.height;this.semantics=t.map(a=>this.createTextSemantic(a,a.cx/n,a.cy/r,n,r))}createTextSemantic(t,e,i,n,r=n){return{confidence:t.score,x:e,y:i,semantic:SemanticType.rect_Text,extension:{text:t.text,type:t.type,width:t.width/n,height:t.height/r,theta:t.theta,textFeature:t.feature_dict}}}assemble({textAnnotations:t=null}={},e=new DummyLogger){if(this.tokens=[],this.lyricTokens=[],this.systems.forEach(i=>i.tokens=[]),this.systems.length){const i=this.systems.map(r=>r.left),n=i[Math.floor((i.length-1)/2)];this.systems.forEach(r=>r.indent=r.left>n+INDENT_THRESHOLD)}if(this.semantics){const i=this.source?this.source.name:this.index.toString();this.semantics.forEach(n=>{hashPageSemanticPoint(i,n);const r={id:n.id,type:TokenType.Text,confidence:n.confidence,textType:TEXT_TYPE_ALIAS[n.extension.type]||n.extension.type,text:t&&t[n.id]||n.extension.text,textFeasure:n.extension.textFeature,width:n.extension.width,fontSize:n.extension.height};switch(n.semantic){case SemanticType.rect_Text:switch(r.textType){case TextType.Title:case TextType.Author:case TextType.PageMargin:case TextType.Other:this.tokens.push(new TextToken({x:n.x,y:n.y,...r}));break;case TextType.TempoNumeral:case TextType.Chord:case TextType.MeasureNumber:case TextType.Instrument:case TextType.Alternation1:case TextType.Alternation2:{const a=this.systems.find(o=>o.top+o.staffTop>n.y);a&&a.appendToken(new TextToken({x:n.x-a.left,y:n.y-a.top,...r}))}break;case TextType.Lyric:(this.lyricTokens||(this.lyricTokens=[])).push(new TextToken({x:n.x,y:n.y,...r}));break;case TextType.TextualMark:case TextType.Times:{const a=[...this.systems].reverse().find(o=>o.topo>=l.top&&oc>=u.left&&c(s[s.BOS=0]="BOS",s[s.PAD=1]="PAD",s[s.NoteheadS0=2]="NoteheadS0",s[s.NoteheadS1=3]="NoteheadS1",s[s.NoteheadS2=4]="NoteheadS2",s[s.NoteheadGrace=5]="NoteheadGrace",s[s.vline_Stem=6]="vline_Stem",s[s.Flag3=7]="Flag3",s[s.BeamLeft=8]="BeamLeft",s[s.BeamContinue=9]="BeamContinue",s[s.BeamRight=10]="BeamRight",s[s.Dot=11]="Dot",s[s.Rest0=12]="Rest0",s[s.Rest1=13]="Rest1",s[s.Rest2=14]="Rest2",s[s.Rest3=15]="Rest3",s[s.Rest4=16]="Rest4",s[s.Rest5=17]="Rest5",s[s.Rest6=18]="Rest6",s[s.TimeD2=19]="TimeD2",s[s.TimeD4=20]="TimeD4",s[s.TimeD8=21]="TimeD8",s[s.TimeN1=22]="TimeN1",s[s.TimeN2=23]="TimeN2",s[s.TimeN3=24]="TimeN3",s[s.TimeN4=25]="TimeN4",s[s.TimeN5=26]="TimeN5",s[s.TimeN6=27]="TimeN6",s[s.TimeN7=28]="TimeN7",s[s.TimeN8=29]="TimeN8",s[s.TimeN9=30]="TimeN9",s[s.TimeN10=31]="TimeN10",s[s.TimeN11=32]="TimeN11",s[s.TimeN12=33]="TimeN12",s))(SemanticElementType||{});const TIME_SIG_DENOMINATORS=Object.fromEntries([2,4,8].map(s=>[s,SemanticElementType[`TimeD${s}`]])),TIME_SIG_NUMERATORS=Object.fromEntries(Array(12).fill(null).map((s,t)=>t+1).map(s=>[s,SemanticElementType[`TimeN${s}`]])),et=SemanticElementType,ELEMENT_TOKEN_NAMES={[et.BOS]:"BOS",[et.NoteheadS0]:"noteheads-s0",[et.NoteheadS1]:"noteheads-s1",[et.NoteheadS2]:"noteheads-s2",[et.NoteheadGrace]:"GraceNotehead",[et.Flag3]:"flags-u3",[et.BeamLeft]:"BeamLeft",[et.BeamContinue]:"BeamContinue",[et.BeamRight]:"BeamRight",[et.Dot]:"dot",[et.Rest0]:"rests-0o",[et.Rest1]:"rests-1o",[et.Rest2]:"rests-2",[et.Rest3]:"rests-3",[et.Rest4]:"rests-4",[et.Rest5]:"rests-5",[et.Rest6]:"rests-6"},NOTEHEAD_BASE_DIVISION={[et.NoteheadS0]:0,[et.NoteheadS1]:1,[et.NoteheadS2]:2,[et.NoteheadGrace]:2},NOTEHEAD_ELEMENT_TYPES=[et.NoteheadS0,et.NoteheadS1,et.NoteheadS2,et.NoteheadGrace],REST_ELEMENT_TYPES=[et.Rest0,et.Rest1,et.Rest2,et.Rest3,et.Rest4,et.Rest5,et.Rest6],BEAM_ELEMENT_TYPES=[et.BeamLeft,et.BeamContinue,et.BeamRight],NOTE_ELEMENT_TYPES=[...NOTEHEAD_ELEMENT_TYPES,...REST_ELEMENT_TYPES],SOURCE_ELEMENT_TYPES=[...NOTEHEAD_ELEMENT_TYPES,...REST_ELEMENT_TYPES,et.vline_Stem],TARGET_ELEMENT_TYPES=[et.BOS,et.NoteheadS0,et.vline_Stem,...REST_ELEMENT_TYPES],ROOT_NOTE_ELEMENT_TYPES=[...NOTE_ELEMENT_TYPES,et.vline_Stem],ELEMENT_TO_STEMBEAM={[et.BeamLeft]:"Open",[et.BeamRight]:"Close"},metaElem=s=>({type:s,staff:-1,x:0,y1:0,y2:0}),BOS_ELEMENT=metaElem(0),fractionToElems=s=>[metaElem(TIME_SIG_NUMERATORS[s.numerator]),metaElem(TIME_SIG_DENOMINATORS[s.denominator])],argmax=(s,t)=>{const e=s.filter((n,r)=>t[r]),i=Math.max(...e);return s.findIndex(n=>n===i)};class SemanticCluster extends SimpleClass{index;elements;matrixH;_matrixV;groupsV;masks;static elementToJSON(t){const e={type:t.type,staff:t.staff,x:t.x,y1:t.y1,y2:t.y2};return t.id&&(e.id=t.id),e}constructor(t){super(),super.assign(t)}get sourceMask(){return this.elements.map(t=>SOURCE_ELEMENT_TYPES.includes(t.type))}get targetMask(){return this.elements.map(t=>TARGET_ELEMENT_TYPES.includes(t.type))}get vMask(){return this.elements.map(t=>ROOT_NOTE_ELEMENT_TYPES.includes(t.type))}get compactMatrixH(){if(!this.matrixH)return null;const t=this.sourceMask,e=this.targetMask;return this.matrixH.filter((i,n)=>t[n]).map(i=>i.filter((n,r)=>e[r]))}set compactMatrixH(t){this.matrixH=expandMatrixByMasks([].concat(...t),[this.sourceMask,this.targetMask])}get compactMatrixV(){if(!this._matrixV)return null;const t=this.vMask,e=this._matrixV.filter((i,n)=>t[n]).map(i=>i.filter((n,r)=>t[r]));return[].concat(...e.map((i,n)=>i.slice(0,n)))}set compactMatrixV(t){this.matrixV=t&&expandMatrixByMaskTriu(t,this.vMask)}get matrixV(){return this.groupsV&&matrixFromGroups(this.elements.length,this.groupsV)}set matrixV(t){if(!t){this.groupsV=null,this._matrixV=t;return}const e=.5,i=[],n=t.map((r,a)=>r.some(Number.isFinite)||t.some(o=>Number.isFinite(o[a])));t.forEach((r,a)=>{if(n[a]){let o=!1;for(let c=0;c=e){const l=i.findIndex(u=>u.includes(c));i[l].push(a),o=!0;break}o||i.push([a])}}),this.groupsV=i,this._matrixV=t}toJSON(){return{__prototype:"SemanticCluster",index:this.index,elements:this.elements.map(SemanticCluster.elementToJSON),compactMatrixH:this.compactMatrixH,compactMatrixV:this.compactMatrixV}}static mapMatrix(t,e,i){return e.reduce((r,a,o)=>(r[a]?r[a]=r[a].map((c,d)=>c+t[o][d]?1:0):r[a]=t[o],r),[]).map(r=>i.map(a=>r[a]))}mergeOverlapping(){const t=this.overlappedNoteheads();if(t.length){const e=this.elements.map((n,r)=>{const a=t.find(c=>r===c[1]),o=a?a[0]:r;return o-t.filter(c=>c[1]e.findIndex(a=>a===r));this.elements=i.map(n=>this.elements[n]),console.assert(this.elements.every(Boolean),"null element found:",this,e,i),this.matrixH=SemanticCluster.mapMatrix(this.matrixH,e,i),this.groupsV=this.groupsV.map(n=>Array.from(new Set(n.map(r=>e[r]))))}}overlappedNoteheads(){const t=[],e=this.elements.filter(i=>NOTEHEAD_ELEMENT_TYPES.includes(i.type));for(let i=0;iT),i=this.masks?this.masks[1]:e.map(m=>TARGET_ELEMENT_TYPES.includes(this.elements[m].type)),n=e.map(m=>this.elements[m].type===et.vline_Stem&&this.elements[m].y2-this.elements[m].y1>2),r=e.filter(m=>[et.NoteheadS1,et.NoteheadS2,et.NoteheadGrace].includes(this.elements[m].type)),a=e.filter(m=>this.elements[m].type===et.NoteheadS0),o=e.map(()=>!1),c={};r.forEach(m=>{const T=this.elements[m];e.filter(g=>n[g]).filter(g=>this.elements[g].y1-.5T.y1).sort((g,v)=>this.matrixH[m][v]-this.matrixH[m][g]).slice(0,2).filter((g,v)=>v===0||this.matrixH[m][g]>=t).forEach(g=>{c[g]=c[g]||[],c[g].push(m)})}),a.forEach(m=>{const T=this.elements[m],x=argmax(this.matrixH[m],i),g=this.elements[x];g.type===et.NoteheadS0&&Math.abs(T.x-g.x)<2.6?(o[m]=!0,c[x]=c[x]||[x],c[x].push(m)):c[m]=c[m]||[m]});const d={},l=e.filter(m=>c[m]||REST_ELEMENT_TYPES.includes(this.elements[m].type));l.sort((m,T)=>this.elements[m].x-this.elements[T].x);const u=e.map(m=>m===et.BOS);l.forEach(m=>{const T=argmax(this.matrixH[m],u);d[m]=T,T&&!REST_ELEMENT_TYPES.includes(this.elements[T].type)&&(u[T]=!1),u[m]=!0});const h=this.elements.filter(m=>m.type===et.Dot),y=this.elements.filter(m=>m.type===et.Flag3),f=this.elements.filter(m=>BEAM_ELEMENT_TYPES.includes(m.type)),p=this.groupsV;return l.map(m=>{const T=this.elements[m],x=p?p.findIndex(g=>g.includes(m)):null;if(REST_ELEMENT_TYPES.includes(T.type)){const g=h.filter(v=>v.x>T.x+.5&&v.xT.y1-1&&v.y1this.elements[A]),v=Math.min(...g.map(A=>A.x-.7)),S=Math.max(...g.map(A=>A.x+.7));g.sort((A,N)=>N.y1-A.y1);const E=g.map(A=>A.y1),k=g.map(A=>A.id),O=E[0],M=E[E.length-1],_=h.filter(A=>A.x>S&&A.xO-1&&A.y1{const F=roundNumber(N.y1,.5);return A[F]=A[F]||[],A[F].push(N),A},{}),R=Math.max(...Object.values(_).map(A=>A.length),0);let I=NOTEHEAD_BASE_DIVISION[g[0].type],D=null,w=null,B=null;if(T.type===et.vline_Stem){const A=O-T.y1,N=T.y2-M;if(D=A>N?"u":"d",B={x:T.x,y:D==="u"?T.y1:T.y2},I===2){const H=D==="u"?[T.y1-.4,T.y2-1]:[T.y1+1,T.y2+.4],W=y.filter(P=>Math.abs(P.x-T.x)<.2&&P.y1>H[0]&&P.y1Math.abs(H.x-T.x)<.2&&H.y1>F[0]&&H.y1[n,SemanticElementType[i]]).filter(([i,n])=>i!==n).reduce((i,[n,r])=>(i[n]=r,i),{});this.clusters.forEach(i=>i.elements.forEach(n=>{Number.isFinite(e[n.type])&&(n.type=e[n.type])}))}}toJSON(){return{__prototype:"SemanticClusterSet",vocab:Object.entries(SemanticElementType).filter(e=>Number.isFinite(e[1])).map(e=>e[0]),clusters:this.clusters.map(e=>e.toJSON())}}}const expandMatrixByMasks=(s,t)=>{const i=function*(){for(const a of s)yield a}(),[n,r]=t;return n.map(a=>r.map(o=>a&&o?i.next().value:null))},expandMatrixByMaskTriu=(s,t)=>{const i=function*(){for(const n of s)yield n}();return t.map((n,r)=>t.map((a,o)=>n&&a&&o{const e=Array(s).fill(null).map((i,n)=>t.findIndex(r=>r.includes(n)));return Array(s).fill(null).map((i,n)=>Array(s).fill(null).map((r,a)=>{if(a>=n)return null;const o=e[n],c=e[a];return o<0||c<0?null:o===c?1:0}))};var sha256={exports:{}},core={exports:{}},hasRequiredCore;function requireCore(){return hasRequiredCore||(hasRequiredCore=1,function(s,t){(function(e,i){s.exports=i()})(commonjsGlobal,function(){var e=e||function(i,n){var r;if(typeof window<"u"&&window.crypto&&(r=window.crypto),typeof self<"u"&&self.crypto&&(r=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(r=globalThis.crypto),!r&&typeof window<"u"&&window.msCrypto&&(r=window.msCrypto),!r&&typeof commonjsGlobal<"u"&&commonjsGlobal.crypto&&(r=commonjsGlobal.crypto),!r&&typeof commonjsRequire=="function")try{r=require$$5}catch{}var a=function(){if(r){if(typeof r.getRandomValues=="function")try{return r.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof r.randomBytes=="function")try{return r.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},o=Object.create||function(){function x(){}return function(g){var v;return x.prototype=g,v=new x,x.prototype=null,v}}(),c={},d=c.lib={},l=d.Base=function(){return{extend:function(x){var g=o(this);return x&&g.mixIn(x),(!g.hasOwnProperty("init")||this.init===g.init)&&(g.init=function(){g.$super.init.apply(this,arguments)}),g.init.prototype=g,g.$super=this,g},create:function(){var x=this.extend();return x.init.apply(x,arguments),x},init:function(){},mixIn:function(x){for(var g in x)x.hasOwnProperty(g)&&(this[g]=x[g]);x.hasOwnProperty("toString")&&(this.toString=x.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),u=d.WordArray=l.extend({init:function(x,g){x=this.words=x||[],g!=n?this.sigBytes=g:this.sigBytes=x.length*4},toString:function(x){return(x||y).stringify(this)},concat:function(x){var g=this.words,v=x.words,S=this.sigBytes,E=x.sigBytes;if(this.clamp(),S%4)for(var k=0;k>>2]>>>24-k%4*8&255;g[S+k>>>2]|=O<<24-(S+k)%4*8}else for(var M=0;M>>2]=v[M>>>2];return this.sigBytes+=E,this},clamp:function(){var x=this.words,g=this.sigBytes;x[g>>>2]&=4294967295<<32-g%4*8,x.length=i.ceil(g/4)},clone:function(){var x=l.clone.call(this);return x.words=this.words.slice(0),x},random:function(x){for(var g=[],v=0;v>>2]>>>24-E%4*8&255;S.push((k>>>4).toString(16)),S.push((k&15).toString(16))}return S.join("")},parse:function(x){for(var g=x.length,v=[],S=0;S>>3]|=parseInt(x.substr(S,2),16)<<24-S%8*4;return new u.init(v,g/2)}},f=h.Latin1={stringify:function(x){for(var g=x.words,v=x.sigBytes,S=[],E=0;E>>2]>>>24-E%4*8&255;S.push(String.fromCharCode(k))}return S.join("")},parse:function(x){for(var g=x.length,v=[],S=0;S>>2]|=(x.charCodeAt(S)&255)<<24-S%4*8;return new u.init(v,g)}},p=h.Utf8={stringify:function(x){try{return decodeURIComponent(escape(f.stringify(x)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(x){return f.parse(unescape(encodeURIComponent(x)))}},m=d.BufferedBlockAlgorithm=l.extend({reset:function(){this._data=new u.init,this._nDataBytes=0},_append:function(x){typeof x=="string"&&(x=p.parse(x)),this._data.concat(x),this._nDataBytes+=x.sigBytes},_process:function(x){var g,v=this._data,S=v.words,E=v.sigBytes,k=this.blockSize,O=k*4,M=E/O;x?M=i.ceil(M):M=i.max((M|0)-this._minBufferSize,0);var b=M*k,_=i.min(b*4,E);if(b){for(var R=0;R>>7)^(M<<14|M>>>18)^M>>>3,_=u[O-2],R=(_<<15|_>>>17)^(_<<13|_>>>19)^_>>>10;u[O]=b+u[O-7]+R+u[O-16]}var I=v&S^~v&E,D=m&T^m&x^T&x,w=(m<<30|m>>>2)^(m<<19|m>>>13)^(m<<10|m>>>22),B=(v<<26|v>>>6)^(v<<21|v>>>11)^(v<<7|v>>>25),C=k+B+I+l[O]+u[O],A=w+D;k=E,E=S,S=v,v=g+C|0,g=x,x=T,T=m,m=C+A|0}p[0]=p[0]+m|0,p[1]=p[1]+T|0,p[2]=p[2]+x|0,p[3]=p[3]+g|0,p[4]=p[4]+v|0,p[5]=p[5]+S|0,p[6]=p[6]+E|0,p[7]=p[7]+k|0},_doFinalize:function(){var y=this._data,f=y.words,p=this._nDataBytes*8,m=y.sigBytes*8;return f[m>>>5]|=128<<24-m%32,f[(m+64>>>9<<4)+14]=i.floor(p/4294967296),f[(m+64>>>9<<4)+15]=p,y.sigBytes=f.length*4,this._process(),this._hash},clone:function(){var y=o.clone.call(this);return y._hash=this._hash.clone(),y}});n.SHA256=o._createHelper(h),n.HmacSHA256=o._createHmacHelper(h)}(Math),e.SHA256})})(sha256);var sha256Exports=sha256.exports;const _SHA256=getDefaultExportFromCjs(sha256Exports),SHA256=s=>{const{words:t,sigBytes:e}=_SHA256(s),i=t.map(r=>r<0?r+4294967296:r),n=e/t.length;return new Uint8Array(e).map((r,a)=>i[Math.floor(a/n)]>>(3-a%n)*8&255)},HASH_LEN=256;class HashVector{fields;static fromHash(t){const e=[];for(const i of t)for(let n=0;n<8;++n)e.push(i>>n&1?1:-1);return new HashVector(e)}static fromString(t){const e=SHA256(t);return HashVector.fromHash(e)}static fromWords(t){return t.map(i=>HashVector.fromString(i)).reduce((i,n)=>i.add(n),HashVector.zero)}static concat(...t){const e=t.map(i=>i.fields).flat(1);return new HashVector(e)}constructor(t=null){this.fields=t||Array(HASH_LEN).fill(0)}get length(){return this.fields.length}toHash(){return Uint8Array.from(Array(this.length/8).fill(0).map((t,e)=>this.fields.slice(e*8,(e+1)*8).reduce((n,r,a)=>n|(r>0?1:0)<this.fields[i]=e+t.fields[i]),this}scale(t){return this.fields=this.fields.map(e=>e*t),this}sub(t){const e=t>0?this.fields.slice(0,t):this.fields.slice(t);return new HashVector(e)}static get zero(){return new HashVector}}const odds=s=>{let t=0;for(let e=s;e>0;e>>=1)e%2&&++t;return t},ODDS=Array(2**8).fill(0).map((s,t)=>odds(t));ODDS.reduce((s,t,e)=>({...s,[("0"+e.toString(16)).slice(-2)]:t}),{});const countOnes=s=>s.reduce((t,e)=>t+ODDS[e],0),xorHashes=(s,t)=>s.map((e,i)=>e^t[i]),cosHashes=(s,t)=>{const e=s.length*8,i=xorHashes(s,t),n=countOnes(i);return(e-n*2)/e},i2hex=s=>("0"+s.toString(16)).slice(-2),hashToHex=s=>Array.from(s).map(i2hex).join(""),hashToBigInt=s=>Array.from(s).reduce((t,e)=>t*0x100n+BigInt(e),0n),emptyVoiceFromStaffMeasure=(s,t=!1)=>({empty:!0,duration:s.duration,tickMap:{0:EventTerm.space({duration:s.duration,tick:0})},timeSignature:s.timeSignature,timeSigNumeric:s.timeSigNumeric,keySignature:s.keySignature,contextedTerms:s.terms.filter(e=>e instanceof ContextedTerm&&(!e.staffLevel||t)),marks:[]}),removeEmptyMeasuresInVoicesStaves=s=>{if(!(s[0]&&s[0].voices[0])){console.warn("empty voices:",s);return}const t=s[0].voices[0].measures.length;Array(t).fill(null).map((i,n)=>{for(const r of s)for(const a of r.voices)if(!a.measures[n].empty)return!1;return!0}).forEach((i,n)=>{i&&s.forEach(r=>r.voices.forEach(a=>{const o=a.measures[n];o.tickMap={}}))})},moveFirstSystemTempoToHead=(s,t)=>{var i,n,r;const e=(n=(i=s[0])==null?void 0:i.voices[0])==null?void 0:n.measures[0];if(!(!e||t<=0))for(const a of s)for(const o of a.voices)for(const c of o.measures.slice(0,t)){const d=(r=c==null?void 0:c.marks)==null?void 0:r.findIndex(l=>l instanceof TempoTerm);if(d>=0){const[l]=c.marks.splice(d,1);l.tick=0,e.marks=[l,...e.marks.filter(u=>!(u instanceof TempoTerm))];return}}},filterSyntheticOctaveZeroContexts=s=>{const t=Array(s.length).fill(0),e=Math.max(0,...s.flatMap(i=>i.voices.map(n=>n.measures.length)));for(let i=0;io.measures[i]).filter(Boolean);if(!r.length)continue;let a=t[n];for(const o of r)o.contextedTerms=o.contextedTerms.filter(c=>{if(!(c instanceof ContextedTerm)||c.type!==ContextType.OctaveShift)return!0;const d=c.octaveShift;return c.tokenType===TokenType.OctaveShift0&&!c.id&&c.x===0&&a===0?!1:(a=d,!0)});t[n]=a}},markingTiesInVoice=s=>{const t=[].concat(...s.measures.map(e=>Object.values(e.tickMap).filter(i=>i instanceof EventTerm)));for(let e=1;er.type===TokenType.SlurBegin)&&n.accessories.some(r=>r.type===TokenType.SlurEnd)){const r=i.pitches.filter(a=>n.pitches.some(o=>o.note===a.note&&o.alter===a.alter));r.length>0&&(i.tying=!0,n.tied=!0,r.forEach(a=>{a.tying=!0;const o=n.pitches.find(c=>c.note===a.note&&c.alter===a.alter);o.tied=!0}),r.forEach(()=>{const a=i.accessories.findIndex(c=>c.type===TokenType.SlurBegin);a>=0&&i.accessories.splice(a,1);const o=n.accessories.findIndex(c=>c.type===TokenType.SlurEnd);o>=0&&n.accessories.splice(o,1)}))}}};class Spartito extends SimpleClass{static className="Spartito";stavesCount;staffGroups;measures;tags;constructor(t){super(),super.assign(t),this.measures.forEach(e=>e.staffGroups=this.staffGroups)}get regulated(){return this.measures.every(t=>t.regulated)}get solidMeasureCount(){return this.measures.filter(t=>!t.empty).length}get measureIndexMapping(){let t=0;return this.measures.map(e=>e.empty?null:t++)}get headBPM(){for(const t of this.measures)if(t.marks){const e=t.marks.find(i=>i instanceof TempoTerm&&i.isValid());if(e)return e.bpm}return null}get measureLayoutCode(){const t=this.measures.filter(e=>!e.empty).map((e,i)=>({index:i+1,vb:e.voltaBegin,ve:e.voltaEnd,alter:e.alternative,leftSign:"",rightSign:""}));return t.forEach((e,i)=>{if(e.vb){const n=t.slice(i+1).findIndex(a=>a.vb),r=n>=0?i+n:t.length;t.slice(i,r-1).some(a=>a.ve)&&(e.leftSign="2*[")}if(e.ve){const n=t.slice(0,i+1).reverse(),r=n.slice(1).findIndex(a=>a.ve);if(r>=0&&!n.slice(1,r+1).some(a=>a.vb))return;if(e.alter){const a=n.findIndex(o=>!o.alter);a>0&&(n[a].rightSign="]",n[a-1].leftSign="{[",e.rightSign="],",t[i+1]&&(t[i+1].rightSign="},"))}else e.rightSign="],";n.some(a=>a.vb)||(t[0].leftSign="2*[")}}),t.map(e=>e.leftSign+e.index.toString()+e.rightSign+(e.rightSign?"":",")).join(" ").replace(/,$/,"")}get qualityScore(){const t=this.measures.filter(n=>!n.empty),i=t.map(evaluateMeasure).map(n=>n.qualityScore).reduce((n,r)=>n+r,0);return t.length?i/t.length:null}dumpEvaluations(){const t=this.measures.filter(n=>!n.empty).map(n=>({measureIndex:n.measureIndex,...evaluateMeasure(n)})),i=t.map(n=>n.qualityScore).reduce((n,r)=>n+r,0);console.log("qualityScore:",i/t.length),console.table(t)}regulate(t={}){this.measures.forEach(e=>e.regulated||e.regulate(t))}cleanupRegulation(){this.measures.forEach(t=>t.voices=null)}rectifyTimeSignatures(t=new DummyLogger){const e=this.measures.map((n,r)=>({measure:n,index:r})).filter(({measure:n,index:r})=>!r||n.timeSignatureChanged).map(({index:n})=>n);e.map((n,r)=>this.measures.slice(n,rn.filter(r=>r.estimatedDuration>0)).filter(n=>n.length>=3||n.some(r=>r.doubtfulTimesig)).forEach(n=>{if(n[0].patched){const y=n[0].timeSignature,f=n.slice(1).filter(p=>!p.patched&&printFraction(p.timeSignature)!==printFraction(y));if(f.length){const p=f[0].timeSignature;f.forEach(m=>m.basics.forEach(T=>T.timeSignature=y)),t.info("[rectifyTimeSignatures] timesignator overwrote by patched head:",`${printFraction(p)} -> ${printFraction(y)}`,f.map(m=>m.measureIndex))}return}const r=n[0].timeSignature,a=Number.isInteger(Math.log2(r.denominator));let o=a?4:8;a&&(o=Math.max(o,n[0].timeSignature.denominator));const c=n.map(y=>Math.round(y.estimatedDuration*o/WHOLE_DURATION)),d=Object.entries(c.reduce((y,f)=>(y[f]=(y[f]||0)+1,y),{})).sort((y,f)=>f[1]-y[1]),l=d[0][1],h=d.filter(([y,f])=>f>l*.6).reduce((y,f)=>Number(f[0])>Number(y[0])?f:y);if(h[1]>1){let y=Number(h[0]);if(!a||r.denominator*y!==r.numerator*o){if(a&&o!==r.denominator){const m=y*r.denominator/o;Number.isInteger(m)&&(y=m,o=r.denominator)}const f=n.filter(m=>!m.patched),p=frac(y,o);f.forEach(m=>m.basics.forEach(T=>T.timeSignature=p)),t.info("[rectifyTimeSignatures] timesignator overwrote by estimation:",`${printFraction(r)} -> ${y}/${o}`,f.map(m=>m.measureIndex))}}})}makeVoiceStaves(){var d,l,u;this.regulate();const t=Math.max(...this.measures.map(h=>{var y;return h.voices.length?h.voices.length:(y=h.events)!=null&&y.some(f=>f==null?void 0:f.grace)?1:0}));if(!t||!Number.isFinite(t))return null;this.measures.filter(h=>h.patched).forEach(h=>{h.events.forEach(y=>{y.tied&&y.pitches.forEach(f=>f.tied=!0)})});for(let h=0;hv.staff===p))||[]).reduce((v,S)=>Math.max(v,S.x||0),-1/0);if(!Number.isFinite(x))continue;const g=[];y.contexts[p]=m.filter(v=>v.type===0&&v.x>x?(g.push(v),!1):!0),g.length>0&&f.contexts[p]&&(g.forEach(v=>v.tick=0),f.contexts[p]=[...g,...f.contexts[p]])}}const e=this.measures.map(h=>{var x,g;console.assert(h.validRegulated,"[makeVoiceStaves] measure is invalid:",h);const y={};h.events.forEach(v=>y[v.id]=v);const f=new Set(Array(h.contexts.length).fill(null).map((v,S)=>S));let p=null;if(h.barType)switch(h.barType){case"Segment":p="||";break;case"Terminal":p="|.";break}const T=(h.voices.length?h.voices:(x=h.events)!=null&&x.some(v=>v==null?void 0:v.grace)?[h.events.filter(v=>v==null?void 0:v.grace).map(v=>v.id)]:[]).map(v=>{var C;const S=v.map(A=>y[A]);S.sort((A,N)=>A.tick-N.tick);const E={},k=A=>{let N=`t${A.tick}`,F=1;for(;E[N];)N=`t${A.tick}:${F++}`;E[N]=A},O=S.find(A=>A&&!A.zeroHolder&&!A.grace),M=S.filter(A=>(A==null?void 0:A.grace)&&(!O||A.xA.id);if(M.length&&(!O||O.tick!==0)){const A=EventTerm.space({tick:0,duration:0});A.staff=((C=S.find(N=>(N==null?void 0:N.grace)&&N.tick===0))==null?void 0:C.staff)??0,A.graceIds=M,A.placeholder=!0,k(A),M.forEach(N=>{const F=h.eventMap[N];F&&k(F)})}let b=0,_=null;for(const A of S){if(!Number.isFinite(A==null?void 0:A.tick)){console.warn("invalid event tick:",A);continue}M.includes(A.id)||(A.tick>b?k(EventTerm.space({tick:b,duration:A.tick-b})):!A.grace&&A.tick{const F=h.eventMap[N];F&&k(F)})))}h.endEvent&&h.endEvent.graceIds&&h.endEvent.graceIds.forEach(A=>{const N=h.eventMap[A];N&&(!_||N.staff===_.staff)&&k(N)}),_&&bh.duration&&Number.isFinite(h.duration)&&(_.timeWarp=reducedFraction(h.duration-_.tick,_.duration)),console.assert(!_||!_.timeWarp||Number.isInteger(_.timeWarp.numerator)&&Number.isInteger(_.timeWarp.denominator),"invalid time warp:",_);const R=S[0]?S[0].staff:0;f.delete(R);const I=h.basics[R],D=h.contexts[R],w=S[S.length-1],B=w?w.staff:0;return{tickMap:E,duration:h.duration,...I,contextedTerms:D,marks:[],break:h.break,pageBreak:h.pageBreak,headStaff:R,tailStaff:B,bar:p}});for(;T.lengthM.headStaff!==v),O=emptyVoiceFromStaffMeasure({terms:E,duration:h.duration,...S,break:h.break,pageBreak:h.pageBreak},k);O.headStaff=v,O.tailStaff=v,T.push(O)}return(g=h.marks)!=null&&g.length&&(T[0].marks=h.marks),T});e.forEach(h=>h.forEach(y=>{const f=[];y.empty||(f.push(`s${y.headStaff}`),f.push(`s${y.tailStaff}`)),Object.values(y.tickMap).forEach(p=>{if(p instanceof EventTerm){if(f.push(`s${p.staff}`),p.stemDirection){const m=`st${p.staff}-${p.stemDirection}`;f.push(m,m)}p.grace?f.push(`gd${p.mainDuration}`):f.push(`d${p.mainDuration}`),p.rest?f.push("r-"+p.rest):p.pitches.forEach(m=>{f.push(`p1-${m.note}`),f.push(`p8-${Math.round(m.note/8)}`)})}}),y.trait=HashVector.fromWords(f)}));const i=this.staffGroups.flat(1).reduce((h,y)=>(h[y]=this.staffGroups.findIndex(f=>f.includes(y)),h),{}),n=Array(t).fill(null).map((h,y)=>({vector:HashVector.zero,index:y,weight:0,headStaff:null}));e.forEach((h,y)=>{n.sort((p,m)=>m.weight-p.weight);const f=new Set(h);n.forEach(p=>{const m=[...f];let T=m[0];if(y>0&&m.length>1){const x=m.map(g=>i[g.headStaff]===i[p.headStaff]?cosHashes(p.vector.toHash(),g.trait.toHash()):-1);T=m[argmax$1(x)]}f.delete(T),T.voiceIndex=p.index,p.vector.scale(.4).add(T.trait),p.weight=Object.keys(T.tickMap).length,y===0&&(p.headStaff=T.headStaff)}),h.sort((p,m)=>p.voiceIndex-m.voiceIndex)});const r=Array(this.stavesCount).fill(null).map(()=>[]);n.forEach(h=>{r[h.headStaff].push(h.index)});const a=Array(this.stavesCount).fill(null).map((h,y)=>e[0]?{voices:r[y].map(m=>({mode:"relative",measures:e.map(T=>T[m])}))}:{voices:[]}),o=(u=(l=this.measures.find(h=>!h.empty))==null?void 0:l.position)==null?void 0:u.systemIndex,c=Number.isFinite(o)?this.measures.findIndex(h=>{var y;return!h.empty&&((y=h.position)==null?void 0:y.systemIndex)!==o}):0;return removeEmptyMeasuresInVoicesStaves(a),moveFirstSystemTempoToHead(a,c<0?this.measures.length:c),filterSyntheticOctaveZeroContexts(a),a.forEach(h=>h.voices.forEach(markingTiesInVoice)),a}perform(){const t=this.makeVoiceStaves();if(!t)return null;const e=new Map,i=Array(this.stavesCount).fill(null).reduce((l,u,h)=>(l[h]=h,l),{}),n=[].concat(...t.map((l,u)=>l.voices.map(()=>i[u])));let r=!1,a=0,o=null;const c=this.measures.filter(l=>!l.empty).map(l=>{const{systemIndex:u,right:h}=l.position,y=l.measureIndex,f=[].concat(...t.map(v=>v.voices.map(S=>S.measures[y]))),p=f[0],m=a;a+=p.duration;const T=[].concat(...f.map((v,S)=>{const k=n[S],O=Object.values(v.tickMap).filter(M=>M instanceof EventTerm&&!M.rest).map(M=>{const b=Math.round(M.duration*1);console.assert(Number.isFinite(M.tick),"invalid event term tick:",M),console.assert(Number.isFinite(b),"invalid event term duration:",M),M.tick>=0&&M.noteIds.forEach(R=>{e.set(R,{system:u,measure:y,x:M.roundX,endX:h})});const _=this.staffGroups.findIndex(R=>R.includes(M.staff));return{tick:Math.round(M.tick*1),duration:b,pitches:M.pitches,noteIds:M.noteIds,part:_,staff:M.staff}});return[].concat(...O.map(M=>{const b=M.pitches.reduce((R,I)=>(R[noteToPitch(I)]=I,R),{});return Object.values(b).sort((R,I)=>R.note-I.note).filter(R=>!R.tied).map((R,I)=>{const D=noteToPitch(R),w=M.noteIds&&M.noteIds[I];return{tick:M.tick,pitch:D,duration:M.duration,chordPosition:{index:I,count:M.pitches.length},tied:R.tied,id:w,ids:[w],track:M.part,staff:M.staff,channel:k,subNotes:[{startTick:0,endTick:M.duration,pitch:D,velocity:127}]}})}))})),x=[];o=o||x,l.marks&&l.marks.forEach(v=>{if(v instanceof TempoTerm){const S=v.bpm;if(v.isValid()){const E=r?x:o,k=r?v.tick:0;E.push({track:0,ticks:k,data:{type:"meta",subtype:"setTempo",microsecondsPerBeat:Math.round(6e7/S)}}),r=!0}}});const g=l.basics[0];return{tick:m,duration:l.duration,notes:T,events:x,timeSignature:g&&g.timeSignature,keySignature:g&&g.keySignature}});return r||c[0].events.push({track:0,ticks:0,data:{type:"meta",subtype:"setTempo",microsecondsPerBeat:5e5}}),{notation:new MetaNotation({measures:c}),tokenMap:e}}performByEstimation(){const t=new Map;let e=0;const i=this.measures.filter(r=>r.events.some(a=>a.predisposition)).map(r=>{const a=e,o=Math.round(r.estimatedDuration||fractionMul(WHOLE_DURATION,r.timeSignature)),c=r.basics[0];e+=o;const{systemIndex:d,right:l}=r.position,u=r.measureIndex,y=r.events.filter(f=>f.predisposition&&f.predisposition.fake<.5&&!f.rest).map(f=>{const p=Math.round(f.predisposition.tick);return f.noteIds.forEach(m=>{t.set(m,{system:d,measure:u,x:f.roundX,endX:l})}),f.pitches.map((m,T)=>{const x=noteToPitch(m),g=f.noteIds&&f.noteIds[T],v=this.staffGroups.findIndex(S=>S.includes(f.staff));return{tick:p,pitch:x,duration:f.duration,chordPosition:{index:T,count:f.pitches.length},tied:m.tied,id:g,ids:[g],track:v,staff:f.staff,channel:0,subNotes:[{startTick:0,endTick:f.duration,pitch:x,velocity:127}]}})}).flat(1);return{tick:a,duration:o,notes:y,events:[],timeSignature:c&&c.timeSignature,keySignature:c&&c.keySignature}});return{notation:new MetaNotation({measures:i}),tokenMap:t}}featureHash(){const e=this.measures.slice(0,16).map(n=>n.featureWords),i=[1,4,16].map(n=>{const r=e.slice(0,n).filter(Boolean),a=r.map(h=>h[0]).flat(1),o=r.map(h=>h[1]).flat(1),c=r.map(h=>h[2]).flat(1),[d,l,u]=[a,o,c].map(HashVector.fromWords);return HashVector.concat(d,l.sub(128),u.sub(128))});return HashVector.concat(...i).toHash()}featureHashHex(){return hashToHex(this.featureHash())}featureHashBigInt(){return hashToBigInt(this.featureHash())}assignMeasureNumbers(){let t=null;for(const e of this.measures)!e.discard&&!e.events.length||(e.indent&&(t=null),Number.isFinite(t)||(t=e.partialDuration?0:1),e.measureNumber=t++)}}const GROUP_N_TO_PITCH=[0,2,4,5,7,9,11],MIDDLE_C=60,mod7=s=>{let t=s%7;for(;t<0;)t+=7;return t},mod12=s=>{let t=s%12;for(;t<0;)t+=12;return t},PHONETS="CDEFGAB",ALTER_NAMES={[-2]:"♭♭",[-1]:"♭",0:"♮",1:"♯",2:"𝄪"};class StaffContext{logger=new DummyLogger;clef=-3;keyAlters=[];octaveShift=0;alters=[];timeSignature={numerator:4,denominator:4};timeSigNumeric=!1;timeSigNumSet=!1;timeSigDenSet=!1;doubtingTimesig=!0;change(t){switch(t.type){case ContextType.Clef:this.clef=t.clef;break;case ContextType.KeyAcc:this.keyAlters[mod7(this.yToNote(t.y))]=t.alter;break;case ContextType.Acc:this.alters[this.yToNote(t.y)]=t.alter;break;case ContextType.OctaveShift:this.octaveShift=t.octaveShift;break;case ContextType.TimeSignatureC:switch(this.timeSigNumeric=!1,t.tokenType){case"timesig-C44":this.timeSignature.numerator=4,this.timeSignature.denominator=4;break;case"timesig-C22":this.timeSignature.numerator=2,this.timeSignature.denominator=2;break}this.doubtingTimesig=this.partialTimeSignature;break;case ContextType.TimeSignatureN:switch(this.timeSigNumeric=!0,t.y){case 1:this.timeSigDenSet?this.timeSignature.denominator=this.timeSignature.denominator*10+t.number:this.timeSignature.denominator=t.number,this.timeSigDenSet=!0;break;case-1:this.timeSigNumSet?this.timeSignature.numerator=this.timeSignature.numerator*10+t.number:this.timeSignature.numerator=t.number,this.timeSigNumSet=!0;break;default:this.logger.warn("unexpected time signature Y:",t.y)}this.doubtingTimesig=this.partialTimeSignature;break}}resetMeasure(){this.alters=[],this.timeSigNumSet=!1,this.timeSigDenSet=!1}resetSystem(){this.keyAlters=[]}get keySignature(){return this.keyAlters.filter(t=>Number.isInteger(t)).reduce((t,e)=>t+e,0)}get partialTimeSignature(){return!this.timeSigNumSet!=!this.timeSigDenSet}noteToY(t){return-t/2-this.clef-this.octaveShift*3.5}pitchToNote(t,{preferredAlter:e=null}={}){e||(e=this.keySignature<0?-1:1);const i=Math.floor((t-MIDDLE_C)/12),n=mod12(t),r=GROUP_N_TO_PITCH.includes(n)?n:mod12(n-e),a=GROUP_N_TO_PITCH.indexOf(r);this.logger.assert(a>=0,"invalid preferredAlter:",t,e,r);const o=i*7+a,c=n-r,d=this.keyAlters[a]||0,u=Number.isInteger(this.alters[o])?c:c===d?null:c;return{note:o,alter:u}}pitchToY(t,{preferredAlter:e=null}={}){const{note:i,alter:n}=this.pitchToNote(t,{preferredAlter:e});return{y:this.noteToY(i),alter:n}}yToNote(t){return this.logger.assert(Number.isInteger(t*2),"invalid y:",t),(-t-this.octaveShift*3.5-this.clef)*2}alterOnNote(t){if(Number.isInteger(this.alters[t]))return this.alters[t];const e=mod7(t);return Number.isInteger(this.keyAlters[e])?this.keyAlters[e]:0}noteToPitch(t){const e=Math.floor(t/7),i=mod7(t),n=MIDDLE_C+e*12+GROUP_N_TO_PITCH[i]+this.alterOnNote(t);return Number.isFinite(n)?n:(this.logger.warn("invalid pitch value:",n,t,e,i),-1)}yToPitch(t){return this.noteToPitch(this.yToNote(t))}yToPitchName(t){const e=this.yToNote(t),i=Math.floor(e/7),n=mod7(e);let r=this.alterOnNote(e);return!r&&!Number.isInteger(this.alters[e])&&(r=null),`${ALTER_NAMES[r]?ALTER_NAMES[r]:""}${PHONETS[n]}${i+4}`}}const VERSION=14,GRAND_STAFF_LAYOUT="{-}",processStaffContext=(s,t=new DummyLogger)=>{const e=new StaffContext;e.logger=t;for(const i of s.rows){for(const n of i){const r=n.terms.find(o=>o instanceof EventTerm);let a=r?Math.min(r.tick,0):0;n.terms.forEach(o=>{if(o instanceof ContextedTerm)o.tick=a,e.change(o);else if(o instanceof EventTerm){const c=o.tick+(o.duration||0);c>a&&(a=c),o.ys&&(o.pitches=o.ys.map(d=>{const l=e.yToNote(d),u=e.alterOnNote(l);return{note:l,alter:u,octaveShift:e.octaveShift}}))}}),n.timeSignature={...e.timeSignature},n.timeSigNumeric=e.timeSigNumeric,n.doubtfulTimesig=e.doubtingTimesig||!Number.isInteger(Math.log2(n.timeSignature.denominator))||n.timeSignature.numerator<=n.timeSignature.denominator/4,n.keySignature=e.keySignature,n.duration===0&&(n.duration=WHOLE_DURATION*n.timeSignature.numerator/n.timeSignature.denominator),e.resetMeasure()}e.resetSystem()}},upgradeScoreData=s=>{if(s.version<3){const{version:t,stavesCount:e,layoutTemplate:i,...n}=s;let r=e>1?Array(e-1).fill(",").join(""):"";e===2&&(r="{-}"),s={version:3,staffLayoutCode:r,...n}}return s.version<8&&(s.pages.forEach(t=>{t.systems.forEach(e=>{if(e.semantics){const i=e.semantics.filter(n=>n.semantic===SemanticType.vline_BarMeasure);e.semantics=[].concat(...e.staves.map(n=>{const r=n.top+n.staffY;return i.map(a=>({...a,y:a.y+r,extension:{...a.extension,y1:a.extension.y1+r,y2:a.extension.y2+r}}))}))}})}),s.version=8),s.version<9&&(s.spartito=null,s.version=9),s},bitsToMask=s=>s.reduce((t,e,i)=>e?t|1<t.systems))}get measureCount(){return this.systems.reduce((t,e)=>t+(e.measureCount||0),0)}get imageKeys(){return[...this.pages.map(t=>{var e;return(e=t.source)==null?void 0:e.url}),...this.systems.map(t=>t.backgroundImage),...[].concat(...this.systems.map(t=>[...t.staves.map(e=>e.backgroundImage),...t.staves.map(e=>e.maskImage)].filter(Boolean)))].filter(Boolean)}get breakSystemIndices(){const t=[];let e=0;return this.pages.forEach((i,n)=>{nt.staves.length),0)}get sidBlackList(){const t=[].concat(...this.systems.map(e=>e.sidBlackList));return new Set(t)}get sidWhiteList(){const t=[].concat(...this.systems.map(e=>e.sidWhiteList));return new Set(t)}get semanticHash(){const t=[].concat(...this.systems.map(e=>[].concat(...e.staves.map(i=>i.semantics?e.qualifiedSemantics(i.semantics).map(n=>n.id):[]))));return sha1(t.join(""))}eventSystemsToTermStaves(t,e=new DummyLogger){const i=Array(this.maxStavesCount).fill(null).map((n,r)=>({rows:t.map((a,o)=>a.columns.map((c,d)=>{const l=c.rows[r];console.assert(l,"[eventSystemsToTermStaves] measure is null:",r,c.rows);const u=l.contexts;d===0&&(u.some(f=>f.type===ContextType.OctaveShift)||u.unshift(new ContextedTerm({staff:r,x:0,y:0,tokenType:TokenType.OctaveShift0,tick:0})));const h=[...l.events||[],...u].sort((f,p)=>f.x-p.x),y=r===0&&d===a.columns.length-1&&this.breakSystemIndices.includes(o);return{terms:h,duration:c.duration,pageBreak:y}}))}));return i.forEach(n=>processStaffContext(n,e)),i}resetPageLayout(t){const{unitSize:e=this.unitSize,pageSize:i=this.pageSize}=t,n={x:i.width*.5/e,y:i.height*.5/e};this.pages.forEach(r=>{const a=n.x-r.width/2,o=n.y-r.height/2;r.systems.forEach(c=>{c.left+=a,c.top+=o}),r.semantics&&r.semantics.forEach(c=>{c.x+=a,c.y+=o}),r.width=i.width/e,r.height=i.height/e,r.assemble({textAnnotations:this.textAnnotations})}),this.unitSize=e,this.pageSize=i}getMeasure(t){let e=t;for(const i of this.systems){if(eo&&o.measures[e]);return{measureIndex:t,system:i,localIndex:e,left:r.left,right:r.right,measures:a}}e-=i.measureCount}return null}getRawCluster(t,e,{timeSignature:i}={}){const n=this.getMeasure(t);if(!n)return null;const{system:r,left:a,right:o}=n,c=[BOS_ELEMENT];i&&c.push(...fractionToElems(i));const d=r.staves[0].top+r.staves[0].staffY-2;return r.staves.forEach(l=>{let u=r.qualifiedSemantics(l.semantics,e).filter(f=>f.x>a&&f.xf.semantic===SemanticType.TempoNotehead).forEach(f=>{const p=u.findIndex(m=>/^Notehead/.test(m.semantic)&&distance2D(f,m)<.3);p>=0&&u.splice(p,1)});const y=l.top+l.staffY-d;u.forEach(f=>{const p=SemanticElementType[f.semantic];if(p){let m=f.y,T=f.y;p===SemanticElementType.vline_Stem&&(m=f.extension.y1,T=f.extension.y2),c.push({id:f.id,type:p,staff:l.index,x:f.x-a,y1:m+y,y2:T+y})}})}),new SemanticCluster({index:t,elements:c})}getRawClusters(t=1){return Array(this.measureCount).fill(null).map((e,i)=>this.getRawCluster(i,t))}makeSpartito(t=new DummyLogger){let e=this.systems.map(c=>c.getEvents(this.maxStavesCount));const i=this.eventSystemsToTermStaves(e,t);e.forEach((c,d)=>{c.columns.forEach((l,u)=>{l.basics=i.map(h=>{const{timeSignature:y,timeSigNumeric:f,keySignature:p,doubtfulTimesig:m}=h.rows[d][u];return{timeSignature:y,timeSigNumeric:f,keySignature:p,doubtfulTimesig:m}})})});const n=null,r=[].concat(...e.map(c=>c.columns.map(d=>{const l=d.measureIndex,{system:u,localIndex:h,left:y,right:f}=this.getMeasure(l),p=n,m=[];u.staves.forEach(S=>m[S.index]=S.top+S.staffY);const T=this.patches&&this.patches.find(S=>S.measureIndex===l),x=T?T.events:SpartitoMeasure.reorderEvents([].concat(...d.rows.map(S=>S.events)),m),g=Object.fromEntries(Object.entries(d.barTypes).map(([S,E])=>[S,E/u.staves.length])),v=h===0&&u.indent;return new SpartitoMeasure({measureIndex:l,staffMask:c.staffMask,position:{systemIndex:u.index,localIndex:h,left:y,right:f,staffYs:u.staves.map(S=>S.top+S.staffY),staffYsFull:m},duration:T?T.duration:d.duration,events:x,contexts:d.rows.map(S=>S.contexts),marks:d.marks,break:d.break,pageBreak:d.pageBreak,voltaBegin:d.voltaBegin,voltaEnd:d.voltaEnd,alternative:d.alternative,barTypes:g,indent:v,basics:T?T.basics:d.basics,matrixH:p,matrixV:p,voices:T?T.voices:null,patched:!!T})}))),a=this.staffLayout,o=a.standaloneGroups.map(c=>c.map(d=>a.staffIds.indexOf(d)));return this.spartito=new Spartito({stavesCount:this.maxStavesCount,staffGroups:o,measures:r}),this.spartito}makeMusicSheet(){const t=this.spartito||this.makeSpartito();t.regulated||console.warn("[makeMusicSheet] spartito not regulated.");const e=t.makeVoiceStaves(),{lanes:i,diagnostics:n}=this.makeLyricLanes(e);i.length&&console.debug("[makeMusicSheet] lyric lanes:",i.length,n);const{title:r,pageSize:a,unitSize:o,staffLayout:c,paperOptions:d,headers:l,instrumentDict:u}=this,h=this.getMeasureLayout();return{title:r,pageSize:a,unitSize:o,measureLayout:h,staffLayout:c,paperOptions:d,headers:l,voiceStaves:e,instrumentDict:u,lyricLanes:i,lyricDiagnostics:n}}makeLyricLanes(t){const e={total:0,matched:0,unmatched:0,ambiguousVoice:0,duplicateEventAssignments:0,outOfOrderAssignments:0},i=this.spartito;if(!i||!i.measures||!i.measures.length||!t||!t.length)return{lanes:[],diagnostics:e};const n=[];this.pages.forEach((u,h)=>{(u.lyricTokens||[]).forEach(y=>{n.push({pageIndex:h,x:y.x,y:y.y,text:y.text,sid:y.id})})});const r={...e,total:n.length,unmatchedSids:[]};if(!n.length)return{lanes:[],diagnostics:r};const a=u=>Math.max(u*2,12),o=[];n.forEach(u=>{const h=this.pages[u.pageIndex];if(!h||!h.systems||!h.systems.length){r.unmatched++,u.sid&&r.unmatchedSids.push(u.sid);return}let y=null;for(const k of h.systems)k.top>u.y||u.xk.left+k.width||(!y||k.top>y.top)&&(y=k);if(!y){r.unmatched++,u.sid&&r.unmatchedSids.push(u.sid);return}const f=y.getStaffArray(this.maxStavesCount);let p=-1,m=-1/0,T=0;for(let k=0;km&&(m=M,p=k,T=O.height)}if(p<0||u.y-m>a(T)){r.unmatched++,u.sid&&r.unmatchedSids.push(u.sid);return}const x=u.x-y.left;let g=0;const v=y.measureBars||[];for(;g=y.measureCount&&(g=y.measureCount-1);const E=(y.headMeasureIndex||0)+g;o.push({...u,systemIndex:y.index,staffIndex:p,measureIndex:E,localIndex:g,systemX:x,voiceIndex:-1,verse:0})});const c=u=>!u||!(u instanceof EventTerm)||u.rest||u.grace||u.zeroHolder?!1:Number.isFinite(u.x);o.forEach(u=>{const h=i.measures[u.measureIndex];if(!h||!h.events){r.unmatched++,u.sid&&r.unmatchedSids.push(u.sid);return}const y=h.events.filter(m=>c(m)&&m.staff===u.staffIndex);if(!y.length){r.unmatched++,u.sid&&r.unmatchedSids.push(u.sid);return}let f=null,p=1/0;for(const m of y){const T=Math.abs(m.x-u.systemX);T{var m,T;if(!u.event)return;const h=t[u.staffIndex];if(!h||!h.voices||!h.voices.length){r.unmatched++,u.sid&&r.unmatchedSids.push(u.sid);return}if(!((T=(m=h.voices[0])==null?void 0:m.measures)==null?void 0:T[u.measureIndex])){r.unmatched++,u.sid&&r.unmatchedSids.push(u.sid);return}let f=-1,p=!1;h.voices.forEach((x,g)=>{var E;const v=(E=x.measures)==null?void 0:E[u.measureIndex];if(!v||!v.tickMap)return;Object.values(v.tickMap).find(k=>k===u.event||k&&k.id!=null&&u.event.id!=null&&k.id===u.event.id)&&(f>=0&&f!==g&&(p=!0),f<0&&(f=g))}),p&&r.ambiguousVoice++,f<0&&(f=0),u.voiceIndex=f,r.matched++});const d=new Map;o.forEach(u=>{if(!u.event)return;const h=d.get(u.staffIndex)||[];h.push(u),d.set(u.staffIndex,h)});const l=[];d.forEach((u,h)=>{const y=new Map;u.forEach(m=>{const T=y.get(m.systemIndex)||[];T.push(m),y.set(m.systemIndex,T)});let f=1;const p=new Map;y.forEach((m,T)=>{m.sort((k,O)=>k.y-O.y);const x=m.map(k=>k.y),g=x.length>1?Math.max(...x)-Math.min(...x):2,v=Math.max(g/4,1.5),S=[];m.forEach(k=>{const O=S.find(M=>Math.abs(M.y-k.y)<=v);O?O.members.push(k):S.push({y:k.y,members:[k]})}),S.sort((k,O)=>k.y-O.y);const E=new Map;S.forEach((k,O)=>k.members.forEach(M=>E.set(u.indexOf(M),O))),p.set(T,E),S.length>f&&(f=S.length)});for(let m=0;m{const v=p.get(x.systemIndex);(v?v.get(g)??0:0)===m&&T.push({text:x.text,sid:x.sid,measureIndex:x.measureIndex,tick:x.event.tick,staffIndex:x.staffIndex,voiceIndex:x.voiceIndex,eventId:x.event.id,verse:m,source:{pageIndex:x.pageIndex,systemIndex:x.systemIndex,x:x.x,y:x.y}})}),T.length&&(T.sort((x,g)=>x.measureIndex-g.measureIndex||x.tick-g.tick),l.push({staffIndex:h,voiceIndex:u[0].voiceIndex,verse:m,syllables:T}))}});for(const u of l){const h=new Set;let y=-1/0,f=-1;for(const p of u.syllables){const m=`${p.staffIndex}:${p.voiceIndex}:${p.measureIndex}:${p.tick}`;h.has(m)&&r.duplicateEventAssignments++,h.add(m),(p.measureIndexr.id===t);if(n){const r=this.pages.findIndex(a=>a.systems.includes(e));return{point:n,pageIndex:r,systemIndex:e.index,staffIndex:i}}}return null}getMeasureSemantics(t,e){const i=this.systems[t];if(!i)return null;const n=e?i.measureBars[e-1]:0,r=i.measureBars[e]||i.width;return i.staves.map((a,o)=>{const c=a.top+a.staffY;return a.semantics.filter(d=>d.x>=n&&d.x{var h;const[l,u]=Number.isFinite((h=d.extension)==null?void 0:h.y1)?[d.extension.y1,d.extension.y2]:[d.y,d.y];return{...d,staff:o,sy1:l+c,sy2:u+c}})}).flat(1)}makeTimewiseGraph({store:t=!1}={}){return this.spartito?{measures:this.spartito.measures.filter(i=>i.events.length>0).map(i=>{const n=this.getMeasureSemantics(i.position.systemIndex,i.position.localIndex),r={measureIndex:i.measureIndex,left:i.position.left,right:i.position.right,points:n};return t&&(i.graph=r),r})}:null}getTokenMap(){const t=new Map;return this.systems.forEach(e=>e.staves.forEach(i=>i.measures.forEach(n=>n.tokens.forEach(r=>t.set(r.id,r))))),t}assemble(t=1,e=new DummyLogger){const i=new Map,n=(a,o,c)=>{const d=hashSemanticPoint(a,o,c);e.assert(!i.has(d),"semantic point hash conflicted:",d,c,i.get(d)),i.set(d,c)};this.pages.forEach((a,o)=>a.index=o);let r=0;this.systems.forEach((a,o)=>{a.index=o,a.headMeasureIndex=r,a.prev=this.systems[o-1]||null,a.next=this.systems[o+1]||null,a.semantics&&a.semantics.length&&a.semantics.forEach(c=>n(o,null,c)),a.assemble(t,e),r+=a.measureCount}),this.pages.forEach((a,o)=>{a.systems.forEach(c=>c.pageIndex=o),a.assemble({textAnnotations:this.textAnnotations},e)})}assembleSystem(t,e=1){this.systems.forEach((n,r)=>n.index=r);const i=t.index;t.semantics&&t.semantics.length&&(t.semantics.forEach(n=>hashSemanticPoint(i,null,n)),t.assemble(e))}markVoices(t){const e=this.getTokenMap();for(const n of e.values())n.voice=0;const i=[].concat(...t.map((n,r)=>(n.voices||[]).map((a,o)=>[r,o]))).sort(([n,r],[a,o])=>r-o||n-a).map(([n,r])=>`${n}|${r}`);t.forEach((n,r)=>(n.voices||[]).forEach((a,o)=>a.measures.forEach(c=>{const d=i.indexOf(`${r}|${o}`);Object.values(c.tickMap).filter(u=>u instanceof EventTerm).forEach(u=>{const h=u.noteIds?u.noteIds.map(f=>e.get(f)).filter(Boolean):[],y=u.accessories?u.accessories.map(f=>e.get(f.id)).filter(Boolean):[];[...h,...y].forEach(f=>f.voice|=1<f.timeWarped=!0)})})))}async replaceImageKeys(t){await Promise.all([...this.pages.map(async e=>{e.source&&(e.source.url=await t(e.source.url))}),...this.systems.map(e=>Promise.all([t(e.backgroundImage).then(i=>e.backgroundImage=i),...e.staves.map(async i=>{i.backgroundImage=await t(i.backgroundImage),i.maskImage=await t(i.maskImage)})]))])}inferenceStaffLayout(){const t=Math.max(...this.systems.map(l=>l.staves.length),0);this.staffLayoutCode=Array(t).fill("").join(",");const e=this.systems.filter(l=>l.staves.length===t&&l.bracketsAppearance);if(!e.length)return;const i=e.map(l=>{try{return parseCode$1(l.bracketsAppearance).staffIds.length!==l.staves.length?null:l.bracketsAppearance}catch{return null}}).filter(Boolean);if(!i.length)return;const n=i.reduce((l,u)=>{const h=l[u]||0;return l[u]=h+1,l},{}),r=Math.max(...Object.values(n)),o=Object.entries(n).find(([l,u])=>u===r)[0].replace(/\{,*\}/g,l=>l.replace(/,/g,"-")),c=parseCode$1(o);this.staffLayoutCode=o;let d=null;for(const l of this.systems){if(d&&l.staves.length===d.staves.length&&l.bracketsAppearance===d.bracketsAppearance){l.staffMaskChanged=null;continue}if(l.staves.length{if(y.length>c.staffIds.length)return null;if(y.reduce((f,p)=>f+p,0)===l.staves.length)return bitsToMask(y);for(const f of[1,0]){const p=[...y,f],m=c.partialMaskCode(p);if(m===l.bracketsAppearance)return bitsToMask(p);if(l.bracketsAppearance.startsWith(m)){const T=u(p);if(T)return T}}return null},h=u([]);l.staffMaskChanged=!d||h!==d.staffMask?h:null}d=l}}assignBackgroundForMeasure(t){t.backgroundImages=[];const e=this.systems[t.position.systemIndex];e.backgroundImage&&t.backgroundImages.push({url:e.backgroundImage,position:e.imagePosition,original:!0}),e.staves.forEach(i=>{!e.backgroundImage&&i.backgroundImage&&t.backgroundImages.push({url:i.backgroundImage.toString(),position:{...i.imagePosition,y:i.imagePosition.y+i.top},original:!0}),i.maskImage&&t.backgroundImages.push({url:i.maskImage.toString(),position:{...i.imagePosition,y:i.imagePosition.y+i.top}})})}blackoutFakeNotes(t="patched"){if(!this.spartito)return;let e=a=>!0;switch(t){case"patched":e=a=>a.patched;break;case"perfect":e=a=>a.patched||a.regulated&&evaluateMeasure(a).perfect;break}const n=this.spartito.measures.filter(e).reduce((a,o)=>{if(!o.regulated)return;const c=o.voices.flat(1);return o.events.filter(l=>!l.rest&&!l.grace&&!c.includes(l.id)).forEach(l=>l.noteIds&&a.push(...l.noteIds)),a},[]),r=new Set(n);return this.systems.forEach(a=>a.staves.forEach(o=>{const c=o.semantics.filter(d=>r.has(d.id)).map(d=>d.id);a.sidBlackList.push(...c)})),n}getMeasureLayout(){const t=this.spartito&&this.spartito.measureLayoutCode;if(t)try{return parseCode(t)}catch(e){console.debug("invalid measure layout code:",e)}return null}*splitToSingleScoresGen(){this.assemble();const t=this.systems.filter(n=>n.index>0&&n.indent&&n.timeSignatureOnHead).map(n=>n.index);if(!t.length){yield this.deepCopy();return}const e=new Score({...this,pages:[],topology:void 0,spartito:void 0,patches:void 0});this.pages.forEach(n=>{delete n.tokens,n.systems.forEach(r=>{delete r.tokens,r.staves.forEach(a=>{a.measures=[]})})});let i=0;for(const n of[...t,this.systems.length]){const r=c=>c.index>=i&&c.indexc.systems.some(r)).map(c=>{const{systems:d,...l}=c;return new Page({...l,systems:d.filter(r).map(u=>new System({...u}))})}),o=e.deepCopy();o.headers.SubScoreSystem=`${i}-${n-1}`,o.headers.SubScorePage=`${a[0].index}-${a[a.length-1].index}`,o.pages=a,o.assemble(),o.inferenceStaffLayout(),i=n,yield o}}splitToSingleScores(){return[...this.splitToSingleScoresGen()]}}const DIVISION_NAMES=["whole","half","quarter","eighth","sixteenth","thirtysecond","sixtyfourth","128th","256th"],RESIDUE_LOSS_WEIGHT=.2,VOICEN_LOSS_WEIGHT=.002,SPACE_LOSS_WEIGHT=.4/WHOLE_DURATION,PRETENTIOUSNESS_LOSS_WEIGHT=.02,POSSIBILITY_LOW_BOUNDARY=1e-12,PRETENTIOUSNESS_CLIP=100,STEM_DIRECTION_OPTIONS=[void 0,"u","d"],BEAM_OPTIONS=[void 0,StemBeam.Open,StemBeam.Continue,StemBeam.Close],saveClusterState=s=>({elements:s.elements.map(t=>({tick:t.tick,division:t.division,dots:t.dots,beam:t.beam,stemDirection:t.stemDirection,grace:t.grace,timeWarped:t.timeWarped,fullMeasure:t.fullMeasure,fake:t.fake,order:t.order,predisposition:t.predisposition}))}),restoreClusterState=(s,t)=>s.elements.forEach((e,i)=>Object.assign(e,t.elements[i])),measurePretentious=s=>Math.min(PRETENTIOUSNESS_CLIP,-Math.log(s));class BeadNode{cluster;elemIndex;type;possibilities;pretentiousness;children;accessCount;constructor(t){Object.assign(this,t),this.children={},this.accessCount=0}nextBranch(){const t=this.possibilities.map((e,i)=>e/(this.children[i]?this.children[i].accessCount+1:1));return t.every(e=>!e)?(this.accessCount=1/0,null):argmax$1(t)}get currentElem(){return this.cluster.elements[this.elemIndex]}branchID(t){switch(this.type){case"i":return`i_${t}`;case"d":return DIVISION_NAMES[t];case"o":return"o"+".".repeat(t)}return""}async deduce({picker:t,logger:e,ptFactor:i},n=0){++this.accessCount;const r=this.nextBranch();if(e.debug(String.fromCodePoint(127817)+" ".repeat(n),this.branchID(r),this.accessCount>1?`[${this.accessCount}]`:""),!Number.isInteger(r)||r<0)return this.accessCount=1/0,evaluateCluster(this.cluster,this.currentElem.order+1,this.pretentiousness);if(this.pretentiousness+=measurePretentious(this.possibilities[r]),this.pretentiousness>PRETENTIOUSNESS_CLIP*i)return this.accessCount=1/0,evaluateCluster(this.cluster,this.currentElem.order+1,this.pretentiousness);let a=null;switch(this.type){case"i":{const c=this.currentElem.order+1,d=this.cluster.elements[r];if(console.assert(d,"null element:",r,this.cluster.elements.length),d.type===EventElementType.EOS){if(a=evaluateCluster(this.cluster,c,this.pretentiousness),!a.residue||a.fatalError)return this.accessCount=1/0,a;if(this.cluster.elements[0].order=c,!this.children[r]){if(!t.quota)return a;const l=(await t.predictCluster(this.cluster,c+1)).map((u,h)=>this.cluster.elements[h].orderMath.max(POSSIBILITY_LOW_BOUNDARY,u));this.children[r]=new BeadNode({cluster:this.cluster,elemIndex:r,type:"d",possibilities:l,pretentiousness:this.pretentiousness})}}break;case"d":if(this.currentElem.division=r,!this.children[r]){const c=this.currentElem.predisposition.dotsVector.map(d=>Math.max(POSSIBILITY_LOW_BOUNDARY,d));this.children[r]=new BeadNode({cluster:this.cluster,elemIndex:this.elemIndex,type:"o",possibilities:c,pretentiousness:this.pretentiousness})}break;case"o":{if(this.currentElem.dots=r,a=evaluateCluster(this.cluster,this.currentElem.order+1,this.pretentiousness),!a.residue||a.fatalError)return this.accessCount=1/0,a;if(!this.children[r]){if(!t.quota)return a;const c=this.currentElem.order+1,d=(await t.predictCluster(this.cluster,c)).map((l,u)=>this.cluster.elements[u].order{d.order>c&&(d.order=void 0)}),this.cluster.elements.forEach(d=>d.order=d.order>this.currentElem.order?void 0:d.order),this.cluster.elements[this.cluster.elements.length-1].tick=a.endTick,a}return o}}const estimateElementDuration=s=>WHOLE_DURATION*2**-s.division*(2-2**-s.dots),evaluateCluster=(s,t,e)=>{const i=s.elements.filter(k=>[EventElementType.CHORD,EventElementType.REST].includes(k.type)&&Number.isInteger(k.order)&&k.orderk.order-O.order);const n=s.elements[s.elements.length-1];let r=0,a=0,o=0,c=1;const d=[[n.x,s.signatureDuration,s.signatureDuration]];let l=0;i.forEach(k=>{k.order>a+1&&(r=0,++c);const O=d.find(_=>_[1]>=r);if(O&&k.x>O[0]+3){const _=d.reduce((R,I)=>Math.abs(k.predisposition.tick-I[2])_[0]>k.x));d.splice(M,0,[k.x,k.tick,k.predisposition.tick]);let b=estimateElementDuration(k);k.predisposition.timeWarped>.5&&(b=b*2/3),r+=b,l+=b,o=Math.max(o,r),a=k.order}),o>0&&(s.elements[s.elements.length-1].tick=o);const u=s.elements[s.elements.length-1].pivotX-s.elements[1].pivotX,h=Math.max(...i.map(k=>k.tick),o),y=[...i].sort((k,O)=>k.pivotX-O.pivotX),f=y.slice(1).map((k,O)=>{const M=y[O],b=k.pivotX-M.pivotX,_=k.tick-M.tick;return _?(Math.atan2(_/h,b/u)*4/Math.PI-1)**2:b/u}),p=Math.max(...f,0),m=i.map(k=>(k.tick-k.predisposition.tick)**2),T=m.length?Math.sqrt(m.reduce((k,O)=>k+O,0)/m.length):0,g=s.elements.filter(k=>[EventElementType.CHORD,EventElementType.REST].includes(k.type)&&!(Number.isInteger(k.order)&&k.order.5)).length,v=p>=1||o>s.signatureDuration,S=Math.max(0,s.signatureDuration-l/c),E=T/WHOLE_DURATION+p+g*RESIDUE_LOSS_WEIGHT+c*VOICEN_LOSS_WEIGHT+S*SPACE_LOSS_WEIGHT+e*PRETENTIOUSNESS_LOSS_WEIGHT;return{tickErr:T,twist:p,residue:g,endTick:o,fatalError:v,voiceN:c,spaceDuration:S,pretentiousness:e,loss:E}},solveCluster=async(s,t,e,i=200,n=0,r=1)=>{s.elements.forEach((f,p)=>f.order=p?void 0:0);const a=await t.predictCluster(s,1),o=new BeadNode({cluster:s,elemIndex:0,pretentiousness:0,type:"i",possibilities:a});let c=null,d=null;for(t.quota=i;t.quota;){s.elements.forEach((p,m)=>p.order=m?void 0:0);const f=await o.deduce({picker:t,logger:e,ptFactor:r});if(e.debug("loss:",f),(!c||f.loss[EventElementType.CHORD,EventElementType.REST].includes(f.type)&&Number.isInteger(f.order)),u=s.elements.filter(f=>[EventElementType.CHORD,EventElementType.REST].includes(f.type)&&!Number.isInteger(f.order));l.length&&u.forEach(f=>{if(f.tick=void 0,f.predisposition.fakeP<.5){const p=estimateElementDuration(f),m=l.filter(T=>T.tick+p<=c.endTick);if(m.length){const T=m.reduce((x,g)=>Math.abs(g.x-f.x)f.order-p.order),[...l,...u].forEach(f=>{f.grace=!Number.isFinite(f.tick)&&f.predisposition.grace,f.timeWarped=f.predisposition.timeWarped>.5,f.fullMeasure=f.predisposition.fullMeasure>.5,f.stemDirection=STEM_DIRECTION_OPTIONS[argmax$1(f.predisposition.stemDirectionVector)],f.beam=BEAM_OPTIONS[argmax$1(f.predisposition.beamVector)]});const h=s.elements.map(f=>f.index),y=f=>h.indexOf(f);return s.matrixH=s.elements.map(()=>Array(s.elements.length).fill(0)),l.forEach((f,p)=>{const m=l[p-1];!m||m.order{const{stopLoss:e=.09,quotaMax:i=1e3,quotaFactor:n=5,ptFactor:r=1,logger:a=new DummyLogger}=t;let o=0;const c=s.createClusters();for(const y of c){const f=Math.min(i,Math.ceil(y.elements.length*n));a.info(`[measure-${s.measureIndex}]`,f);const{loss:p}=await solveCluster(y,t.picker,a,f,e,r);o=Math.max(o,p)}const d=[],l=[],u=[];c.forEach(y=>{const f=y.elements.filter(E=>[EventElementType.CHORD,EventElementType.REST].includes(E.type)&&Number.isInteger(E.order));if(f.sort((E,k)=>E.order-k.order),!f.length)return;let p=[];d.push(p);let m=0;f.forEach(E=>{E.fullMeasure||E.grace||E.tremoloCatcher||(E.order>m+1?(p=[E.index],d.push(p)):p.push(E.index),m=E.order)});let T=f[f.length-1];const x=y.elements.filter(E=>[EventElementType.CHORD,EventElementType.REST].includes(E.type)&&Number.isFinite(E.tick)&&!Number.isInteger(E.order));for(;x.length;){const E=x.findIndex(k=>k.tick>=T.tick+estimateElementDuration(T));E>=0?p.push(x.splice(E,1)[0].index):(T=x.splice(0,1)[0],p=[T.index],d.push(p))}if(f.some(E=>!E.fullMeasure&&Number.isInteger(E.order))){const E=y.elements.find(k=>k.type===EventElementType.EOS);l.push(E.tick)}const g=s.eventMap,v=y.elements.reduce((E,k)=>(Number.isFinite(k.tick)&&E.add(k.tick),E),new Set),S=Array.from(v).sort((E,k)=>E-k);f.forEach(E=>{const k=g[E.index];k&&u.push({id:k.id,tick:E.tick,tickGroup:S.indexOf(E.tick),division:E.division!==k.division?E.division:void 0,dots:E.dots!==k.dots?E.dots:void 0,timeWarp:E.timeWarped?frac(2,3):void 0,beam:E.beam!==k.beam?E.beam:void 0,grace:E.grace!==!!k.grace?E.grace:void 0,fullMeasure:E.fullMeasure||void 0})})});const h=Math.max(...c.map(y=>y.estimatedDuration));return{voices:d.filter(y=>y.length),duration:Math.max(...l),events:u,priority:-o,estimatedDuration:h}},glimpseMeasure=async(s,{picker:t,resetSignatureForDoubtfulOnly:e})=>{const i=s.createClusters(),n=s.eventMap;for(const r of i)(!e||s.doubtfulTimesig)&&(r.signatureDuration=0),r.elements.forEach((a,o)=>a.order=o?void 0:0),await t.predictCluster(r,1),r.elements.filter(a=>[EventElementType.CHORD,EventElementType.REST].includes(a.type)).forEach(a=>{const o=n[a.index];o.predisposition=a.predisposition});s.estimatedDuration=Math.max(...i.map(r=>r.estimatedDuration))},estimateMeasure=async(s,t)=>glimpseMeasure(s,{picker:t,resetSignatureForDoubtfulOnly:!0}),beadSolver=Object.freeze(Object.defineProperty({__proto__:null,estimateMeasure,glimpseMeasure,solveCluster,solveMeasure},Symbol.toStringTag,{value:"Module"})),starry=Object.freeze(Object.defineProperty({__proto__:null,AccessoryDirection,ArpeggioStyle,BOS_ELEMENT,CONFLICTION_GROUPS,ChordmodeTerm,CommandTerm,ContextType,ContextedTerm,ELEMENT_TOKEN_NAMES,EditableEvent,EditableMeasure,EventCluster,EventClusterSet,EventElementType,EventTerm,GlissandoStyle,GlyphTerm,GraceType,LyricTerm,MarkTerm,Measure,NOTEHEAD_ELEMENT_TYPES,NOTEHEAD_WIDTHS,NOTE_ELEMENT_TYPES,ONE_D_SEMANTICS,Page,PageLayoutMethod,PatchMeasure,STAMP_RECTS,STAMP_SEMANTICS,SYSTEM_SEMANTIC_TYPES,Score,SemanticCluster,SemanticClusterSet,SemanticElementType,SemanticGraph,SemanticType,SimpleClass,Spartito,SpartitoMeasure,Staff,StemBeam,System,TOKEN_Y_FIXED,TOKEN_Y_ROUND,TempoTerm,Term,TextTerm,TextToken,TextType,Token,TokenAccessories,TokenAccidentals,TokenArcs,TokenBareNoteheads,TokenBeams,TokenClefs,TokenDirectionalNoteheads,TokenDirectionless,TokenDots,TokenDynamics,TokenFlags,TokenGlyphs,TokenNoteheads,TokenNumbers,TokenOctshifts,TokenPedals,TokenRests,TokenScripts,TokenTimesigs,TokenTimesigsC,TokenTimesigsN,TokenType,TokenTypes,TokenVolta,TokenWedges,TremoloLink,VERSION,WHOLE_DURATION,beadSolver,emptyVoiceFromStaffMeasure,evaluateMeasure,expandMatrixByMaskTriu,expandMatrixByMasks,fractionToElems,glyphCenters,glyphSemanticMapping,hashPageSemanticPoint,hashSemanticPoint,matrixFromGroups,mod7,recoverJSON,semanticPriorities},Symbol.toStringTag,{value:"Module"}));export{AccessoryDirection as A,EditableMeasure as B,ContextedTerm as C,SpartitoMeasure as D,EventTerm as E,EventElementType as F,GlyphTerm as G,LayoutType as L,MetaNotation as M,PageLayoutMethod as P,SemanticType as S,TokenBareNoteheads as T,WHOLE_DURATION as W,TokenType as a,ContextType as b,TempoTerm as c,TremoloLink as d,TokenDynamics as e,reducedFraction as f,ChordmodeTerm as g,TextTerm as h,CommandTerm as i,LyricTerm as j,Staff as k,System as l,mod7$1 as m,STAMP_SEMANTICS as n,STAMP_RECTS as o,TokenGlyphs as p,Score as q,recoverJSON as r,starry as s,Page as t,EventClusterSet as u,SimpleClass as v,GROUP_N_TO_PITCH$1 as w,sha1 as x,MIDDLE_C$1 as y,evaluateMeasure as z}; +`)}get regulationHash(){return sha1(this.brief)}get regulationHash0(){return this.originalRegulationHash||this.regulationHash}get regulationHashes(){return Array.from(new Set([this.originalRegulationHash,this.regulationHash].filter(Boolean)))}get featureWords(){if(!this.regulated||!this.voices||!this.voices.length)return null;const t=this.tickRatesInStaves.some(c=>c<0),i=this.events.filter(c=>!c.zeroHolder&&!c.rest).map(c=>c.ys).flat(1).map(c=>`Y${-c*2}`),n=Array.from(new Set(i));this.keySignature&&n.push(`K${this.keySignature}`);const r=this.voices.map(c=>c.map(d=>this.events.find(l=>l.id===d)).filter(d=>!d.zeroHolder&&!d.rest)).filter(c=>c.length),a=t?[]:r.map(c=>c.map(d=>d.scaleChord).join("-")),o=t?[]:r.map(c=>c.map(d=>d.division).join(""));return this.timeSignature&&o.push(`T${this.timeSignature.numerator}/${this.timeSignature.denominator}`),[n,a,o]}get barType(){if(this.voltaEnd)return"VoltaRight";const t=Object.entries(this.barTypes).sort((e,i)=>i[1]-e[1]);return t[0]&&t[0][1]>=1?t[0][0]:null}get partialDuration(){if(!Number.isFinite(this.duration))return!1;const t=fractionMul(WHOLE_DURATION,this.timeSignature);return this.duration{const i=t[e.tick];Number.isFinite(i)&&(e.roundX=i)})}updateContextTick(){if(!this.staffGroups)return;const t=this.contexts.flat(1);this.staffGroups.flat(1).forEach(e=>{const i=[...this.events.filter(r=>r.staff===e),...t.filter(r=>r.staff===e)];i.sort((r,a)=>a.x-r.x);let n=this.duration;i.forEach(r=>{r instanceof EventTerm?!r.fullMeasureRest&&!r.zeroHolder&&(n=r.tick):r instanceof ContextedTerm&&(r.tick=n)})})}asSolution(t=void 0){var e;return this.regulated?{events:this.events.map(i=>{const n={id:i.id,tick:i.tick,tickGroup:i.tickGroup,timeWarp:i.timeWarp};if(t){const r=t.events.find(a=>a.id===i.id);r&&(i.division!==r.division&&(n.division=i.division),i.dots!==r.dots&&(n.dots=i.dots),i.grace!==r.grace&&(n.grace=!!i.grace),i.beam!==r.beam&&(n.beam=i.beam),i.fullMeasureRest!==r.fullMeasureRest&&(n.fullMeasure=i.fullMeasureRest))}return n}),voices:this.voices,duration:this.duration,priority:-((e=this.solutionStat)==null?void 0:e.loss)}:null}applySolution(t){t.timeSignature&&this.basics.forEach(e=>{e.timeSignature=t.timeSignature,e.doubtfulTimesig=!1}),this.voices=t.voices,this.duration=t.duration,this.events.forEach(e=>{var n;e.timeWarp=null,e.tick=null,e.tickGroup=null;const i=(n=t.events)==null?void 0:n.find(r=>r.id===e.id);i&&(e.tick=i.tick,e.timeWarp=i.timeWarp,e.tickGroup=i.tickGroup,Number.isFinite(i.division)&&(e.division=i.division),Number.isFinite(i.dots)&&(e.dots=i.dots),i.beam!==void 0&&(e.beam=i.beam),i.grace!==void 0&&(e.grace=i.grace?GraceType.Grace:void 0),i.fullMeasure&&(e.rest="R"))}),Number.isFinite(t.priority)&&(this.solutionStat={loss:-t.priority}),this.postRegulate()}cleanupRegulation(){this.voices=null,this.duration=null,this.events.forEach(t=>{t.tick=null,t.tickGroup=null,t.timeWarp=null})}regulateTest(){this.duration=0,this.voices=this.rows.map(t=>t.events.map(e=>e.id)),this.voices.forEach(t=>{let e=0;t.map(n=>this.events.find(r=>r.id===n)).forEach((n,r)=>{n.tickGroup=r,n.tick=e,e+=n.duration}),this.duration=Math.max(this.duration,e)})}regulateSimple(){SimplePolicy.computeMeasureTicks(this),SimplePolicy.computeMeasureVoices(this)}async regulateEquations(t){await EquationPolicy.regulateMeasure(this,t)}async regulate({policy:t="advanced",...e}={}){switch(t){case"test":this.regulateTest();break;case"equations":case"advanced":await this.regulateEquations(e);break;case"simple":default:this.regulateSimple()}this.postRegulate()}createPatch(){return new PatchMeasure({measureIndex:this.measureIndex,staffMask:this.staffMask,basic:this.basics[0],events:this.events,contexts:this.contexts,marks:this.marks,voices:this.voices})}createClusters(){const t=this.voices&&new Set(this.voices.flat(1));return this.staffGroups.filter(e=>e.length).map(e=>{const i=this.position.staffYs[0],n=u=>this.position.staffYs[e.indexOf(u)]-i,r=this.events.filter(u=>e.includes(u.staff));if(!r.length)return null;const a=r.map(u=>({index:u.id,voice:(this.voices||[]).findIndex(h=>h.includes(u.id)),type:u.rest?EventElementType.REST:EventElementType.CHORD,staff:e.indexOf(u.staff),x:u.tipX,pivotX:u.pivotX,y1:n(u.staff)+(u.stemDirection==="u"?u.tipY:u.ys[u.ys.length-1]),y2:n(u.staff)+(u.stemDirection==="u"?u.ys[0]:u.tipY),headY:u.stemDirection==="u"?u.ys[0]:u.ys[u.ys.length-1],feature:u.feature,division:u.division,dots:u.dots,beam:u.beam||null,stemDirection:u.stemDirection,grace:!!u.grace,tremoloCatcher:u.tremoloCatcher,timeWarped:!!u.timeWarp,fullMeasure:u.fullMeasureRest,tick:u.tick||0,fake:!u.fullMeasureRest&&!u.grace&&this.voices&&!t.has(u.id)}));if(!a.some(u=>!u.fake))return null;const o=fractionMul(WHOLE_DURATION,this.timeSignature);a.unshift({index:0,type:EventElementType.BOS,staff:null,division:null,beam:null,dots:null,stemDirection:null,grace:!1,tremoloCatcher:!1,fullMeasure:!1,x:this.position.left,pivotX:this.position.left,y1:0,y2:0,headY:0,feature:null,timeWarped:this.durationa.map(()=>0)),this.voices.forEach(u=>{let h=0;u.forEach(y=>{const f=a.findIndex(p=>p.index===y);f>0&&h>=0&&(c[f][h]=1),h=f}),h>=0&&(c[a.length-1][h]=1)}));const d={...this.solutionStat,patched:this.patched},l=this.backgroundImages&&this.backgroundImages.map(({url:u,position:h})=>({url:u,position:{...h,y:h.y-i}}));return new EventCluster({index:this.measureIndex,duration:this.duration,signatureDuration:o,staffY0:i,elements:a,matrixH:c,annotation:d,backgroundImages:l})}).filter(Boolean)}applyClusters(t){const e=this.events.reduce((i,n)=>Math.max(i,n.id),0)+1;this.matrixH=Array(e+1).fill(null).map(()=>Array(e).fill(0)),t.forEach(i=>{const n=i.elements.map(r=>r.index);console.assert(i.matrixH.length===n.length-1,"unexpected matrixH size:",i.matrixH.length,n.length);for(let r=1;r{const a=this.events.find(o=>o.id===r.index);a&&(a.predisposition=r.predisposition,a.predisposition.grace!==void 0&&(a.grace=a.predisposition.grace?GraceType.Grace:null))})}),this.estimatedDuration=t.reduce((i,n)=>i+n.estimatedDuration,0)/t.length}}class EditableEvent extends EventTerm{voice;constructor(t){super(t)}get agent(){return new Proxy(this,{get(t,e){const i=t;switch(e){case"id":case"tick":case"duration":case"rest":case"division":case"dots":case"stemDirection":case"beam":case"tremolo":case"tremoloLink":case"arpeggioStyle":{const n=i[e];return n===void 0?null:n}case"tying":case"tied":case"glissando":{const n=i[e];return n===void 0?!1:n}case"grace":return!!i.grace;case"timeWarp":return i.timeWarp?`${i.timeWarp.numerator}/${i.timeWarp.denominator}`:null;case"multiplier":return i.multiplier?`${i.multiplier.numerator}/${i.multiplier.denominator}`:null;case"pitches":return i.pitches}},set:(t,e,i)=>{const n=t;switch(e){case"tick":case"duration":case"rest":case"division":case"dots":case"stemDirection":case"tying":case"tied":case"beam":case"tremolo":case"tremoloLink":case"glissando":case"arpeggioStyle":return n[e]=i,!0;case"grace":return n.grace=i?GraceType.Grace:null,!0;case"timeWarp":if(n.timeWarp=null,i&&typeof i=="string"){const r=i.match(/^(\d+)\/(\d+)/);r&&(n.timeWarp={numerator:parseInt(r[1]),denominator:parseInt(r[2])})}return!0;case"multiplier":if(n.multiplier=null,i&&typeof i=="string"){const r=i.match(/^(\d+)\/(\d+)/);r&&(n.multiplier={numerator:parseInt(r[1]),denominator:parseInt(r[2])})}return!0;case"id":case"pitches":return!0}return!1},ownKeys:()=>["id","duration","rest","division","dots","stemDirection","tying","tied","beam","timeWarp","multiplier","tremolo","tremoloLink","glissando","arpeggioStyle","tick","grace","pitches"],getOwnPropertyDescriptor(){return{enumerable:!0,configurable:!0}}})}}class EditableMeasure extends SpartitoMeasure{static className="EditableMeasure";static blackKeys=[];events=null;constructor(t){var e;super(t),this.events=t.events,(e=this.events)!=null&&e.some(i=>!(i instanceof EditableEvent))&&(this.events=this.events.map(i=>new EditableEvent(i))),this.voices&&this.syncVoiceToEvents()}syncVoiceToEvents(){this.events.forEach(t=>t.voice=-1),this.voices.forEach((t,e)=>{t.forEach(i=>{const n=this.events.find(r=>r.id===i);n?n.voice=e:console.warn("no event with id:",i,this.events.length)})})}syncVoiceFromEvents(){const t=[];this.events.forEach(e=>{(e==null?void 0:e.voice)>=0&&(t[e.voice]=t[e.voice]||[],t[e.voice].push(e))}),t.forEach(e=>e.sort((i,n)=>i.tick-n.tick)),this.voices=t.map(e=>e.map(i=>i.id))}get agent(){return new Proxy(this,{get:(t,e)=>{var n;const i=t;switch(e){case"measureIndex":case"duration":return i[e];case"voices":return((n=i.voices)==null?void 0:n.map(r=>r.join(",")))||null;case"timeSignature":case"keySignature":case"doubtfulTimesig":return i.basics[0][e];case"toJSON":return()=>({measureIndex:i.measureIndex,voices:i.voices,duration:i.duration,timeSignature:i.basics[0].timeSignature,keySignature:i.basics[0].keySignature})}},set:(t,e,i)=>{const n=t;switch(e){case"timeSignature":case"keySignature":case"doubtfulTimesig":return n.basics[0][e]=i,n.basics=n.basics.map(()=>n.basics[0]),!0;case"duration":return n.duration=i,!0;case"measureIndex":case"voices":return!0}return!1},ownKeys:()=>["measureIndex","timeSignature","doubtfulTimesig","keySignature","duration","voices"],getOwnPropertyDescriptor(){return{enumerable:!0,configurable:!0}}})}makeMIDI(t=120){if(!this.regulated)return null;const e=6e7/t,i={formatType:0,ticksPerBeat:480},n=this.voices.map((r,a)=>{const o=r.map(l=>{const u=this.events.find(h=>h.id===l);return u?[...u.graceIds?u.graceIds.map(y=>this.events.find(f=>f.id===y)):[],u]:[]}).flat(1),c=0,d=o.filter(l=>!l.rest&&Number.isFinite(l.tick)&&l.tick>=0&&Number.isFinite(l.duration)).map(l=>l.pitches.map(u=>[{id:l.id,time:l.tick,type:"channel",subtype:"noteOn",channel:l.staff,noteNumber:noteToPitch(u),velocity:96},{id:l.id,time:l.tick+l.duration,type:"channel",subtype:"noteOff",channel:l.staff,noteNumber:noteToPitch(u)}])).flat(2);return d.sort(function(l,u){return l.time-u.time}),a===0&&d.unshift({time:c,type:"meta",subtype:"timeSignature",numerator:this.timeSignature.numerator,denominator:this.timeSignature.denominator,thirtyseconds:8},{time:c,type:"meta",subtype:"setTempo",microsecondsPerBeat:e}),d.forEach(l=>{l.ticks=Math.round(l.time-c)}),d.forEach((l,u)=>{l.deltaTime=l.ticks-(u>0?d[u-1].ticks:0)}),d.push({deltaTime:0,type:"meta",subtype:"endOfTrack"}),d});return{header:i,tracks:n}}}var PageLayoutMethod=(s=>(s.ByLines="ByLines",s.ByBlocks="ByBlocks",s))(PageLayoutMethod||{}),TextType=(s=>(s.Title="Title",s.Author="Author",s.TempoText="TempoText",s.TempoNumeral="TempoNumeral",s.TextualMark="TextualMark",s.Lyric="Lyric",s.Instrument="Instrument",s.MeasureNumber="MeasureNumber",s.Times="Times",s.Alternation1="Alternation1",s.Alternation2="Alternation2",s.Chord="Chord",s.PageMargin="PageMargin",s.Other="Other",s))(TextType||{});const BEAM_STATUS={[StemBeam.Open]:1,[StemBeam.Continue]:0,[StemBeam.Close]:-1},evaluateMeasure=s=>{if(!s.regulated)return;const t=s.eventMap,e=s.events.length,i=s.voices.flat(1).length,n=s.events.filter(N=>N.timeWarp).length,r=new Set(s.events.filter(N=>N.timeWarp&&!(N.rest&&N.division===0)).map(N=>`${N.timeWarp.numerator}/${N.timeWarp.denominator}`)),a=new Set(r);a.delete("2/3");const o=s.voices.some(N=>{const F=N.map(P=>t[P]);if(!F.some(P=>P.timeWarp))return!1;let L=0,H=0,W=0;return F.some((P,j)=>{const z=P.timeWarp?P.timeWarp.denominator:0;if(z!==L){if(L>0&&(H%L||W<2))return!0;H=0,W=0}return L=z,H+=P.duration,++W,!!(j===F.length-1&&L>0&&(H%L||W<2))})}),c=s.voices.some(N=>{const F=N.map(H=>t[H]);let L=0;return F.some(H=>H.grace?!1:H.tickN.timeWarp&&N.timeWarp.denominator>3).map(N=>N.duration)).size>1,u=fractionMul(WHOLE_DURATION,s.timeSignature),h=s.doubtfulTimesig?s.duration:u,y=s.voices.flat(1).map(N=>t[N]),f=y.some(N=>!N||!Number.isFinite(N.tick)||!Number.isFinite(N.division)||N.division<0||!Number.isFinite(N.duration)||N.duration<=0),p=y.reduce((N,F)=>N||F.tick<0||F.tick+F.duration>h,!1),m=s.duration>u,T=y.some(N=>N.grace),x=s.events.filter(N=>N.grace).length,g=x>=y.length,v=y.some(N=>{let F=N.tick*2**(N.division+2);return N.timeWarp&&(F*=N.timeWarp.denominator),Number.isFinite(F)?gcd(Math.round(F),WHOLE_DURATION)N.reduce(({status:F,broken:L},H,W)=>{const P=t[H];return P.beam?(W===0&&[StemBeam.Continue,StemBeam.Close].includes(P.beam)&&(F=1),F+=BEAM_STATUS[P.beam],L=L||!(F>=0&&F<=1)):P.rest||(L=L||F!==0),{status:F,broken:L}},{status:0,broken:!1})).some(({broken:N})=>N);let k=0,O=0;s.voices.forEach(N=>{const F=N.reduce((L,H)=>L+t[H].duration,0);k+=Math.max(0,s.duration-F),O+=Math.max(0,F-s.duration)}),k/=WHOLE_DURATION;const M=s.events.filter(N=>!N.grace&&!N.fullMeasureRest&&!N.tremoloCatcher&&(!N.predisposition||N.predisposition.fakeP<.1)&&!Number.isFinite(N.tick)).length,b=s.events.filter(N=>!N.fullMeasureRest&&!N.grace&&!N.tremoloCatcher&&!y.includes(N)).length,{voiceRugged:_}=s.voices.flat(1).reduce((N,F)=>!N.voiceRugged&&N.es.has(F)?{voiceRugged:!0,es:N.es}:(N.es.add(F),N),{voiceRugged:!1,es:new Set}),R=s.tickTwist||0,I=f||R>=1||c||_||s.tickRatesInStaves.some(N=>N<0)||M>2||!s.timeSignature||p||s.duration>h||s.events.some(N=>N.timeWarp&&N.timeWarp.numerator/N.timeWarp.denominator<=.5),D=!I&&!m&&R<.2&&!o&&!a.size&&!v&&!k&&!O&&!!s.voices.length&&!E&&!T&&!g&&(s.duration===h||Number.isFinite(s.estimatedDuration)&&s.estimatedDuration<=h*.75),w=!I&&!m&&R<.3&&!o&&!v&&!O&&!E&&!T;let B=Math.min(h,WHOLE_DURATION*2);Number.isFinite(s.estimatedDuration)&&(B=Math.max(0,Math.min(B,s.estimatedDuration)));const C=s.duration/B;let A=0;if(s.patched&&!f)A=1;else if(!I){const N=Math.tanh(Math.abs(k/Math.max(1,s.voices.length))*1);let F=Math.min(h,WHOLE_DURATION*2);Number.isFinite(s.estimatedDuration)&&(F=Math.max(0,Math.min(F,s.estimatedDuration)));const L=F?Math.max(0,1-C)**2:0,H=Math.tanh(a.size);A=(1-N)*(1-L)*(1-H)*(1-R**2)}return{events:e,validEvents:i,voiceRugged:_,nullEvents:M,fakeEvents:b,warpedEvents:n,complicatedTimewarp:l,spaceTime:k,surplusTime:O,durationRate:C,beamBroken:E,fractionalWarp:o,irregularWarpsN:a.size,irregularTick:v,tickTwist:R,tickOverlapped:c,graceInVoice:T,graceN:x,graceDominant:g,perfect:D,fine:w,error:I,qualityScore:A}};class SemanticGraph extends SimpleClass{static className="SemanticGraph";points;constructor(t){super(),super.assign(t)}static fromPoints(t=[]){const e=new SemanticGraph;return e.points=t,e}getLayer(t){return this.points.filter(e=>e.semantic===t)}getConfidentLayer(t,e){return this.points.filter(i=>i.semantic===t&&(!Number.isFinite(i.confidence)||i.confidence>=e))}getSystemPoints(){return this.points.filter(t=>SYSTEM_SEMANTIC_TYPES.includes(t.semantic))}getStaffPoints(){return this.points.filter(t=>!SYSTEM_SEMANTIC_TYPES.includes(t.semantic))}offset(t,e){this.points.forEach(i=>{i.x+=t,i.y+=e})}scale(t){this.points.forEach(e=>{e.x*=t,e.y*=t})}transform(t){this.points.forEach(e=>{let i=e.x*t[0][0]+e.y*t[1][0]+t[2][0];const n=e.x*t[0][1]+e.y*t[1][1]+t[2][1];if(e.extension){if(Number.isFinite(e.extension.y1)){const r=e.x*t[0][1]+e.extension.y1*t[1][1]+t[2][1],a=e.x*t[0][1]+e.extension.y2*t[1][1]+t[2][1];i=e.x*t[0][0]+(e.extension.y1+e.extension.y2)*.5*t[1][0]+t[2][0],e.extension.y1=r,e.extension.y2=a}if(Number.isFinite(e.extension.width)){const r=Math.sqrt(t[0][0]*t[1][1]-t[0][1]*t[1][0]);e.extension.width*=r,e.extension.height*=r}}e.x=i,e.y=n})}}const CHORD_X_TOLERANCE=.2,STEM_LENGTH_MAX=6,INDENT_THRESHOLD=2,MEASURE_SEMANTICS=[SemanticType.ClefG,SemanticType.ClefF,SemanticType.ClefC,SemanticType.TimesigC44,SemanticType.TimesigC22,SemanticType.TimesigZero,SemanticType.TimesigOne,SemanticType.TimesigTwo,SemanticType.TimesigThree,SemanticType.TimesigFour,SemanticType.TimesigFive,SemanticType.TimesigSix,SemanticType.TimesigSeven,SemanticType.TimesigEight,SemanticType.TimesigNine,SemanticType.OctaveShift8va,SemanticType.OctaveShift8vb,SemanticType.OctaveShift0,SemanticType.Zero,SemanticType.One,SemanticType.Two,SemanticType.Three,SemanticType.Four,SemanticType.Five,SemanticType.Six,SemanticType.Seven,SemanticType.Eight,SemanticType.Nine,SemanticType.AccNatural,SemanticType.AccSharp,SemanticType.AccDoublesharp,SemanticType.AccFlat,SemanticType.AccFlatflat,SemanticType.NoteheadS0,SemanticType.NoteheadS1,SemanticType.NoteheadS2,SemanticType.NoteheadS1stemU,SemanticType.NoteheadS1stemD,SemanticType.NoteheadS2stemU,SemanticType.NoteheadS2stemD,SemanticType.Rest0,SemanticType.Rest1,SemanticType.Rest2,SemanticType.Rest3,SemanticType.Rest4,SemanticType.Rest5,SemanticType.Rest6,SemanticType.Rest0W,SemanticType.RestM1,SemanticType.SlurBegin,SemanticType.SlurEnd,SemanticType.Dot,SemanticType.f,SemanticType.p,SemanticType.m,SemanticType.n,SemanticType.r,SemanticType.s,SemanticType.z,SemanticType.ScriptFermata,SemanticType.ScriptShortFermata,SemanticType.ScriptSforzato,SemanticType.ScriptStaccato,SemanticType.ScriptStaccatissimo,SemanticType.ScriptTurn,SemanticType.ScriptTrill,SemanticType.ScriptSegno,SemanticType.ScriptCoda,SemanticType.ScriptArpeggio,SemanticType.ScriptPrall,SemanticType.ScriptMordent,SemanticType.ScriptMarcato,SemanticType.ScriptTenuto,SemanticType.ScriptPortato,SemanticType.PedalStar,SemanticType.PedalPed,SemanticType.GraceNotehead,SemanticType.BeamLeft,SemanticType.BeamRight,SemanticType.BeamContinue,SemanticType.CrescendoBegin,SemanticType.CrescendoEnd,SemanticType.DecrescendoBegin,SemanticType.DecrescendoEnd,SemanticType.TremoloLeft,SemanticType.TremoloRight,SemanticType.TremoloMiddle],STAFF_LINED_SEMANTICS=[SemanticType.AccNatural,SemanticType.AccSharp,SemanticType.AccDoublesharp,SemanticType.AccFlat,SemanticType.AccFlatflat,SemanticType.NoteheadS0,SemanticType.NoteheadS1,SemanticType.NoteheadS2,SemanticType.NoteheadS1stemU,SemanticType.NoteheadS1stemD,SemanticType.NoteheadS2stemU,SemanticType.NoteheadS2stemD],LINED_INTERVAL_SEMANTICS=[SemanticType.SignLined,SemanticType.SignInterval],NOTEHEAD_FOR_STEM_SEMANTICS=[SemanticType.NoteheadS1,SemanticType.NoteheadS2],KEYACC_CANDIDATE_SEMANTICS={AccSharp:TokenType.KeySharp,AccNatural:TokenType.KeyNatural,AccFlat:TokenType.KeyFlat},NOTEHEAD_TABLE={[SemanticType.NoteheadS1]:{up:SemanticType.NoteheadS1stemU,down:SemanticType.NoteheadS1stemD},[SemanticType.NoteheadS2]:{up:SemanticType.NoteheadS2stemU,down:SemanticType.NoteheadS2stemD}},REST_SEMANTICS=[SemanticType.Rest0,SemanticType.Rest1,SemanticType.Rest2,SemanticType.Rest3,SemanticType.Rest4,SemanticType.Rest5,SemanticType.Rest6],TOKEN_TO_STEMBEAM={[TokenType.BeamLeft]:"Open",[TokenType.BeamRight]:"Close",[TokenType.BeamContinue]:"Continue"},TEXT_TYPE_ALIAS={Alter1:TextType.Alternation1,Alter2:TextType.Alternation2},noteheadsXPivot=(s,t)=>{switch(s.length){case 0:return;case 1:return s[0];case 2:return t==="u"?Math.min(...s):Math.max(...s);default:{const e=s.reduce((i,n)=>i+n,0)/s.length;return s.sort((i,n)=>Math.abs(i-e)-Math.abs(n-e)),noteheadsXPivot(s.slice(0,s.length-1),t)}}},noteheadsPivot=s=>noteheadsXPivot(s.map(t=>Number.isFinite(t.pivotX)?t.pivotX:t.x),s[0].direction);class Measure extends SimpleClass{static className="Measure";static blackKeys=["tokens","antiTokens"];left;width;height;alternative;tokens;antiTokens;barTypes;constructor(t){super(),super.assign(t),this.tokens=this.tokens||[],this.antiTokens=this.antiTokens||[],this.barTypes=this.barTypes||{}}get right(){return this.left+this.width}get noteheads(){return this.tokens.filter(t=>t.isNotehead).sort((t,e)=>t.x-e.x)}get chordRects(){const t=this.noteheads.filter(n=>[TokenType.NoteheadS0,TokenType.NoteheadS1stemU,TokenType.NoteheadS2stemU,TokenType.NoteheadS1stemD,TokenType.NoteheadS2stemD].includes(n.type));let e=0;const i=t.reduce((n,r)=>{const a=r.tip?`${r.tip.x}|${r.tip.y}`:`nul${e}`;let o=`${r.type}|${a}`;return!r.tip&&n[o]&&(n[o].some(c=>Math.abs(c.x-r.x){const r=Math.min(...n.map(f=>f.x)),a=Math.max(...n.map(f=>f.x)),o=Math.min(...n.map(f=>f.y)),c=Math.max(...n.map(f=>f.y)),d=n[0],l=d&&d.tip?d.tip.x:r;let u=r,h=a-r,y=null;switch(d.type){case TokenType.NoteheadS0:u-=NOTEHEAD_WIDTHS.NoteheadS0/2,h+=NOTEHEAD_WIDTHS.NoteheadS0;break;case TokenType.NoteheadS1stemU:case TokenType.NoteheadS2stemU:y="u",u-=NOTEHEAD_WIDTHS.NoteheadS1,h+=NOTEHEAD_WIDTHS.NoteheadS1;break;case TokenType.NoteheadS1stemD:case TokenType.NoteheadS2stemD:y="d",h+=NOTEHEAD_WIDTHS.NoteheadS1;break}return{x:u,width:h,stemX:l,stemDirection:y,top:o,bottom:c,tip:d.tip}})}get timeWarped(){return this.tokens&&this.tokens.some(t=>t.timeWarped)}get additionalLines(){const t=this.getChords(),e=t.filter(n=>n.ys.some(r=>r<=-3)).map(n=>({left:n.left,right:n.right,n:Math.ceil(Math.min(...n.ys))+2})),i=t.filter(n=>n.ys.some(r=>r>=3)).map(n=>({left:n.left,right:n.right,n:Math.floor(Math.max(...n.ys))-2}));return[...e,...i].map(n=>({left:n.left-.28,right:n.right+.28,n:n.n}))}getChords(){const t=this.tokens.filter(o=>TokenFlags.includes(o.type)),e=this.tokens.filter(o=>TokenDots.includes(o.type)),i=this.tokens.filter(o=>TokenBeams.includes(o.type)),n=this.chordRects.map(o=>{const c=this.noteheads.filter(h=>h.direction===o.stemDirection&&h.left>=o.x&&h.right<=o.x+o.width+CHORD_X_TOLERANCE&&h.y>=o.top&&h.y<=o.bottom);c.sort((h,y)=>y.y-h.y);const d=c.map(h=>h.y),l=c.map(h=>h.id),u=c.reduce((h,y)=>Math.max(h,y.division),0);return{rect:o,left:o.x,right:o.x+o.width,pivotX:noteheadsPivot(c),ys:d,tip:o.tip,noteIds:l,division:u,dots:null,rest:!1,stemDirection:o.stemDirection,beam:null}}).sort((o,c)=>c.left-o.left),r=new Set,a=n.map(({rect:o,...c})=>{if(c.division>=1){const l=[o.bottom,o.top];switch(o.stemDirection){case"u":l[0]=o.tip?o.tip.y-.2:o.top-STEM_LENGTH_MAX-.5;break;case"d":l[1]=o.tip?o.tip.y+.2:o.bottom+STEM_LENGTH_MAX+.5;break}const u=t.filter(h=>!r.has(h.id)&&h.x>o.stemX-CHORD_X_TOLERANCE&&h.xl[0]&&h.yMath.max(h,y.division),c.division),u.forEach(h=>r.add(h.id)),c.division>=3){const h=o.tip&&i.find(y=>Math.abs(o.tip.x-y.x)<.3&&Math.abs(o.tip.y-y.y)<.7);h&&(c.beam=TOKEN_TO_STEMBEAM[h.type])}}const d=e.filter(l=>!r.has(l.id)&&l.x>o.x+o.width-.2&&l.xo.top-1&&l.y<=o.bottom+.5);return c.dots=d.reduce((l,u)=>Math.max(l,u.dots),0),d.forEach(l=>r.add(l.id)),c});return a.reverse(),a}getRests(){const t=this.tokens.filter(i=>TokenRests.includes(i.type)),e=this.tokens.filter(i=>TokenDots.includes(i.type));return t.map(i=>{const r=e.filter(a=>a.x>i.x+.5&&a.xi.y-1&&a.yMath.max(a,o.dots),0);return{left:i.x-.75,right:i.x+.75,pivotX:i.x,rest:!0,ys:[i.y],noteIds:[i.id],dots:r,division:i.division,stemDirection:null}})}getEvents(){return[...this.getChords(),...this.getRests()].sort((t,e)=>t.left-e.left)}getContexts(t={}){return this.tokens.filter(e=>e.isContexted).sort((e,i)=>e.x-i.x).map(e=>new ContextedTerm({x:e.x,y:e.y,tokenType:e.type,...t}))}assignAccessoriesOnEvents(t){t.forEach(l=>l.accessories=l.accessories||[]),this.tokens.filter(l=>TokenAccessories.includes(l.type)).forEach(l=>{const u=t.filter(h=>l.x>h.left-1&&l.x0){let h=u[0];u.length>1&&(h=u.map(f=>({event:f,d:Math.min(...f.ys.map(p=>Math.abs(p-l.y)))})).sort(({d:f},{d:p})=>f-p).map(({event:f})=>f)[0]);let y=l.y>Math.max(...h.ys)?AccessoryDirection.Down:AccessoryDirection.Up;TokenDirectionless.includes(l.type)&&(y=null),h.accessories.push({type:l.type,id:l.id,direction:y,x:l.x-h.left})}});const i=[...t];i.sort((l,u)=>l.left-u.left),this.tokens.filter(l=>l.type===TokenType.ScriptArpeggio).forEach(l=>{const u=i.find(h=>l.xyy>l.y));u&&u.accessories.push({type:TokenType.ScriptArpeggio,id:l.id,x:l.x-u.left})}),this.tokens.filter(l=>l.type===TokenType.GraceNotehead).forEach(l=>{const u=t.find(h=>l.x>h.left&&l.xMath.abs(l.y-y)<.4));u&&(u.grace=GraceType.Grace)});const a=this.tokens.filter(l=>l.type===TokenType.TremoloLeft),o=this.tokens.filter(l=>l.type===TokenType.TremoloRight),c=this.tokens.filter(l=>l.type===TokenType.TremoloMiddle),d=t.filter(l=>!l.rest).map(l=>{const u=[...l.ys];l.tip?u.push(l.tip.y):(u.push(l.ys[0]+2),u.push(l.ys[l.ys.length-1]-2));const h=l.tip?l.tip.x:l.left,y=l.tip?l.tip.x:l.right;return{event:l,top:Math.min(...u),bottom:Math.max(...u),stemL:h,stemR:y}});c.forEach(l=>{const u=d.find(h=>h.event.tip?l.y>h.top&&l.y{const u=d.find(h=>l.y>h.top&&l.yh.stemR&&l.x{const u=d.find(h=>l.y>h.top&&l.yh.stemL-1.6);u&&(u.event.tremolo=u.event.tremolo||2,++u.event.tremolo,u.event.tremoloLink=TremoloLink.Catcher)})}assignFeaturesOnEvents(t,e){const i=e.filter(m=>m.x>this.left&&m.xREST_SEMANTICS.includes(m.semantic)),r=i.filter(m=>m.semantic===SemanticType.Flag3),a=i.filter(m=>m.semantic===SemanticType.Dot),o=i.filter(m=>m.semantic===SemanticType.BeamLeft),c=i.filter(m=>m.semantic===SemanticType.BeamContinue),d=i.filter(m=>m.semantic===SemanticType.BeamRight),l=i.filter(m=>m.semantic===SemanticType.GraceNotehead),u=i.filter(m=>m.semantic===SemanticType.TremoloRight),h=i.filter(m=>m.semantic===SemanticType.vline_Stem),y=i.filter(m=>m.semantic===SemanticType.NoteheadS0),f=i.filter(m=>m.semantic===SemanticType.NoteheadS1),p=i.filter(m=>m.semantic===SemanticType.NoteheadS2);t.forEach(m=>{const T=m.tip?m.tip.x:(m.left+m.right)/2,x=m.tip?Math.min(m.tip.y,m.ys[m.ys.length-1]):m.ys[m.ys.length-1],g=m.tip?Math.max(m.tip.y,m.ys[0]):m.ys[0],v=m.tip?m.tip.x:m.left,S=[0,0,0,0,0,0,0];if(m.rest)n.filter(A=>distance2D(A,{x:T,y:m.ys[0]})<.5).forEach(A=>{const N=REST_SEMANTICS.indexOf(A.semantic);S[N]=Math.max(S[N],A.confidence)});else{const C=[y,f,p].map(N=>N.filter(F=>F.x>m.left&&F.xx-.25&&F.yMath.max(0,...N.map(F=>F.confidence))),A=r.filter(N=>N.y>x-.2&&N.yF.confidence-N.confidence),S[0]=C[0],S[1]=C[1],S[2]=C[2],Array(S.length-3).fill(0).forEach((N,F)=>S[3+F]=A[F]?A[F].confidence:0)}const E=a.filter(C=>C.x>T&&C.xE.some(A=>C.x>A.x&&Math.abs(C.y-A.y)<.2)),O=[Math.max(0,...E.map(C=>C.confidence)),Math.max(0,...k.map(C=>C.confidence))],M=[o,c,d].map(C=>C.filter(A=>Math.abs(A.x-T)<.2&&A.y>x-.2&&A.yMath.max(0,...C.map(A=>A.confidence))),b=h.filter(C=>distance2D({x:T,y:m.ys[0]},{x:C.x,y:C.extension.y2})<.5),_=h.filter(C=>distance2D({x:T,y:m.ys[m.ys.length-1]},{x:C.x,y:C.extension.y1})<.5),R=[Math.max(0,...b.map(C=>C.confidence)),Math.max(0,..._.map(C=>C.confidence))],I=l.filter(C=>Math.abs(C.x-T)<.6&&m.ys.some(A=>Math.abs(C.y-A)<.4)),D=Math.max(0,...I.map(C=>C.confidence)),w=m.division===0?u.filter(C=>C.x>m.left-2&&C.xC.y>x-.04&&C.yv-2&&C.xC.confidence));m.feature={divisions:S,dots:O,beams:M,stemDirections:R,grace:D,tremoloCatcher:B}})}}class Staff extends SimpleClass{static className="Staff";static blackKeys=["index","semanticTop","semanticBttom"];index;top;height;staffY;semanticTop;semanticBottom;backgroundImage;maskImage;imagePosition;measures;semantics;constructor({measureCount:t=null,measureBars:e=null,...i}={}){if(super(),super.assign(i),this.height=this.height||10,this.staffY=this.staffY||5,e){let n=0;this.measures=e.map(r=>{const a=new Measure({left:n,width:r-n,height:this.height});return n=r,a})}else t?this.measures=Array(t).fill(null).map(()=>new Measure):this.measures=[]}get noteRange(){const e=[].concat(...this.measures.map(r=>r.noteheads)).map(r=>r.y),i=Math.min(-2,...e),n=Math.max(2,...e);return{top:i,bottom:n}}get additionalLines(){return[].concat(...this.measures.map(t=>t.additionalLines))}rearrangeMeasures(t){var n;if(!t.length){console.warn("rearrangeMeasures error, measureBars are empty.");return}const e=((n=this.measures)==null?void 0:n.map(r=>r.tokens).flat(1))||[];let i=0;this.measures=t.map(r=>{const a=new Measure({left:i,width:r-i,height:this.height});return i=r,a}),this.reassignTokens(e)}reassignTokens(t=null){t||(t=[].concat(...this.measures.map(e=>e.tokens))),this.measures.forEach(e=>e.tokens=[]),t.forEach(e=>{for(const i of this.measures)if(e.xg.semantic===SemanticType.TempoNotehead).forEach(g=>{const v=n.findIndex(S=>/^Notehead/.test(S.semantic)&&distance2D(g,S)<.3);v>=0&&n.splice(v,1)});const a=g=>{var v;return(v=e.displacementSemantics)!=null&&v[g]?this.semantics.find(S=>S.id===g):null};n.filter(g=>MEASURE_SEMANTICS.includes(g.semantic)).forEach(g=>this.appendPoint(g,{points:n}));const o=n.filter(g=>g.semantic===SemanticType.vline_Stem).filter(g=>g.extension.y2-g.extension.y1>1.5).map(g=>({x:g.x,y1:g.extension.y1,y2:g.extension.y2,direction:null})),c=n.filter(g=>NOTEHEAD_FOR_STEM_SEMANTICS.includes(g.semantic)&&g.y>this.semanticTop&&g.y{if((S?1:0)^(g.x{const v=c.filter(S=>Math.abs(S.x-g.x)-NOTEHEAD_WIDTHS[S.semantic]/2<.32&&Math.abs(S.x-g.x)-NOTEHEAD_WIDTHS[S.semantic]/2>-.44&&S.y>g.y1-.5&&S.yg.x&&S.y>g.y2)&&!(S.xb.y-_.y);const S=Math.min(...v.map(b=>b.y-g.y1)),E=Math.min(...v.map(b=>g.y2-b.y));if(Math.min(S,E)>.5)return;const k=S!d.has(g.id)).forEach(g=>{const S=o.filter(E=>Math.abs(E.x-g.x)<2&&g.y>E.y1&&g.yMath.abs(E.x-g.x)-Math.abs(k.x-g.x))[0];if(S){const E=S.direction==="d",k=E?NOTEHEAD_TABLE[g.semantic].down:NOTEHEAD_TABLE[g.semantic].up;this.appendPoint({id:g.id,semantic:k,x:S.x+l(g,S,E),y:g.y,pivotX:g.x,confidence:g.confidence},{tip:{x:S.x,y:E?S.y2:S.y1},antiPoint:a(g.id),points:n})}else i.debug("isolated notehead:",e.index,this.index,g)});const u=n.filter(g=>g.semantic===SemanticType.Flag3);u.sort((g,v)=>g.x-v.x),this.appendFlags(u,o);const y=n.filter(g=>g.semantic===SemanticType.Dot).map(g=>{const v=roundNumber(g.y,.5);return{x:g.x,y:v}}).reduce((g,v)=>(g[v.y]=g[v.y]||[],g[v.y].push(v),g),{});Object.entries(y).forEach(([g,v])=>{const S=Number(g);if(v.length>1){v.sort((E,k)=>E.x-k.x);for(let E=0;EO.x>k.x&&O.x-k.x<1.2)&&this.appendPoint({id:k.id,x:k.x,y:S,confidence:k.confidence},{type:TokenType.DotDot,antiPoint:a(k.id),points:n})}}});const f=n.filter(g=>g.semantic===SemanticType.KeyAcc);n.filter(g=>KEYACC_CANDIDATE_SEMANTICS[g.semantic]).forEach(g=>{f.some(v=>Math.abs(g.x-v.x)<.5&&Math.abs(g.y-v.y)<1)&&this.appendPoint({id:g.id,semantic:g.semantic,x:g.x,y:g.y,confidence:g.confidence},{type:KEYACC_CANDIDATE_SEMANTICS[g.semantic],points:n})}),n.filter(g=>g.semantic===SemanticType.OctaveShift8).forEach(g=>{const v=g.y<0?TokenType.OctaveShift8va:TokenType.OctaveShift8vb;this.appendPoint({id:g.id,x:g.x,y:g.y,confidence:g.confidence},{type:v,points:n})});const T=this.semantics.filter(g=>[SemanticType.VoltaLeft,SemanticType.VoltaRight].includes(g.semantic));T.sort((g,v)=>g.x-v.x);const x=T.reduce((g,v)=>{const S=g[v.semantic],k=Array.from(Object.keys(S)).map(Number).find(O=>v.x{if(S.length>1){const E=S.reduce((k,O)=>k+O.confidence,0);S[0].y*S[1].y<0&&E>=t*2&&this.appendPoint(S[0],{type:TokenType[g]})}})}appendPoint(t,{type:e,points:i=null,antiPoint:n,...r}={}){const a=t.x,o=this.measures.find(f=>aLINED_INTERVAL_SEMANTICS.includes(p.semantic)&&Math.abs(p.y-t.y)<.2&&Math.abs(p.x-t.x)<1.2);f.some(p=>p.semantic===SemanticType.SignLined)?c=!0:f.some(p=>p.semantic===SemanticType.SignInterval)&&(d=!0)}e=e||TokenType[t.semantic];const l=TOKEN_Y_FIXED[e];let u=TOKEN_Y_ROUND[e];(c||d)&&(u=Math.max(u,1));let h=t.y;Number.isFinite(l)?h=l:u&&(d?h=roundNumber(h+.5,u)-.5:h=roundNumber(h,u));const y=o.tokens.find(f=>f.type===e&&Math.abs(f.x-a)<.1&&Math.abs(f.y-h)<.1);if(y){Number.isFinite(y.confidence)&&y.confidence3||(o.tokens.push(new Token({id:t.id,type:e,x:a,y:h,pivotX:t.pivotX,confidence:t.confidence,...r})),n&&o.antiTokens.push(new Token({id:n.id,type:e,x:a,y:n.y,confidence:n.confidence})))}appendFlags(t,e){e.map(n=>({...n,flags:t.filter(r=>Math.abs(r.x-n.x)<.3&&r.y>n.y1-.5&&r.yn.flags.length).forEach(n=>{const r=n.flags.reduce((u,h)=>u&&u.confidence>h.confidence?u:h,null),a=n.direction==="d",o=a?Math.min(n.y2,n.y1+STEM_LENGTH_MAX):Math.max(n.y1,n.y2-STEM_LENGTH_MAX),d=n.flags.map(u=>({tip:(o-u.y)*(a?1:-1),confidence:u.confidence})).filter(u=>u.tip<2||u.confidence>r.confidence*.7).length,l=TokenFlags[d-1];l&&this.appendPoint({id:n.flags[0].id,x:n.x,y:o,confidence:Math.min(...n.flags.map(u=>u.confidence))},{type:l})})}clearTokens(){this.measures.forEach(t=>t.tokens=[]),this.semantics=[]}clearPredictedTokens(){this.measures.forEach(t=>t.tokens=t.tokens.filter(e=>!e.isPredicted))}}class System extends SimpleClass{static className="System";static blackKeys=["index","pageIndex","prev","next","headMeasureIndex","tokens","indent"];index;pageIndex;prev;next;headMeasureIndex;left;top;width;indent;measureCount;staves;measureBars;backgroundImage;imagePosition;semantics;tokens;sidBlackList;sidWhiteList;displacementSemantics;staffMaskChanged;bracketsAppearance;constructor({stavesCount:t,...e}){if(super(),super.assign(e),!this.measureBars){const n=(this.width-5)/this.measureCount;this.measureBars=Array(this.measureCount).fill(0).map((r,a)=>5+n*(a+1))}!e.staves&&t&&(this.staves=Array(t).fill(null).map(()=>new Staff({measureBars:this.measureBars}))),this.arrangePosition(),this.measureCount=this.measureCount||this.measureBars.length,this.sidBlackList=this.sidBlackList||[],this.sidWhiteList=this.sidWhiteList||[]}get noteRange(){if(!this.staves.length)return null;const t=this.staves[0],e=this.staves[this.staves.length-1];return{top:t.top+t.staffY+t.noteRange.top,bottom:e.top+e.staffY+e.noteRange.bottom}}get staffPositions(){return this.staves.map(t=>({y:t.top+t.staffY,radius:2}))}get staffMask(){return this.staffMaskChanged?this.staffMaskChanged:this.prev&&this.staves.length===this.prev.staves.length?this.prev.staffMask:2**this.staves.length-1}get staffTop(){const t=this.staffPositions;return t.length?t[0].y-t[0].radius:0}get staffBottom(){const t=this.staffPositions;return t.length?t[t.length-1].y+t[t.length-1].radius:0}arrangePosition(){let t=0;for(const e of this.staves){if(Number.isFinite(e.top))break;e.top=t,t+=e.height}}tidyMeasureBars(){this.measureBars=this.measureBars.filter(e=>e>1),this.measureBars.sort((e,i)=>e-i);const t=this.width-this.measureBars[this.measureBars.length-1];t>12?this.measureBars.push(this.width):t<2&&(this.measureBars[this.measureBars.length-1]=this.width),this.measureBars=this.measureBars.filter((e,i)=>i<1||e-this.measureBars[i-1]>4)}rearrangeMeasures(){this.measureCount=this.measureBars.length,this.staves.forEach(t=>t.rearrangeMeasures(this.measureBars))}get height(){return this.staves.reduce((t,e)=>t+e.height,0)}get connectionLine(){const t=this.staves[0],e=this.staves[this.staves.length-1];return t&&{top:t.top+t.staffY-2,bottom:e.top+e.staffY+2}}get middleY(){return this.staves.length?this.staves.reduce((e,i)=>e+i.top+i.staffY,0)/this.staves.length:0}get timeSignatureOnHead(){return this.staves.some(t=>{var e;return(e=t.measures[0])==null?void 0:e.tokens.some(i=>TokenTimesigs.includes(i.type))})}getStaffArray(t){let e=0;return Array(t).fill(null).map((i,n)=>{const r=this.staffMask&1<0?this.measureBars[t-1]:0,i=this.measureBars[t];return[...(this.tokens??[]).filter(r=>r.x>=e&&r.xTempoTerm.fromNumeralText(r.text)).filter(Boolean)]}getEvents(t){var a;if(console.assert(Number.isInteger(this.headMeasureIndex),"invalid headMeasureIndex:",this.headMeasureIndex),!((a=this.measureBars)!=null&&a.length)&&this.staves.every(o=>{var c;return!((c=o.measures)!=null&&c.length)}))return{staffMask:this.staffMask,columns:[]};const i=this.getStaffArray(t).map(o=>o?o.measures.map(c=>{const d=c.getEvents();return c.assignAccessoriesOnEvents(d),c.assignFeaturesOnEvents(d,o.semantics),{events:d.map(l=>new EventTerm({staff:o.index,system:this.index,...l,rest:l.rest?"r":null})),contexts:c.getContexts({staff:o.index}),voltaBegin:c.tokens.some(l=>l.type===TokenType.VoltaLeft),voltaEnd:c.tokens.some(l=>l.type===TokenType.VoltaRight),alternative:c.alternative,barTypes:c.barTypes}}):Array(this.measureCount).fill(null).map(()=>({events:[],contexts:[],voltaBegin:!1,voltaEnd:!1,alternative:!1,barTypes:{}})));for(let o=0;o{var u,h;return(h=(u=l[o])==null?void 0:u.contexts)==null?void 0:h.filter(y=>[ContextType.TimeSignatureC,ContextType.TimeSignatureN].includes(y.type))}).find(l=>l==null?void 0:l.length);d&&i.forEach(l=>{l[o]&&!l[o].contexts.length&&!l[o].events.length&&l[o].contexts.push(...d)})}const n=Array(this.measureCount).fill(null).map((o,c)=>({measureIndex:this.headMeasureIndex+c,rows:i.map(d=>d[c]),marks:this.getMarksInMeasure(c),duration:0,voltaBegin:i.some(d=>{var l;return(l=d[c])==null?void 0:l.voltaBegin}),voltaEnd:i.some(d=>{var l;return(l=d[c])==null?void 0:l.voltaEnd}),alternative:i.some(d=>{var l;return(l=d[c])==null?void 0:l.alternative}),barTypes:i.reduce((d,l)=>{var u;return{...d,...(u=l[c])==null?void 0:u.barTypes}},{})}));n.forEach(o=>{[].concat(...o.rows.filter(Boolean).map(d=>d.events)).forEach((d,l)=>d.id=l+1)});const r=n[n.length-1];return r&&(r.break=!0),{staffMask:this.staffMask,columns:n}}getEventsFunctional(t,e,i=[],{useXMap:n=!1}={}){const a=this.getStaffArray(t).map((c,d)=>c?c.measures.map((l,u)=>{const h=e(d,u);return h&&{events:h.map(y=>new EventTerm({system:this.index,...y,rest:y.rest?"r":null})),contexts:l.getContexts({staff:d}),voltaBegin:l.tokens.some(y=>y.type===TokenType.VoltaLeft),voltaEnd:l.tokens.some(y=>y.type===TokenType.VoltaRight),alternative:l.alternative,barTypes:l.barTypes}}):Array(this.measureCount).fill(null).map(()=>({events:[],contexts:[],voltaBegin:!1,voltaEnd:!1,alternative:!1,barTypes:{}}))),o=Array(this.measureCount).fill(null).map((c,d)=>{const l=a.map(h=>h[d]);if(l.some(h=>!h))return null;let u=null;if(n){const y=[].concat(...l.map(f=>f.events)).reduce((f,p)=>(Number.isFinite(p.tickGroup)&&(f[p.tickGroup]=f[p.tickGroup]||[]),f[p.tickGroup].push(p),f),{});u=Object.values(y).reduce((f,p)=>{const m=Math.min(...p.map(T=>(T.left+T.right)/2));return f.set(m,p),f},new Map)}return{measureIndex:this.headMeasureIndex+d,rows:l,marks:this.getMarksInMeasure(d),duration:0,xMap:u,voltaBegin:l.some(h=>h.voltaBegin),voltaEnd:l.some(h=>h.voltaEnd),alternative:l.some(h=>h.alternative),barTypes:l.reduce((h,y)=>({...h,...y.barTypes}),{})}});return i.forEach(c=>o.forEach(c)),{staffMask:this.staffMask,columns:o}}getContexts(t){const i=this.getStaffArray(t).map(r=>r?r.measures.map(a=>({events:null,contexts:a.getContexts(),voltaBegin:a.tokens.some(o=>o.type===TokenType.VoltaLeft),voltaEnd:a.tokens.some(o=>o.type===TokenType.VoltaRight),alternative:i.some(o=>o.alternative),barTypes:a.barTypes})):Array(this.measureCount).fill(null).map(()=>({events:null,contexts:[],voltaBegin:!1,voltaEnd:!1,alternative:!1,barTypes:{}})));for(let r=0;r{var d;return(d=c[r])==null?void 0:d.contexts.filter(l=>[ContextType.TimeSignatureC,ContextType.TimeSignatureN].includes(l.type))}).find(c=>c==null?void 0:c.length);o&&i.forEach(c=>{c[r].contexts.length||c[r].contexts.push(...o)})}const n=Array(this.measureCount).fill(null).map((r,a)=>({measureIndex:this.headMeasureIndex+a,rows:i.map(o=>o[a]),marks:[],duration:0,voltaBegin:i.some(o=>o[a].voltaBegin),voltaEnd:i.some(o=>o[a].voltaEnd),alternative:i.some(o=>o.alternative),barTypes:i.reduce((o,c)=>({...o,...c[a].barTypes}),{})}));return{staffMask:this.staffMask,columns:n}}assignSemantics(t,e){const i=this.staves[t];console.assert(i,"staff is null:",t,this.staves);const n=i.top+i.staffY;e.getSystemPoints().forEach(r=>{const a={...r};a.y+=n,a.extension&&(a.extension={...a.extension},Number.isFinite(a.extension.y1)&&(a.extension.y1+=n,a.extension.y2+=n)),this.semantics.push(a)})}assemble(t,e=new DummyLogger){if(this.measureBars=[],!this.semantics)return;const n=SemanticGraph.fromPoints(this.semantics).getConfidentLayer(SemanticType.vline_BarMeasure,t);n.sort((f,p)=>f.x-p.x);const r=this.staffTop,a=this.staffBottom,o=.4;let c=0;const d=n.reduce((f,p)=>{const m=Number.isFinite(p.confidence)?Math.tanh(p.confidence):1,T=p.x-c>o?p.x:c;c=p.x;let x=f[T]||0;return x+=(Math.min(p.extension.y2,a)-Math.max(p.extension.y1,r))*m,p.x!==T&&delete f[T],f[p.x]=x,f},{}),l=Object.entries(d).filter(([f,p])=>p>3*this.staves.length).map(([f])=>Number(f));if(this.sidWhiteList.length)for(const f of n)this.sidWhiteList.includes(f.id)&&!l.some(p=>Math.abs(p-f.x)<=2)&&l.push(f.x);l.sort((f,p)=>f-p),l.forEach((f,p)=>{(p<=0||f-l[p-1]>2)&&this.measureBars.push(f)}),this.measureBars.length||this.measureBars.push(this.width),this.tidyMeasureBars(),this.rearrangeMeasures(),this.semantics.filter(f=>[SemanticType.vline_BarTerminal,SemanticType.vline_BarSegment].includes(f.semantic)).forEach(f=>{const p=this.staves[0].measures.find(m=>f.x>m.right-2&&f.x{for(;!(y&1<hashSemanticPoint(this.index,p,m)),f.clearPredictedTokens(),f.assemble(t,this,e))})}qualifiedSemantics(t,e=1){return t.filter(i=>this.sidWhiteList.includes(i.id)||!this.sidBlackList.includes(i.id)&&(i.confidence>=e||!Number.isFinite(i.confidence))).map(i=>this.displacementSemantics&&this.displacementSemantics[i.id]?{...i,...this.displacementSemantics[i.id]}:i)}clearTokens(){this.staves.forEach(t=>t.clearTokens()),this.semantics=[]}newPoint(t,e,i=1){const n=this.staves[t];console.assert(n,"staff index out of bound:",t,this.staves.length);const{semantic:r,x:a,y:o,confidence:c=0,extension:d=null}=e,l={semantic:r,x:a,y:o,confidence:c,extension:d};return l.extension||delete l.extension,hashSemanticPoint(this.index,t,l),n.semantics.push(l),n.clearPredictedTokens(),n.assemble(i,this),l}appendToken(t){switch(this.tokens.push(t),t.textType){case TextType.TempoNumeral:{const e=this.staves[0];if(e){const i=e.top+e.staffY;e.measures.forEach(n=>{n.tokens=n.tokens.filter(r=>!TokenNoteheads.includes(r.type)||Math.abs(r.x-t.x)>t.width/2||Math.abs(i+r.y-t.y)>t.fontSize/2)})}}break;case TextType.Alternation1:case TextType.Alternation2:this.staves[0].measures.forEach(e=>{const i=Math.min(e.left+e.width,t.x+t.width/2)-Math.max(e.left,t.x-t.width/2);e.alternative=e.alternative||i/e.width>.5});break}}}class Page extends SimpleClass{static className="Page";static blackKeys=["index","tokens"];index;width;height;systems;source;layout;semantics;tokens;lyricTokens;constructor(t){super(),super.assign(t),this.systems=this.systems||[],this.source&&(this.source.matrix=this.source.matrix||[1,0,0,1,0,0])}get sidBlackList(){const t=[].concat(...this.systems.map(e=>e.sidBlackList));return new Set(t)}get sidWhiteList(){const t=[].concat(...this.systems.map(e=>e.sidWhiteList));return new Set(t)}clearTokens(){this.semantics=null,this.tokens=null,this.lyricTokens=null,this.systems.forEach(t=>t.tokens=null)}assignTexts(t,[e,i]){const n=this.source&&this.source.interval?this.source.interval*(e/this.source.dimensions.height):e/this.height;this.semantics=t.map(r=>{const a={x:(r.cx-i/2)/n,y:(r.cy-e/2)/n},o=this.source&&this.source.matrix?trans23(a,this.source.matrix):a;return this.createTextSemantic(r,o.x+this.width/2,o.y+this.height/2,n)})}assignPageTexts(t,[e,i]){const n=i/this.width,r=e/this.height;this.semantics=t.map(a=>this.createTextSemantic(a,a.cx/n,a.cy/r,n,r))}createTextSemantic(t,e,i,n,r=n){return{confidence:t.score,x:e,y:i,semantic:SemanticType.rect_Text,extension:{text:t.text,type:t.type,width:t.width/n,height:t.height/r,theta:t.theta,textFeature:t.feature_dict}}}assemble({textAnnotations:t=null}={},e=new DummyLogger){if(this.tokens=[],this.lyricTokens=[],this.systems.forEach(i=>i.tokens=[]),this.systems.length){const i=this.systems.map(r=>r.left),n=i[Math.floor((i.length-1)/2)];this.systems.forEach(r=>r.indent=r.left>n+INDENT_THRESHOLD)}if(this.semantics){const i=this.source?this.source.name:this.index.toString();this.semantics.forEach(n=>{hashPageSemanticPoint(i,n);const r={id:n.id,type:TokenType.Text,confidence:n.confidence,textType:TEXT_TYPE_ALIAS[n.extension.type]||n.extension.type,text:t&&t[n.id]||n.extension.text,textFeasure:n.extension.textFeature,width:n.extension.width,fontSize:n.extension.height};switch(n.semantic){case SemanticType.rect_Text:switch(r.textType){case TextType.Title:case TextType.Author:case TextType.PageMargin:case TextType.Other:this.tokens.push(new TextToken({x:n.x,y:n.y,...r}));break;case TextType.TempoNumeral:case TextType.Chord:case TextType.MeasureNumber:case TextType.Instrument:case TextType.Alternation1:case TextType.Alternation2:{const a=this.systems.find(o=>o.top+o.staffTop>n.y);a&&a.appendToken(new TextToken({x:n.x-a.left,y:n.y-a.top,...r}))}break;case TextType.Lyric:(this.lyricTokens||(this.lyricTokens=[])).push(new TextToken({x:n.x,y:n.y,...r}));break;case TextType.TextualMark:case TextType.Times:{const a=[...this.systems].reverse().find(o=>o.topo>=l.top&&oc>=u.left&&c(s[s.BOS=0]="BOS",s[s.PAD=1]="PAD",s[s.NoteheadS0=2]="NoteheadS0",s[s.NoteheadS1=3]="NoteheadS1",s[s.NoteheadS2=4]="NoteheadS2",s[s.NoteheadGrace=5]="NoteheadGrace",s[s.vline_Stem=6]="vline_Stem",s[s.Flag3=7]="Flag3",s[s.BeamLeft=8]="BeamLeft",s[s.BeamContinue=9]="BeamContinue",s[s.BeamRight=10]="BeamRight",s[s.Dot=11]="Dot",s[s.Rest0=12]="Rest0",s[s.Rest1=13]="Rest1",s[s.Rest2=14]="Rest2",s[s.Rest3=15]="Rest3",s[s.Rest4=16]="Rest4",s[s.Rest5=17]="Rest5",s[s.Rest6=18]="Rest6",s[s.TimeD2=19]="TimeD2",s[s.TimeD4=20]="TimeD4",s[s.TimeD8=21]="TimeD8",s[s.TimeN1=22]="TimeN1",s[s.TimeN2=23]="TimeN2",s[s.TimeN3=24]="TimeN3",s[s.TimeN4=25]="TimeN4",s[s.TimeN5=26]="TimeN5",s[s.TimeN6=27]="TimeN6",s[s.TimeN7=28]="TimeN7",s[s.TimeN8=29]="TimeN8",s[s.TimeN9=30]="TimeN9",s[s.TimeN10=31]="TimeN10",s[s.TimeN11=32]="TimeN11",s[s.TimeN12=33]="TimeN12",s))(SemanticElementType||{});const TIME_SIG_DENOMINATORS=Object.fromEntries([2,4,8].map(s=>[s,SemanticElementType[`TimeD${s}`]])),TIME_SIG_NUMERATORS=Object.fromEntries(Array(12).fill(null).map((s,t)=>t+1).map(s=>[s,SemanticElementType[`TimeN${s}`]])),et=SemanticElementType,ELEMENT_TOKEN_NAMES={[et.BOS]:"BOS",[et.NoteheadS0]:"noteheads-s0",[et.NoteheadS1]:"noteheads-s1",[et.NoteheadS2]:"noteheads-s2",[et.NoteheadGrace]:"GraceNotehead",[et.Flag3]:"flags-u3",[et.BeamLeft]:"BeamLeft",[et.BeamContinue]:"BeamContinue",[et.BeamRight]:"BeamRight",[et.Dot]:"dot",[et.Rest0]:"rests-0o",[et.Rest1]:"rests-1o",[et.Rest2]:"rests-2",[et.Rest3]:"rests-3",[et.Rest4]:"rests-4",[et.Rest5]:"rests-5",[et.Rest6]:"rests-6"},NOTEHEAD_BASE_DIVISION={[et.NoteheadS0]:0,[et.NoteheadS1]:1,[et.NoteheadS2]:2,[et.NoteheadGrace]:2},NOTEHEAD_ELEMENT_TYPES=[et.NoteheadS0,et.NoteheadS1,et.NoteheadS2,et.NoteheadGrace],REST_ELEMENT_TYPES=[et.Rest0,et.Rest1,et.Rest2,et.Rest3,et.Rest4,et.Rest5,et.Rest6],BEAM_ELEMENT_TYPES=[et.BeamLeft,et.BeamContinue,et.BeamRight],NOTE_ELEMENT_TYPES=[...NOTEHEAD_ELEMENT_TYPES,...REST_ELEMENT_TYPES],SOURCE_ELEMENT_TYPES=[...NOTEHEAD_ELEMENT_TYPES,...REST_ELEMENT_TYPES,et.vline_Stem],TARGET_ELEMENT_TYPES=[et.BOS,et.NoteheadS0,et.vline_Stem,...REST_ELEMENT_TYPES],ROOT_NOTE_ELEMENT_TYPES=[...NOTE_ELEMENT_TYPES,et.vline_Stem],ELEMENT_TO_STEMBEAM={[et.BeamLeft]:"Open",[et.BeamRight]:"Close"},metaElem=s=>({type:s,staff:-1,x:0,y1:0,y2:0}),BOS_ELEMENT=metaElem(0),fractionToElems=s=>[metaElem(TIME_SIG_NUMERATORS[s.numerator]),metaElem(TIME_SIG_DENOMINATORS[s.denominator])],argmax=(s,t)=>{const e=s.filter((n,r)=>t[r]),i=Math.max(...e);return s.findIndex(n=>n===i)};class SemanticCluster extends SimpleClass{index;elements;matrixH;_matrixV;groupsV;masks;static elementToJSON(t){const e={type:t.type,staff:t.staff,x:t.x,y1:t.y1,y2:t.y2};return t.id&&(e.id=t.id),e}constructor(t){super(),super.assign(t)}get sourceMask(){return this.elements.map(t=>SOURCE_ELEMENT_TYPES.includes(t.type))}get targetMask(){return this.elements.map(t=>TARGET_ELEMENT_TYPES.includes(t.type))}get vMask(){return this.elements.map(t=>ROOT_NOTE_ELEMENT_TYPES.includes(t.type))}get compactMatrixH(){if(!this.matrixH)return null;const t=this.sourceMask,e=this.targetMask;return this.matrixH.filter((i,n)=>t[n]).map(i=>i.filter((n,r)=>e[r]))}set compactMatrixH(t){this.matrixH=expandMatrixByMasks([].concat(...t),[this.sourceMask,this.targetMask])}get compactMatrixV(){if(!this._matrixV)return null;const t=this.vMask,e=this._matrixV.filter((i,n)=>t[n]).map(i=>i.filter((n,r)=>t[r]));return[].concat(...e.map((i,n)=>i.slice(0,n)))}set compactMatrixV(t){this.matrixV=t&&expandMatrixByMaskTriu(t,this.vMask)}get matrixV(){return this.groupsV&&matrixFromGroups(this.elements.length,this.groupsV)}set matrixV(t){if(!t){this.groupsV=null,this._matrixV=t;return}const e=.5,i=[],n=t.map((r,a)=>r.some(Number.isFinite)||t.some(o=>Number.isFinite(o[a])));t.forEach((r,a)=>{if(n[a]){let o=!1;for(let c=0;c=e){const l=i.findIndex(u=>u.includes(c));i[l].push(a),o=!0;break}o||i.push([a])}}),this.groupsV=i,this._matrixV=t}toJSON(){return{__prototype:"SemanticCluster",index:this.index,elements:this.elements.map(SemanticCluster.elementToJSON),compactMatrixH:this.compactMatrixH,compactMatrixV:this.compactMatrixV}}static mapMatrix(t,e,i){return e.reduce((r,a,o)=>(r[a]?r[a]=r[a].map((c,d)=>c+t[o][d]?1:0):r[a]=t[o],r),[]).map(r=>i.map(a=>r[a]))}mergeOverlapping(){const t=this.overlappedNoteheads();if(t.length){const e=this.elements.map((n,r)=>{const a=t.find(c=>r===c[1]),o=a?a[0]:r;return o-t.filter(c=>c[1]e.findIndex(a=>a===r));this.elements=i.map(n=>this.elements[n]),console.assert(this.elements.every(Boolean),"null element found:",this,e,i),this.matrixH=SemanticCluster.mapMatrix(this.matrixH,e,i),this.groupsV=this.groupsV.map(n=>Array.from(new Set(n.map(r=>e[r]))))}}overlappedNoteheads(){const t=[],e=this.elements.filter(i=>NOTEHEAD_ELEMENT_TYPES.includes(i.type));for(let i=0;iT),i=this.masks?this.masks[1]:e.map(m=>TARGET_ELEMENT_TYPES.includes(this.elements[m].type)),n=e.map(m=>this.elements[m].type===et.vline_Stem&&this.elements[m].y2-this.elements[m].y1>2),r=e.filter(m=>[et.NoteheadS1,et.NoteheadS2,et.NoteheadGrace].includes(this.elements[m].type)),a=e.filter(m=>this.elements[m].type===et.NoteheadS0),o=e.map(()=>!1),c={};r.forEach(m=>{const T=this.elements[m];e.filter(g=>n[g]).filter(g=>this.elements[g].y1-.5T.y1).sort((g,v)=>this.matrixH[m][v]-this.matrixH[m][g]).slice(0,2).filter((g,v)=>v===0||this.matrixH[m][g]>=t).forEach(g=>{c[g]=c[g]||[],c[g].push(m)})}),a.forEach(m=>{const T=this.elements[m],x=argmax(this.matrixH[m],i),g=this.elements[x];g.type===et.NoteheadS0&&Math.abs(T.x-g.x)<2.6?(o[m]=!0,c[x]=c[x]||[x],c[x].push(m)):c[m]=c[m]||[m]});const d={},l=e.filter(m=>c[m]||REST_ELEMENT_TYPES.includes(this.elements[m].type));l.sort((m,T)=>this.elements[m].x-this.elements[T].x);const u=e.map(m=>m===et.BOS);l.forEach(m=>{const T=argmax(this.matrixH[m],u);d[m]=T,T&&!REST_ELEMENT_TYPES.includes(this.elements[T].type)&&(u[T]=!1),u[m]=!0});const h=this.elements.filter(m=>m.type===et.Dot),y=this.elements.filter(m=>m.type===et.Flag3),f=this.elements.filter(m=>BEAM_ELEMENT_TYPES.includes(m.type)),p=this.groupsV;return l.map(m=>{const T=this.elements[m],x=p?p.findIndex(g=>g.includes(m)):null;if(REST_ELEMENT_TYPES.includes(T.type)){const g=h.filter(v=>v.x>T.x+.5&&v.xT.y1-1&&v.y1this.elements[A]),v=Math.min(...g.map(A=>A.x-.7)),S=Math.max(...g.map(A=>A.x+.7));g.sort((A,N)=>N.y1-A.y1);const E=g.map(A=>A.y1),k=g.map(A=>A.id),O=E[0],M=E[E.length-1],_=h.filter(A=>A.x>S&&A.xO-1&&A.y1{const F=roundNumber(N.y1,.5);return A[F]=A[F]||[],A[F].push(N),A},{}),R=Math.max(...Object.values(_).map(A=>A.length),0);let I=NOTEHEAD_BASE_DIVISION[g[0].type],D=null,w=null,B=null;if(T.type===et.vline_Stem){const A=O-T.y1,N=T.y2-M;if(D=A>N?"u":"d",B={x:T.x,y:D==="u"?T.y1:T.y2},I===2){const H=D==="u"?[T.y1-.4,T.y2-1]:[T.y1+1,T.y2+.4],W=y.filter(P=>Math.abs(P.x-T.x)<.2&&P.y1>H[0]&&P.y1Math.abs(H.x-T.x)<.2&&H.y1>F[0]&&H.y1[n,SemanticElementType[i]]).filter(([i,n])=>i!==n).reduce((i,[n,r])=>(i[n]=r,i),{});this.clusters.forEach(i=>i.elements.forEach(n=>{Number.isFinite(e[n.type])&&(n.type=e[n.type])}))}}toJSON(){return{__prototype:"SemanticClusterSet",vocab:Object.entries(SemanticElementType).filter(e=>Number.isFinite(e[1])).map(e=>e[0]),clusters:this.clusters.map(e=>e.toJSON())}}}const expandMatrixByMasks=(s,t)=>{const i=function*(){for(const a of s)yield a}(),[n,r]=t;return n.map(a=>r.map(o=>a&&o?i.next().value:null))},expandMatrixByMaskTriu=(s,t)=>{const i=function*(){for(const n of s)yield n}();return t.map((n,r)=>t.map((a,o)=>n&&a&&o{const e=Array(s).fill(null).map((i,n)=>t.findIndex(r=>r.includes(n)));return Array(s).fill(null).map((i,n)=>Array(s).fill(null).map((r,a)=>{if(a>=n)return null;const o=e[n],c=e[a];return o<0||c<0?null:o===c?1:0}))};var sha256={exports:{}},core={exports:{}},hasRequiredCore;function requireCore(){return hasRequiredCore||(hasRequiredCore=1,function(s,t){(function(e,i){s.exports=i()})(commonjsGlobal,function(){var e=e||function(i,n){var r;if(typeof window<"u"&&window.crypto&&(r=window.crypto),typeof self<"u"&&self.crypto&&(r=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(r=globalThis.crypto),!r&&typeof window<"u"&&window.msCrypto&&(r=window.msCrypto),!r&&typeof commonjsGlobal<"u"&&commonjsGlobal.crypto&&(r=commonjsGlobal.crypto),!r&&typeof commonjsRequire=="function")try{r=require$$5}catch{}var a=function(){if(r){if(typeof r.getRandomValues=="function")try{return r.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof r.randomBytes=="function")try{return r.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},o=Object.create||function(){function x(){}return function(g){var v;return x.prototype=g,v=new x,x.prototype=null,v}}(),c={},d=c.lib={},l=d.Base=function(){return{extend:function(x){var g=o(this);return x&&g.mixIn(x),(!g.hasOwnProperty("init")||this.init===g.init)&&(g.init=function(){g.$super.init.apply(this,arguments)}),g.init.prototype=g,g.$super=this,g},create:function(){var x=this.extend();return x.init.apply(x,arguments),x},init:function(){},mixIn:function(x){for(var g in x)x.hasOwnProperty(g)&&(this[g]=x[g]);x.hasOwnProperty("toString")&&(this.toString=x.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),u=d.WordArray=l.extend({init:function(x,g){x=this.words=x||[],g!=n?this.sigBytes=g:this.sigBytes=x.length*4},toString:function(x){return(x||y).stringify(this)},concat:function(x){var g=this.words,v=x.words,S=this.sigBytes,E=x.sigBytes;if(this.clamp(),S%4)for(var k=0;k>>2]>>>24-k%4*8&255;g[S+k>>>2]|=O<<24-(S+k)%4*8}else for(var M=0;M>>2]=v[M>>>2];return this.sigBytes+=E,this},clamp:function(){var x=this.words,g=this.sigBytes;x[g>>>2]&=4294967295<<32-g%4*8,x.length=i.ceil(g/4)},clone:function(){var x=l.clone.call(this);return x.words=this.words.slice(0),x},random:function(x){for(var g=[],v=0;v>>2]>>>24-E%4*8&255;S.push((k>>>4).toString(16)),S.push((k&15).toString(16))}return S.join("")},parse:function(x){for(var g=x.length,v=[],S=0;S>>3]|=parseInt(x.substr(S,2),16)<<24-S%8*4;return new u.init(v,g/2)}},f=h.Latin1={stringify:function(x){for(var g=x.words,v=x.sigBytes,S=[],E=0;E>>2]>>>24-E%4*8&255;S.push(String.fromCharCode(k))}return S.join("")},parse:function(x){for(var g=x.length,v=[],S=0;S>>2]|=(x.charCodeAt(S)&255)<<24-S%4*8;return new u.init(v,g)}},p=h.Utf8={stringify:function(x){try{return decodeURIComponent(escape(f.stringify(x)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(x){return f.parse(unescape(encodeURIComponent(x)))}},m=d.BufferedBlockAlgorithm=l.extend({reset:function(){this._data=new u.init,this._nDataBytes=0},_append:function(x){typeof x=="string"&&(x=p.parse(x)),this._data.concat(x),this._nDataBytes+=x.sigBytes},_process:function(x){var g,v=this._data,S=v.words,E=v.sigBytes,k=this.blockSize,O=k*4,M=E/O;x?M=i.ceil(M):M=i.max((M|0)-this._minBufferSize,0);var b=M*k,_=i.min(b*4,E);if(b){for(var R=0;R>>7)^(M<<14|M>>>18)^M>>>3,_=u[O-2],R=(_<<15|_>>>17)^(_<<13|_>>>19)^_>>>10;u[O]=b+u[O-7]+R+u[O-16]}var I=v&S^~v&E,D=m&T^m&x^T&x,w=(m<<30|m>>>2)^(m<<19|m>>>13)^(m<<10|m>>>22),B=(v<<26|v>>>6)^(v<<21|v>>>11)^(v<<7|v>>>25),C=k+B+I+l[O]+u[O],A=w+D;k=E,E=S,S=v,v=g+C|0,g=x,x=T,T=m,m=C+A|0}p[0]=p[0]+m|0,p[1]=p[1]+T|0,p[2]=p[2]+x|0,p[3]=p[3]+g|0,p[4]=p[4]+v|0,p[5]=p[5]+S|0,p[6]=p[6]+E|0,p[7]=p[7]+k|0},_doFinalize:function(){var y=this._data,f=y.words,p=this._nDataBytes*8,m=y.sigBytes*8;return f[m>>>5]|=128<<24-m%32,f[(m+64>>>9<<4)+14]=i.floor(p/4294967296),f[(m+64>>>9<<4)+15]=p,y.sigBytes=f.length*4,this._process(),this._hash},clone:function(){var y=o.clone.call(this);return y._hash=this._hash.clone(),y}});n.SHA256=o._createHelper(h),n.HmacSHA256=o._createHmacHelper(h)}(Math),e.SHA256})})(sha256);var sha256Exports=sha256.exports;const _SHA256=getDefaultExportFromCjs(sha256Exports),SHA256=s=>{const{words:t,sigBytes:e}=_SHA256(s),i=t.map(r=>r<0?r+4294967296:r),n=e/t.length;return new Uint8Array(e).map((r,a)=>i[Math.floor(a/n)]>>(3-a%n)*8&255)},HASH_LEN=256;class HashVector{fields;static fromHash(t){const e=[];for(const i of t)for(let n=0;n<8;++n)e.push(i>>n&1?1:-1);return new HashVector(e)}static fromString(t){const e=SHA256(t);return HashVector.fromHash(e)}static fromWords(t){return t.map(i=>HashVector.fromString(i)).reduce((i,n)=>i.add(n),HashVector.zero)}static concat(...t){const e=t.map(i=>i.fields).flat(1);return new HashVector(e)}constructor(t=null){this.fields=t||Array(HASH_LEN).fill(0)}get length(){return this.fields.length}toHash(){return Uint8Array.from(Array(this.length/8).fill(0).map((t,e)=>this.fields.slice(e*8,(e+1)*8).reduce((n,r,a)=>n|(r>0?1:0)<this.fields[i]=e+t.fields[i]),this}scale(t){return this.fields=this.fields.map(e=>e*t),this}sub(t){const e=t>0?this.fields.slice(0,t):this.fields.slice(t);return new HashVector(e)}static get zero(){return new HashVector}}const odds=s=>{let t=0;for(let e=s;e>0;e>>=1)e%2&&++t;return t},ODDS=Array(2**8).fill(0).map((s,t)=>odds(t));ODDS.reduce((s,t,e)=>({...s,[("0"+e.toString(16)).slice(-2)]:t}),{});const countOnes=s=>s.reduce((t,e)=>t+ODDS[e],0),xorHashes=(s,t)=>s.map((e,i)=>e^t[i]),cosHashes=(s,t)=>{const e=s.length*8,i=xorHashes(s,t),n=countOnes(i);return(e-n*2)/e},i2hex=s=>("0"+s.toString(16)).slice(-2),hashToHex=s=>Array.from(s).map(i2hex).join(""),hashToBigInt=s=>Array.from(s).reduce((t,e)=>t*0x100n+BigInt(e),0n),emptyVoiceFromStaffMeasure=(s,t=!1)=>({empty:!0,duration:s.duration,tickMap:{0:EventTerm.space({duration:s.duration,tick:0})},timeSignature:s.timeSignature,timeSigNumeric:s.timeSigNumeric,keySignature:s.keySignature,contextedTerms:s.terms.filter(e=>e instanceof ContextedTerm&&(!e.staffLevel||t)),marks:[]}),removeEmptyMeasuresInVoicesStaves=s=>{if(!(s[0]&&s[0].voices[0])){console.warn("empty voices:",s);return}const t=s[0].voices[0].measures.length;Array(t).fill(null).map((i,n)=>{for(const r of s)for(const a of r.voices)if(!a.measures[n].empty)return!1;return!0}).forEach((i,n)=>{i&&s.forEach(r=>r.voices.forEach(a=>{const o=a.measures[n];o.tickMap={}}))})},moveFirstSystemTempoToHead=(s,t)=>{var i,n,r;const e=(n=(i=s[0])==null?void 0:i.voices[0])==null?void 0:n.measures[0];if(!(!e||t<=0))for(const a of s)for(const o of a.voices)for(const c of o.measures.slice(0,t)){const d=(r=c==null?void 0:c.marks)==null?void 0:r.findIndex(l=>l instanceof TempoTerm);if(d>=0){const[l]=c.marks.splice(d,1);l.tick=0,e.marks=[l,...e.marks.filter(u=>!(u instanceof TempoTerm))];return}}},filterSyntheticOctaveZeroContexts=s=>{const t=Array(s.length).fill(0),e=Math.max(0,...s.flatMap(i=>i.voices.map(n=>n.measures.length)));for(let i=0;io.measures[i]).filter(Boolean);if(!r.length)continue;let a=t[n];for(const o of r)o.contextedTerms=o.contextedTerms.filter(c=>{if(!(c instanceof ContextedTerm)||c.type!==ContextType.OctaveShift)return!0;const d=c.octaveShift;return c.tokenType===TokenType.OctaveShift0&&!c.id&&c.x===0&&a===0?!1:(a=d,!0)});t[n]=a}},markingTiesInVoice=s=>{const t=[].concat(...s.measures.map(e=>Object.values(e.tickMap).filter(i=>i instanceof EventTerm)));for(let e=1;er.type===TokenType.SlurBegin)&&n.accessories.some(r=>r.type===TokenType.SlurEnd)){const r=i.pitches.filter(a=>n.pitches.some(o=>o.note===a.note&&o.alter===a.alter));r.length>0&&(i.tying=!0,n.tied=!0,r.forEach(a=>{a.tying=!0;const o=n.pitches.find(c=>c.note===a.note&&c.alter===a.alter);o.tied=!0}),r.forEach(()=>{const a=i.accessories.findIndex(c=>c.type===TokenType.SlurBegin);a>=0&&i.accessories.splice(a,1);const o=n.accessories.findIndex(c=>c.type===TokenType.SlurEnd);o>=0&&n.accessories.splice(o,1)}))}}};class Spartito extends SimpleClass{static className="Spartito";stavesCount;staffGroups;measures;tags;constructor(t){super(),super.assign(t),this.measures.forEach(e=>e.staffGroups=this.staffGroups)}get regulated(){return this.measures.every(t=>t.regulated)}get solidMeasureCount(){return this.measures.filter(t=>!t.empty).length}get measureIndexMapping(){let t=0;return this.measures.map(e=>e.empty?null:t++)}get headBPM(){for(const t of this.measures)if(t.marks){const e=t.marks.find(i=>i instanceof TempoTerm&&i.isValid());if(e)return e.bpm}return null}get measureLayoutCode(){const t=this.measures.filter(e=>!e.empty).map((e,i)=>({index:i+1,vb:e.voltaBegin,ve:e.voltaEnd,alter:e.alternative,leftSign:"",rightSign:""}));return t.forEach((e,i)=>{if(e.vb){const n=t.slice(i+1).findIndex(a=>a.vb),r=n>=0?i+n:t.length;t.slice(i,r-1).some(a=>a.ve)&&(e.leftSign="2*[")}if(e.ve){const n=t.slice(0,i+1).reverse(),r=n.slice(1).findIndex(a=>a.ve);if(r>=0&&!n.slice(1,r+1).some(a=>a.vb))return;if(e.alter){const a=n.findIndex(o=>!o.alter);a>0&&(n[a].rightSign="]",n[a-1].leftSign="{[",e.rightSign="],",t[i+1]&&(t[i+1].rightSign="},"))}else e.rightSign="],";n.some(a=>a.vb)||(t[0].leftSign="2*[")}}),t.map(e=>e.leftSign+e.index.toString()+e.rightSign+(e.rightSign?"":",")).join(" ").replace(/,$/,"")}get qualityScore(){const t=this.measures.filter(n=>!n.empty),i=t.map(evaluateMeasure).map(n=>n.qualityScore).reduce((n,r)=>n+r,0);return t.length?i/t.length:null}dumpEvaluations(){const t=this.measures.filter(n=>!n.empty).map(n=>({measureIndex:n.measureIndex,...evaluateMeasure(n)})),i=t.map(n=>n.qualityScore).reduce((n,r)=>n+r,0);console.log("qualityScore:",i/t.length),console.table(t)}regulate(t={}){this.measures.forEach(e=>e.regulated||e.regulate(t))}cleanupRegulation(){this.measures.forEach(t=>t.voices=null)}rectifyTimeSignatures(t=new DummyLogger){const e=this.measures.map((n,r)=>({measure:n,index:r})).filter(({measure:n,index:r})=>!r||n.timeSignatureChanged).map(({index:n})=>n);e.map((n,r)=>this.measures.slice(n,rn.filter(r=>r.estimatedDuration>0)).filter(n=>n.length>=3||n.some(r=>r.doubtfulTimesig)).forEach(n=>{if(n[0].patched){const y=n[0].timeSignature,f=n.slice(1).filter(p=>!p.patched&&printFraction(p.timeSignature)!==printFraction(y));if(f.length){const p=f[0].timeSignature;f.forEach(m=>m.basics.forEach(T=>T.timeSignature=y)),t.info("[rectifyTimeSignatures] timesignator overwrote by patched head:",`${printFraction(p)} -> ${printFraction(y)}`,f.map(m=>m.measureIndex))}return}const r=n[0].timeSignature,a=Number.isInteger(Math.log2(r.denominator));let o=a?4:8;a&&(o=Math.max(o,n[0].timeSignature.denominator));const c=n.map(y=>Math.round(y.estimatedDuration*o/WHOLE_DURATION)),d=Object.entries(c.reduce((y,f)=>(y[f]=(y[f]||0)+1,y),{})).sort((y,f)=>f[1]-y[1]),l=d[0][1],h=d.filter(([y,f])=>f>l*.6).reduce((y,f)=>Number(f[0])>Number(y[0])?f:y);if(h[1]>1){let y=Number(h[0]);if(!a||r.denominator*y!==r.numerator*o){if(a&&o!==r.denominator){const m=y*r.denominator/o;Number.isInteger(m)&&(y=m,o=r.denominator)}const f=n.filter(m=>!m.patched),p=frac(y,o);f.forEach(m=>m.basics.forEach(T=>T.timeSignature=p)),t.info("[rectifyTimeSignatures] timesignator overwrote by estimation:",`${printFraction(r)} -> ${y}/${o}`,f.map(m=>m.measureIndex))}}})}makeVoiceStaves(){var d,l,u;this.regulate();const t=Math.max(...this.measures.map(h=>{var y;return h.voices.length?h.voices.length:(y=h.events)!=null&&y.some(f=>f==null?void 0:f.grace)?1:0}));if(!t||!Number.isFinite(t))return null;this.measures.filter(h=>h.patched).forEach(h=>{h.events.forEach(y=>{y.tied&&y.pitches.forEach(f=>f.tied=!0)})});for(let h=0;hv.staff===p))||[]).reduce((v,S)=>Math.max(v,S.x||0),-1/0);if(!Number.isFinite(x))continue;const g=[];y.contexts[p]=m.filter(v=>v.type===0&&v.x>x?(g.push(v),!1):!0),g.length>0&&f.contexts[p]&&(g.forEach(v=>v.tick=0),f.contexts[p]=[...g,...f.contexts[p]])}}const e=this.measures.map(h=>{var x,g;console.assert(h.validRegulated,"[makeVoiceStaves] measure is invalid:",h);const y={};h.events.forEach(v=>y[v.id]=v);const f=new Set(Array(h.contexts.length).fill(null).map((v,S)=>S));let p=null;if(h.barType)switch(h.barType){case"Segment":p="||";break;case"Terminal":p="|.";break}const T=(h.voices.length?h.voices:(x=h.events)!=null&&x.some(v=>v==null?void 0:v.grace)?[h.events.filter(v=>v==null?void 0:v.grace).map(v=>v.id)]:[]).map(v=>{var C;const S=v.map(A=>y[A]);S.sort((A,N)=>A.tick-N.tick);const E={},k=A=>{let N=`t${A.tick}`,F=1;for(;E[N];)N=`t${A.tick}:${F++}`;E[N]=A},O=S.find(A=>A&&!A.zeroHolder&&!A.grace),M=S.filter(A=>(A==null?void 0:A.grace)&&(!O||A.xA.id);if(M.length&&(!O||O.tick!==0)){const A=EventTerm.space({tick:0,duration:0});A.staff=((C=S.find(N=>(N==null?void 0:N.grace)&&N.tick===0))==null?void 0:C.staff)??0,A.graceIds=M,A.placeholder=!0,k(A),M.forEach(N=>{const F=h.eventMap[N];F&&k(F)})}let b=0,_=null;for(const A of S){if(!Number.isFinite(A==null?void 0:A.tick)){console.warn("invalid event tick:",A);continue}M.includes(A.id)||(A.tick>b?k(EventTerm.space({tick:b,duration:A.tick-b})):!A.grace&&A.tick{const F=h.eventMap[N];F&&k(F)})))}h.endEvent&&h.endEvent.graceIds&&h.endEvent.graceIds.forEach(A=>{const N=h.eventMap[A];N&&(!_||N.staff===_.staff)&&k(N)}),_&&bh.duration&&Number.isFinite(h.duration)&&(_.timeWarp=reducedFraction(h.duration-_.tick,_.duration)),console.assert(!_||!_.timeWarp||Number.isInteger(_.timeWarp.numerator)&&Number.isInteger(_.timeWarp.denominator),"invalid time warp:",_);const R=S[0]?S[0].staff:0;f.delete(R);const I=h.basics[R],D=h.contexts[R],w=S[S.length-1],B=w?w.staff:0;return{tickMap:E,duration:h.duration,...I,contextedTerms:D,marks:[],break:h.break,pageBreak:h.pageBreak,headStaff:R,tailStaff:B,bar:p}});for(;T.lengthM.headStaff!==v),O=emptyVoiceFromStaffMeasure({terms:E,duration:h.duration,...S,break:h.break,pageBreak:h.pageBreak},k);O.headStaff=v,O.tailStaff=v,T.push(O)}return(g=h.marks)!=null&&g.length&&(T[0].marks=h.marks),T});e.forEach(h=>h.forEach(y=>{const f=[];y.empty||(f.push(`s${y.headStaff}`),f.push(`s${y.tailStaff}`)),Object.values(y.tickMap).forEach(p=>{if(p instanceof EventTerm){if(f.push(`s${p.staff}`),p.stemDirection){const m=`st${p.staff}-${p.stemDirection}`;f.push(m,m)}p.grace?f.push(`gd${p.mainDuration}`):f.push(`d${p.mainDuration}`),p.rest?f.push("r-"+p.rest):p.pitches.forEach(m=>{f.push(`p1-${m.note}`),f.push(`p8-${Math.round(m.note/8)}`)})}}),y.trait=HashVector.fromWords(f)}));const i=this.staffGroups.flat(1).reduce((h,y)=>(h[y]=this.staffGroups.findIndex(f=>f.includes(y)),h),{}),n=Array(t).fill(null).map((h,y)=>({vector:HashVector.zero,index:y,weight:0,headStaff:null}));e.forEach((h,y)=>{n.sort((p,m)=>m.weight-p.weight);const f=new Set(h);n.forEach(p=>{const m=[...f];let T=m[0];if(y>0&&m.length>1){const x=m.map(g=>i[g.headStaff]===i[p.headStaff]?cosHashes(p.vector.toHash(),g.trait.toHash()):-1);T=m[argmax$1(x)]}f.delete(T),T.voiceIndex=p.index,p.vector.scale(.4).add(T.trait),p.weight=Object.keys(T.tickMap).length,y===0&&(p.headStaff=T.headStaff)}),h.sort((p,m)=>p.voiceIndex-m.voiceIndex)});const r=Array(this.stavesCount).fill(null).map(()=>[]);n.forEach(h=>{r[h.headStaff].push(h.index)});const a=Array(this.stavesCount).fill(null).map((h,y)=>e[0]?{voices:r[y].map(m=>({mode:"relative",measures:e.map(T=>T[m])}))}:{voices:[]}),o=(u=(l=this.measures.find(h=>!h.empty))==null?void 0:l.position)==null?void 0:u.systemIndex,c=Number.isFinite(o)?this.measures.findIndex(h=>{var y;return!h.empty&&((y=h.position)==null?void 0:y.systemIndex)!==o}):0;return removeEmptyMeasuresInVoicesStaves(a),moveFirstSystemTempoToHead(a,c<0?this.measures.length:c),filterSyntheticOctaveZeroContexts(a),a.forEach(h=>h.voices.forEach(markingTiesInVoice)),a}perform(){const t=this.makeVoiceStaves();if(!t)return null;const e=new Map,i=Array(this.stavesCount).fill(null).reduce((l,u,h)=>(l[h]=h,l),{}),n=[].concat(...t.map((l,u)=>l.voices.map(()=>i[u])));let r=!1,a=0,o=null;const c=this.measures.filter(l=>!l.empty).map(l=>{const{systemIndex:u,right:h}=l.position,y=l.measureIndex,f=[].concat(...t.map(v=>v.voices.map(S=>S.measures[y]))),p=f[0],m=a;a+=p.duration;const T=[].concat(...f.map((v,S)=>{const k=n[S],O=Object.values(v.tickMap).filter(M=>M instanceof EventTerm&&!M.rest).map(M=>{const b=Math.round(M.duration*1);console.assert(Number.isFinite(M.tick),"invalid event term tick:",M),console.assert(Number.isFinite(b),"invalid event term duration:",M),M.tick>=0&&M.noteIds.forEach(R=>{e.set(R,{system:u,measure:y,x:M.roundX,endX:h})});const _=this.staffGroups.findIndex(R=>R.includes(M.staff));return{tick:Math.round(M.tick*1),duration:b,pitches:M.pitches,noteIds:M.noteIds,part:_,staff:M.staff}});return[].concat(...O.map(M=>{const b=M.pitches.reduce((R,I)=>(R[noteToPitch(I)]=I,R),{});return Object.values(b).sort((R,I)=>R.note-I.note).filter(R=>!R.tied).map((R,I)=>{const D=noteToPitch(R),w=M.noteIds&&M.noteIds[I];return{tick:M.tick,pitch:D,duration:M.duration,chordPosition:{index:I,count:M.pitches.length},tied:R.tied,id:w,ids:[w],track:M.part,staff:M.staff,channel:k,subNotes:[{startTick:0,endTick:M.duration,pitch:D,velocity:127}]}})}))})),x=[];o=o||x,l.marks&&l.marks.forEach(v=>{if(v instanceof TempoTerm){const S=v.bpm;if(v.isValid()){const E=r?x:o,k=r?v.tick:0;E.push({track:0,ticks:k,data:{type:"meta",subtype:"setTempo",microsecondsPerBeat:Math.round(6e7/S)}}),r=!0}}});const g=l.basics[0];return{tick:m,duration:l.duration,notes:T,events:x,timeSignature:g&&g.timeSignature,keySignature:g&&g.keySignature}});return r||c[0].events.push({track:0,ticks:0,data:{type:"meta",subtype:"setTempo",microsecondsPerBeat:5e5}}),{notation:new MetaNotation({measures:c}),tokenMap:e}}performByEstimation(){const t=new Map;let e=0;const i=this.measures.filter(r=>r.events.some(a=>a.predisposition)).map(r=>{const a=e,o=Math.round(r.estimatedDuration||fractionMul(WHOLE_DURATION,r.timeSignature)),c=r.basics[0];e+=o;const{systemIndex:d,right:l}=r.position,u=r.measureIndex,y=r.events.filter(f=>f.predisposition&&f.predisposition.fake<.5&&!f.rest).map(f=>{const p=Math.round(f.predisposition.tick);return f.noteIds.forEach(m=>{t.set(m,{system:d,measure:u,x:f.roundX,endX:l})}),f.pitches.map((m,T)=>{const x=noteToPitch(m),g=f.noteIds&&f.noteIds[T],v=this.staffGroups.findIndex(S=>S.includes(f.staff));return{tick:p,pitch:x,duration:f.duration,chordPosition:{index:T,count:f.pitches.length},tied:m.tied,id:g,ids:[g],track:v,staff:f.staff,channel:0,subNotes:[{startTick:0,endTick:f.duration,pitch:x,velocity:127}]}})}).flat(1);return{tick:a,duration:o,notes:y,events:[],timeSignature:c&&c.timeSignature,keySignature:c&&c.keySignature}});return{notation:new MetaNotation({measures:i}),tokenMap:t}}featureHash(){const e=this.measures.slice(0,16).map(n=>n.featureWords),i=[1,4,16].map(n=>{const r=e.slice(0,n).filter(Boolean),a=r.map(h=>h[0]).flat(1),o=r.map(h=>h[1]).flat(1),c=r.map(h=>h[2]).flat(1),[d,l,u]=[a,o,c].map(HashVector.fromWords);return HashVector.concat(d,l.sub(128),u.sub(128))});return HashVector.concat(...i).toHash()}featureHashHex(){return hashToHex(this.featureHash())}featureHashBigInt(){return hashToBigInt(this.featureHash())}assignMeasureNumbers(){let t=null;for(const e of this.measures)!e.discard&&!e.events.length||(e.indent&&(t=null),Number.isFinite(t)||(t=e.partialDuration?0:1),e.measureNumber=t++)}}const GROUP_N_TO_PITCH=[0,2,4,5,7,9,11],MIDDLE_C=60,mod7=s=>{let t=s%7;for(;t<0;)t+=7;return t},mod12=s=>{let t=s%12;for(;t<0;)t+=12;return t},PHONETS="CDEFGAB",ALTER_NAMES={[-2]:"♭♭",[-1]:"♭",0:"♮",1:"♯",2:"𝄪"};class StaffContext{logger=new DummyLogger;clef=-3;keyAlters=[];octaveShift=0;alters=[];timeSignature={numerator:4,denominator:4};timeSigNumeric=!1;timeSigNumSet=!1;timeSigDenSet=!1;doubtingTimesig=!0;change(t){switch(t.type){case ContextType.Clef:this.clef=t.clef;break;case ContextType.KeyAcc:this.keyAlters[mod7(this.yToNote(t.y))]=t.alter;break;case ContextType.Acc:this.alters[this.yToNote(t.y)]=t.alter;break;case ContextType.OctaveShift:this.octaveShift=t.octaveShift;break;case ContextType.TimeSignatureC:switch(this.timeSigNumeric=!1,t.tokenType){case"timesig-C44":this.timeSignature.numerator=4,this.timeSignature.denominator=4;break;case"timesig-C22":this.timeSignature.numerator=2,this.timeSignature.denominator=2;break}this.doubtingTimesig=this.partialTimeSignature;break;case ContextType.TimeSignatureN:switch(this.timeSigNumeric=!0,t.y){case 1:this.timeSigDenSet?this.timeSignature.denominator=this.timeSignature.denominator*10+t.number:this.timeSignature.denominator=t.number,this.timeSigDenSet=!0;break;case-1:this.timeSigNumSet?this.timeSignature.numerator=this.timeSignature.numerator*10+t.number:this.timeSignature.numerator=t.number,this.timeSigNumSet=!0;break;default:this.logger.warn("unexpected time signature Y:",t.y)}this.doubtingTimesig=this.partialTimeSignature;break}}resetMeasure(){this.alters=[],this.timeSigNumSet=!1,this.timeSigDenSet=!1}resetSystem(){this.keyAlters=[]}get keySignature(){return this.keyAlters.filter(t=>Number.isInteger(t)).reduce((t,e)=>t+e,0)}get partialTimeSignature(){return!this.timeSigNumSet!=!this.timeSigDenSet}noteToY(t){return-t/2-this.clef-this.octaveShift*3.5}pitchToNote(t,{preferredAlter:e=null}={}){e||(e=this.keySignature<0?-1:1);const i=Math.floor((t-MIDDLE_C)/12),n=mod12(t),r=GROUP_N_TO_PITCH.includes(n)?n:mod12(n-e),a=GROUP_N_TO_PITCH.indexOf(r);this.logger.assert(a>=0,"invalid preferredAlter:",t,e,r);const o=i*7+a,c=n-r,d=this.keyAlters[a]||0,u=Number.isInteger(this.alters[o])?c:c===d?null:c;return{note:o,alter:u}}pitchToY(t,{preferredAlter:e=null}={}){const{note:i,alter:n}=this.pitchToNote(t,{preferredAlter:e});return{y:this.noteToY(i),alter:n}}yToNote(t){return this.logger.assert(Number.isInteger(t*2),"invalid y:",t),(-t-this.octaveShift*3.5-this.clef)*2}alterOnNote(t){if(Number.isInteger(this.alters[t]))return this.alters[t];const e=mod7(t);return Number.isInteger(this.keyAlters[e])?this.keyAlters[e]:0}noteToPitch(t){const e=Math.floor(t/7),i=mod7(t),n=MIDDLE_C+e*12+GROUP_N_TO_PITCH[i]+this.alterOnNote(t);return Number.isFinite(n)?n:(this.logger.warn("invalid pitch value:",n,t,e,i),-1)}yToPitch(t){return this.noteToPitch(this.yToNote(t))}yToPitchName(t){const e=this.yToNote(t),i=Math.floor(e/7),n=mod7(e);let r=this.alterOnNote(e);return!r&&!Number.isInteger(this.alters[e])&&(r=null),`${ALTER_NAMES[r]?ALTER_NAMES[r]:""}${PHONETS[n]}${i+4}`}}const VERSION=14,GRAND_STAFF_LAYOUT="{-}",processStaffContext=(s,t=new DummyLogger)=>{const e=new StaffContext;e.logger=t;for(const i of s.rows){for(const n of i){const r=n.terms.find(o=>o instanceof EventTerm);let a=r?Math.min(r.tick,0):0;n.terms.forEach(o=>{if(o instanceof ContextedTerm)o.tick=a,e.change(o);else if(o instanceof EventTerm){const c=o.tick+(o.duration||0);c>a&&(a=c),o.ys&&(o.pitches=o.ys.map(d=>{const l=e.yToNote(d),u=e.alterOnNote(l);return{note:l,alter:u,octaveShift:e.octaveShift}}))}}),n.timeSignature={...e.timeSignature},n.timeSigNumeric=e.timeSigNumeric,n.doubtfulTimesig=e.doubtingTimesig||!Number.isInteger(Math.log2(n.timeSignature.denominator))||n.timeSignature.numerator<=n.timeSignature.denominator/4,n.keySignature=e.keySignature,n.duration===0&&(n.duration=WHOLE_DURATION*n.timeSignature.numerator/n.timeSignature.denominator),e.resetMeasure()}e.resetSystem()}},upgradeScoreData=s=>{if(s.version<3){const{version:t,stavesCount:e,layoutTemplate:i,...n}=s;let r=e>1?Array(e-1).fill(",").join(""):"";e===2&&(r="{-}"),s={version:3,staffLayoutCode:r,...n}}return s.version<8&&(s.pages.forEach(t=>{t.systems.forEach(e=>{if(e.semantics){const i=e.semantics.filter(n=>n.semantic===SemanticType.vline_BarMeasure);e.semantics=[].concat(...e.staves.map(n=>{const r=n.top+n.staffY;return i.map(a=>({...a,y:a.y+r,extension:{...a.extension,y1:a.extension.y1+r,y2:a.extension.y2+r}}))}))}})}),s.version=8),s.version<9&&(s.spartito=null,s.version=9),s},bitsToMask=s=>s.reduce((t,e,i)=>e?t|1<t.systems))}get measureCount(){return this.systems.reduce((t,e)=>t+(e.measureCount||0),0)}get imageKeys(){return[...this.pages.map(t=>{var e;return(e=t.source)==null?void 0:e.url}),...this.systems.map(t=>t.backgroundImage),...[].concat(...this.systems.map(t=>[...t.staves.map(e=>e.backgroundImage),...t.staves.map(e=>e.maskImage)].filter(Boolean)))].filter(Boolean)}get breakSystemIndices(){const t=[];let e=0;return this.pages.forEach((i,n)=>{nt.staves.length),0)}get sidBlackList(){const t=[].concat(...this.systems.map(e=>e.sidBlackList));return new Set(t)}get sidWhiteList(){const t=[].concat(...this.systems.map(e=>e.sidWhiteList));return new Set(t)}get semanticHash(){const t=[].concat(...this.systems.map(e=>[].concat(...e.staves.map(i=>i.semantics?e.qualifiedSemantics(i.semantics).map(n=>n.id):[]))));return sha1(t.join(""))}eventSystemsToTermStaves(t,e=new DummyLogger){const i=Array(this.maxStavesCount).fill(null).map((n,r)=>({rows:t.map((a,o)=>a.columns.map((c,d)=>{const l=c.rows[r];console.assert(l,"[eventSystemsToTermStaves] measure is null:",r,c.rows);const u=l.contexts;d===0&&(u.some(f=>f.type===ContextType.OctaveShift)||u.unshift(new ContextedTerm({staff:r,x:0,y:0,tokenType:TokenType.OctaveShift0,tick:0})));const h=[...l.events||[],...u].sort((f,p)=>f.x-p.x),y=r===0&&d===a.columns.length-1&&this.breakSystemIndices.includes(o);return{terms:h,duration:c.duration,pageBreak:y}}))}));return i.forEach(n=>processStaffContext(n,e)),i}resetPageLayout(t){const{unitSize:e=this.unitSize,pageSize:i=this.pageSize}=t,n={x:i.width*.5/e,y:i.height*.5/e};this.pages.forEach(r=>{const a=n.x-r.width/2,o=n.y-r.height/2;r.systems.forEach(c=>{c.left+=a,c.top+=o}),r.semantics&&r.semantics.forEach(c=>{c.x+=a,c.y+=o}),r.width=i.width/e,r.height=i.height/e,r.assemble({textAnnotations:this.textAnnotations})}),this.unitSize=e,this.pageSize=i}getMeasure(t){let e=t;for(const i of this.systems){if(eo&&o.measures[e]);return{measureIndex:t,system:i,localIndex:e,left:r.left,right:r.right,measures:a}}e-=i.measureCount}return null}getRawCluster(t,e,{timeSignature:i}={}){const n=this.getMeasure(t);if(!n)return null;const{system:r,left:a,right:o}=n,c=[BOS_ELEMENT];i&&c.push(...fractionToElems(i));const d=r.staves[0].top+r.staves[0].staffY-2;return r.staves.forEach(l=>{let u=r.qualifiedSemantics(l.semantics,e).filter(f=>f.x>a&&f.xf.semantic===SemanticType.TempoNotehead).forEach(f=>{const p=u.findIndex(m=>/^Notehead/.test(m.semantic)&&distance2D(f,m)<.3);p>=0&&u.splice(p,1)});const y=l.top+l.staffY-d;u.forEach(f=>{const p=SemanticElementType[f.semantic];if(p){let m=f.y,T=f.y;p===SemanticElementType.vline_Stem&&(m=f.extension.y1,T=f.extension.y2),c.push({id:f.id,type:p,staff:l.index,x:f.x-a,y1:m+y,y2:T+y})}})}),new SemanticCluster({index:t,elements:c})}getRawClusters(t=1){return Array(this.measureCount).fill(null).map((e,i)=>this.getRawCluster(i,t))}makeSpartito(t=new DummyLogger){let e=this.systems.map(c=>c.getEvents(this.maxStavesCount));const i=this.eventSystemsToTermStaves(e,t);e.forEach((c,d)=>{c.columns.forEach((l,u)=>{l.basics=i.map(h=>{const{timeSignature:y,timeSigNumeric:f,keySignature:p,doubtfulTimesig:m}=h.rows[d][u];return{timeSignature:y,timeSigNumeric:f,keySignature:p,doubtfulTimesig:m}})})});const n=null,r=[].concat(...e.map(c=>c.columns.map(d=>{const l=d.measureIndex,{system:u,localIndex:h,left:y,right:f}=this.getMeasure(l),p=n,m=[];u.staves.forEach(S=>m[S.index]=S.top+S.staffY);const T=this.patches&&this.patches.find(S=>S.measureIndex===l),x=T?T.events:SpartitoMeasure.reorderEvents([].concat(...d.rows.map(S=>S.events)),m),g=Object.fromEntries(Object.entries(d.barTypes).map(([S,E])=>[S,E/u.staves.length])),v=h===0&&u.indent;return new SpartitoMeasure({measureIndex:l,staffMask:c.staffMask,position:{systemIndex:u.index,localIndex:h,left:y,right:f,staffYs:u.staves.map(S=>S.top+S.staffY),staffYsFull:m},duration:T?T.duration:d.duration,events:x,contexts:d.rows.map(S=>S.contexts),marks:d.marks,break:d.break,pageBreak:d.pageBreak,voltaBegin:d.voltaBegin,voltaEnd:d.voltaEnd,alternative:d.alternative,barTypes:g,indent:v,basics:T?T.basics:d.basics,matrixH:p,matrixV:p,voices:T?T.voices:null,patched:!!T})}))),a=this.staffLayout,o=a.standaloneGroups.map(c=>c.map(d=>a.staffIds.indexOf(d)));return this.spartito=new Spartito({stavesCount:this.maxStavesCount,staffGroups:o,measures:r}),this.spartito}makeMusicSheet(){const t=this.spartito||this.makeSpartito();t.regulated||console.warn("[makeMusicSheet] spartito not regulated.");const e=t.makeVoiceStaves(),{lanes:i,diagnostics:n}=this.makeLyricLanes(e);i.length&&console.debug("[makeMusicSheet] lyric lanes:",i.length,n);const{title:r,pageSize:a,unitSize:o,staffLayout:c,staffLayoutCode:d,paperOptions:l,headers:u,instrumentDict:h}=this,y=this.getMeasureLayout();return{title:r,pageSize:a,unitSize:o,measureLayout:y,staffLayout:c,staffLayoutCode:d,paperOptions:l,headers:u,voiceStaves:e,instrumentDict:h,lyricLanes:i,lyricDiagnostics:n}}makeLyricLanes(t){const e={total:0,matched:0,unmatched:0,ambiguousVoice:0,duplicateEventAssignments:0,outOfOrderAssignments:0},i=this.spartito;if(!i||!i.measures||!i.measures.length||!t||!t.length)return{lanes:[],diagnostics:e};const n=[];this.pages.forEach((u,h)=>{(u.lyricTokens||[]).forEach(y=>{n.push({pageIndex:h,x:y.x,y:y.y,text:y.text,sid:y.id})})});const r={...e,total:n.length,unmatchedSids:[]};if(!n.length)return{lanes:[],diagnostics:r};const a=u=>Math.max(u*2,12),o=[];n.forEach(u=>{const h=this.pages[u.pageIndex];if(!h||!h.systems||!h.systems.length){r.unmatched++,u.sid&&r.unmatchedSids.push(u.sid);return}let y=null;for(const k of h.systems)k.top>u.y||u.xk.left+k.width||(!y||k.top>y.top)&&(y=k);if(!y){r.unmatched++,u.sid&&r.unmatchedSids.push(u.sid);return}const f=y.getStaffArray(this.maxStavesCount);let p=-1,m=-1/0,T=0;for(let k=0;km&&(m=M,p=k,T=O.height)}if(p<0||u.y-m>a(T)){r.unmatched++,u.sid&&r.unmatchedSids.push(u.sid);return}const x=u.x-y.left;let g=0;const v=y.measureBars||[];for(;g=y.measureCount&&(g=y.measureCount-1);const E=(y.headMeasureIndex||0)+g;o.push({...u,systemIndex:y.index,staffIndex:p,measureIndex:E,localIndex:g,systemX:x,voiceIndex:-1,verse:0})});const c=u=>!u||!(u instanceof EventTerm)||u.rest||u.grace||u.zeroHolder?!1:Number.isFinite(u.x);o.forEach(u=>{const h=i.measures[u.measureIndex];if(!h||!h.events){r.unmatched++,u.sid&&r.unmatchedSids.push(u.sid);return}const y=h.events.filter(m=>c(m)&&m.staff===u.staffIndex);if(!y.length){r.unmatched++,u.sid&&r.unmatchedSids.push(u.sid);return}let f=null,p=1/0;for(const m of y){const T=Math.abs(m.x-u.systemX);T{var m,T;if(!u.event)return;const h=t[u.staffIndex];if(!h||!h.voices||!h.voices.length){r.unmatched++,u.sid&&r.unmatchedSids.push(u.sid);return}if(!((T=(m=h.voices[0])==null?void 0:m.measures)==null?void 0:T[u.measureIndex])){r.unmatched++,u.sid&&r.unmatchedSids.push(u.sid);return}let f=-1,p=!1;h.voices.forEach((x,g)=>{var E;const v=(E=x.measures)==null?void 0:E[u.measureIndex];if(!v||!v.tickMap)return;Object.values(v.tickMap).find(k=>k===u.event||k&&k.id!=null&&u.event.id!=null&&k.id===u.event.id)&&(f>=0&&f!==g&&(p=!0),f<0&&(f=g))}),p&&r.ambiguousVoice++,f<0&&(f=0),u.voiceIndex=f,r.matched++});const d=new Map;o.forEach(u=>{if(!u.event)return;const h=d.get(u.staffIndex)||[];h.push(u),d.set(u.staffIndex,h)});const l=[];d.forEach((u,h)=>{const y=new Map;u.forEach(m=>{const T=y.get(m.systemIndex)||[];T.push(m),y.set(m.systemIndex,T)});let f=1;const p=new Map;y.forEach((m,T)=>{m.sort((k,O)=>k.y-O.y);const x=m.map(k=>k.y),g=x.length>1?Math.max(...x)-Math.min(...x):2,v=Math.max(g/4,1.5),S=[];m.forEach(k=>{const O=S.find(M=>Math.abs(M.y-k.y)<=v);O?O.members.push(k):S.push({y:k.y,members:[k]})}),S.sort((k,O)=>k.y-O.y);const E=new Map;S.forEach((k,O)=>k.members.forEach(M=>E.set(u.indexOf(M),O))),p.set(T,E),S.length>f&&(f=S.length)});for(let m=0;m{const v=p.get(x.systemIndex);if((v?v.get(g)??0:0)!==m)return;const E=T.get(x.voiceIndex)||[];E.push({text:x.text,sid:x.sid,measureIndex:x.measureIndex,tick:x.event.tick,staffIndex:x.staffIndex,voiceIndex:x.voiceIndex,eventId:x.event.id,verse:m,source:{pageIndex:x.pageIndex,systemIndex:x.systemIndex,x:x.x,y:x.y}}),T.set(x.voiceIndex,E)}),T.forEach((x,g)=>{x.sort((v,S)=>v.measureIndex-S.measureIndex||v.tick-S.tick),l.push({staffIndex:h,voiceIndex:g,verse:m,syllables:x})})}});for(const u of l){const h=new Set;let y=-1/0,f=-1;for(const p of u.syllables){const m=`${p.staffIndex}:${p.voiceIndex}:${p.measureIndex}:${p.tick}`;h.has(m)&&r.duplicateEventAssignments++,h.add(m),(p.measureIndexr.id===t);if(n){const r=this.pages.findIndex(a=>a.systems.includes(e));return{point:n,pageIndex:r,systemIndex:e.index,staffIndex:i}}}return null}getMeasureSemantics(t,e){const i=this.systems[t];if(!i)return null;const n=e?i.measureBars[e-1]:0,r=i.measureBars[e]||i.width;return i.staves.map((a,o)=>{const c=a.top+a.staffY;return a.semantics.filter(d=>d.x>=n&&d.x{var h;const[l,u]=Number.isFinite((h=d.extension)==null?void 0:h.y1)?[d.extension.y1,d.extension.y2]:[d.y,d.y];return{...d,staff:o,sy1:l+c,sy2:u+c}})}).flat(1)}makeTimewiseGraph({store:t=!1}={}){return this.spartito?{measures:this.spartito.measures.filter(i=>i.events.length>0).map(i=>{const n=this.getMeasureSemantics(i.position.systemIndex,i.position.localIndex),r={measureIndex:i.measureIndex,left:i.position.left,right:i.position.right,points:n};return t&&(i.graph=r),r})}:null}getTokenMap(){const t=new Map;return this.systems.forEach(e=>e.staves.forEach(i=>i.measures.forEach(n=>n.tokens.forEach(r=>t.set(r.id,r))))),t}assemble(t=1,e=new DummyLogger){const i=new Map,n=(a,o,c)=>{const d=hashSemanticPoint(a,o,c);e.assert(!i.has(d),"semantic point hash conflicted:",d,c,i.get(d)),i.set(d,c)};this.pages.forEach((a,o)=>a.index=o);let r=0;this.systems.forEach((a,o)=>{a.index=o,a.headMeasureIndex=r,a.prev=this.systems[o-1]||null,a.next=this.systems[o+1]||null,a.semantics&&a.semantics.length&&a.semantics.forEach(c=>n(o,null,c)),a.assemble(t,e),r+=a.measureCount}),this.pages.forEach((a,o)=>{a.systems.forEach(c=>c.pageIndex=o),a.assemble({textAnnotations:this.textAnnotations},e)})}assembleSystem(t,e=1){this.systems.forEach((n,r)=>n.index=r);const i=t.index;t.semantics&&t.semantics.length&&(t.semantics.forEach(n=>hashSemanticPoint(i,null,n)),t.assemble(e))}markVoices(t){const e=this.getTokenMap();for(const n of e.values())n.voice=0;const i=[].concat(...t.map((n,r)=>(n.voices||[]).map((a,o)=>[r,o]))).sort(([n,r],[a,o])=>r-o||n-a).map(([n,r])=>`${n}|${r}`);t.forEach((n,r)=>(n.voices||[]).forEach((a,o)=>a.measures.forEach(c=>{const d=i.indexOf(`${r}|${o}`);Object.values(c.tickMap).filter(u=>u instanceof EventTerm).forEach(u=>{const h=u.noteIds?u.noteIds.map(f=>e.get(f)).filter(Boolean):[],y=u.accessories?u.accessories.map(f=>e.get(f.id)).filter(Boolean):[];[...h,...y].forEach(f=>f.voice|=1<f.timeWarped=!0)})})))}async replaceImageKeys(t){await Promise.all([...this.pages.map(async e=>{e.source&&(e.source.url=await t(e.source.url))}),...this.systems.map(e=>Promise.all([t(e.backgroundImage).then(i=>e.backgroundImage=i),...e.staves.map(async i=>{i.backgroundImage=await t(i.backgroundImage),i.maskImage=await t(i.maskImage)})]))])}inferenceStaffLayout(){const t=Math.max(...this.systems.map(l=>l.staves.length),0);this.staffLayoutCode=Array(t).fill("").join(",");const e=this.systems.filter(l=>l.staves.length===t&&l.bracketsAppearance);if(!e.length)return;const i=e.map(l=>{try{return parseCode$1(l.bracketsAppearance).staffIds.length!==l.staves.length?null:l.bracketsAppearance}catch{return null}}).filter(Boolean);if(!i.length)return;const n=i.reduce((l,u)=>{const h=l[u]||0;return l[u]=h+1,l},{}),r=Math.max(...Object.values(n)),o=Object.entries(n).find(([l,u])=>u===r)[0].replace(/\{,*\}/g,l=>l.replace(/,/g,"-")),c=parseCode$1(o);this.staffLayoutCode=o;let d=null;for(const l of this.systems){if(d&&l.staves.length===d.staves.length&&l.bracketsAppearance===d.bracketsAppearance){l.staffMaskChanged=null;continue}if(l.staves.length{if(y.length>c.staffIds.length)return null;if(y.reduce((f,p)=>f+p,0)===l.staves.length)return bitsToMask(y);for(const f of[1,0]){const p=[...y,f],m=c.partialMaskCode(p);if(m===l.bracketsAppearance)return bitsToMask(p);if(l.bracketsAppearance.startsWith(m)){const T=u(p);if(T)return T}}return null},h=u([]);l.staffMaskChanged=!d||h!==d.staffMask?h:null}d=l}}assignBackgroundForMeasure(t){t.backgroundImages=[];const e=this.systems[t.position.systemIndex];e.backgroundImage&&t.backgroundImages.push({url:e.backgroundImage,position:e.imagePosition,original:!0}),e.staves.forEach(i=>{!e.backgroundImage&&i.backgroundImage&&t.backgroundImages.push({url:i.backgroundImage.toString(),position:{...i.imagePosition,y:i.imagePosition.y+i.top},original:!0}),i.maskImage&&t.backgroundImages.push({url:i.maskImage.toString(),position:{...i.imagePosition,y:i.imagePosition.y+i.top}})})}blackoutFakeNotes(t="patched"){if(!this.spartito)return;let e=a=>!0;switch(t){case"patched":e=a=>a.patched;break;case"perfect":e=a=>a.patched||a.regulated&&evaluateMeasure(a).perfect;break}const n=this.spartito.measures.filter(e).reduce((a,o)=>{if(!o.regulated)return;const c=o.voices.flat(1);return o.events.filter(l=>!l.rest&&!l.grace&&!c.includes(l.id)).forEach(l=>l.noteIds&&a.push(...l.noteIds)),a},[]),r=new Set(n);return this.systems.forEach(a=>a.staves.forEach(o=>{const c=o.semantics.filter(d=>r.has(d.id)).map(d=>d.id);a.sidBlackList.push(...c)})),n}getMeasureLayout(){const t=this.spartito&&this.spartito.measureLayoutCode;if(t)try{return parseCode(t)}catch(e){console.debug("invalid measure layout code:",e)}return null}*splitToSingleScoresGen(){this.assemble();const t=this.systems.filter(n=>n.index>0&&n.indent&&n.timeSignatureOnHead).map(n=>n.index);if(!t.length){yield this.deepCopy();return}const e=new Score({...this,pages:[],topology:void 0,spartito:void 0,patches:void 0});this.pages.forEach(n=>{delete n.tokens,n.systems.forEach(r=>{delete r.tokens,r.staves.forEach(a=>{a.measures=[]})})});let i=0;for(const n of[...t,this.systems.length]){const r=c=>c.index>=i&&c.indexc.systems.some(r)).map(c=>{const{systems:d,...l}=c;return new Page({...l,systems:d.filter(r).map(u=>new System({...u}))})}),o=e.deepCopy();o.headers.SubScoreSystem=`${i}-${n-1}`,o.headers.SubScorePage=`${a[0].index}-${a[a.length-1].index}`,o.pages=a,o.assemble(),o.inferenceStaffLayout(),i=n,yield o}}splitToSingleScores(){return[...this.splitToSingleScoresGen()]}}const DIVISION_NAMES=["whole","half","quarter","eighth","sixteenth","thirtysecond","sixtyfourth","128th","256th"],RESIDUE_LOSS_WEIGHT=.2,VOICEN_LOSS_WEIGHT=.002,SPACE_LOSS_WEIGHT=.4/WHOLE_DURATION,PRETENTIOUSNESS_LOSS_WEIGHT=.02,POSSIBILITY_LOW_BOUNDARY=1e-12,PRETENTIOUSNESS_CLIP=100,STEM_DIRECTION_OPTIONS=[void 0,"u","d"],BEAM_OPTIONS=[void 0,StemBeam.Open,StemBeam.Continue,StemBeam.Close],saveClusterState=s=>({elements:s.elements.map(t=>({tick:t.tick,division:t.division,dots:t.dots,beam:t.beam,stemDirection:t.stemDirection,grace:t.grace,timeWarped:t.timeWarped,fullMeasure:t.fullMeasure,fake:t.fake,order:t.order,predisposition:t.predisposition}))}),restoreClusterState=(s,t)=>s.elements.forEach((e,i)=>Object.assign(e,t.elements[i])),measurePretentious=s=>Math.min(PRETENTIOUSNESS_CLIP,-Math.log(s));class BeadNode{cluster;elemIndex;type;possibilities;pretentiousness;children;accessCount;constructor(t){Object.assign(this,t),this.children={},this.accessCount=0}nextBranch(){const t=this.possibilities.map((e,i)=>e/(this.children[i]?this.children[i].accessCount+1:1));return t.every(e=>!e)?(this.accessCount=1/0,null):argmax$1(t)}get currentElem(){return this.cluster.elements[this.elemIndex]}branchID(t){switch(this.type){case"i":return`i_${t}`;case"d":return DIVISION_NAMES[t];case"o":return"o"+".".repeat(t)}return""}async deduce({picker:t,logger:e,ptFactor:i},n=0){++this.accessCount;const r=this.nextBranch();if(e.debug(String.fromCodePoint(127817)+" ".repeat(n),this.branchID(r),this.accessCount>1?`[${this.accessCount}]`:""),!Number.isInteger(r)||r<0)return this.accessCount=1/0,evaluateCluster(this.cluster,this.currentElem.order+1,this.pretentiousness);if(this.pretentiousness+=measurePretentious(this.possibilities[r]),this.pretentiousness>PRETENTIOUSNESS_CLIP*i)return this.accessCount=1/0,evaluateCluster(this.cluster,this.currentElem.order+1,this.pretentiousness);let a=null;switch(this.type){case"i":{const c=this.currentElem.order+1,d=this.cluster.elements[r];if(console.assert(d,"null element:",r,this.cluster.elements.length),d.type===EventElementType.EOS){if(a=evaluateCluster(this.cluster,c,this.pretentiousness),!a.residue||a.fatalError)return this.accessCount=1/0,a;if(this.cluster.elements[0].order=c,!this.children[r]){if(!t.quota)return a;const l=(await t.predictCluster(this.cluster,c+1)).map((u,h)=>this.cluster.elements[h].orderMath.max(POSSIBILITY_LOW_BOUNDARY,u));this.children[r]=new BeadNode({cluster:this.cluster,elemIndex:r,type:"d",possibilities:l,pretentiousness:this.pretentiousness})}}break;case"d":if(this.currentElem.division=r,!this.children[r]){const c=this.currentElem.predisposition.dotsVector.map(d=>Math.max(POSSIBILITY_LOW_BOUNDARY,d));this.children[r]=new BeadNode({cluster:this.cluster,elemIndex:this.elemIndex,type:"o",possibilities:c,pretentiousness:this.pretentiousness})}break;case"o":{if(this.currentElem.dots=r,a=evaluateCluster(this.cluster,this.currentElem.order+1,this.pretentiousness),!a.residue||a.fatalError)return this.accessCount=1/0,a;if(!this.children[r]){if(!t.quota)return a;const c=this.currentElem.order+1,d=(await t.predictCluster(this.cluster,c)).map((l,u)=>this.cluster.elements[u].order{d.order>c&&(d.order=void 0)}),this.cluster.elements.forEach(d=>d.order=d.order>this.currentElem.order?void 0:d.order),this.cluster.elements[this.cluster.elements.length-1].tick=a.endTick,a}return o}}const estimateElementDuration=s=>WHOLE_DURATION*2**-s.division*(2-2**-s.dots),evaluateCluster=(s,t,e)=>{const i=s.elements.filter(k=>[EventElementType.CHORD,EventElementType.REST].includes(k.type)&&Number.isInteger(k.order)&&k.orderk.order-O.order);const n=s.elements[s.elements.length-1];let r=0,a=0,o=0,c=1;const d=[[n.x,s.signatureDuration,s.signatureDuration]];let l=0;i.forEach(k=>{k.order>a+1&&(r=0,++c);const O=d.find(_=>_[1]>=r);if(O&&k.x>O[0]+3){const _=d.reduce((R,I)=>Math.abs(k.predisposition.tick-I[2])_[0]>k.x));d.splice(M,0,[k.x,k.tick,k.predisposition.tick]);let b=estimateElementDuration(k);k.predisposition.timeWarped>.5&&(b=b*2/3),r+=b,l+=b,o=Math.max(o,r),a=k.order}),o>0&&(s.elements[s.elements.length-1].tick=o);const u=s.elements[s.elements.length-1].pivotX-s.elements[1].pivotX,h=Math.max(...i.map(k=>k.tick),o),y=[...i].sort((k,O)=>k.pivotX-O.pivotX),f=y.slice(1).map((k,O)=>{const M=y[O],b=k.pivotX-M.pivotX,_=k.tick-M.tick;return _?(Math.atan2(_/h,b/u)*4/Math.PI-1)**2:b/u}),p=Math.max(...f,0),m=i.map(k=>(k.tick-k.predisposition.tick)**2),T=m.length?Math.sqrt(m.reduce((k,O)=>k+O,0)/m.length):0,g=s.elements.filter(k=>[EventElementType.CHORD,EventElementType.REST].includes(k.type)&&!(Number.isInteger(k.order)&&k.order.5)).length,v=p>=1||o>s.signatureDuration,S=Math.max(0,s.signatureDuration-l/c),E=T/WHOLE_DURATION+p+g*RESIDUE_LOSS_WEIGHT+c*VOICEN_LOSS_WEIGHT+S*SPACE_LOSS_WEIGHT+e*PRETENTIOUSNESS_LOSS_WEIGHT;return{tickErr:T,twist:p,residue:g,endTick:o,fatalError:v,voiceN:c,spaceDuration:S,pretentiousness:e,loss:E}},solveCluster=async(s,t,e,i=200,n=0,r=1)=>{s.elements.forEach((f,p)=>f.order=p?void 0:0);const a=await t.predictCluster(s,1),o=new BeadNode({cluster:s,elemIndex:0,pretentiousness:0,type:"i",possibilities:a});let c=null,d=null;for(t.quota=i;t.quota;){s.elements.forEach((p,m)=>p.order=m?void 0:0);const f=await o.deduce({picker:t,logger:e,ptFactor:r});if(e.debug("loss:",f),(!c||f.loss[EventElementType.CHORD,EventElementType.REST].includes(f.type)&&Number.isInteger(f.order)),u=s.elements.filter(f=>[EventElementType.CHORD,EventElementType.REST].includes(f.type)&&!Number.isInteger(f.order));l.length&&u.forEach(f=>{if(f.tick=void 0,f.predisposition.fakeP<.5){const p=estimateElementDuration(f),m=l.filter(T=>T.tick+p<=c.endTick);if(m.length){const T=m.reduce((x,g)=>Math.abs(g.x-f.x)f.order-p.order),[...l,...u].forEach(f=>{f.grace=!Number.isFinite(f.tick)&&f.predisposition.grace,f.timeWarped=f.predisposition.timeWarped>.5,f.fullMeasure=f.predisposition.fullMeasure>.5,f.stemDirection=STEM_DIRECTION_OPTIONS[argmax$1(f.predisposition.stemDirectionVector)],f.beam=BEAM_OPTIONS[argmax$1(f.predisposition.beamVector)]});const h=s.elements.map(f=>f.index),y=f=>h.indexOf(f);return s.matrixH=s.elements.map(()=>Array(s.elements.length).fill(0)),l.forEach((f,p)=>{const m=l[p-1];!m||m.order{const{stopLoss:e=.09,quotaMax:i=1e3,quotaFactor:n=5,ptFactor:r=1,logger:a=new DummyLogger}=t;let o=0;const c=s.createClusters();for(const y of c){const f=Math.min(i,Math.ceil(y.elements.length*n));a.info(`[measure-${s.measureIndex}]`,f);const{loss:p}=await solveCluster(y,t.picker,a,f,e,r);o=Math.max(o,p)}const d=[],l=[],u=[];c.forEach(y=>{const f=y.elements.filter(E=>[EventElementType.CHORD,EventElementType.REST].includes(E.type)&&Number.isInteger(E.order));if(f.sort((E,k)=>E.order-k.order),!f.length)return;let p=[];d.push(p);let m=0;f.forEach(E=>{E.fullMeasure||E.grace||E.tremoloCatcher||(E.order>m+1?(p=[E.index],d.push(p)):p.push(E.index),m=E.order)});let T=f[f.length-1];const x=y.elements.filter(E=>[EventElementType.CHORD,EventElementType.REST].includes(E.type)&&Number.isFinite(E.tick)&&!Number.isInteger(E.order));for(;x.length;){const E=x.findIndex(k=>k.tick>=T.tick+estimateElementDuration(T));E>=0?p.push(x.splice(E,1)[0].index):(T=x.splice(0,1)[0],p=[T.index],d.push(p))}if(f.some(E=>!E.fullMeasure&&Number.isInteger(E.order))){const E=y.elements.find(k=>k.type===EventElementType.EOS);l.push(E.tick)}const g=s.eventMap,v=y.elements.reduce((E,k)=>(Number.isFinite(k.tick)&&E.add(k.tick),E),new Set),S=Array.from(v).sort((E,k)=>E-k);f.forEach(E=>{const k=g[E.index];k&&u.push({id:k.id,tick:E.tick,tickGroup:S.indexOf(E.tick),division:E.division!==k.division?E.division:void 0,dots:E.dots!==k.dots?E.dots:void 0,timeWarp:E.timeWarped?frac(2,3):void 0,beam:E.beam!==k.beam?E.beam:void 0,grace:E.grace!==!!k.grace?E.grace:void 0,fullMeasure:E.fullMeasure||void 0})})});const h=Math.max(...c.map(y=>y.estimatedDuration));return{voices:d.filter(y=>y.length),duration:Math.max(...l),events:u,priority:-o,estimatedDuration:h}},glimpseMeasure=async(s,{picker:t,resetSignatureForDoubtfulOnly:e})=>{const i=s.createClusters(),n=s.eventMap;for(const r of i)(!e||s.doubtfulTimesig)&&(r.signatureDuration=0),r.elements.forEach((a,o)=>a.order=o?void 0:0),await t.predictCluster(r,1),r.elements.filter(a=>[EventElementType.CHORD,EventElementType.REST].includes(a.type)).forEach(a=>{const o=n[a.index];o.predisposition=a.predisposition});s.estimatedDuration=Math.max(...i.map(r=>r.estimatedDuration))},estimateMeasure=async(s,t)=>glimpseMeasure(s,{picker:t,resetSignatureForDoubtfulOnly:!0}),beadSolver=Object.freeze(Object.defineProperty({__proto__:null,estimateMeasure,glimpseMeasure,solveCluster,solveMeasure},Symbol.toStringTag,{value:"Module"})),starry=Object.freeze(Object.defineProperty({__proto__:null,AccessoryDirection,ArpeggioStyle,BOS_ELEMENT,CONFLICTION_GROUPS,ChordmodeTerm,CommandTerm,ContextType,ContextedTerm,ELEMENT_TOKEN_NAMES,EditableEvent,EditableMeasure,EventCluster,EventClusterSet,EventElementType,EventTerm,GlissandoStyle,GlyphTerm,GraceType,LyricTerm,MarkTerm,Measure,NOTEHEAD_ELEMENT_TYPES,NOTEHEAD_WIDTHS,NOTE_ELEMENT_TYPES,ONE_D_SEMANTICS,Page,PageLayoutMethod,PatchMeasure,STAMP_RECTS,STAMP_SEMANTICS,SYSTEM_SEMANTIC_TYPES,Score,SemanticCluster,SemanticClusterSet,SemanticElementType,SemanticGraph,SemanticType,SimpleClass,Spartito,SpartitoMeasure,Staff,StemBeam,System,TOKEN_Y_FIXED,TOKEN_Y_ROUND,TempoTerm,Term,TextTerm,TextToken,TextType,Token,TokenAccessories,TokenAccidentals,TokenArcs,TokenBareNoteheads,TokenBeams,TokenClefs,TokenDirectionalNoteheads,TokenDirectionless,TokenDots,TokenDynamics,TokenFlags,TokenGlyphs,TokenNoteheads,TokenNumbers,TokenOctshifts,TokenPedals,TokenRests,TokenScripts,TokenTimesigs,TokenTimesigsC,TokenTimesigsN,TokenType,TokenTypes,TokenVolta,TokenWedges,TremoloLink,VERSION,WHOLE_DURATION,beadSolver,emptyVoiceFromStaffMeasure,evaluateMeasure,expandMatrixByMaskTriu,expandMatrixByMasks,fractionToElems,glyphCenters,glyphSemanticMapping,hashPageSemanticPoint,hashSemanticPoint,matrixFromGroups,mod7,recoverJSON,semanticPriorities},Symbol.toStringTag,{value:"Module"}));export{AccessoryDirection as A,EditableMeasure as B,ContextedTerm as C,SpartitoMeasure as D,EventTerm as E,EventElementType as F,GlyphTerm as G,LayoutType as L,MetaNotation as M,PageLayoutMethod as P,SemanticType as S,TokenBareNoteheads as T,WHOLE_DURATION as W,TokenType as a,ContextType as b,TempoTerm as c,TremoloLink as d,TokenDynamics as e,reducedFraction as f,ChordmodeTerm as g,TextTerm as h,CommandTerm as i,LyricTerm as j,Staff as k,System as l,mod7$1 as m,STAMP_SEMANTICS as n,STAMP_RECTS as o,TokenGlyphs as p,Score as q,recoverJSON as r,starry as s,Page as t,EventClusterSet as u,SimpleClass as v,GROUP_N_TO_PITCH$1 as w,sha1 as x,MIDDLE_C$1 as y,evaluateMeasure as z}; diff --git a/dist/assets/index-da8ccbdf.js b/dist/assets/index-5722ce0d.js similarity index 99% rename from dist/assets/index-da8ccbdf.js rename to dist/assets/index-5722ce0d.js index cf39e94aee2646e91f387ffa800ecc5b1b4ff9bc..63fdf58b75d4e6e168f805ad0b494c298bc039ff 100644 --- a/dist/assets/index-da8ccbdf.js +++ b/dist/assets/index-5722ce0d.js @@ -1,4 +1,4 @@ -import{r as En,bj as Pn,bk as $n,s as xn,k as ie,g as Cr}from"./umi-9940633e.js";function Us(){const r=En.useContext(Pn);return $n(r),r}var kr=function(){return kr=Object.assign||function(e){for(var t,n=1,o=arguments.length;n-1e3&&r<1e3||Ft.call(/e/,e))return e;var t=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof r=="number"){var n=r<0?-tt(-r):tt(r);if(n!==r){var o=String(n),a=Mr.call(e,o.length+1);return J.call(o,t,"$&_")+"."+J.call(J.call(a,/([0-9]{3})/g,"$&_"),/_$/,"")}}return J.call(e,t,"$&_")}var Ar=In,at=Ar.custom,it=Dt(at)?at:null,Mt={__proto__:null,double:'"',single:"'"},Ln={__proto__:null,double:/(["\\])/g,single:/(['\\])/g},We=function r(e,t,n,o){var a=t||{};if(K(a,"quoteStyle")&&!K(Mt,a.quoteStyle))throw new TypeError('option "quoteStyle" must be "single" or "double"');if(K(a,"maxStringLength")&&(typeof a.maxStringLength=="number"?a.maxStringLength<0&&a.maxStringLength!==1/0:a.maxStringLength!==null))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var f=K(a,"customInspect")?a.customInspect:!0;if(typeof f!="boolean"&&f!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(K(a,"indent")&&a.indent!==null&&a.indent!==" "&&!(parseInt(a.indent,10)===a.indent&&a.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(K(a,"numericSeparator")&&typeof a.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var p=a.numericSeparator;if(typeof e>"u")return"undefined";if(e===null)return"null";if(typeof e=="boolean")return e?"true":"false";if(typeof e=="string")return jt(e,a);if(typeof e=="number"){if(e===0)return 1/0/e>0?"0":"-0";var c=String(e);return p?ot(e,c):c}if(typeof e=="bigint"){var y=String(e)+"n";return p?ot(e,y):y}var v=typeof a.depth>"u"?5:a.depth;if(typeof n>"u"&&(n=0),n>=v&&v>0&&typeof e=="object")return _r(e)?"[Array]":"[Object]";var g=ao(a,n);if(typeof o>"u")o=[];else if(Ut(o,e)>=0)return"[Circular]";function m(B,V,z){if(V&&(o=Nn.call(o),o.push(V)),z){var ye={depth:a.depth};return K(a,"quoteStyle")&&(ye.quoteStyle=a.quoteStyle),r(B,ye,n+1,o)}return r(B,a,n+1,o)}if(typeof e=="function"&&!st(e)){var S=kn(e),b=Te(e,m);return"[Function"+(S?": "+S:" (anonymous)")+"]"+(b.length>0?" { "+L.call(b,", ")+" }":"")}if(Dt(e)){var O=ue?J.call(String(e),/^(Symbol\(.*\))_[^)]*$/,"$1"):Or.call(e);return typeof e=="object"&&!ue?de(O):O}if(to(e)){for(var w="<"+et.call(String(e.nodeName)),h=e.attributes||[],d=0;d",w}if(_r(e)){if(e.length===0)return"[]";var i=Te(e,m);return g&&!oo(i)?"["+Er(i,g)+"]":"[ "+L.call(i,", ")+" ]"}if(Gn(e)){var s=Te(e,m);return!("cause"in Error.prototype)&&"cause"in e&&!qt.call(e,"cause")?"{ ["+String(e)+"] "+L.call(rt.call("[cause]: "+m(e.cause),s),", ")+" }":s.length===0?"["+String(e)+"]":"{ ["+String(e)+"] "+L.call(s,", ")+" }"}if(typeof e=="object"&&f){if(it&&typeof e[it]=="function"&&Ar)return Ar(e,{depth:v-n});if(f!=="symbol"&&typeof e.inspect=="function")return e.inspect()}if(Xn(e)){var l=[];return Xr&&Xr.call(e,function(B,V){l.push(m(V,e,!0)+" => "+m(B,e))}),ft("Map",De.call(e),l,g)}if(eo(e)){var u=[];return Yr&&Yr.call(e,function(B){u.push(m(B,e))}),ft("Set",Ue.call(e),u,g)}if(Yn(e))return er("WeakMap");if(ro(e))return er("WeakSet");if(Zn(e))return er("WeakRef");if(Kn(e))return de(m(Number(e)));if(Jn(e))return de(m(Sr.call(e)));if(Vn(e))return de(Mn.call(e));if(zn(e))return de(m(String(e)));if(typeof window<"u"&&e===window)return"{ [object Window] }";if(typeof globalThis<"u"&&e===globalThis||typeof ie<"u"&&e===ie)return"{ [object globalThis] }";if(!Wn(e)&&!st(e)){var _=Te(e,m),T=nt?nt(e)===Object.prototype:e instanceof Object||e.constructor===Object,E=e instanceof Object?"":"null prototype",I=!T&&be&&Object(e)===e&&be in e?Mr.call(k(e),8,-1):E?"Object":"",U=T||typeof e.constructor!="function"?"":e.constructor.name?e.constructor.name+" ":"",M=U+(I||E?"["+L.call(rt.call([],I||[],E||[]),": ")+"] ":"");return _.length===0?M+"{}":g?M+"{"+Er(_,g)+"}":M+"{ "+L.call(_,", ")+" }"}return String(e)};function Bt(r,e,t){var n=t.quoteStyle||e,o=Mt[n];return o+r+o}function Hn(r){return J.call(String(r),/"/g,""")}function te(r){return!be||!(typeof r=="object"&&(be in r||typeof r[be]<"u"))}function _r(r){return k(r)==="[object Array]"&&te(r)}function Wn(r){return k(r)==="[object Date]"&&te(r)}function st(r){return k(r)==="[object RegExp]"&&te(r)}function Gn(r){return k(r)==="[object Error]"&&te(r)}function zn(r){return k(r)==="[object String]"&&te(r)}function Kn(r){return k(r)==="[object Number]"&&te(r)}function Vn(r){return k(r)==="[object Boolean]"&&te(r)}function Dt(r){if(ue)return r&&typeof r=="object"&&r instanceof Symbol;if(typeof r=="symbol")return!0;if(!r||typeof r!="object"||!Or)return!1;try{return Or.call(r),!0}catch{}return!1}function Jn(r){if(!r||typeof r!="object"||!Sr)return!1;try{return Sr.call(r),!0}catch{}return!1}var Qn=Object.prototype.hasOwnProperty||function(r){return r in this};function K(r,e){return Qn.call(r,e)}function k(r){return Bn.call(r)}function kn(r){if(r.name)return r.name;var e=Un.call(Dn.call(r),/^function\s*([\w$]+)/);return e?e[1]:null}function Ut(r,e){if(r.indexOf)return r.indexOf(e);for(var t=0,n=r.length;te.maxStringLength){var t=r.length-e.maxStringLength,n="... "+t+" more character"+(t>1?"s":"");return jt(Mr.call(r,0,e.maxStringLength),e)+n}var o=Ln[e.quoteStyle||"single"];o.lastIndex=0;var a=J.call(J.call(r,o,"\\$1"),/[\x00-\x1f]/g,no);return Bt(a,"single",e)}function no(r){var e=r.charCodeAt(0),t={8:"b",9:"t",10:"n",12:"f",13:"r"}[e];return t?"\\"+t:"\\x"+(e<16?"0":"")+jn.call(e.toString(16))}function de(r){return"Object("+r+")"}function er(r){return r+" { ? }"}function ft(r,e,t,n){var o=n?Er(t,n):L.call(t,", ");return r+" ("+e+") {"+o+"}"}function oo(r){for(var e=0;e-1e3&&r<1e3||Ft.call(/e/,e))return e;var t=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof r=="number"){var n=r<0?-tt(-r):tt(r);if(n!==r){var o=String(n),a=Mr.call(e,o.length+1);return J.call(o,t,"$&_")+"."+J.call(J.call(a,/([0-9]{3})/g,"$&_"),/_$/,"")}}return J.call(e,t,"$&_")}var Ar=In,at=Ar.custom,it=Dt(at)?at:null,Mt={__proto__:null,double:'"',single:"'"},Ln={__proto__:null,double:/(["\\])/g,single:/(['\\])/g},We=function r(e,t,n,o){var a=t||{};if(K(a,"quoteStyle")&&!K(Mt,a.quoteStyle))throw new TypeError('option "quoteStyle" must be "single" or "double"');if(K(a,"maxStringLength")&&(typeof a.maxStringLength=="number"?a.maxStringLength<0&&a.maxStringLength!==1/0:a.maxStringLength!==null))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var f=K(a,"customInspect")?a.customInspect:!0;if(typeof f!="boolean"&&f!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(K(a,"indent")&&a.indent!==null&&a.indent!==" "&&!(parseInt(a.indent,10)===a.indent&&a.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(K(a,"numericSeparator")&&typeof a.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var p=a.numericSeparator;if(typeof e>"u")return"undefined";if(e===null)return"null";if(typeof e=="boolean")return e?"true":"false";if(typeof e=="string")return jt(e,a);if(typeof e=="number"){if(e===0)return 1/0/e>0?"0":"-0";var c=String(e);return p?ot(e,c):c}if(typeof e=="bigint"){var y=String(e)+"n";return p?ot(e,y):y}var v=typeof a.depth>"u"?5:a.depth;if(typeof n>"u"&&(n=0),n>=v&&v>0&&typeof e=="object")return _r(e)?"[Array]":"[Object]";var g=ao(a,n);if(typeof o>"u")o=[];else if(Ut(o,e)>=0)return"[Circular]";function m(B,V,z){if(V&&(o=Nn.call(o),o.push(V)),z){var ye={depth:a.depth};return K(a,"quoteStyle")&&(ye.quoteStyle=a.quoteStyle),r(B,ye,n+1,o)}return r(B,a,n+1,o)}if(typeof e=="function"&&!st(e)){var S=kn(e),b=Te(e,m);return"[Function"+(S?": "+S:" (anonymous)")+"]"+(b.length>0?" { "+L.call(b,", ")+" }":"")}if(Dt(e)){var O=ue?J.call(String(e),/^(Symbol\(.*\))_[^)]*$/,"$1"):Or.call(e);return typeof e=="object"&&!ue?de(O):O}if(to(e)){for(var w="<"+et.call(String(e.nodeName)),h=e.attributes||[],d=0;d",w}if(_r(e)){if(e.length===0)return"[]";var i=Te(e,m);return g&&!oo(i)?"["+Er(i,g)+"]":"[ "+L.call(i,", ")+" ]"}if(Gn(e)){var s=Te(e,m);return!("cause"in Error.prototype)&&"cause"in e&&!qt.call(e,"cause")?"{ ["+String(e)+"] "+L.call(rt.call("[cause]: "+m(e.cause),s),", ")+" }":s.length===0?"["+String(e)+"]":"{ ["+String(e)+"] "+L.call(s,", ")+" }"}if(typeof e=="object"&&f){if(it&&typeof e[it]=="function"&&Ar)return Ar(e,{depth:v-n});if(f!=="symbol"&&typeof e.inspect=="function")return e.inspect()}if(Xn(e)){var l=[];return Xr&&Xr.call(e,function(B,V){l.push(m(V,e,!0)+" => "+m(B,e))}),ft("Map",De.call(e),l,g)}if(eo(e)){var u=[];return Yr&&Yr.call(e,function(B){u.push(m(B,e))}),ft("Set",Ue.call(e),u,g)}if(Yn(e))return er("WeakMap");if(ro(e))return er("WeakSet");if(Zn(e))return er("WeakRef");if(Kn(e))return de(m(Number(e)));if(Jn(e))return de(m(Sr.call(e)));if(Vn(e))return de(Mn.call(e));if(zn(e))return de(m(String(e)));if(typeof window<"u"&&e===window)return"{ [object Window] }";if(typeof globalThis<"u"&&e===globalThis||typeof ie<"u"&&e===ie)return"{ [object globalThis] }";if(!Wn(e)&&!st(e)){var _=Te(e,m),T=nt?nt(e)===Object.prototype:e instanceof Object||e.constructor===Object,E=e instanceof Object?"":"null prototype",I=!T&&be&&Object(e)===e&&be in e?Mr.call(k(e),8,-1):E?"Object":"",U=T||typeof e.constructor!="function"?"":e.constructor.name?e.constructor.name+" ":"",M=U+(I||E?"["+L.call(rt.call([],I||[],E||[]),": ")+"] ":"");return _.length===0?M+"{}":g?M+"{"+Er(_,g)+"}":M+"{ "+L.call(_,", ")+" }"}return String(e)};function Bt(r,e,t){var n=t.quoteStyle||e,o=Mt[n];return o+r+o}function Hn(r){return J.call(String(r),/"/g,""")}function te(r){return!be||!(typeof r=="object"&&(be in r||typeof r[be]<"u"))}function _r(r){return k(r)==="[object Array]"&&te(r)}function Wn(r){return k(r)==="[object Date]"&&te(r)}function st(r){return k(r)==="[object RegExp]"&&te(r)}function Gn(r){return k(r)==="[object Error]"&&te(r)}function zn(r){return k(r)==="[object String]"&&te(r)}function Kn(r){return k(r)==="[object Number]"&&te(r)}function Vn(r){return k(r)==="[object Boolean]"&&te(r)}function Dt(r){if(ue)return r&&typeof r=="object"&&r instanceof Symbol;if(typeof r=="symbol")return!0;if(!r||typeof r!="object"||!Or)return!1;try{return Or.call(r),!0}catch{}return!1}function Jn(r){if(!r||typeof r!="object"||!Sr)return!1;try{return Sr.call(r),!0}catch{}return!1}var Qn=Object.prototype.hasOwnProperty||function(r){return r in this};function K(r,e){return Qn.call(r,e)}function k(r){return Bn.call(r)}function kn(r){if(r.name)return r.name;var e=Un.call(Dn.call(r),/^function\s*([\w$]+)/);return e?e[1]:null}function Ut(r,e){if(r.indexOf)return r.indexOf(e);for(var t=0,n=r.length;te.maxStringLength){var t=r.length-e.maxStringLength,n="... "+t+" more character"+(t>1?"s":"");return jt(Mr.call(r,0,e.maxStringLength),e)+n}var o=Ln[e.quoteStyle||"single"];o.lastIndex=0;var a=J.call(J.call(r,o,"\\$1"),/[\x00-\x1f]/g,no);return Bt(a,"single",e)}function no(r){var e=r.charCodeAt(0),t={8:"b",9:"t",10:"n",12:"f",13:"r"}[e];return t?"\\"+t:"\\x"+(e<16?"0":"")+jn.call(e.toString(16))}function de(r){return"Object("+r+")"}function er(r){return r+" { ? }"}function ft(r,e,t,n){var o=n?Er(t,n):L.call(t,", ");return r+" ("+e+") {"+o+"}"}function oo(r){for(var e=0;e=0)return!1;return!0}function ao(r,e){var t;if(r.indent===" ")t=" ";else if(typeof r.indent=="number"&&r.indent>0)t=L.call(Array(r.indent+1)," ");else return null;return{base:t,prev:L.call(Array(e+1),t)}}function Er(r,e){if(r.length===0)return"";var t=` `+e.prev+e.base;return t+L.call(r,","+t)+` `+e.prev}function Te(r,e){var t=_r(r),n=[];if(t){n.length=r.length;for(var o=0;o"u"||!R?A:R(Uint8Array),ee={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?A:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?A:ArrayBuffer,"%ArrayIteratorPrototype%":ne&&R?R([][Symbol.iterator]()):A,"%AsyncFromSyncIteratorPrototype%":A,"%AsyncFunction%":ae,"%AsyncGenerator%":ae,"%AsyncGeneratorFunction%":ae,"%AsyncIteratorPrototype%":ae,"%Atomics%":typeof Atomics>"u"?A:Atomics,"%BigInt%":typeof BigInt>"u"?A:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?A:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?A:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?A:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Jo,"%eval%":eval,"%EvalError%":Qo,"%Float16Array%":typeof Float16Array>"u"?A:Float16Array,"%Float32Array%":typeof Float32Array>"u"?A:Float32Array,"%Float64Array%":typeof Float64Array>"u"?A:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?A:FinalizationRegistry,"%Function%":Kt,"%GeneratorFunction%":ae,"%Int8Array%":typeof Int8Array>"u"?A:Int8Array,"%Int16Array%":typeof Int16Array>"u"?A:Int16Array,"%Int32Array%":typeof Int32Array>"u"?A:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":ne&&R?R(R([][Symbol.iterator]())):A,"%JSON%":typeof JSON=="object"?JSON:A,"%Map%":typeof Map>"u"?A:Map,"%MapIteratorPrototype%":typeof Map>"u"||!ne||!R?A:R(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Vo,"%Object.getOwnPropertyDescriptor%":Ae,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?A:Promise,"%Proxy%":typeof Proxy>"u"?A:Proxy,"%RangeError%":ko,"%ReferenceError%":Xo,"%Reflect%":typeof Reflect>"u"?A:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?A:Set,"%SetIteratorPrototype%":typeof Set>"u"||!ne||!R?A:R(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?A:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":ne&&R?R(""[Symbol.iterator]()):A,"%Symbol%":ne?Symbol:A,"%SyntaxError%":le,"%ThrowTypeError%":sa,"%TypedArray%":la,"%TypeError%":fe,"%Uint8Array%":typeof Uint8Array>"u"?A:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?A:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?A:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?A:Uint32Array,"%URIError%":Yo,"%WeakMap%":typeof WeakMap>"u"?A:WeakMap,"%WeakRef%":typeof WeakRef>"u"?A:WeakRef,"%WeakSet%":typeof WeakSet>"u"?A:WeakSet,"%Function.prototype.call%":Pe,"%Function.prototype.apply%":Vt,"%Object.defineProperty%":ia,"%Object.getPrototypeOf%":fa,"%Math.abs%":Zo,"%Math.floor%":ea,"%Math.max%":ra,"%Math.min%":ta,"%Math.pow%":na,"%Math.round%":oa,"%Math.sign%":aa,"%Reflect.getPrototypeOf%":ua};if(R)try{null.error}catch(r){var ca=R(R(r));ee["%Error.prototype%"]=ca}var pa=function r(e){var t;if(e==="%AsyncFunction%")t=pr("async function () {}");else if(e==="%GeneratorFunction%")t=pr("function* () {}");else if(e==="%AsyncGeneratorFunction%")t=pr("async function* () {}");else if(e==="%AsyncGenerator%"){var n=r("%AsyncGeneratorFunction%");n&&(t=n.prototype)}else if(e==="%AsyncIteratorPrototype%"){var o=r("%AsyncGenerator%");o&&R&&(t=R(o.prototype))}return ee[e]=t,t},wt={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},$e=ze(),je=Ko(),ya=$e.call(Pe,Array.prototype.concat),da=$e.call(Vt,Array.prototype.splice),St=$e.call(Pe,String.prototype.replace),Ne=$e.call(Pe,String.prototype.slice),ha=$e.call(Pe,RegExp.prototype.exec),va=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,ma=/\\(\\)?/g,ga=function(e){var t=Ne(e,0,1),n=Ne(e,-1);if(t==="%"&&n!=="%")throw new le("invalid intrinsic syntax, expected closing `%`");if(n==="%"&&t!=="%")throw new le("invalid intrinsic syntax, expected opening `%`");var o=[];return St(e,va,function(a,f,p,c){o[o.length]=p?St(c,ma,"$1"):f||a}),o},ba=function(e,t){var n=e,o;if(je(wt,n)&&(o=wt[n],n="%"+o[0]+"%"),je(ee,n)){var a=ee[n];if(a===ae&&(a=pa(n)),typeof a>"u"&&!t)throw new fe("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:o,name:n,value:a}}throw new le("intrinsic "+e+" does not exist!")},Dr=function(e,t){if(typeof e!="string"||e.length===0)throw new fe("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof t!="boolean")throw new fe('"allowMissing" argument must be a boolean');if(ha(/^%?[^%]*%?$/,e)===null)throw new le("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var n=ga(e),o=n.length>0?n[0]:"",a=ba("%"+o+"%",t),f=a.name,p=a.value,c=!1,y=a.alias;y&&(o=y[0],da(n,ya([0,1],y)));for(var v=1,g=!0;v=n.length){var O=Ae(p,m);g=!!O,g&&"get"in O&&!("originalValue"in O.get)?p=O.get:p=p[m]}else g=je(p,m),p=p[m];g&&!c&&(ee[f]=p)}}return p},Jt=Dr,Qt=zt,wa=Qt([Jt("%String.prototype.indexOf%")]),kt=function(e,t){var n=Jt(e,!!t);return typeof n=="function"&&wa(e,".prototype.")>-1?Qt([n]):n},Sa=Dr,xe=kt,Oa=We,Aa=ce,Ot=Sa("%Map%",!0),_a=xe("Map.prototype.get",!0),Ea=xe("Map.prototype.set",!0),Pa=xe("Map.prototype.has",!0),$a=xe("Map.prototype.delete",!0),xa=xe("Map.prototype.size",!0),Xt=!!Ot&&function(){var e,t={assert:function(n){if(!t.has(n))throw new Aa("Side channel does not contain "+Oa(n))},delete:function(n){if(e){var o=$a(e,n);return xa(e)===0&&(e=void 0),o}return!1},get:function(n){if(e)return _a(e,n)},has:function(n){return e?Pa(e,n):!1},set:function(n,o){e||(e=new Ot),Ea(e,n,o)}};return t},Ra=Dr,Ke=kt,Ta=We,Ie=Xt,Ia=ce,oe=Ra("%WeakMap%",!0),Ca=Ke("WeakMap.prototype.get",!0),Fa=Ke("WeakMap.prototype.set",!0),qa=Ke("WeakMap.prototype.has",!0),Ma=Ke("WeakMap.prototype.delete",!0),Ba=oe?function(){var e,t,n={assert:function(o){if(!n.has(o))throw new Ia("Side channel does not contain "+Ta(o))},delete:function(o){if(oe&&o&&(typeof o=="object"||typeof o=="function")){if(e)return Ma(e,o)}else if(Ie&&t)return t.delete(o);return!1},get:function(o){return oe&&o&&(typeof o=="object"||typeof o=="function")&&e?Ca(e,o):t&&t.get(o)},has:function(o){return oe&&o&&(typeof o=="object"||typeof o=="function")&&e?qa(e,o):!!t&&t.has(o)},set:function(o,a){oe&&o&&(typeof o=="object"||typeof o=="function")?(e||(e=new oe),Fa(e,o,a)):Ie&&(t||(t=Ie()),t.set(o,a))}};return n}:Ie,Da=ce,Ua=We,ja=po,Na=Xt,La=Ba,Ha=La||Na||ja,Yt=function(){var e,t={assert:function(n){if(!t.has(n))throw new Da("Side channel does not contain "+Ua(n))},delete:function(n){return!!e&&e.delete(n)},get:function(n){return e&&e.get(n)},has:function(n){return!!e&&e.has(n)},set:function(n,o){e||(e=Ha()),e.set(n,o)}};return t},Wa=String.prototype.replace,Ga=/%20/g,dr={RFC1738:"RFC1738",RFC3986:"RFC3986"},Ur={default:dr.RFC3986,formatters:{RFC1738:function(r){return Wa.call(r,Ga,"+")},RFC3986:function(r){return String(r)}},RFC1738:dr.RFC1738,RFC3986:dr.RFC3986},za=Ur,Ka=Yt,hr=Object.prototype.hasOwnProperty,X=Array.isArray,Ve=Ka(),se=function(e,t){return Ve.set(e,t),e},Y=function(e){return Ve.has(e)},he=function(e){return Ve.get(e)},Pr=function(e,t){Ve.set(e,t)},j=function(){for(var r=[],e=0;e<256;++e)r[r.length]="%"+((e<16?"0":"")+e.toString(16)).toUpperCase();return r}(),Va=function(e){for(;e.length>1;){var t=e.pop(),n=t.obj[t.prop];if(X(n)){for(var o=[],a=0;an.arrayLimit)return se(we(e.concat(t),n),o);e[o]=t}else if(e&&typeof e=="object")if(Y(e)){var a=he(e)+1;e[a]=t,Pr(e,a)}else(n&&(n.plainObjects||n.allowPrototypes)||!hr.call(Object.prototype,t))&&(e[t]=!0);else return[e,t];return e}if(!e||typeof e!="object"){if(Y(t)){for(var f=Object.keys(t),p=n&&n.plainObjects?{__proto__:null,0:e}:{0:e},c=0;cn.arrayLimit?se(we(v,n),v.length-1):v}var g=e;return X(e)&&!X(t)&&(g=we(e,n)),X(e)&&X(t)?(t.forEach(function(m,S){if(hr.call(e,S)){var b=e[S];b&&typeof b=="object"&&m&&typeof m=="object"?e[S]=r(b,m,n):e[e.length]=m}else e[S]=m}),e):Object.keys(t).reduce(function(m,S){var b=t[S];if(hr.call(m,S)?m[S]=r(m[S],b,n):m[S]=b,Y(t)&&!Y(m)&&se(m,he(t)),Y(m)){var O=parseInt(S,10);String(O)===S&&O>=0&&O>he(m)&&Pr(m,O)}return m},g)},Qa=function(e,t){return Object.keys(t).reduce(function(n,o){return n[o]=t[o],n},e)},ka=function(r,e,t){var n=r.replace(/\+/g," ");if(t==="iso-8859-1")return n.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(n)}catch{return n}},vr=1024,Xa=function(e,t,n,o,a){if(e.length===0)return e;var f=e;if(typeof e=="symbol"?f=Symbol.prototype.toString.call(e):typeof e!="string"&&(f=String(e)),n==="iso-8859-1")return escape(f).replace(/%u[0-9a-f]{4}/gi,function(S){return"%26%23"+parseInt(S.slice(2),16)+"%3B"});for(var p="",c=0;c=vr?f.slice(c,c+vr):f,v=[],g=0;g=48&&m<=57||m>=65&&m<=90||m>=97&&m<=122||a===za.RFC1738&&(m===40||m===41)){v[v.length]=y.charAt(g);continue}if(m<128){v[v.length]=j[m];continue}if(m<2048){v[v.length]=j[192|m>>6]+j[128|m&63];continue}if(m<55296||m>=57344){v[v.length]=j[224|m>>12]+j[128|m>>6&63]+j[128|m&63];continue}g+=1,m=65536+((m&1023)<<10|y.charCodeAt(g)&1023),v[v.length]=j[240|m>>18]+j[128|m>>12&63]+j[128|m>>6&63]+j[128|m&63]}p+=v.join("")}return p},Ya=function(e){for(var t=[{obj:{o:e},prop:"o"}],n=[],o=0;on?se(we(f,{plainObjects:o}),f.length-1):f},ti=function(e,t){if(X(e)){for(var n=[],o=0;o"u"&&(l=0)}if(typeof v=="function"?i=v(t,i):i instanceof Date?i=S(i):n==="comma"&&N(i)&&(i=qe.maybeMap(i,function(ke){return ke instanceof Date?S(ke):ke})),i===null){if(f)return y&&!w?y(t,$.encoder,h,"key",b):t;i=""}if(ii(i)||qe.isBuffer(i)){if(y){var T=w?t:y(t,$.encoder,h,"key",b);return[O(T)+"="+O(y(i,$.encoder,h,"value",b))]}return[O(t)+"="+O(String(i))]}var E=[];if(typeof i>"u")return E;var I;if(n==="comma"&&N(i))w&&y&&(i=qe.maybeMap(i,y)),I=[{value:i.length>0?i.join(",")||null:void 0}];else if(N(v))I=v;else{var U=Object.keys(i);I=g?U.sort(g):U}var M=c?String(t).replace(/\./g,"%2E"):String(t),B=o&&N(i)&&i.length===1?M+"[]":M;if(a&&N(i)&&i.length===0)return B+"[]";for(var V=0;V"u"?e.encodeDotInKeys===!0?!0:$.allowDots:!!e.allowDots;return{addQueryPrefix:typeof e.addQueryPrefix=="boolean"?e.addQueryPrefix:$.addQueryPrefix,allowDots:p,allowEmptyArrays:typeof e.allowEmptyArrays=="boolean"?!!e.allowEmptyArrays:$.allowEmptyArrays,arrayFormat:f,charset:t,charsetSentinel:typeof e.charsetSentinel=="boolean"?e.charsetSentinel:$.charsetSentinel,commaRoundTrip:!!e.commaRoundTrip,delimiter:typeof e.delimiter>"u"?$.delimiter:e.delimiter,encode:typeof e.encode=="boolean"?e.encode:$.encode,encodeDotInKeys:typeof e.encodeDotInKeys=="boolean"?e.encodeDotInKeys:$.encodeDotInKeys,encoder:typeof e.encoder=="function"?e.encoder:$.encoder,encodeValuesOnly:typeof e.encodeValuesOnly=="boolean"?e.encodeValuesOnly:$.encodeValuesOnly,filter:a,format:n,formatter:o,serializeDate:typeof e.serializeDate=="function"?e.serializeDate:$.serializeDate,skipNulls:typeof e.skipNulls=="boolean"?e.skipNulls:$.skipNulls,sort:typeof e.sort=="function"?e.sort:null,strictNullHandling:typeof e.strictNullHandling=="boolean"?e.strictNullHandling:$.strictNullHandling}},ui=function(r,e){var t=r,n=fi(e),o,a;typeof n.filter=="function"?(a=n.filter,t=a("",t)):N(n.filter)&&(a=n.filter,o=a);var f=[];if(typeof t!="object"||t===null)return"";var p=rn[n.arrayFormat],c=p==="comma"&&n.commaRoundTrip;o||(o=Object.keys(t)),n.sort&&o.sort(n.sort);for(var y=en(),v=0;v0?b+S:""},W=Zt,Me=Object.prototype.hasOwnProperty,gr=Array.isArray,P={allowDots:!1,allowEmptyArrays:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decodeDotInKeys:!1,decoder:W.decode,delimiter:"&",depth:5,duplicates:"combine",ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictDepth:!1,strictNullHandling:!1,throwOnLimitExceeded:!1},li=function(r){return r.replace(/&#(\d+);/g,function(e,t){return String.fromCharCode(parseInt(t,10))})},nn=function(r,e,t){if(r&&typeof r=="string"&&e.comma&&r.indexOf(",")>-1)return r.split(",");if(e.throwOnLimitExceeded&&t>=e.arrayLimit)throw new RangeError("Array limit exceeded. Only "+e.arrayLimit+" element"+(e.arrayLimit===1?"":"s")+" allowed in an array.");return r},ci="utf8=%26%2310003%3B",pi="utf8=%E2%9C%93",yi=function(e,t){var n={__proto__:null},o=t.ignoreQueryPrefix?e.replace(/^\?/,""):e;o=o.replace(/%5B/gi,"[").replace(/%5D/gi,"]");var a=t.parameterLimit===1/0?void 0:t.parameterLimit,f=o.split(t.delimiter,t.throwOnLimitExceeded?a+1:a);if(t.throwOnLimitExceeded&&f.length>a)throw new RangeError("Parameter limit exceeded. Only "+a+" parameter"+(a===1?"":"s")+" allowed.");var p=-1,c,y=t.charset;if(t.charsetSentinel)for(c=0;c-1&&(b=gr(b)?[b]:b),t.comma&&gr(b)&&b.length>t.arrayLimit){if(t.throwOnLimitExceeded)throw new RangeError("Array limit exceeded. Only "+t.arrayLimit+" element"+(t.arrayLimit===1?"":"s")+" allowed in an array.");b=W.combine([],b,t.arrayLimit,t.plainObjects)}if(S!==null){var O=Me.call(n,S);O&&t.duplicates==="combine"?n[S]=W.combine(n[S],b,t.arrayLimit,t.plainObjects):(!O||t.duplicates==="last")&&(n[S]=b)}}return n},di=function(r,e,t,n){var o=0;if(r.length>0&&r[r.length-1]==="[]"){var a=r.slice(0,-1).join("");o=Array.isArray(e)&&e[a]?e[a].length:0}for(var f=n?e:nn(e,t,o),p=r.length-1;p>=0;--p){var c,y=r[p];if(y==="[]"&&t.parseArrays)W.isOverflow(f)?c=f:c=t.allowEmptyArrays&&(f===""||t.strictNullHandling&&f===null)?[]:W.combine([],f,t.arrayLimit,t.plainObjects);else{c=t.plainObjects?{__proto__:null}:{};var v=y.charAt(0)==="["&&y.charAt(y.length-1)==="]"?y.slice(1,-1):y,g=t.decodeDotInKeys?v.replace(/%2E/g,"."):v,m=parseInt(g,10),S=!isNaN(m)&&y!==g&&String(m)===g&&m>=0&&t.parseArrays;if(!t.parseArrays&&g==="")c={0:f};else if(S&&m"u"?P.charset:e.charset,n=typeof e.duplicates>"u"?P.duplicates:e.duplicates;if(n!=="combine"&&n!=="first"&&n!=="last")throw new TypeError("The duplicates option must be either combine, first, or last");var o=typeof e.allowDots>"u"?e.decodeDotInKeys===!0?!0:P.allowDots:!!e.allowDots;return{allowDots:o,allowEmptyArrays:typeof e.allowEmptyArrays=="boolean"?!!e.allowEmptyArrays:P.allowEmptyArrays,allowPrototypes:typeof e.allowPrototypes=="boolean"?e.allowPrototypes:P.allowPrototypes,allowSparse:typeof e.allowSparse=="boolean"?e.allowSparse:P.allowSparse,arrayLimit:typeof e.arrayLimit=="number"?e.arrayLimit:P.arrayLimit,charset:t,charsetSentinel:typeof e.charsetSentinel=="boolean"?e.charsetSentinel:P.charsetSentinel,comma:typeof e.comma=="boolean"?e.comma:P.comma,decodeDotInKeys:typeof e.decodeDotInKeys=="boolean"?e.decodeDotInKeys:P.decodeDotInKeys,decoder:typeof e.decoder=="function"?e.decoder:P.decoder,delimiter:typeof e.delimiter=="string"||W.isRegExp(e.delimiter)?e.delimiter:P.delimiter,depth:typeof e.depth=="number"||e.depth===!1?+e.depth:P.depth,duplicates:n,ignoreQueryPrefix:e.ignoreQueryPrefix===!0,interpretNumericEntities:typeof e.interpretNumericEntities=="boolean"?e.interpretNumericEntities:P.interpretNumericEntities,parameterLimit:typeof e.parameterLimit=="number"?e.parameterLimit:P.parameterLimit,parseArrays:e.parseArrays!==!1,plainObjects:typeof e.plainObjects=="boolean"?e.plainObjects:P.plainObjects,strictDepth:typeof e.strictDepth=="boolean"?!!e.strictDepth:P.strictDepth,strictNullHandling:typeof e.strictNullHandling=="boolean"?e.strictNullHandling:P.strictNullHandling,throwOnLimitExceeded:typeof e.throwOnLimitExceeded=="boolean"?e.throwOnLimitExceeded:!1}},gi=function(r,e){var t=mi(e);if(r===""||r===null||typeof r>"u")return t.plainObjects?{__proto__:null}:{};for(var n=typeof r=="string"?yi(r,t):r,o=t.plainObjects?{__proto__:null}:{},a=Object.keys(n),f=0;f-1};function pe(r){if(typeof r!="string"&&(r=String(r)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(r)||r==="")throw new TypeError('Invalid character in header field name: "'+r+'"');return r.toLowerCase()}function Nr(r){return typeof r!="string"&&(r=String(r)),r}function Lr(r){var e={next:function(){var t=r.shift();return{done:t===void 0,value:t}}};return F.iterable&&(e[Symbol.iterator]=function(){return e}),e}function x(r){this.map={},r instanceof x?r.forEach(function(e,t){this.append(t,e)},this):Array.isArray(r)?r.forEach(function(e){if(e.length!=2)throw new TypeError("Headers constructor: expected name/value pair to be length 2, found"+e.length);this.append(e[0],e[1])},this):r&&Object.getOwnPropertyNames(r).forEach(function(e){this.append(e,r[e])},this)}x.prototype.append=function(r,e){r=pe(r),e=Nr(e);var t=this.map[r];this.map[r]=t?t+", "+e:e};x.prototype.delete=function(r){delete this.map[pe(r)]};x.prototype.get=function(r){return r=pe(r),this.has(r)?this.map[r]:null};x.prototype.has=function(r){return this.map.hasOwnProperty(pe(r))};x.prototype.set=function(r,e){this.map[pe(r)]=Nr(e)};x.prototype.forEach=function(r,e){for(var t in this.map)this.map.hasOwnProperty(t)&&r.call(e,this.map[t],t,this)};x.prototype.keys=function(){var r=[];return this.forEach(function(e,t){r.push(t)}),Lr(r)};x.prototype.values=function(){var r=[];return this.forEach(function(e){r.push(e)}),Lr(r)};x.prototype.entries=function(){var r=[];return this.forEach(function(e,t){r.push([t,e])}),Lr(r)};F.iterable&&(x.prototype[Symbol.iterator]=x.prototype.entries);function br(r){if(!r._noBody){if(r.bodyUsed)return Promise.reject(new TypeError("Already read"));r.bodyUsed=!0}}function on(r){return new Promise(function(e,t){r.onload=function(){e(r.result)},r.onerror=function(){t(r.error)}})}function Pi(r){var e=new FileReader,t=on(e);return e.readAsArrayBuffer(r),t}function $i(r){var e=new FileReader,t=on(e),n=/charset=([A-Za-z0-9_-]+)/.exec(r.type),o=n?n[1]:"utf-8";return e.readAsText(r,o),t}function xi(r){for(var e=new Uint8Array(r),t=new Array(e.length),n=0;n-1?e:r}function re(r,e){if(!(this instanceof re))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');e=e||{};var t=e.body;if(r instanceof re){if(r.bodyUsed)throw new TypeError("Already read");this.url=r.url,this.credentials=r.credentials,e.headers||(this.headers=new x(r.headers)),this.method=r.method,this.mode=r.mode,this.signal=r.signal,!t&&r._bodyInit!=null&&(t=r._bodyInit,r.bodyUsed=!0)}else this.url=String(r);if(this.credentials=e.credentials||this.credentials||"same-origin",(e.headers||!this.headers)&&(this.headers=new x(e.headers)),this.method=Ti(e.method||this.method||"GET"),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal||function(){if("AbortController"in C){var a=new AbortController;return a.signal}}(),this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&t)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(t),(this.method==="GET"||this.method==="HEAD")&&(e.cache==="no-store"||e.cache==="no-cache")){var n=/([?&])_=[^&]*/;if(n.test(this.url))this.url=this.url.replace(n,"$1_="+new Date().getTime());else{var o=/\?/;this.url+=(o.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}re.prototype.clone=function(){return new re(this,{body:this._bodyInit})};function Ii(r){var e=new FormData;return r.trim().split("&").forEach(function(t){if(t){var n=t.split("="),o=n.shift().replace(/\+/g," "),a=n.join("=").replace(/\+/g," ");e.append(decodeURIComponent(o),decodeURIComponent(a))}}),e}function Ci(r){var e=new x,t=r.replace(/\r?\n[\t ]+/g," ");return t.split("\r").map(function(n){return n.indexOf(` diff --git a/dist/assets/index-84b5b30a.js b/dist/assets/index-7a6e3cac.js similarity index 97% rename from dist/assets/index-84b5b30a.js rename to dist/assets/index-7a6e3cac.js index 507c16623fe07593625cbe8e240ac72b92864e42..f05fb9292d406afd4c2596e14beda659ca408621 100644 --- a/dist/assets/index-84b5b30a.js +++ b/dist/assets/index-7a6e3cac.js @@ -1,4 +1,4 @@ -import{r as F,j as c,c as Ne,f as Ge,m as Se,v as ze}from"./umi-9940633e.js";import{q as He,L as Je,P as Ye,Q as Ke}from"./index-a694f10d.js";import{u as qe,c as Xe,d as Qe,b as Ze,E as et,S as tt,s as ye,P as st,e as nt,f as rt,A as it,a as at}from"./index.less_used_.module-48415e76.js";import{d as Be,j as ot,p as lt}from"./tiny-invariant-00aeb6f0.js";import{u as ct,e as ut}from"./index-d0e185c0.js";import{a as oe,v as ht}from"./parser-9472c317.js";import{S as mt}from"./scheduler-a7fa9c3c.js";import{v as ne,M as dt,r as le,W as pt,w as Me,x as gt,y as ft}from"./index-1a249a16.js";import{u as yt,r as be,n as Ie,q as bt,x as xt,v as Pe,w as Ce,y as vt}from"./index-da8ccbdf.js";import{S as kt}from"./schedulePool-cc4538c2.js";import{B as ee}from"./button-eaadfeb4.js";import{a as wt,H as St,R as _t,C as _e,L as jt,c as Nt,E as Et}from"./util-477962f3.js";import{b as Mt,S as xe,T as je}from"./TextArea-b3aeb374.js";import{S as It}from"./index-1b65ca98.js";import{u as Oe}from"./useAsync-b9da6d72.js";import{u as Pt}from"./useAsyncFn-b0803fd6.js";import{P as Ct,a as Ot}from"./PlaySquareOutlined-646d1a37.js";import{E as Rt}from"./EditOutlined-fac0ac1a.js";import"./_setToString-98c064b8.js";import"./download-cbece843.js";import"./jszip.min-37f7e998.js";var ke={},ve=function(){var s=function(_,u,p,g){for(p=p||{},g=_.length;g--;p[_[g]]=u);return p},e=[19,26,29],r=[2,15],t=[1,12],i=[1,10],a=[4,13,19,25,26,29],n=[1,15],l=[4,12,13,19,25,26,29],y=[1,21],S=[1,23],d=[1,22],v=[19,25,26,29],w=[4,12,13,15,19,20,26,29],N=[1,31],W=[1,32],L=[1,33],E=[4,12,13,15,19,20,25,26,27,28,29],H=[25,26,29],V=[15,19,25,26,29],M={trace:function(){},yy:{},symbols_:{error:2,start_symbol:3,EOF:4,measure:5,music_events:6,music_event:7,event:8,music_breath:9,note:10,grace:11,"|":12,"{":13,note_list:14,"}":15,left_divisions:16,pitch:17,right_divisions:18,"<":19,">":20,syllable:21,accidental:22,decorators:23,notations:24,V:25,ACC:26,DECORATOR:27,NOTATION:28,N:29,$accept:0,$end:1},terminals_:{2:"error",4:"EOF",12:"|",13:"{",15:"}",19:"<",20:">",25:"V",26:"ACC",27:"DECORATOR",28:"NOTATION",29:"N"},productions_:[0,[3,1],[3,2],[5,1],[6,1],[6,2],[7,1],[7,1],[8,1],[8,3],[8,3],[11,3],[14,1],[14,2],[10,3],[16,0],[16,2],[18,0],[18,2],[17,1],[17,2],[17,2],[17,2],[17,2],[17,2],[22,1],[22,2],[23,1],[23,2],[24,1],[24,2],[21,1],[9,1]],performAction:function(u,p,g,f,j,k,ce){var I=k.length-1;switch(j){case 1:return null;case 2:return k[I-1];case 3:this.$=m(k[I]);break;case 4:case 12:case 27:case 29:this.$=[k[I]];break;case 5:case 13:case 28:case 30:this.$=[...k[I-1],k[I]];break;case 9:this.$={...k[I],grace:k[I-2]};break;case 10:this.$={...k[I-2],postGrace:k[I]};break;case 11:case 24:this.$=k[I-1];break;case 14:this.$={ldiv:k[I-2],...A(k[I-1]),rdiv:k[I]};break;case 15:case 17:this.$=0;break;case 16:case 18:this.$=k[I-1]+1;break;case 19:this.$={syllable:k[I]};break;case 20:this.$={acc:k[I-1],...k[I]};break;case 21:this.$={...k[I-1],decorators:[...k[I-1].decorators||[],...k[I]]};break;case 22:this.$={...k[I-1],notations:[...k[I-1].notations||[],...k[I]]};break;case 23:case 25:this.$=k[I];break;case 26:this.$=k[I-1]+k[I];break}},table:[s(e,r,{3:1,5:3,6:4,7:5,8:6,9:7,10:8,11:9,16:11,4:[1,2],13:t,25:i}),{1:[3]},{1:[2,1]},{4:[1,13]},s(e,r,{8:6,9:7,10:8,11:9,16:11,7:14,4:[2,3],13:t,25:i}),s(a,[2,4]),s(a,[2,6],{12:n}),s(a,[2,7]),s(l,[2,8]),{12:[1,16]},s(a,[2,32]),{17:17,19:[1,18],21:19,22:20,25:y,26:S,29:d},s(v,r,{16:11,14:24,10:25}),{1:[2,2]},s(a,[2,5]),{11:26,13:t},s(v,r,{10:8,11:9,16:11,8:27,13:t}),s(w,[2,17],{18:28,23:29,24:30,25:N,27:W,28:L}),s(v,[2,16]),s(E,[2,19]),{17:34,21:19,22:20,25:y,26:[1,35],29:d},{17:36,21:19,22:20,25:y,26:S,29:d},s(E,[2,31]),s(H,[2,25]),s(v,r,{16:11,10:38,15:[1,37]}),s(V,[2,12]),s(l,[2,10]),s(a,[2,9],{12:n}),s([4,12,13,15,19,25,26,29],[2,14],{20:[1,39]}),s([4,12,13,15,19,20,25,26,28,29],[2,21],{27:[1,40]}),s([4,12,13,15,19,20,25,26,27,29],[2,22],{28:[1,41]}),s(E,[2,24]),s(E,[2,27]),s(E,[2,29]),s(w,[2,20],{23:29,24:30,25:N,27:W,28:L}),s(H,[2,26]),s(w,[2,23],{23:29,24:30,25:N,27:W,28:L}),s(l,[2,11]),s(V,[2,13]),s([4,12,13,15,19,20,25,26,29],[2,18]),s(E,[2,28]),s(E,[2,30])],defaultActions:{2:[2,1],13:[2,2]},parseError:function(u,p){if(p.recoverable)this.trace(u);else{var g=new Error(u);throw g.hash=p,g}},parse:function(u){var p=this,g=[0],f=[null],j=[],k=this.table,ce="",I=0,pe=0,q=2,ge=1,fe=j.slice.call(arguments,1),U=Object.create(this.lexer),X={yy:{}};for(var ie in this.yy)Object.prototype.hasOwnProperty.call(this.yy,ie)&&(X.yy[ie]=this.yy[ie]);U.setInput(u,X.yy),X.yy.lexer=U,X.yy.parser=this,typeof U.yylloc>"u"&&(U.yylloc={});var ue=U.yylloc;j.push(ue);var we=U.options&&U.options.ranges;typeof X.yy.parseError=="function"?this.parseError=X.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;for(var he=function(){var T;return T=U.lex()||ge,typeof T!="number"&&(T=p.symbols_[T]||T),T},z,Q,J,ae,te={},o,b,O,x;;){if(Q=g[g.length-1],this.defaultActions[Q]?J=this.defaultActions[Q]:((z===null||typeof z>"u")&&(z=he()),J=k[Q]&&k[Q][z]),typeof J>"u"||!J.length||!J[0]){var P="";x=[];for(o in k[Q])this.terminals_[o]&&o>q&&x.push("'"+this.terminals_[o]+"'");U.showPosition?P="Parse error on line "+(I+1)+`: +import{r as F,j as c,c as Ne,f as Ge,m as Se,v as ze}from"./umi-a12c8253.js";import{q as He,L as Je,P as Ye,Q as Ke}from"./index-a2a53045.js";import{u as qe,c as Xe,d as Qe,b as Ze,E as et,S as tt,s as ye,P as st,e as nt,f as rt,A as it,a as at}from"./index.less_used_.module-0a64bdd1.js";import{d as Be,j as ot,p as lt}from"./tiny-invariant-28d484ad.js";import{u as ct,e as ut}from"./index-ead1f686.js";import{a as oe,v as ht}from"./parser-b66b074b.js";import{S as mt}from"./scheduler-a7fa9c3c.js";import{v as ne,M as dt,r as le,W as pt,w as Me,x as gt,y as ft}from"./index-43517c6d.js";import{u as yt,r as be,n as Ie,q as bt,x as xt,v as Pe,w as Ce,y as vt}from"./index-5722ce0d.js";import{S as kt}from"./schedulePool-cc4538c2.js";import{B as ee}from"./button-f56a19a0.js";import{a as wt,H as St,R as _t,C as _e,L as jt,c as Nt,E as Et}from"./util-590d1471.js";import{b as Mt,S as xe,T as je}from"./TextArea-ec8ab387.js";import{S as It}from"./index-40bfaf7c.js";import{u as Oe}from"./useAsync-4e4b92b3.js";import{u as Pt}from"./useAsyncFn-b4ac32aa.js";import{P as Ct,a as Ot}from"./PlaySquareOutlined-1144cdf9.js";import{E as Rt}from"./EditOutlined-d468c101.js";import"./_setToString-ca5ad23e.js";import"./download-ef7cdf5d.js";import"./jszip.min-f65a05ae.js";var ke={},ve=function(){var s=function(_,u,p,g){for(p=p||{},g=_.length;g--;p[_[g]]=u);return p},e=[19,26,29],r=[2,15],t=[1,12],i=[1,10],a=[4,13,19,25,26,29],n=[1,15],l=[4,12,13,19,25,26,29],y=[1,21],S=[1,23],d=[1,22],v=[19,25,26,29],w=[4,12,13,15,19,20,26,29],N=[1,31],W=[1,32],L=[1,33],E=[4,12,13,15,19,20,25,26,27,28,29],H=[25,26,29],V=[15,19,25,26,29],M={trace:function(){},yy:{},symbols_:{error:2,start_symbol:3,EOF:4,measure:5,music_events:6,music_event:7,event:8,music_breath:9,note:10,grace:11,"|":12,"{":13,note_list:14,"}":15,left_divisions:16,pitch:17,right_divisions:18,"<":19,">":20,syllable:21,accidental:22,decorators:23,notations:24,V:25,ACC:26,DECORATOR:27,NOTATION:28,N:29,$accept:0,$end:1},terminals_:{2:"error",4:"EOF",12:"|",13:"{",15:"}",19:"<",20:">",25:"V",26:"ACC",27:"DECORATOR",28:"NOTATION",29:"N"},productions_:[0,[3,1],[3,2],[5,1],[6,1],[6,2],[7,1],[7,1],[8,1],[8,3],[8,3],[11,3],[14,1],[14,2],[10,3],[16,0],[16,2],[18,0],[18,2],[17,1],[17,2],[17,2],[17,2],[17,2],[17,2],[22,1],[22,2],[23,1],[23,2],[24,1],[24,2],[21,1],[9,1]],performAction:function(u,p,g,f,j,k,ce){var I=k.length-1;switch(j){case 1:return null;case 2:return k[I-1];case 3:this.$=m(k[I]);break;case 4:case 12:case 27:case 29:this.$=[k[I]];break;case 5:case 13:case 28:case 30:this.$=[...k[I-1],k[I]];break;case 9:this.$={...k[I],grace:k[I-2]};break;case 10:this.$={...k[I-2],postGrace:k[I]};break;case 11:case 24:this.$=k[I-1];break;case 14:this.$={ldiv:k[I-2],...A(k[I-1]),rdiv:k[I]};break;case 15:case 17:this.$=0;break;case 16:case 18:this.$=k[I-1]+1;break;case 19:this.$={syllable:k[I]};break;case 20:this.$={acc:k[I-1],...k[I]};break;case 21:this.$={...k[I-1],decorators:[...k[I-1].decorators||[],...k[I]]};break;case 22:this.$={...k[I-1],notations:[...k[I-1].notations||[],...k[I]]};break;case 23:case 25:this.$=k[I];break;case 26:this.$=k[I-1]+k[I];break}},table:[s(e,r,{3:1,5:3,6:4,7:5,8:6,9:7,10:8,11:9,16:11,4:[1,2],13:t,25:i}),{1:[3]},{1:[2,1]},{4:[1,13]},s(e,r,{8:6,9:7,10:8,11:9,16:11,7:14,4:[2,3],13:t,25:i}),s(a,[2,4]),s(a,[2,6],{12:n}),s(a,[2,7]),s(l,[2,8]),{12:[1,16]},s(a,[2,32]),{17:17,19:[1,18],21:19,22:20,25:y,26:S,29:d},s(v,r,{16:11,14:24,10:25}),{1:[2,2]},s(a,[2,5]),{11:26,13:t},s(v,r,{10:8,11:9,16:11,8:27,13:t}),s(w,[2,17],{18:28,23:29,24:30,25:N,27:W,28:L}),s(v,[2,16]),s(E,[2,19]),{17:34,21:19,22:20,25:y,26:[1,35],29:d},{17:36,21:19,22:20,25:y,26:S,29:d},s(E,[2,31]),s(H,[2,25]),s(v,r,{16:11,10:38,15:[1,37]}),s(V,[2,12]),s(l,[2,10]),s(a,[2,9],{12:n}),s([4,12,13,15,19,25,26,29],[2,14],{20:[1,39]}),s([4,12,13,15,19,20,25,26,28,29],[2,21],{27:[1,40]}),s([4,12,13,15,19,20,25,26,27,29],[2,22],{28:[1,41]}),s(E,[2,24]),s(E,[2,27]),s(E,[2,29]),s(w,[2,20],{23:29,24:30,25:N,27:W,28:L}),s(H,[2,26]),s(w,[2,23],{23:29,24:30,25:N,27:W,28:L}),s(l,[2,11]),s(V,[2,13]),s([4,12,13,15,19,20,25,26,29],[2,18]),s(E,[2,28]),s(E,[2,30])],defaultActions:{2:[2,1],13:[2,2]},parseError:function(u,p){if(p.recoverable)this.trace(u);else{var g=new Error(u);throw g.hash=p,g}},parse:function(u){var p=this,g=[0],f=[null],j=[],k=this.table,ce="",I=0,pe=0,q=2,ge=1,fe=j.slice.call(arguments,1),U=Object.create(this.lexer),X={yy:{}};for(var ie in this.yy)Object.prototype.hasOwnProperty.call(this.yy,ie)&&(X.yy[ie]=this.yy[ie]);U.setInput(u,X.yy),X.yy.lexer=U,X.yy.parser=this,typeof U.yylloc>"u"&&(U.yylloc={});var ue=U.yylloc;j.push(ue);var we=U.options&&U.options.ranges;typeof X.yy.parseError=="function"?this.parseError=X.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;for(var he=function(){var T;return T=U.lex()||ge,typeof T!="number"&&(T=p.symbols_[T]||T),T},z,Q,J,ae,te={},o,b,O,x;;){if(Q=g[g.length-1],this.defaultActions[Q]?J=this.defaultActions[Q]:((z===null||typeof z>"u")&&(z=he()),J=k[Q]&&k[Q][z]),typeof J>"u"||!J.length||!J[0]){var P="";x=[];for(o in k[Q])this.terminals_[o]&&o>q&&x.push("'"+this.terminals_[o]+"'");U.showPosition?P="Parse error on line "+(I+1)+`: `+U.showPosition()+` Expecting `+x.join(", ")+", got '"+(this.terminals_[z]||z)+"'":P="Parse error on line "+(I+1)+": Unexpected "+(z==ge?"end of input":"'"+(this.terminals_[z]||z)+"'"),this.parseError(P,{text:U.match,token:this.terminals_[z]||z,line:U.yylineno,loc:ue,expected:x})}if(J[0]instanceof Array&&J.length>1)throw new Error("Parse Error: multiple actions possible at state: "+Q+", token: "+z);switch(J[0]){case 1:g.push(z),f.push(U.yytext),j.push(U.yylloc),g.push(J[1]),z=null,pe=U.yyleng,ce=U.yytext,I=U.yylineno,ue=U.yylloc;break;case 2:if(b=this.productions_[J[1]][1],te.$=f[f.length-b],te._$={first_line:j[j.length-(b||1)].first_line,last_line:j[j.length-1].last_line,first_column:j[j.length-(b||1)].first_column,last_column:j[j.length-1].last_column},we&&(te._$.range=[j[j.length-(b||1)].range[0],j[j.length-1].range[1]]),ae=this.performAction.apply(te,[ce,pe,I,X.yy,J[1],f,j].concat(fe)),typeof ae<"u")return ae;b&&(g=g.slice(0,-1*b*2),f=f.slice(0,-1*b),j=j.slice(0,-1*b)),g.push(this.productions_[J[1]][0]),f.push(te.$),j.push(te._$),O=k[g[g.length-2]][g[g.length-1]],g.push(O);break;case 3:return!0}}return!0}};const m=_=>{const u=_.filter(f=>f!=="V"&&f.syllable!=="-");let p=0;for(let f of u)p+=f.ldiv,f.underline=p,p-=f.rdiv,f.grace&&(f.grace=m(f.grace)),f.postGrace&&(f.postGrace=m(f.postGrace)),delete f.ldiv,delete f.rdiv;let g=[];for(let f of u)f.ltuplet&&g.push(f),g.length>0&&!f.ltuplet&&!f.rtuplet&&g.push(f),f.rtuplet&&(g.push(f),g.forEach(j=>{const k=g.length;j.timeWarp={numerator:k-1,denominator:k}}),g=[]),delete f.ltuplet,delete f.rtuplet;return _},A=_=>{if(_.octaves=0,_.dots=0,_.ltuplet=0,_.rtuplet=0,_.decorators){for(let u=0;u<_.decorators.length;u++)switch(_.decorators[u]){case"'":_.octaves+=1;break;case",":_.octaves-=1;break;case".":_.dots+=1;break;case"[":_.ltuplet=1;break;case"]":_.rtuplet=1;break}delete _.decorators}return _.notations&&(_.notations=_.notations.map(u=>u.replace(/[^a-z]/g,""))),_};var R=function(){var _={EOF:1,parseError:function(p,g){if(this.yy.parser)this.yy.parser.parseError(p,g);else throw new Error(p)},setInput:function(u,p){return this.yy=p||this.yy||{},this._input=u,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var u=this._input[0];this.yytext+=u,this.yyleng++,this.offset++,this.match+=u,this.matched+=u;var p=u.match(/(?:\r\n?|\n).*/g);return p?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),u},unput:function(u){var p=u.length,g=u.split(/(?:\r\n?|\n)/g);this._input=u+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-p),this.offset-=p;var f=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),g.length-1&&(this.yylineno-=g.length-1);var j=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:g?(g.length===f.length?this.yylloc.first_column:0)+f[f.length-g.length].length-g[0].length:this.yylloc.first_column-p},this.options.ranges&&(this.yylloc.range=[j[0],j[0]+this.yyleng-p]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){if(this.options.backtrack_lexer)this._backtrack=!0;else return this.parseError("Lexical error on line "+(this.yylineno+1)+`. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true). `+this.showPosition(),{text:"",token:null,line:this.yylineno});return this},less:function(u){this.unput(this.match.slice(u))},pastInput:function(){var u=this.matched.substr(0,this.matched.length-this.match.length);return(u.length>20?"...":"")+u.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var u=this.match;return u.length<20&&(u+=this._input.substr(0,20-u.length)),(u.substr(0,20)+(u.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var u=this.pastInput(),p=new Array(u.length+1).join("-");return u+this.upcomingInput()+` diff --git a/dist/assets/index-690c95dc.js b/dist/assets/index-868eaf8d.js similarity index 98% rename from dist/assets/index-690c95dc.js rename to dist/assets/index-868eaf8d.js index 6fb6d75768bcd9161823c98dc98531e57cd46f94..5a731c15967e38a1e8dd05a72889805290f8fb6e 100644 --- a/dist/assets/index-690c95dc.js +++ b/dist/assets/index-868eaf8d.js @@ -1 +1 @@ -import{G as K,F as X,E as Y,r as c,H as R,I as q,av as J,a as Q,C as V,c as x,b as g,e as Z,d as h,y as ee,a2 as te,aG as ae,Y as ne,a3 as re,aA as oe,ai as ce,aB as se,az as le,g as ie}from"./umi-9940633e.js";import{z as ue}from"./_setToString-98c064b8.js";function de(a){return Object.keys(a).reduce(function(e,t){return(t.startsWith("data-")||t.startsWith("aria-")||t==="role")&&!t.startsWith("data-__")&&(e[t]=a[t]),e},{})}function fe(a,e,t){return e=R(e),q(a,J()?Reflect.construct(e,t||[],R(a).constructor):e.apply(a,t))}var me=function(a){K(e,a);function e(){var t;return X(this,e),t=fe(this,e,arguments),t.state={error:void 0,info:{componentStack:""}},t}return Y(e,[{key:"componentDidCatch",value:function(n,r){this.setState({error:n,info:r})}},{key:"render",value:function(){var n=this.props,r=n.message,s=n.description,l=n.children,o=this.state,d=o.error,m=o.info,i=m&&m.componentStack?m.componentStack:null,p=typeof r>"u"?(d||"").toString():r,b=typeof s>"u"?i:s;return d?c.createElement(he,{type:"error",message:p,description:c.createElement("pre",null,b)}):l}}]),e}(c.Component);const pe=me;var Ce=globalThis&&globalThis.__rest||function(a,e){var t={};for(var n in a)Object.prototype.hasOwnProperty.call(a,n)&&e.indexOf(n)<0&&(t[n]=a[n]);if(a!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,n=Object.getOwnPropertySymbols(a);r"u"){t&&console.warn("unable to use e.clipboardData"),t&&console.warn("trying IE specific stuff"),window.clipboardData.clearData();var p=A[e.format]||A.default;window.clipboardData.setData(p,a)}else i.clipboardData.clearData(),i.clipboardData.setData(e.format,a);e.onCopy&&(i.preventDefault(),e.onCopy(i.clipboardData))}),document.body.appendChild(o),s.selectNodeContents(o),l.addRange(s);var m=document.execCommand("copy");if(!m)throw new Error("copy command was unsuccessful");d=!0}catch(i){t&&console.error("unable to copy using execCommand: ",i),t&&console.warn("trying IE specific stuff");try{window.clipboardData.setData(e.format||"text",a),e.onCopy&&e.onCopy(window.clipboardData),d=!0}catch(p){t&&console.error("unable to copy using clipboardData: ",p),t&&console.error("falling back to prompt"),n=Ne("message"in e?e.message:we),window.prompt(n,a)}}finally{l&&(typeof l.removeRange=="function"?l.removeRange(s):l.removeAllRanges()),o&&document.body.removeChild(o),r()}return d}var Ie=Se;const Oe=ie(Ie);export{he as A,de as g,Oe as w}; +import{G as K,F as X,E as Y,r as c,H as R,I as q,av as J,a as Q,C as V,c as x,b as g,e as Z,d as h,y as ee,a2 as te,aG as ae,Y as ne,a3 as re,aA as oe,ai as ce,aB as se,az as le,g as ie}from"./umi-a12c8253.js";import{z as ue}from"./_setToString-ca5ad23e.js";function de(a){return Object.keys(a).reduce(function(e,t){return(t.startsWith("data-")||t.startsWith("aria-")||t==="role")&&!t.startsWith("data-__")&&(e[t]=a[t]),e},{})}function fe(a,e,t){return e=R(e),q(a,J()?Reflect.construct(e,t||[],R(a).constructor):e.apply(a,t))}var me=function(a){K(e,a);function e(){var t;return X(this,e),t=fe(this,e,arguments),t.state={error:void 0,info:{componentStack:""}},t}return Y(e,[{key:"componentDidCatch",value:function(n,r){this.setState({error:n,info:r})}},{key:"render",value:function(){var n=this.props,r=n.message,s=n.description,l=n.children,o=this.state,d=o.error,m=o.info,i=m&&m.componentStack?m.componentStack:null,p=typeof r>"u"?(d||"").toString():r,b=typeof s>"u"?i:s;return d?c.createElement(he,{type:"error",message:p,description:c.createElement("pre",null,b)}):l}}]),e}(c.Component);const pe=me;var Ce=globalThis&&globalThis.__rest||function(a,e){var t={};for(var n in a)Object.prototype.hasOwnProperty.call(a,n)&&e.indexOf(n)<0&&(t[n]=a[n]);if(a!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,n=Object.getOwnPropertySymbols(a);r"u"){t&&console.warn("unable to use e.clipboardData"),t&&console.warn("trying IE specific stuff"),window.clipboardData.clearData();var p=A[e.format]||A.default;window.clipboardData.setData(p,a)}else i.clipboardData.clearData(),i.clipboardData.setData(e.format,a);e.onCopy&&(i.preventDefault(),e.onCopy(i.clipboardData))}),document.body.appendChild(o),s.selectNodeContents(o),l.addRange(s);var m=document.execCommand("copy");if(!m)throw new Error("copy command was unsuccessful");d=!0}catch(i){t&&console.error("unable to copy using execCommand: ",i),t&&console.warn("trying IE specific stuff");try{window.clipboardData.setData(e.format||"text",a),e.onCopy&&e.onCopy(window.clipboardData),d=!0}catch(p){t&&console.error("unable to copy using clipboardData: ",p),t&&console.error("falling back to prompt"),n=Ne("message"in e?e.message:we),window.prompt(n,a)}}finally{l&&(typeof l.removeRange=="function"?l.removeRange(s):l.removeAllRanges()),o&&document.body.removeChild(o),r()}return d}var Ie=Se;const Oe=ie(Ie);export{he as A,de as g,Oe as w}; diff --git a/dist/assets/index-a694f10d.js b/dist/assets/index-a2a53045.js similarity index 98% rename from dist/assets/index-a694f10d.js rename to dist/assets/index-a2a53045.js index ed28bf728614d18e129ec81954e172fdaaf8e0c9..3c87fb1e1d0247cc800638be04ee61c46c88ab8e 100644 --- a/dist/assets/index-a694f10d.js +++ b/dist/assets/index-a2a53045.js @@ -1 +1 @@ -import{r as l,C as U,d as p,c as L,b as V,G as Ne,F as _e,E as Te,H as le,I as Se,av as ke,z as $e,a4 as Fe,a as H,A as Ie,i as ie,au as dt,W as ye,aw as je,y as mt,ag as vt,_ as X,ax as Ct,ay as gt,az as Me,ai as yt,aA as ht,aB as bt,aC as xt,Z as Re,a3 as pt,j as fe,aD as Ot,aE as Pt,g as Et}from"./umi-9940633e.js";import{T as De,e as J,k as wt,S as Nt,u as Ae,A as _t,B as Tt,z as St,K as kt}from"./TextArea-b3aeb374.js";import{k as ze,f as $t,D as Ft}from"./util-477962f3.js";import{t as It,u as jt,B as q,N as Le,c as he}from"./button-eaadfeb4.js";import{c as ee,i as ce,o as Be,t as Mt}from"./_setToString-98c064b8.js";import{D as Rt,M as Dt,u as At,S as zt,a as Ve,b as Lt,c as He,d as Bt}from"./EditOutlined-fac0ac1a.js";var de=function(e){return e?typeof e=="function"?e():e:null},Vt=globalThis&&globalThis.__rest||function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,n=Object.getOwnPropertySymbols(t);o"u"?s=g?w:"":x===!1&&(s="");var c={title:s};!o&&!y&&(c.title=null,c.open=!1);var u=It(w).length,b=l.createElement(Dt,p({},i,{className:L(V(V({},"".concat(v,"-item-danger"),a),"".concat(v,"-item-only-child"),(P?u+1:u)===1),E),title:typeof x=="string"?x:void 0}),ee(P,{className:L(ce(P)?(f=P.props)===null||f===void 0?void 0:f.className:"","".concat(v,"-item-icon"))}),r.renderItemChildren(y));return C||(b=l.createElement(De,p({},c,{placement:m==="rtl"?"left":"right",overlayClassName:"".concat(v,"-inline-collapsed-tooltip")}),b)),b},r}return Te(e,[{key:"renderItemChildren",value:function(n){var o=this.context,f=o.prefixCls,d=o.firstLevel,v=this.props,g=v.icon,y=v.children,m=l.createElement("span",{className:"".concat(f,"-title-content")},y);return(!g||ce(y)&&y.type==="span")&&y&&n&&d&&typeof y=="string"?l.createElement("div",{className:"".concat(f,"-inline-collapsed-noicon")},y.charAt(0)):m}},{key:"render",value:function(){return l.createElement(ze.Consumer,null,this.renderItem)}}]),e}(l.Component);be.contextType=se;function qe(t){var e,r=t.popupClassName,n=t.icon,o=t.title,f=t.theme,d=l.useContext(se),v=d.prefixCls,g=d.inlineCollapsed,y=d.antdMenuTheme,m=At(),C;if(!n)C=g&&!m.length&&o&&typeof o=="string"?l.createElement("div",{className:"".concat(v,"-inline-collapsed-noicon")},o.charAt(0)):l.createElement("span",{className:"".concat(v,"-title-content")},o);else{var O=ce(o)&&o.type==="span";C=l.createElement(l.Fragment,null,ee(n,{className:L(ce(n)?(e=n.props)===null||e===void 0?void 0:e.className:"","".concat(v,"-item-icon"))}),O?o:l.createElement("span",{className:"".concat(v,"-title-content")},o))}var E=l.useMemo(function(){return p(p({},d),{firstLevel:!1})},[d]);return l.createElement(se.Provider,{value:E},l.createElement(zt,p({},Be(t,["icon"]),{title:C,popupClassName:L(v,"".concat(v,"-").concat(f||y),r)})))}var Yt=globalThis&&globalThis.__rest||function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,n=Object.getOwnPropertySymbols(t);ojn.includes(t)?t:"en-US",Zn=()=>fe.jsx(Ke,{menu:{items:Mn,selectedKeys:[Rn(Ot())],onClick:({key:t})=>Pt(t,!1)},children:fe.jsx(q,{icon:fe.jsx(In,{}),size:"small",style:{marginLeft:12}})});var at={},Dn=t=>encodeURIComponent(t).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`),ot="%[a-f0-9]{2}",Ee=new RegExp("("+ot+")|([^%]+?)","gi"),we=new RegExp("("+ot+")+","gi");function ge(t,e){try{return[decodeURIComponent(t.join(""))]}catch{}if(t.length===1)return t;e=e||1;var r=t.slice(0,e),n=t.slice(e);return Array.prototype.concat.call([],ge(r),ge(n))}function An(t){try{return decodeURIComponent(t)}catch{for(var e=t.match(Ee)||[],r=1;r{if(!(typeof t=="string"&&typeof e=="string"))throw new TypeError("Expected the arguments to be of type `string`");if(e==="")return[t];const r=t.indexOf(e);return r===-1?[t]:[t.slice(0,r),t.slice(r+e.length)]},Vn=function(t,e){for(var r={},n=Object.keys(t),o=Array.isArray(e),f=0;fa==null,d=Symbol("encodeFragmentIdentifier");function v(a){switch(a.arrayFormat){case"index":return i=>(s,c)=>{const u=s.length;return c===void 0||a.skipNull&&c===null||a.skipEmptyString&&c===""?s:c===null?[...s,[m(i,a),"[",u,"]"].join("")]:[...s,[m(i,a),"[",m(u,a),"]=",m(c,a)].join("")]};case"bracket":return i=>(s,c)=>c===void 0||a.skipNull&&c===null||a.skipEmptyString&&c===""?s:c===null?[...s,[m(i,a),"[]"].join("")]:[...s,[m(i,a),"[]=",m(c,a)].join("")];case"colon-list-separator":return i=>(s,c)=>c===void 0||a.skipNull&&c===null||a.skipEmptyString&&c===""?s:c===null?[...s,[m(i,a),":list="].join("")]:[...s,[m(i,a),":list=",m(c,a)].join("")];case"comma":case"separator":case"bracket-separator":{const i=a.arrayFormat==="bracket-separator"?"[]=":"=";return s=>(c,u)=>u===void 0||a.skipNull&&u===null||a.skipEmptyString&&u===""?c:(u=u===null?"":u,c.length===0?[[m(s,a),i,m(u,a)].join("")]:[[c,m(u,a)].join(a.arrayFormatSeparator)])}default:return i=>(s,c)=>c===void 0||a.skipNull&&c===null||a.skipEmptyString&&c===""?s:c===null?[...s,m(i,a)]:[...s,[m(i,a),"=",m(c,a)].join("")]}}function g(a){let i;switch(a.arrayFormat){case"index":return(s,c,u)=>{if(i=/\[(\d*)\]$/.exec(s),s=s.replace(/\[\d*\]$/,""),!i){u[s]=c;return}u[s]===void 0&&(u[s]={}),u[s][i[1]]=c};case"bracket":return(s,c,u)=>{if(i=/(\[\])$/.exec(s),s=s.replace(/\[\]$/,""),!i){u[s]=c;return}if(u[s]===void 0){u[s]=[c];return}u[s]=[].concat(u[s],c)};case"colon-list-separator":return(s,c,u)=>{if(i=/(:list)$/.exec(s),s=s.replace(/:list$/,""),!i){u[s]=c;return}if(u[s]===void 0){u[s]=[c];return}u[s]=[].concat(u[s],c)};case"comma":case"separator":return(s,c,u)=>{const b=typeof c=="string"&&c.includes(a.arrayFormatSeparator),h=typeof c=="string"&&!b&&C(c,a).includes(a.arrayFormatSeparator);c=h?C(c,a):c;const k=b||h?c.split(a.arrayFormatSeparator).map(A=>C(A,a)):c===null?c:C(c,a);u[s]=k};case"bracket-separator":return(s,c,u)=>{const b=/(\[\])$/.test(s);if(s=s.replace(/\[\]$/,""),!b){u[s]=c&&C(c,a);return}const h=c===null?[]:c.split(a.arrayFormatSeparator).map(k=>C(k,a));if(u[s]===void 0){u[s]=h;return}u[s]=[].concat(u[s],h)};default:return(s,c,u)=>{if(u[s]===void 0){u[s]=c;return}u[s]=[].concat(u[s],c)}}}function y(a){if(typeof a!="string"||a.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function m(a,i){return i.encode?i.strict?e(a):encodeURIComponent(a):a}function C(a,i){return i.decode?r(a):a}function O(a){return Array.isArray(a)?a.sort():typeof a=="object"?O(Object.keys(a)).sort((i,s)=>Number(i)-Number(s)).map(i=>a[i]):a}function E(a){const i=a.indexOf("#");return i!==-1&&(a=a.slice(0,i)),a}function w(a){let i="";const s=a.indexOf("#");return s!==-1&&(i=a.slice(s)),i}function N(a){a=E(a);const i=a.indexOf("?");return i===-1?"":a.slice(i+1)}function x(a,i){return i.parseNumbers&&!Number.isNaN(Number(a))&&typeof a=="string"&&a.trim()!==""?a=Number(a):i.parseBooleans&&a!==null&&(a.toLowerCase()==="true"||a.toLowerCase()==="false")&&(a=a.toLowerCase()==="true"),a}function P(a,i){i=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},i),y(i.arrayFormatSeparator);const s=g(i),c=Object.create(null);if(typeof a!="string"||(a=a.trim().replace(/^[?#&]/,""),!a))return c;for(const u of a.split("&")){if(u==="")continue;let[b,h]=n(i.decode?u.replace(/\+/g," "):u,"=");h=h===void 0?null:["comma","separator","bracket-separator"].includes(i.arrayFormat)?h:C(h,i),s(C(b,i),h,c)}for(const u of Object.keys(c)){const b=c[u];if(typeof b=="object"&&b!==null)for(const h of Object.keys(b))b[h]=x(b[h],i);else c[u]=x(b,i)}return i.sort===!1?c:(i.sort===!0?Object.keys(c).sort():Object.keys(c).sort(i.sort)).reduce((u,b)=>{const h=c[b];return h&&typeof h=="object"&&!Array.isArray(h)?u[b]=O(h):u[b]=h,u},Object.create(null))}t.extract=N,t.parse=P,t.stringify=(a,i)=>{if(!a)return"";i=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},i),y(i.arrayFormatSeparator);const s=h=>i.skipNull&&f(a[h])||i.skipEmptyString&&a[h]==="",c=v(i),u={};for(const h of Object.keys(a))s(h)||(u[h]=a[h]);const b=Object.keys(u);return i.sort!==!1&&b.sort(i.sort),b.map(h=>{const k=a[h];return k===void 0?"":k===null?m(h,i):Array.isArray(k)?k.length===0&&i.arrayFormat==="bracket-separator"?m(h,i)+"[]":k.reduce(c(h),[]).join("&"):m(h,i)+"="+m(k,i)}).filter(h=>h.length>0).join("&")},t.parseUrl=(a,i)=>{i=Object.assign({decode:!0},i);const[s,c]=n(a,"#");return Object.assign({url:s.split("?")[0]||"",query:P(N(a),i)},i&&i.parseFragmentIdentifier&&c?{fragmentIdentifier:C(c,i)}:{})},t.stringifyUrl=(a,i)=>{i=Object.assign({encode:!0,strict:!0,[d]:!0},i);const s=E(a.url).split("?")[0]||"",c=t.extract(a.url),u=t.parse(c,{sort:!1}),b=Object.assign(u,a.query);let h=t.stringify(b,i);h&&(h=`?${h}`);let k=w(a.url);return a.fragmentIdentifier&&(k=`#${i[d]?m(a.fragmentIdentifier,i):a.fragmentIdentifier}`),`${s}${h}${k}`},t.pick=(a,i,s)=>{s=Object.assign({parseFragmentIdentifier:!0,[d]:!1},s);const{url:c,query:u,fragmentIdentifier:b}=t.parseUrl(a,s);return t.stringifyUrl({url:c,query:o(u,i),fragmentIdentifier:b},s)},t.exclude=(a,i,s)=>{const c=Array.isArray(i)?u=>!i.includes(u):(u,b)=>!i(u,b);return t.pick(a,c,s)}})(at);const Jn=Et(at);export{Ke as D,Zn as L,Xn as M,en as O,Yn as P,Wn as Q,qt as _,an as a,Jn as q}; +import{r as l,C as U,d as p,c as L,b as V,G as Ne,F as _e,E as Te,H as le,I as Se,av as ke,z as $e,a4 as Fe,a as H,A as Ie,i as ie,au as dt,W as ye,aw as je,y as mt,ag as vt,_ as X,ax as Ct,ay as gt,az as Me,ai as yt,aA as ht,aB as bt,aC as xt,Z as Re,a3 as pt,j as fe,aD as Ot,aE as Pt,g as Et}from"./umi-a12c8253.js";import{T as De,e as J,k as wt,S as Nt,u as Ae,A as _t,B as Tt,z as St,K as kt}from"./TextArea-ec8ab387.js";import{k as ze,f as $t,D as Ft}from"./util-590d1471.js";import{t as It,u as jt,B as q,N as Le,c as he}from"./button-f56a19a0.js";import{c as ee,i as ce,o as Be,t as Mt}from"./_setToString-ca5ad23e.js";import{D as Rt,M as Dt,u as At,S as zt,a as Ve,b as Lt,c as He,d as Bt}from"./EditOutlined-d468c101.js";var de=function(e){return e?typeof e=="function"?e():e:null},Vt=globalThis&&globalThis.__rest||function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,n=Object.getOwnPropertySymbols(t);o"u"?s=g?w:"":x===!1&&(s="");var c={title:s};!o&&!y&&(c.title=null,c.open=!1);var u=It(w).length,b=l.createElement(Dt,p({},i,{className:L(V(V({},"".concat(v,"-item-danger"),a),"".concat(v,"-item-only-child"),(P?u+1:u)===1),E),title:typeof x=="string"?x:void 0}),ee(P,{className:L(ce(P)?(f=P.props)===null||f===void 0?void 0:f.className:"","".concat(v,"-item-icon"))}),r.renderItemChildren(y));return C||(b=l.createElement(De,p({},c,{placement:m==="rtl"?"left":"right",overlayClassName:"".concat(v,"-inline-collapsed-tooltip")}),b)),b},r}return Te(e,[{key:"renderItemChildren",value:function(n){var o=this.context,f=o.prefixCls,d=o.firstLevel,v=this.props,g=v.icon,y=v.children,m=l.createElement("span",{className:"".concat(f,"-title-content")},y);return(!g||ce(y)&&y.type==="span")&&y&&n&&d&&typeof y=="string"?l.createElement("div",{className:"".concat(f,"-inline-collapsed-noicon")},y.charAt(0)):m}},{key:"render",value:function(){return l.createElement(ze.Consumer,null,this.renderItem)}}]),e}(l.Component);be.contextType=se;function qe(t){var e,r=t.popupClassName,n=t.icon,o=t.title,f=t.theme,d=l.useContext(se),v=d.prefixCls,g=d.inlineCollapsed,y=d.antdMenuTheme,m=At(),C;if(!n)C=g&&!m.length&&o&&typeof o=="string"?l.createElement("div",{className:"".concat(v,"-inline-collapsed-noicon")},o.charAt(0)):l.createElement("span",{className:"".concat(v,"-title-content")},o);else{var O=ce(o)&&o.type==="span";C=l.createElement(l.Fragment,null,ee(n,{className:L(ce(n)?(e=n.props)===null||e===void 0?void 0:e.className:"","".concat(v,"-item-icon"))}),O?o:l.createElement("span",{className:"".concat(v,"-title-content")},o))}var E=l.useMemo(function(){return p(p({},d),{firstLevel:!1})},[d]);return l.createElement(se.Provider,{value:E},l.createElement(zt,p({},Be(t,["icon"]),{title:C,popupClassName:L(v,"".concat(v,"-").concat(f||y),r)})))}var Yt=globalThis&&globalThis.__rest||function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,n=Object.getOwnPropertySymbols(t);ojn.includes(t)?t:"en-US",Zn=()=>fe.jsx(Ke,{menu:{items:Mn,selectedKeys:[Rn(Ot())],onClick:({key:t})=>Pt(t,!1)},children:fe.jsx(q,{icon:fe.jsx(In,{}),size:"small",style:{marginLeft:12}})});var at={},Dn=t=>encodeURIComponent(t).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`),ot="%[a-f0-9]{2}",Ee=new RegExp("("+ot+")|([^%]+?)","gi"),we=new RegExp("("+ot+")+","gi");function ge(t,e){try{return[decodeURIComponent(t.join(""))]}catch{}if(t.length===1)return t;e=e||1;var r=t.slice(0,e),n=t.slice(e);return Array.prototype.concat.call([],ge(r),ge(n))}function An(t){try{return decodeURIComponent(t)}catch{for(var e=t.match(Ee)||[],r=1;r{if(!(typeof t=="string"&&typeof e=="string"))throw new TypeError("Expected the arguments to be of type `string`");if(e==="")return[t];const r=t.indexOf(e);return r===-1?[t]:[t.slice(0,r),t.slice(r+e.length)]},Vn=function(t,e){for(var r={},n=Object.keys(t),o=Array.isArray(e),f=0;fa==null,d=Symbol("encodeFragmentIdentifier");function v(a){switch(a.arrayFormat){case"index":return i=>(s,c)=>{const u=s.length;return c===void 0||a.skipNull&&c===null||a.skipEmptyString&&c===""?s:c===null?[...s,[m(i,a),"[",u,"]"].join("")]:[...s,[m(i,a),"[",m(u,a),"]=",m(c,a)].join("")]};case"bracket":return i=>(s,c)=>c===void 0||a.skipNull&&c===null||a.skipEmptyString&&c===""?s:c===null?[...s,[m(i,a),"[]"].join("")]:[...s,[m(i,a),"[]=",m(c,a)].join("")];case"colon-list-separator":return i=>(s,c)=>c===void 0||a.skipNull&&c===null||a.skipEmptyString&&c===""?s:c===null?[...s,[m(i,a),":list="].join("")]:[...s,[m(i,a),":list=",m(c,a)].join("")];case"comma":case"separator":case"bracket-separator":{const i=a.arrayFormat==="bracket-separator"?"[]=":"=";return s=>(c,u)=>u===void 0||a.skipNull&&u===null||a.skipEmptyString&&u===""?c:(u=u===null?"":u,c.length===0?[[m(s,a),i,m(u,a)].join("")]:[[c,m(u,a)].join(a.arrayFormatSeparator)])}default:return i=>(s,c)=>c===void 0||a.skipNull&&c===null||a.skipEmptyString&&c===""?s:c===null?[...s,m(i,a)]:[...s,[m(i,a),"=",m(c,a)].join("")]}}function g(a){let i;switch(a.arrayFormat){case"index":return(s,c,u)=>{if(i=/\[(\d*)\]$/.exec(s),s=s.replace(/\[\d*\]$/,""),!i){u[s]=c;return}u[s]===void 0&&(u[s]={}),u[s][i[1]]=c};case"bracket":return(s,c,u)=>{if(i=/(\[\])$/.exec(s),s=s.replace(/\[\]$/,""),!i){u[s]=c;return}if(u[s]===void 0){u[s]=[c];return}u[s]=[].concat(u[s],c)};case"colon-list-separator":return(s,c,u)=>{if(i=/(:list)$/.exec(s),s=s.replace(/:list$/,""),!i){u[s]=c;return}if(u[s]===void 0){u[s]=[c];return}u[s]=[].concat(u[s],c)};case"comma":case"separator":return(s,c,u)=>{const b=typeof c=="string"&&c.includes(a.arrayFormatSeparator),h=typeof c=="string"&&!b&&C(c,a).includes(a.arrayFormatSeparator);c=h?C(c,a):c;const k=b||h?c.split(a.arrayFormatSeparator).map(A=>C(A,a)):c===null?c:C(c,a);u[s]=k};case"bracket-separator":return(s,c,u)=>{const b=/(\[\])$/.test(s);if(s=s.replace(/\[\]$/,""),!b){u[s]=c&&C(c,a);return}const h=c===null?[]:c.split(a.arrayFormatSeparator).map(k=>C(k,a));if(u[s]===void 0){u[s]=h;return}u[s]=[].concat(u[s],h)};default:return(s,c,u)=>{if(u[s]===void 0){u[s]=c;return}u[s]=[].concat(u[s],c)}}}function y(a){if(typeof a!="string"||a.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function m(a,i){return i.encode?i.strict?e(a):encodeURIComponent(a):a}function C(a,i){return i.decode?r(a):a}function O(a){return Array.isArray(a)?a.sort():typeof a=="object"?O(Object.keys(a)).sort((i,s)=>Number(i)-Number(s)).map(i=>a[i]):a}function E(a){const i=a.indexOf("#");return i!==-1&&(a=a.slice(0,i)),a}function w(a){let i="";const s=a.indexOf("#");return s!==-1&&(i=a.slice(s)),i}function N(a){a=E(a);const i=a.indexOf("?");return i===-1?"":a.slice(i+1)}function x(a,i){return i.parseNumbers&&!Number.isNaN(Number(a))&&typeof a=="string"&&a.trim()!==""?a=Number(a):i.parseBooleans&&a!==null&&(a.toLowerCase()==="true"||a.toLowerCase()==="false")&&(a=a.toLowerCase()==="true"),a}function P(a,i){i=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},i),y(i.arrayFormatSeparator);const s=g(i),c=Object.create(null);if(typeof a!="string"||(a=a.trim().replace(/^[?#&]/,""),!a))return c;for(const u of a.split("&")){if(u==="")continue;let[b,h]=n(i.decode?u.replace(/\+/g," "):u,"=");h=h===void 0?null:["comma","separator","bracket-separator"].includes(i.arrayFormat)?h:C(h,i),s(C(b,i),h,c)}for(const u of Object.keys(c)){const b=c[u];if(typeof b=="object"&&b!==null)for(const h of Object.keys(b))b[h]=x(b[h],i);else c[u]=x(b,i)}return i.sort===!1?c:(i.sort===!0?Object.keys(c).sort():Object.keys(c).sort(i.sort)).reduce((u,b)=>{const h=c[b];return h&&typeof h=="object"&&!Array.isArray(h)?u[b]=O(h):u[b]=h,u},Object.create(null))}t.extract=N,t.parse=P,t.stringify=(a,i)=>{if(!a)return"";i=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},i),y(i.arrayFormatSeparator);const s=h=>i.skipNull&&f(a[h])||i.skipEmptyString&&a[h]==="",c=v(i),u={};for(const h of Object.keys(a))s(h)||(u[h]=a[h]);const b=Object.keys(u);return i.sort!==!1&&b.sort(i.sort),b.map(h=>{const k=a[h];return k===void 0?"":k===null?m(h,i):Array.isArray(k)?k.length===0&&i.arrayFormat==="bracket-separator"?m(h,i)+"[]":k.reduce(c(h),[]).join("&"):m(h,i)+"="+m(k,i)}).filter(h=>h.length>0).join("&")},t.parseUrl=(a,i)=>{i=Object.assign({decode:!0},i);const[s,c]=n(a,"#");return Object.assign({url:s.split("?")[0]||"",query:P(N(a),i)},i&&i.parseFragmentIdentifier&&c?{fragmentIdentifier:C(c,i)}:{})},t.stringifyUrl=(a,i)=>{i=Object.assign({encode:!0,strict:!0,[d]:!0},i);const s=E(a.url).split("?")[0]||"",c=t.extract(a.url),u=t.parse(c,{sort:!1}),b=Object.assign(u,a.query);let h=t.stringify(b,i);h&&(h=`?${h}`);let k=w(a.url);return a.fragmentIdentifier&&(k=`#${i[d]?m(a.fragmentIdentifier,i):a.fragmentIdentifier}`),`${s}${h}${k}`},t.pick=(a,i,s)=>{s=Object.assign({parseFragmentIdentifier:!0,[d]:!1},s);const{url:c,query:u,fragmentIdentifier:b}=t.parseUrl(a,s);return t.stringifyUrl({url:c,query:o(u,i),fragmentIdentifier:b},s)},t.exclude=(a,i,s)=>{const c=Array.isArray(i)?u=>!i.includes(u):(u,b)=>!i(u,b);return t.pick(a,c,s)}})(at);const Jn=Et(at);export{Ke as D,Zn as L,Xn as M,en as O,Yn as P,Wn as Q,qt as _,an as a,Jn as q}; diff --git a/dist/assets/index-bcc6d528.js b/dist/assets/index-bec4ae4d.js similarity index 96% rename from dist/assets/index-bcc6d528.js rename to dist/assets/index-bec4ae4d.js index b5e1196383ffd969c9689c1f6395acb76354f577..1046d833da5cd8b24a39f58c8048e198a5a7af91 100644 --- a/dist/assets/index-bcc6d528.js +++ b/dist/assets/index-bec4ae4d.js @@ -1 +1 @@ -import{c as $,b,r as c,d as P,C as U,A as pe,i as fe,_ as be,z as Ce,B as ge,S as Ne,j as v,m as ke}from"./umi-9940633e.js";import{p as Ee,a as K,v as we,x as Pe}from"./parser-9472c317.js";import{S as Se}from"./scheduler-a7fa9c3c.js";import{S as je}from"./schedulePool-cc4538c2.js";import{A as Oe}from"./index-690c95dc.js";import{B as de}from"./button-eaadfeb4.js";import{o as Q}from"./_setToString-98c064b8.js";import{T as Te,a as $e}from"./index-e846d634.js";import{S as ve,C as ze}from"./TextArea-b3aeb374.js";import{S as Me}from"./index-1b65ca98.js";import{I as Le,U as he,a as _e}from"./UploadOutlined-e9942b1c.js";import{J as Re}from"./jszip.min-37f7e998.js";import{S as Be}from"./index-d3bdb233.js";import{S as Ie}from"./index-f5d9ea7b.js";import{a as Ae,P as Fe}from"./PlaySquareOutlined-646d1a37.js";import"./EditOutlined-fac0ac1a.js";import"./progress-06af2db7.js";import"./DeleteOutlined-a511b2d4.js";import"./DownloadOutlined-0b32cbf8.js";var De=function(t){var r=t.prefixCls,a=t.className,s=t.style,o=t.size,l=t.shape,n=$(b(b({},"".concat(r,"-lg"),o==="large"),"".concat(r,"-sm"),o==="small")),u=$(b(b(b({},"".concat(r,"-circle"),l==="circle"),"".concat(r,"-square"),l==="square"),"".concat(r,"-round"),l==="round")),i=c.useMemo(function(){return typeof o=="number"?{width:o,height:o,lineHeight:"".concat(o,"px")}:{}},[o]);return c.createElement("span",{className:$(r,n,u,a),style:P(P({},i),s)})};const ee=De;var Ue=function(t){var r=t.prefixCls,a=t.className,s=t.active,o=t.shape,l=o===void 0?"circle":o,n=t.size,u=n===void 0?"default":n,i=c.useContext(U),m=i.getPrefixCls,h=m("skeleton",r),p=Q(t,["prefixCls","className"]),C=$(h,"".concat(h,"-element"),b({},"".concat(h,"-active"),s),a);return c.createElement("div",{className:C},c.createElement(ee,P({prefixCls:"".concat(h,"-avatar"),shape:l,size:u},p)))};const qe=Ue;var Ye=function(t){var r=t.prefixCls,a=t.className,s=t.active,o=t.block,l=o===void 0?!1:o,n=t.size,u=n===void 0?"default":n,i=c.useContext(U),m=i.getPrefixCls,h=m("skeleton",r),p=Q(t,["prefixCls"]),C=$(h,"".concat(h,"-element"),b(b({},"".concat(h,"-active"),s),"".concat(h,"-block"),l),a);return c.createElement("div",{className:C},c.createElement(ee,P({prefixCls:"".concat(h,"-button"),size:u},p)))};const Ke=Ye;var Ge={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M888 792H200V168c0-4.4-3.6-8-8-8h-56c-4.4 0-8 3.6-8 8v688c0 4.4 3.6 8 8 8h752c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zM288 604a64 64 0 10128 0 64 64 0 10-128 0zm118-224a48 48 0 1096 0 48 48 0 10-96 0zm158 228a96 96 0 10192 0 96 96 0 10-192 0zm148-314a56 56 0 10112 0 56 56 0 10-112 0z"}}]},name:"dot-chart",theme:"outlined"};const Je=Ge;var We=function(t,r){return c.createElement(pe,fe(fe({},t),{},{ref:r,icon:Je}))},Xe=c.forwardRef(We);const He=Xe;var Ze=function(t){var r=t.prefixCls,a=t.className,s=t.style,o=t.active,l=t.children,n=c.useContext(U),u=n.getPrefixCls,i=u("skeleton",r),m=$(i,"".concat(i,"-element"),b({},"".concat(i,"-active"),o),a),h=l??c.createElement(He,null);return c.createElement("div",{className:m},c.createElement("div",{className:$("".concat(i,"-image"),a),style:s},h))};const Ve=Ze;var Qe="M365.714286 329.142857q0 45.714286-32.036571 77.677714t-77.677714 32.036571-77.677714-32.036571-32.036571-77.677714 32.036571-77.677714 77.677714-32.036571 77.677714 32.036571 32.036571 77.677714zM950.857143 548.571429l0 256-804.571429 0 0-109.714286 182.857143-182.857143 91.428571 91.428571 292.571429-292.571429zM1005.714286 146.285714l-914.285714 0q-7.460571 0-12.873143 5.412571t-5.412571 12.873143l0 694.857143q0 7.460571 5.412571 12.873143t12.873143 5.412571l914.285714 0q7.460571 0 12.873143-5.412571t5.412571-12.873143l0-694.857143q0-7.460571-5.412571-12.873143t-12.873143-5.412571zM1097.142857 164.571429l0 694.857143q0 37.741714-26.843429 64.585143t-64.585143 26.843429l-914.285714 0q-37.741714 0-64.585143-26.843429t-26.843429-64.585143l0-694.857143q0-37.741714 26.843429-64.585143t64.585143-26.843429l914.285714 0q37.741714 0 64.585143 26.843429t26.843429 64.585143z",et=function(t){var r=t.prefixCls,a=t.className,s=t.style,o=t.active,l=c.useContext(U),n=l.getPrefixCls,u=n("skeleton",r),i=$(u,"".concat(u,"-element"),b({},"".concat(u,"-active"),o),a);return c.createElement("div",{className:i},c.createElement("div",{className:$("".concat(u,"-image"),a),style:s},c.createElement("svg",{viewBox:"0 0 1098 1024",xmlns:"http://www.w3.org/2000/svg",className:"".concat(u,"-image-svg")},c.createElement("path",{d:Qe,className:"".concat(u,"-image-path")}))))};const tt=et;var at=function(t){var r=t.prefixCls,a=t.className,s=t.active,o=t.block,l=t.size,n=l===void 0?"default":l,u=c.useContext(U),i=u.getPrefixCls,m=i("skeleton",r),h=Q(t,["prefixCls"]),p=$(m,"".concat(m,"-element"),b(b({},"".concat(m,"-active"),s),"".concat(m,"-block"),o),a);return c.createElement("div",{className:p},c.createElement(ee,P({prefixCls:"".concat(m,"-input"),size:n},h)))};const rt=at;var st=function(t){var r=function(i){var m=t.width,h=t.rows,p=h===void 0?2:h;if(Array.isArray(m))return m[i];if(p-1===i)return m},a=t.prefixCls,s=t.className,o=t.style,l=t.rows,n=be(Array(l)).map(function(u,i){return c.createElement("li",{key:i,style:{width:r(i)}})});return c.createElement("ul",{className:$(a,s),style:o},n)};const nt=st;var ct=function(t){var r=t.prefixCls,a=t.className,s=t.width,o=t.style;return c.createElement("h3",{className:$(r,a),style:P({width:s},o)})};const it=ct;function ie(e){return e&&Ce(e)==="object"?e:{}}function ot(e,t){return e&&!t?{size:"large",shape:"square"}:{size:"large",shape:"circle"}}function lt(e,t){return!e&&t?{width:"38%"}:e&&t?{width:"50%"}:{}}function ut(e,t){var r={};return(!e||!t)&&(r.width="61%"),!e&&t?r.rows=3:r.rows=2,r}var G=function(t){var r=t.prefixCls,a=t.loading,s=t.className,o=t.style,l=t.children,n=t.avatar,u=n===void 0?!1:n,i=t.title,m=i===void 0?!0:i,h=t.paragraph,p=h===void 0?!0:h,C=t.active,T=t.round,z=c.useContext(U),A=z.getPrefixCls,_=z.direction,S=A("skeleton",r);if(a||!("loading"in t)){var M=!!u,f=!!m,j=!!p,E;if(M){var w=P(P({prefixCls:"".concat(S,"-avatar")},ot(f,j)),ie(u));E=c.createElement("div",{className:"".concat(S,"-header")},c.createElement(ee,P({},w)))}var O;if(f||j){var N;if(f){var R=P(P({prefixCls:"".concat(S,"-title")},lt(M,j)),ie(m));N=c.createElement(it,P({},R))}var B;if(j){var I=P(P({prefixCls:"".concat(S,"-paragraph")},ut(M,f)),ie(p));B=c.createElement(nt,P({},I))}O=c.createElement("div",{className:"".concat(S,"-content")},N,B)}var F=$(S,b(b(b(b({},"".concat(S,"-with-avatar"),M),"".concat(S,"-active"),C),"".concat(S,"-rtl"),_==="rtl"),"".concat(S,"-round"),T),s);return c.createElement("div",{className:F,style:o},E,O)}return typeof l<"u"?l:null};G.Button=Ke;G.Avatar=qe;G.Input=rt;G.Image=tt;G.Node=Ve;const mt=G;var ft=globalThis&&globalThis.__rest||function(e,t){var r={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.indexOf(a)<0&&(r[a]=e[a]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,a=Object.getOwnPropertySymbols(e);s((e==null?void 0:e.pages.slice(0,t).reduce((a,s)=>a+s.systems.length,0))||0)+r,kt=e=>{const t=e.source;if(!(t!=null&&t.w)||!(t!=null&&t.h))return"";const r=t.interval||1,a=t.matrix||[1,0,0,1,0,0];return`translate(${e.w/2} ${e.h/2}) matrix(${a.join(" ")}) scale(${1/r}) translate(${-t.w/2} ${-t.h/2})`},Et=e=>[...e.pages.map(t=>{var r;return(r=t.source)==null?void 0:r.url}),...e.pages.flatMap(t=>t.systems.flatMap(r=>r.staves.map(a=>{var s;return(s=a.image)==null?void 0:s.url})))].filter(Boolean),oe=e=>{if((e==null?void 0:e.format)!=="LiveScore"||(e==null?void 0:e.version)!==1||!Array.isArray(e==null?void 0:e.pages))throw new Error("Invalid LiveScore file.");return e},wt=async(e,t)=>{const r=[];return await Promise.all(Et(e).map(async a=>{if(!a||/^\w+:/.test(a)||a.startsWith("/"))return;const s=t.files[a];if(!s)throw new Error(`Missing asset: ${a}`);const o=await s.async("blob"),l=URL.createObjectURL(o);r.push(l),e.pages.forEach(n=>{var u;((u=n.source)==null?void 0:u.url)===a&&(n.source.url=l),n.systems.forEach(i=>{i.staves.forEach(m=>{var h;((h=m.image)==null?void 0:h.url)===a&&(m.image.url=l)})})})})),r},Pt=async e=>{if(/\.json$/i.test(e.name)||e.type==="application/json")return{liveScore:oe(JSON.parse(await e.text())),objectUrls:[]};const t=await Re.loadAsync(e),r=t.files["index.json"];if(!r)throw new Error("No index.json found in LiveScore package.");const a=oe(JSON.parse(await r.async("text"))),s=await wt(a,t);return{liveScore:a,objectUrls:s}},St=(e,t)=>{var a;const r=JSON.parse(JSON.stringify(t));(a=r.pages)==null||a.forEach(s=>{var o,l;(l=(o=s.source)==null?void 0:o.url)!=null&&l.startsWith("blob:")&&(s.source.url=""),s.systems.forEach(n=>{n.staves.forEach(u=>{var i,m;(m=(i=u.image)==null?void 0:i.url)!=null&&m.startsWith("blob:")&&(u.image.url="")})})}),sessionStorage.setItem(ue,JSON.stringify({fileName:e,liveScore:r}))},jt=()=>{const e=sessionStorage.getItem(ue);if(!e)return null;const t=JSON.parse(e);return{fileName:t.fileName||"Restored LiveScore",liveScore:oe(t.liveScore)}},Ot=e=>{switch(e){case"program":return"programChange";case"note-on":return"noteOn";case"note-off":return"noteOff";case"control":return"controller";case"pitch-bend":return"pitchBend";case"aftertouch":return"channelAftertouch";default:return e}},Tt=e=>{var s,o,l;if(!((s=e==null?void 0:e.events)!=null&&s.length))return null;const t=Math.max(1,...e.events.map(n=>Number.isFinite(n.track)?n.track+1:1)),r=Array(t).fill(null).map(()=>[]);e.events.forEach(n=>{var i;const u=Number.isFinite(n.track)?n.track:0;r[u].push({ticks:n.tick,type:"channel",subtype:Ot(n.type),...Number.isFinite(n.channel)?{channel:n.channel}:{},...Number.isFinite(n.note)?{noteNumber:n.note}:{},...Number.isFinite(n.velocity)?{velocity:n.velocity}:{},...Number.isFinite(n.program)?{programNumber:n.program}:{},...Number.isFinite(n.controller)?{controllerType:n.controller}:{},...Number.isFinite(n.value)?{value:n.value}:{},...(i=n.ids)!=null&&i.length?{ids:n.ids.map(String)}:{}})}),(o=e.tempos)==null||o.forEach(n=>{r[0].push({ticks:n.tick,type:"meta",subtype:"setTempo",microsecondsPerBeat:n.tempo})}),r.forEach(n=>{n.sort((i,m)=>i.ticks-m.ticks||(i.subtype==="noteOff"?-1:0));let u=0;n.forEach(i=>{i.deltaTime=Math.max(i.ticks-u,0),u=i.ticks}),n.push({deltaTime:Math.max((e.endTick||u)-u,0),type:"meta",subtype:"endOfTrack"})});const a=Pe.Notation.parseMidi({header:{formatType:1,ticksPerBeat:e.ticksPerBeat||480},tracks:r});return a.measures=(l=e.measures)==null?void 0:l.map(n=>({index:n.i,startTick:n.t1,endTick:n.t2})),a},$t=e=>{const t=new Map;return e==null||e.pages.forEach((r,a)=>{r.systems.forEach((s,o)=>{const l=me(e,a,o);s.staves.forEach(n=>{var u;(u=n.measures)==null||u.forEach((i,m)=>{var p,C;const h=((p=s.bars)==null?void 0:p[m])??s.w;(C=i.tokens)==null||C.forEach(T=>{T.id!==void 0&&t.set(String(T.id),{system:l,measure:m,x:T.x,endX:h})})})})})}),t},zt=e=>{var r;const t=(r=e==null?void 0:e.playback)==null?void 0:r.positions;return t!=null&&t.length?new Map(t.map(a=>[String(a.id),{system:a.system,measure:a.measure,x:a.x,endX:a.endX}])):$t(e)},Mt=e=>{var a,s;const t=zt(e),r={};return(s=(a=e==null?void 0:e.playback)==null?void 0:a.events)==null||s.forEach(o=>{var n;if(o.type!=="note-on"||!((n=o.ids)!=null&&n.length))return;const l=o.ids.map(u=>t.get(String(u))).filter(Boolean);l.length&&(r[o.tick]=r[o.tick]||[],r[o.tick].push(...l))}),Object.keys(r).length?Se.createFromTokenTable(r,e.playback.endTick):null},Lt=(e,t)=>{if(!e)return 0;let r=0;for(let a=0;a=r&&t{var r;if(!e)return null;for(let a=0;an.x1<=t.x&&n.x2>=t.x);return!l||!Number.isFinite(l.t1)||!Number.isFinite(l.t2)||l.x2===l.x1?null:l.t1+(t.x-l.x1)*(l.t2-l.t1)/(l.x2-l.x1)}}return null},Rt=(e,t,r)=>{const a=e==null?void 0:e.lookupTick(r);if(Number.isFinite(a))return{position:e.lookupPosition(a),tick:a};const o=((e==null?void 0:e.tickTable.filter(n=>n.system===r.system))||[]).flatMap(n=>[n.x,n.endX]).filter(Number.isFinite);if(o.length){const n=o.reduce((m,h)=>Math.abs(h-r.x){var n,u;return v.jsxs("svg",{className:"live-score-page",viewBox:`0 0 ${t.w} ${t.h}`,children:[v.jsx(Be,{}),a&&((n=t.source)==null?void 0:n.url)&&v.jsx("image",{href:t.source.url,width:t.source.w,height:t.source.h,transform:kt(t),opacity:.35,preserveAspectRatio:"none"}),!a&&((u=t.tokens)==null?void 0:u.map((i,m)=>v.jsx("text",{className:`live-score-page-token ${i.textType}`,x:i.x,y:i.y,dominantBaseline:"hanging",textAnchor:"middle",style:{fontSize:i.fontSize},children:i.text},i.id??m))),t.systems.map((i,m)=>{var M;const h=me(e,r,m),p=i.staves[0],C=i.staves.at(-1),T=((p==null?void 0:p.y)??0)+((p==null?void 0:p.staffY)??0)-2,z=((C==null?void 0:C.y)??0)+((C==null?void 0:C.staffY)??0)+2,A=i.staves.map(f=>({y:f.y+f.staffY,radius:2})),_=s&&i.staffMask!==void 0?s.mask(i.staffMask):null,S=f=>{const j=f.currentTarget,E=j.getBoundingClientRect(),w=j.getBBox(),O=(f.clientX-E.left)/E.width*w.width;l({system:h,x:O})};return v.jsxs("g",{className:"live-score-system",transform:`translate(${i.x}, ${i.y})`,children:[i.staves.map((f,j)=>{var E,w,O;return v.jsxs("g",{className:"live-score-staff",transform:`translate(0, ${f.y})`,children:[!a&&((E=f.image)==null?void 0:E.url)&&v.jsx("image",{className:"background",href:f.image.url,x:f.image.x,y:f.image.y,width:f.image.width,height:f.image.height}),[-2,-1,0,1,2].map(N=>v.jsx("line",{x1:"0",x2:i.w,y1:f.staffY+N,y2:f.staffY+N},N)),(w=f.additionalLines)==null?void 0:w.map((N,R)=>v.jsx("line",{x1:N.left,x2:N.right,y1:f.staffY+N.n,y2:f.staffY+N.n},R)),(O=f.measures)==null?void 0:O.map((N,R)=>{var B;return v.jsx("g",{children:(B=N.tokens)==null?void 0:B.map((I,F)=>v.jsx("use",{id:I.id!==void 0?String(I.id):void 0,href:`#score-token-def-${I.t}`,x:I.x,y:f.staffY+I.y},F))},R)})]},j)}),!a&&((M=i.bars)==null?void 0:M.flatMap((f,j)=>[...i.staves.map((E,w)=>v.jsx("line",{className:"bar",x1:f,x2:f,y1:E.y+E.staffY-2,y2:E.y+E.staffY+2},`${j}-staff-${w}`)),...((_==null?void 0:_.conjunctions)||[]).map((E,w)=>{const O=i.staves[w],N=i.staves[w+1];return!O||!N?null:v.jsx("line",{className:`bar staff-layout-measure-bar${E===1?" dashed":""}${E===0?" blank":""}`,x1:f,x2:f,y1:O.y+O.staffY+2,y2:N.y+N.staffY-2},`${j}-conjunction-${w}`)})])),!a&&s&&i.staffMask!==void 0&&v.jsxs(v.Fragment,{children:[i.staves.length>=2&&v.jsx("line",{className:"connection",x1:0,x2:0,y1:T,y2:z}),v.jsx(Ie,{layout:s.mask(i.staffMask),positions:A})]}),(o==null?void 0:o.system)===h&&v.jsx("line",{className:"cursor",x1:o.x,x2:o.x,y1:T,y2:z}),v.jsx("rect",{className:"live-score-system-hit",x:0,y:T,width:i.w,height:z-T,onClick:S})]},m)})]})},It=()=>{const[e,t]=c.useState(),[r,a]=c.useState(""),[s,o]=c.useState([]),[l,n]=c.useState(!0),[u,i]=c.useState(!1),[m,h]=c.useState(!1),[p,C]=c.useState(!1),[T,z]=c.useState(!1),[A,_]=c.useState(0),[S,M]=c.useState(null),f=c.useRef(null),j=c.useRef(null),E=c.useRef(new je(performance)),w=c.useRef([]),O=c.useRef(null),N=c.useRef(0),R=c.useMemo(()=>Tt(e==null?void 0:e.playback),[e]),B=c.useMemo(()=>Mt(e),[e]),I=c.useMemo(()=>e!=null&&e.staffLayout?Ee(e.staffLayout):null,[e==null?void 0:e.staffLayout]),F=!!(e!=null&&e.pages.some(d=>{var y;return(y=d.source)==null?void 0:y.url})),te=!!(e!=null&&e.pages.some(d=>d.systems.some(y=>y.staves.some(g=>{var x;return(x=g.image)==null?void 0:x.url})))),J=(S==null?void 0:S.tick)===A?S:(B==null?void 0:B.lookupPosition(A))||null,k=J?Lt(e,J.system):null;c.useEffect(()=>{j.current=B},[B]),c.useEffect(()=>{var d;k===null||k===O.current||(O.current=k,(d=w.current[k])==null||d.scrollIntoView({behavior:"smooth",inline:"center",block:"nearest"}))},[k]),c.useEffect(()=>{try{const d=jt();if(!d)return;t(d.liveScore),a(d.fileName)}catch{sessionStorage.removeItem(ue)}},[]),c.useEffect(()=>{K.WebAudio.empty()?K.loadPlugin({soundfontUrl:"/soundfont/",api:"webaudio"}).then(()=>z(!0)):z(!0)},[]),c.useEffect(()=>()=>s.forEach(d=>URL.revokeObjectURL(d)),[s]),c.useEffect(()=>{var y,g;if(!R)return;const d=((y=f.current)==null?void 0:y.progressTicks)||0;return(g=f.current)==null||g.dispose(),f.current=new we(R,{cacheSpan:200,onMidi:(x,L)=>{let q;x.subtype==="noteOn"?(K.noteOn(x.channel,x.noteNumber,x.velocity,L),q=()=>{var D;return(D=x.ids)==null?void 0:D.forEach(Y=>{var X;return(X=document.getElementById(Y))==null?void 0:X.classList.add("notePlayOn")})}):x.subtype==="noteOff"&&(K.noteOff(x.channel,x.noteNumber,L),q=()=>{var D;return(D=x.ids)==null?void 0:D.forEach(Y=>{var X;return(X=document.getElementById(Y))==null?void 0:X.classList.remove("notePlayOn")})}),q&&E.current.appendTask(L,q)},onPlayFinish:()=>{C(!1),M(null),_(0),document.querySelectorAll(".notePlayOn").forEach(x=>x.classList.remove("notePlayOn"))}}),f.current.progressTicks=d,()=>{var x;return(x=f.current)==null?void 0:x.dispose()}},[R]);const ae=async d=>(await Z(d),he.LIST_IGNORE),H=async d=>{const y=Rt(j.current,e,d);if(!y||!f.current)return;const g=f.current.isPlaying;g&&(f.current.pause(),await new Promise(x=>setTimeout(x,0))),document.querySelectorAll(".notePlayOn").forEach(x=>x.classList.remove("notePlayOn")),f.current.progressTicks=y.tick,M({...y.position,tick:y.tick}),_(y.tick),g&&W()},Z=async d=>{var y;i(!0);try{const g=await Pt(d);s.forEach(x=>URL.revokeObjectURL(x)),(y=f.current)==null||y.pause(),document.querySelectorAll(".notePlayOn").forEach(x=>x.classList.remove("notePlayOn")),o(g.objectUrls),t(g.liveScore),a(d.name),St(d.name,g.liveScore),O.current=null,C(!1),M(null),_(0)}catch(g){ke.error((g==null?void 0:g.message)||"Failed to load LiveScore.")}finally{i(!1)}},W=async()=>{var d,y,g,x,L;(d=f.current)!=null&&d.isPlaying?(f.current.pause(),C(!1)):((g=(y=K.WebAudio).needsWarmup)!=null&&g.call(y)&&await((L=(x=K.WebAudio).awaitWarmup)==null?void 0:L.call(x)),f.current.play({nextFrame:()=>new Promise(q=>requestAnimationFrame(()=>{var Y;const D=((Y=f.current)==null?void 0:Y.progressTicks)||0;M(null),_(D),q()}))}),C(!0))},V=d=>d.dataTransfer.types.includes("Files"),re=d=>{d.preventDefault(),V(d)&&(N.current+=1,h(!0))},se=d=>{d.preventDefault()},ne=d=>{d.preventDefault(),N.current=Math.max(N.current-1,0),N.current===0&&h(!1)},ce=async d=>{var g;d.preventDefault(),N.current=0,h(!1);const y=(g=d.dataTransfer.files)==null?void 0:g[0];y&&await Z(y)};return v.jsxs("div",{className:"live-score-viewer",onDragEnter:re,onDragOver:se,onDragLeave:ne,onDrop:ce,children:[m&&v.jsxs("div",{className:"live-score-drop-mask",children:[v.jsx(Le,{}),v.jsx("div",{children:"Drop LiveScore ZIP/JSON to open"})]}),v.jsx(xe,{className:"live-score-controls",children:v.jsxs(ve,{direction:"vertical",size:"middle",style:{width:"100%"},children:[v.jsxs(ve,{wrap:!0,align:"center",children:[v.jsx(Nt,{level:4,style:{margin:0},children:"LiveScore"}),v.jsx(he,{accept:".livescore.zip,.zip,.json,application/json,application/zip",showUploadList:!1,beforeUpload:ae,multiple:!1,children:v.jsx(de,{icon:v.jsx(_e,{}),children:"Open file"})}),v.jsx(de,{icon:p?v.jsx(Ae,{}):v.jsx(Fe,{}),onClick:W,disabled:!R||!T,children:p?"Pause":"Play"}),v.jsx(ze,{checked:l,onChange:d=>n(d.target.checked),disabled:!F&&!te,children:"Original image"}),v.jsx(Ct,{type:"secondary",children:r||"Drop a LiveScore ZIP/JSON anywhere"})]}),e&&!R&&v.jsx(Oe,{type:"info",showIcon:!0,message:"This LiveScore has no playback events."})]})}),v.jsx("div",{className:"live-score-stage-wrap",children:v.jsx(Me,{spinning:u,wrapperClassName:"live-score-spin",children:v.jsx(xe,{className:"live-score-stage",children:e?v.jsx("div",{className:"live-score-pages",children:e.pages.map((d,y)=>v.jsx("div",{className:"live-score-page-frame",ref:g=>{g&&(w.current[y]=g)},children:v.jsx(Bt,{liveScore:e,page:d,pageIndex:y,showSource:l,staffLayout:I,cursor:J,onSeekPosition:H})},y))}):v.jsx("div",{className:"live-score-empty",children:"Upload a LiveScore package to preview display and playback."})})})})]})},sa=c.memo(It);export{sa as default}; +import{c as $,b,r as c,d as P,C as U,A as pe,i as fe,_ as be,z as Ce,B as ge,S as Ne,j as v,m as ke}from"./umi-a12c8253.js";import{p as Ee,a as K,v as we,x as Pe}from"./parser-b66b074b.js";import{S as Se}from"./scheduler-a7fa9c3c.js";import{S as je}from"./schedulePool-cc4538c2.js";import{A as Oe}from"./index-868eaf8d.js";import{B as de}from"./button-f56a19a0.js";import{o as Q}from"./_setToString-ca5ad23e.js";import{T as Te,a as $e}from"./index-dfec1b5b.js";import{S as ve,C as ze}from"./TextArea-ec8ab387.js";import{S as Me}from"./index-40bfaf7c.js";import{I as Le,U as he,a as _e}from"./UploadOutlined-31d12a4f.js";import{J as Re}from"./jszip.min-f65a05ae.js";import{S as Be}from"./index-1d8a15fd.js";import{S as Ie}from"./index-02e1374a.js";import{a as Ae,P as Fe}from"./PlaySquareOutlined-1144cdf9.js";import"./EditOutlined-d468c101.js";import"./progress-81ce73da.js";import"./DeleteOutlined-e5d1e611.js";import"./DownloadOutlined-b3f9ad21.js";var De=function(t){var r=t.prefixCls,a=t.className,s=t.style,o=t.size,l=t.shape,n=$(b(b({},"".concat(r,"-lg"),o==="large"),"".concat(r,"-sm"),o==="small")),u=$(b(b(b({},"".concat(r,"-circle"),l==="circle"),"".concat(r,"-square"),l==="square"),"".concat(r,"-round"),l==="round")),i=c.useMemo(function(){return typeof o=="number"?{width:o,height:o,lineHeight:"".concat(o,"px")}:{}},[o]);return c.createElement("span",{className:$(r,n,u,a),style:P(P({},i),s)})};const ee=De;var Ue=function(t){var r=t.prefixCls,a=t.className,s=t.active,o=t.shape,l=o===void 0?"circle":o,n=t.size,u=n===void 0?"default":n,i=c.useContext(U),m=i.getPrefixCls,h=m("skeleton",r),p=Q(t,["prefixCls","className"]),C=$(h,"".concat(h,"-element"),b({},"".concat(h,"-active"),s),a);return c.createElement("div",{className:C},c.createElement(ee,P({prefixCls:"".concat(h,"-avatar"),shape:l,size:u},p)))};const qe=Ue;var Ye=function(t){var r=t.prefixCls,a=t.className,s=t.active,o=t.block,l=o===void 0?!1:o,n=t.size,u=n===void 0?"default":n,i=c.useContext(U),m=i.getPrefixCls,h=m("skeleton",r),p=Q(t,["prefixCls"]),C=$(h,"".concat(h,"-element"),b(b({},"".concat(h,"-active"),s),"".concat(h,"-block"),l),a);return c.createElement("div",{className:C},c.createElement(ee,P({prefixCls:"".concat(h,"-button"),size:u},p)))};const Ke=Ye;var Ge={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M888 792H200V168c0-4.4-3.6-8-8-8h-56c-4.4 0-8 3.6-8 8v688c0 4.4 3.6 8 8 8h752c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zM288 604a64 64 0 10128 0 64 64 0 10-128 0zm118-224a48 48 0 1096 0 48 48 0 10-96 0zm158 228a96 96 0 10192 0 96 96 0 10-192 0zm148-314a56 56 0 10112 0 56 56 0 10-112 0z"}}]},name:"dot-chart",theme:"outlined"};const Je=Ge;var We=function(t,r){return c.createElement(pe,fe(fe({},t),{},{ref:r,icon:Je}))},Xe=c.forwardRef(We);const He=Xe;var Ze=function(t){var r=t.prefixCls,a=t.className,s=t.style,o=t.active,l=t.children,n=c.useContext(U),u=n.getPrefixCls,i=u("skeleton",r),m=$(i,"".concat(i,"-element"),b({},"".concat(i,"-active"),o),a),h=l??c.createElement(He,null);return c.createElement("div",{className:m},c.createElement("div",{className:$("".concat(i,"-image"),a),style:s},h))};const Ve=Ze;var Qe="M365.714286 329.142857q0 45.714286-32.036571 77.677714t-77.677714 32.036571-77.677714-32.036571-32.036571-77.677714 32.036571-77.677714 77.677714-32.036571 77.677714 32.036571 32.036571 77.677714zM950.857143 548.571429l0 256-804.571429 0 0-109.714286 182.857143-182.857143 91.428571 91.428571 292.571429-292.571429zM1005.714286 146.285714l-914.285714 0q-7.460571 0-12.873143 5.412571t-5.412571 12.873143l0 694.857143q0 7.460571 5.412571 12.873143t12.873143 5.412571l914.285714 0q7.460571 0 12.873143-5.412571t5.412571-12.873143l0-694.857143q0-7.460571-5.412571-12.873143t-12.873143-5.412571zM1097.142857 164.571429l0 694.857143q0 37.741714-26.843429 64.585143t-64.585143 26.843429l-914.285714 0q-37.741714 0-64.585143-26.843429t-26.843429-64.585143l0-694.857143q0-37.741714 26.843429-64.585143t64.585143-26.843429l914.285714 0q37.741714 0 64.585143 26.843429t26.843429 64.585143z",et=function(t){var r=t.prefixCls,a=t.className,s=t.style,o=t.active,l=c.useContext(U),n=l.getPrefixCls,u=n("skeleton",r),i=$(u,"".concat(u,"-element"),b({},"".concat(u,"-active"),o),a);return c.createElement("div",{className:i},c.createElement("div",{className:$("".concat(u,"-image"),a),style:s},c.createElement("svg",{viewBox:"0 0 1098 1024",xmlns:"http://www.w3.org/2000/svg",className:"".concat(u,"-image-svg")},c.createElement("path",{d:Qe,className:"".concat(u,"-image-path")}))))};const tt=et;var at=function(t){var r=t.prefixCls,a=t.className,s=t.active,o=t.block,l=t.size,n=l===void 0?"default":l,u=c.useContext(U),i=u.getPrefixCls,m=i("skeleton",r),h=Q(t,["prefixCls"]),p=$(m,"".concat(m,"-element"),b(b({},"".concat(m,"-active"),s),"".concat(m,"-block"),o),a);return c.createElement("div",{className:p},c.createElement(ee,P({prefixCls:"".concat(m,"-input"),size:n},h)))};const rt=at;var st=function(t){var r=function(i){var m=t.width,h=t.rows,p=h===void 0?2:h;if(Array.isArray(m))return m[i];if(p-1===i)return m},a=t.prefixCls,s=t.className,o=t.style,l=t.rows,n=be(Array(l)).map(function(u,i){return c.createElement("li",{key:i,style:{width:r(i)}})});return c.createElement("ul",{className:$(a,s),style:o},n)};const nt=st;var ct=function(t){var r=t.prefixCls,a=t.className,s=t.width,o=t.style;return c.createElement("h3",{className:$(r,a),style:P({width:s},o)})};const it=ct;function ie(e){return e&&Ce(e)==="object"?e:{}}function ot(e,t){return e&&!t?{size:"large",shape:"square"}:{size:"large",shape:"circle"}}function lt(e,t){return!e&&t?{width:"38%"}:e&&t?{width:"50%"}:{}}function ut(e,t){var r={};return(!e||!t)&&(r.width="61%"),!e&&t?r.rows=3:r.rows=2,r}var G=function(t){var r=t.prefixCls,a=t.loading,s=t.className,o=t.style,l=t.children,n=t.avatar,u=n===void 0?!1:n,i=t.title,m=i===void 0?!0:i,h=t.paragraph,p=h===void 0?!0:h,C=t.active,T=t.round,z=c.useContext(U),A=z.getPrefixCls,_=z.direction,S=A("skeleton",r);if(a||!("loading"in t)){var M=!!u,f=!!m,j=!!p,E;if(M){var w=P(P({prefixCls:"".concat(S,"-avatar")},ot(f,j)),ie(u));E=c.createElement("div",{className:"".concat(S,"-header")},c.createElement(ee,P({},w)))}var O;if(f||j){var N;if(f){var R=P(P({prefixCls:"".concat(S,"-title")},lt(M,j)),ie(m));N=c.createElement(it,P({},R))}var B;if(j){var I=P(P({prefixCls:"".concat(S,"-paragraph")},ut(M,f)),ie(p));B=c.createElement(nt,P({},I))}O=c.createElement("div",{className:"".concat(S,"-content")},N,B)}var F=$(S,b(b(b(b({},"".concat(S,"-with-avatar"),M),"".concat(S,"-active"),C),"".concat(S,"-rtl"),_==="rtl"),"".concat(S,"-round"),T),s);return c.createElement("div",{className:F,style:o},E,O)}return typeof l<"u"?l:null};G.Button=Ke;G.Avatar=qe;G.Input=rt;G.Image=tt;G.Node=Ve;const mt=G;var ft=globalThis&&globalThis.__rest||function(e,t){var r={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.indexOf(a)<0&&(r[a]=e[a]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,a=Object.getOwnPropertySymbols(e);s((e==null?void 0:e.pages.slice(0,t).reduce((a,s)=>a+s.systems.length,0))||0)+r,kt=e=>{const t=e.source;if(!(t!=null&&t.w)||!(t!=null&&t.h))return"";const r=t.interval||1,a=t.matrix||[1,0,0,1,0,0];return`translate(${e.w/2} ${e.h/2}) matrix(${a.join(" ")}) scale(${1/r}) translate(${-t.w/2} ${-t.h/2})`},Et=e=>[...e.pages.map(t=>{var r;return(r=t.source)==null?void 0:r.url}),...e.pages.flatMap(t=>t.systems.flatMap(r=>r.staves.map(a=>{var s;return(s=a.image)==null?void 0:s.url})))].filter(Boolean),oe=e=>{if((e==null?void 0:e.format)!=="LiveScore"||(e==null?void 0:e.version)!==1||!Array.isArray(e==null?void 0:e.pages))throw new Error("Invalid LiveScore file.");return e},wt=async(e,t)=>{const r=[];return await Promise.all(Et(e).map(async a=>{if(!a||/^\w+:/.test(a)||a.startsWith("/"))return;const s=t.files[a];if(!s)throw new Error(`Missing asset: ${a}`);const o=await s.async("blob"),l=URL.createObjectURL(o);r.push(l),e.pages.forEach(n=>{var u;((u=n.source)==null?void 0:u.url)===a&&(n.source.url=l),n.systems.forEach(i=>{i.staves.forEach(m=>{var h;((h=m.image)==null?void 0:h.url)===a&&(m.image.url=l)})})})})),r},Pt=async e=>{if(/\.json$/i.test(e.name)||e.type==="application/json")return{liveScore:oe(JSON.parse(await e.text())),objectUrls:[]};const t=await Re.loadAsync(e),r=t.files["index.json"];if(!r)throw new Error("No index.json found in LiveScore package.");const a=oe(JSON.parse(await r.async("text"))),s=await wt(a,t);return{liveScore:a,objectUrls:s}},St=(e,t)=>{var a;const r=JSON.parse(JSON.stringify(t));(a=r.pages)==null||a.forEach(s=>{var o,l;(l=(o=s.source)==null?void 0:o.url)!=null&&l.startsWith("blob:")&&(s.source.url=""),s.systems.forEach(n=>{n.staves.forEach(u=>{var i,m;(m=(i=u.image)==null?void 0:i.url)!=null&&m.startsWith("blob:")&&(u.image.url="")})})}),sessionStorage.setItem(ue,JSON.stringify({fileName:e,liveScore:r}))},jt=()=>{const e=sessionStorage.getItem(ue);if(!e)return null;const t=JSON.parse(e);return{fileName:t.fileName||"Restored LiveScore",liveScore:oe(t.liveScore)}},Ot=e=>{switch(e){case"program":return"programChange";case"note-on":return"noteOn";case"note-off":return"noteOff";case"control":return"controller";case"pitch-bend":return"pitchBend";case"aftertouch":return"channelAftertouch";default:return e}},Tt=e=>{var s,o,l;if(!((s=e==null?void 0:e.events)!=null&&s.length))return null;const t=Math.max(1,...e.events.map(n=>Number.isFinite(n.track)?n.track+1:1)),r=Array(t).fill(null).map(()=>[]);e.events.forEach(n=>{var i;const u=Number.isFinite(n.track)?n.track:0;r[u].push({ticks:n.tick,type:"channel",subtype:Ot(n.type),...Number.isFinite(n.channel)?{channel:n.channel}:{},...Number.isFinite(n.note)?{noteNumber:n.note}:{},...Number.isFinite(n.velocity)?{velocity:n.velocity}:{},...Number.isFinite(n.program)?{programNumber:n.program}:{},...Number.isFinite(n.controller)?{controllerType:n.controller}:{},...Number.isFinite(n.value)?{value:n.value}:{},...(i=n.ids)!=null&&i.length?{ids:n.ids.map(String)}:{}})}),(o=e.tempos)==null||o.forEach(n=>{r[0].push({ticks:n.tick,type:"meta",subtype:"setTempo",microsecondsPerBeat:n.tempo})}),r.forEach(n=>{n.sort((i,m)=>i.ticks-m.ticks||(i.subtype==="noteOff"?-1:0));let u=0;n.forEach(i=>{i.deltaTime=Math.max(i.ticks-u,0),u=i.ticks}),n.push({deltaTime:Math.max((e.endTick||u)-u,0),type:"meta",subtype:"endOfTrack"})});const a=Pe.Notation.parseMidi({header:{formatType:1,ticksPerBeat:e.ticksPerBeat||480},tracks:r});return a.measures=(l=e.measures)==null?void 0:l.map(n=>({index:n.i,startTick:n.t1,endTick:n.t2})),a},$t=e=>{const t=new Map;return e==null||e.pages.forEach((r,a)=>{r.systems.forEach((s,o)=>{const l=me(e,a,o);s.staves.forEach(n=>{var u;(u=n.measures)==null||u.forEach((i,m)=>{var p,C;const h=((p=s.bars)==null?void 0:p[m])??s.w;(C=i.tokens)==null||C.forEach(T=>{T.id!==void 0&&t.set(String(T.id),{system:l,measure:m,x:T.x,endX:h})})})})})}),t},zt=e=>{var r;const t=(r=e==null?void 0:e.playback)==null?void 0:r.positions;return t!=null&&t.length?new Map(t.map(a=>[String(a.id),{system:a.system,measure:a.measure,x:a.x,endX:a.endX}])):$t(e)},Mt=e=>{var a,s;const t=zt(e),r={};return(s=(a=e==null?void 0:e.playback)==null?void 0:a.events)==null||s.forEach(o=>{var n;if(o.type!=="note-on"||!((n=o.ids)!=null&&n.length))return;const l=o.ids.map(u=>t.get(String(u))).filter(Boolean);l.length&&(r[o.tick]=r[o.tick]||[],r[o.tick].push(...l))}),Object.keys(r).length?Se.createFromTokenTable(r,e.playback.endTick):null},Lt=(e,t)=>{if(!e)return 0;let r=0;for(let a=0;a=r&&t{var r;if(!e)return null;for(let a=0;an.x1<=t.x&&n.x2>=t.x);return!l||!Number.isFinite(l.t1)||!Number.isFinite(l.t2)||l.x2===l.x1?null:l.t1+(t.x-l.x1)*(l.t2-l.t1)/(l.x2-l.x1)}}return null},Rt=(e,t,r)=>{const a=e==null?void 0:e.lookupTick(r);if(Number.isFinite(a))return{position:e.lookupPosition(a),tick:a};const o=((e==null?void 0:e.tickTable.filter(n=>n.system===r.system))||[]).flatMap(n=>[n.x,n.endX]).filter(Number.isFinite);if(o.length){const n=o.reduce((m,h)=>Math.abs(h-r.x){var n,u;return v.jsxs("svg",{className:"live-score-page",viewBox:`0 0 ${t.w} ${t.h}`,children:[v.jsx(Be,{}),a&&((n=t.source)==null?void 0:n.url)&&v.jsx("image",{href:t.source.url,width:t.source.w,height:t.source.h,transform:kt(t),opacity:.35,preserveAspectRatio:"none"}),!a&&((u=t.tokens)==null?void 0:u.map((i,m)=>v.jsx("text",{className:`live-score-page-token ${i.textType}`,x:i.x,y:i.y,dominantBaseline:"hanging",textAnchor:"middle",style:{fontSize:i.fontSize},children:i.text},i.id??m))),t.systems.map((i,m)=>{var M;const h=me(e,r,m),p=i.staves[0],C=i.staves.at(-1),T=((p==null?void 0:p.y)??0)+((p==null?void 0:p.staffY)??0)-2,z=((C==null?void 0:C.y)??0)+((C==null?void 0:C.staffY)??0)+2,A=i.staves.map(f=>({y:f.y+f.staffY,radius:2})),_=s&&i.staffMask!==void 0?s.mask(i.staffMask):null,S=f=>{const j=f.currentTarget,E=j.getBoundingClientRect(),w=j.getBBox(),O=(f.clientX-E.left)/E.width*w.width;l({system:h,x:O})};return v.jsxs("g",{className:"live-score-system",transform:`translate(${i.x}, ${i.y})`,children:[i.staves.map((f,j)=>{var E,w,O;return v.jsxs("g",{className:"live-score-staff",transform:`translate(0, ${f.y})`,children:[!a&&((E=f.image)==null?void 0:E.url)&&v.jsx("image",{className:"background",href:f.image.url,x:f.image.x,y:f.image.y,width:f.image.width,height:f.image.height}),[-2,-1,0,1,2].map(N=>v.jsx("line",{x1:"0",x2:i.w,y1:f.staffY+N,y2:f.staffY+N},N)),(w=f.additionalLines)==null?void 0:w.map((N,R)=>v.jsx("line",{x1:N.left,x2:N.right,y1:f.staffY+N.n,y2:f.staffY+N.n},R)),(O=f.measures)==null?void 0:O.map((N,R)=>{var B;return v.jsx("g",{children:(B=N.tokens)==null?void 0:B.map((I,F)=>v.jsx("use",{id:I.id!==void 0?String(I.id):void 0,href:`#score-token-def-${I.t}`,x:I.x,y:f.staffY+I.y},F))},R)})]},j)}),!a&&((M=i.bars)==null?void 0:M.flatMap((f,j)=>[...i.staves.map((E,w)=>v.jsx("line",{className:"bar",x1:f,x2:f,y1:E.y+E.staffY-2,y2:E.y+E.staffY+2},`${j}-staff-${w}`)),...((_==null?void 0:_.conjunctions)||[]).map((E,w)=>{const O=i.staves[w],N=i.staves[w+1];return!O||!N?null:v.jsx("line",{className:`bar staff-layout-measure-bar${E===1?" dashed":""}${E===0?" blank":""}`,x1:f,x2:f,y1:O.y+O.staffY+2,y2:N.y+N.staffY-2},`${j}-conjunction-${w}`)})])),!a&&s&&i.staffMask!==void 0&&v.jsxs(v.Fragment,{children:[i.staves.length>=2&&v.jsx("line",{className:"connection",x1:0,x2:0,y1:T,y2:z}),v.jsx(Ie,{layout:s.mask(i.staffMask),positions:A})]}),(o==null?void 0:o.system)===h&&v.jsx("line",{className:"cursor",x1:o.x,x2:o.x,y1:T,y2:z}),v.jsx("rect",{className:"live-score-system-hit",x:0,y:T,width:i.w,height:z-T,onClick:S})]},m)})]})},It=()=>{const[e,t]=c.useState(),[r,a]=c.useState(""),[s,o]=c.useState([]),[l,n]=c.useState(!0),[u,i]=c.useState(!1),[m,h]=c.useState(!1),[p,C]=c.useState(!1),[T,z]=c.useState(!1),[A,_]=c.useState(0),[S,M]=c.useState(null),f=c.useRef(null),j=c.useRef(null),E=c.useRef(new je(performance)),w=c.useRef([]),O=c.useRef(null),N=c.useRef(0),R=c.useMemo(()=>Tt(e==null?void 0:e.playback),[e]),B=c.useMemo(()=>Mt(e),[e]),I=c.useMemo(()=>e!=null&&e.staffLayout?Ee(e.staffLayout):null,[e==null?void 0:e.staffLayout]),F=!!(e!=null&&e.pages.some(d=>{var y;return(y=d.source)==null?void 0:y.url})),te=!!(e!=null&&e.pages.some(d=>d.systems.some(y=>y.staves.some(g=>{var x;return(x=g.image)==null?void 0:x.url})))),J=(S==null?void 0:S.tick)===A?S:(B==null?void 0:B.lookupPosition(A))||null,k=J?Lt(e,J.system):null;c.useEffect(()=>{j.current=B},[B]),c.useEffect(()=>{var d;k===null||k===O.current||(O.current=k,(d=w.current[k])==null||d.scrollIntoView({behavior:"smooth",inline:"center",block:"nearest"}))},[k]),c.useEffect(()=>{try{const d=jt();if(!d)return;t(d.liveScore),a(d.fileName)}catch{sessionStorage.removeItem(ue)}},[]),c.useEffect(()=>{K.WebAudio.empty()?K.loadPlugin({soundfontUrl:"/soundfont/",api:"webaudio"}).then(()=>z(!0)):z(!0)},[]),c.useEffect(()=>()=>s.forEach(d=>URL.revokeObjectURL(d)),[s]),c.useEffect(()=>{var y,g;if(!R)return;const d=((y=f.current)==null?void 0:y.progressTicks)||0;return(g=f.current)==null||g.dispose(),f.current=new we(R,{cacheSpan:200,onMidi:(x,L)=>{let q;x.subtype==="noteOn"?(K.noteOn(x.channel,x.noteNumber,x.velocity,L),q=()=>{var D;return(D=x.ids)==null?void 0:D.forEach(Y=>{var X;return(X=document.getElementById(Y))==null?void 0:X.classList.add("notePlayOn")})}):x.subtype==="noteOff"&&(K.noteOff(x.channel,x.noteNumber,L),q=()=>{var D;return(D=x.ids)==null?void 0:D.forEach(Y=>{var X;return(X=document.getElementById(Y))==null?void 0:X.classList.remove("notePlayOn")})}),q&&E.current.appendTask(L,q)},onPlayFinish:()=>{C(!1),M(null),_(0),document.querySelectorAll(".notePlayOn").forEach(x=>x.classList.remove("notePlayOn"))}}),f.current.progressTicks=d,()=>{var x;return(x=f.current)==null?void 0:x.dispose()}},[R]);const ae=async d=>(await Z(d),he.LIST_IGNORE),H=async d=>{const y=Rt(j.current,e,d);if(!y||!f.current)return;const g=f.current.isPlaying;g&&(f.current.pause(),await new Promise(x=>setTimeout(x,0))),document.querySelectorAll(".notePlayOn").forEach(x=>x.classList.remove("notePlayOn")),f.current.progressTicks=y.tick,M({...y.position,tick:y.tick}),_(y.tick),g&&W()},Z=async d=>{var y;i(!0);try{const g=await Pt(d);s.forEach(x=>URL.revokeObjectURL(x)),(y=f.current)==null||y.pause(),document.querySelectorAll(".notePlayOn").forEach(x=>x.classList.remove("notePlayOn")),o(g.objectUrls),t(g.liveScore),a(d.name),St(d.name,g.liveScore),O.current=null,C(!1),M(null),_(0)}catch(g){ke.error((g==null?void 0:g.message)||"Failed to load LiveScore.")}finally{i(!1)}},W=async()=>{var d,y,g,x,L;(d=f.current)!=null&&d.isPlaying?(f.current.pause(),C(!1)):((g=(y=K.WebAudio).needsWarmup)!=null&&g.call(y)&&await((L=(x=K.WebAudio).awaitWarmup)==null?void 0:L.call(x)),f.current.play({nextFrame:()=>new Promise(q=>requestAnimationFrame(()=>{var Y;const D=((Y=f.current)==null?void 0:Y.progressTicks)||0;M(null),_(D),q()}))}),C(!0))},V=d=>d.dataTransfer.types.includes("Files"),re=d=>{d.preventDefault(),V(d)&&(N.current+=1,h(!0))},se=d=>{d.preventDefault()},ne=d=>{d.preventDefault(),N.current=Math.max(N.current-1,0),N.current===0&&h(!1)},ce=async d=>{var g;d.preventDefault(),N.current=0,h(!1);const y=(g=d.dataTransfer.files)==null?void 0:g[0];y&&await Z(y)};return v.jsxs("div",{className:"live-score-viewer",onDragEnter:re,onDragOver:se,onDragLeave:ne,onDrop:ce,children:[m&&v.jsxs("div",{className:"live-score-drop-mask",children:[v.jsx(Le,{}),v.jsx("div",{children:"Drop LiveScore ZIP/JSON to open"})]}),v.jsx(xe,{className:"live-score-controls",children:v.jsxs(ve,{direction:"vertical",size:"middle",style:{width:"100%"},children:[v.jsxs(ve,{wrap:!0,align:"center",children:[v.jsx(Nt,{level:4,style:{margin:0},children:"LiveScore"}),v.jsx(he,{accept:".livescore.zip,.zip,.json,application/json,application/zip",showUploadList:!1,beforeUpload:ae,multiple:!1,children:v.jsx(de,{icon:v.jsx(_e,{}),children:"Open file"})}),v.jsx(de,{icon:p?v.jsx(Ae,{}):v.jsx(Fe,{}),onClick:W,disabled:!R||!T,children:p?"Pause":"Play"}),v.jsx(ze,{checked:l,onChange:d=>n(d.target.checked),disabled:!F&&!te,children:"Original image"}),v.jsx(Ct,{type:"secondary",children:r||"Drop a LiveScore ZIP/JSON anywhere"})]}),e&&!R&&v.jsx(Oe,{type:"info",showIcon:!0,message:"This LiveScore has no playback events."})]})}),v.jsx("div",{className:"live-score-stage-wrap",children:v.jsx(Me,{spinning:u,wrapperClassName:"live-score-spin",children:v.jsx(xe,{className:"live-score-stage",children:e?v.jsx("div",{className:"live-score-pages",children:e.pages.map((d,y)=>v.jsx("div",{className:"live-score-page-frame",ref:g=>{g&&(w.current[y]=g)},children:v.jsx(Bt,{liveScore:e,page:d,pageIndex:y,showSource:l,staffLayout:I,cursor:J,onSeekPosition:H})},y))}):v.jsx("div",{className:"live-score-empty",children:"Upload a LiveScore package to preview display and playback."})})})})]})},sa=c.memo(It);export{sa as default}; diff --git a/dist/assets/index-6a5b1b3e.js b/dist/assets/index-c353c509.js similarity index 99% rename from dist/assets/index-6a5b1b3e.js rename to dist/assets/index-c353c509.js index 8446911ec3a8bde78439801183c39faf91c1d6df..43fa61faefe1f2d34ffbf817ada7ff5846350dc5 100644 --- a/dist/assets/index-6a5b1b3e.js +++ b/dist/assets/index-c353c509.js @@ -1,3 +1,3 @@ -import{r as n,a as ne,c as ye,b7 as _n,i as G,M as Ln,z as gt,b as H,d as Re,K as ut,T as cn,ae as Vn,_ as je,aF as Fn,a6 as An,w as Ze,E as Kn,F as $n,a1 as zn,a4 as jt,t as Ut,Q as Hn,B as Wn,A as Bn,Y as jn,y as sn,L as fn,C as At,S as dn,V as vn,e as Yt}from"./umi-9940633e.js";import{p as Rt,G as Un,K as Z,c as Yn,x as Xn,u as Dt,j as lt,R as mn,F as Gn,g as Qn,e as Lt,f as Jn,h as Zn,z as qn}from"./TextArea-b3aeb374.js";import{t as ea,u as ta,N as na,W as aa}from"./button-eaadfeb4.js";import{o as hn,t as ra}from"./_setToString-98c064b8.js";import{E as It,S as oa,P as ia}from"./util-477962f3.js";import{C as la}from"./progress-06af2db7.js";var gn=n.createContext(null);function ua(){return n.useContext(gn)}function ca(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:10,t=n.useState(!1),r=ne(t,2),a=r[0],o=r[1],i=n.useRef(null),l=function(){window.clearTimeout(i.current)};n.useEffect(function(){return l},[]);var s=function(v,h){l(),i.current=window.setTimeout(function(){o(v),h&&h()},e)};return[a,s,l]}function pn(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:250,t=n.useRef(null),r=n.useRef(null);n.useEffect(function(){return function(){window.clearTimeout(r.current)}},[]);function a(o){(o||t.current===null)&&(t.current=o),window.clearTimeout(r.current),r.current=window.setTimeout(function(){t.current=null},e)}return[function(){return t.current},a]}function sa(e,t,r,a){var o=n.useRef(null);o.current={open:t,triggerOpen:r,customizedTrigger:a},n.useEffect(function(){function i(l){var s;if(!((s=o.current)!==null&&s!==void 0&&s.customizedTrigger)){var d=l.target;d.shadowRoot&&l.composed&&(d=l.composedPath()[0]||d),o.current.open&&e().filter(function(v){return v}).every(function(v){return!v.contains(d)&&v!==d})&&o.current.triggerOpen(!1)}}return window.addEventListener("mousedown",i),function(){return window.removeEventListener("mousedown",i)}},[])}var Nt=function(t){var r=t.className,a=t.customizeIcon,o=t.customizeIconProps,i=t.onMouseDown,l=t.onClick,s=t.children,d;return typeof a=="function"?d=a(o):d=a,n.createElement("span",{className:r,onMouseDown:function(h){h.preventDefault(),i&&i(h)},style:{userSelect:"none",WebkitUserSelect:"none"},unselectable:"on",onClick:l,"aria-hidden":!0},d!==void 0?d:n.createElement("span",{className:ye(r.split(/\s+/).map(function(v){return"".concat(v,"-icon")}))},s))},fa=function(t,r){var a,o,i=t.prefixCls,l=t.id,s=t.inputElement,d=t.disabled,v=t.tabIndex,h=t.autoFocus,u=t.autoComplete,f=t.editable,c=t.activeDescendantId,g=t.value,m=t.maxLength,S=t.onKeyDown,C=t.onMouseDown,p=t.onChange,b=t.onPaste,y=t.onCompositionStart,Q=t.onCompositionEnd,U=t.open,T=t.attrs,E=s||n.createElement("input",null),D=E,Y=D.ref,q=D.props,ae=q.onKeyDown,_=q.onChange,X=q.onMouseDown,te=q.onCompositionStart,M=q.onCompositionEnd,K=q.style;return _n(!("maxLength"in E.props)),E=n.cloneElement(E,G(G(G({type:"search"},q),{},{id:l,ref:Ln(r,Y),disabled:d,tabIndex:v,autoComplete:u||"off",autoFocus:h,className:ye("".concat(i,"-selection-search-input"),(a=E)===null||a===void 0||(o=a.props)===null||o===void 0?void 0:o.className),role:"combobox","aria-expanded":U,"aria-haspopup":"listbox","aria-owns":"".concat(l,"_list"),"aria-autocomplete":"list","aria-controls":"".concat(l,"_list"),"aria-activedescendant":c},T),{},{value:f?g:"",maxLength:m,readOnly:!f,unselectable:f?null:"on",style:G(G({},K),{},{opacity:f?null:0}),onKeyDown:function(w){S(w),ae&&ae(w)},onMouseDown:function(w){C(w),X&&X(w)},onChange:function(w){p(w),_&&_(w)},onCompositionStart:function(w){y(w),te&&te(w)},onCompositionEnd:function(w){Q(w),M&&M(w)},onPaste:b})),E},Kt=n.forwardRef(fa);Kt.displayName="Input";function Sn(e){return Array.isArray(e)?e:e!==void 0?[e]:[]}var da=typeof window<"u"&&window.document&&window.document.documentElement,va=da;function ma(e){return e!=null}function Xt(e){return["string","number"].includes(gt(e))}function Cn(e){var t=void 0;return e&&(Xt(e.title)?t=e.title.toString():Xt(e.label)&&(t=e.label.toString())),t}function ha(e,t){va?n.useLayoutEffect(e,t):n.useEffect(e,t)}function ga(e){var t;return(t=e.key)!==null&&t!==void 0?t:e.value}var Gt=function(t){t.preventDefault(),t.stopPropagation()},pa=function(t){var r=t.id,a=t.prefixCls,o=t.values,i=t.open,l=t.searchValue,s=t.autoClearSearchValue,d=t.inputRef,v=t.placeholder,h=t.disabled,u=t.mode,f=t.showSearch,c=t.autoFocus,g=t.autoComplete,m=t.activeDescendantId,S=t.tabIndex,C=t.removeIcon,p=t.maxTagCount,b=t.maxTagTextLength,y=t.maxTagPlaceholder,Q=y===void 0?function(se){return"+ ".concat(se.length," ...")}:y,U=t.tagRender,T=t.onToggleOpen,E=t.onRemove,D=t.onInputChange,Y=t.onInputPaste,q=t.onInputKeyDown,ae=t.onInputMouseDown,_=t.onInputCompositionStart,X=t.onInputCompositionEnd,te=n.useRef(null),M=n.useState(0),K=ne(M,2),O=K[0],w=K[1],ce=n.useState(!1),$=ne(ce,2),de=$[0],oe=$[1],L="".concat(a,"-selection"),I=i||u==="multiple"&&s===!1||u==="tags"?l:"",W=u==="tags"||u==="multiple"&&s===!1||f&&(i||de);ha(function(){w(te.current.scrollWidth)},[I]);function N(se,ve,fe,me,Ce){return n.createElement("span",{className:ye("".concat(L,"-item"),H({},"".concat(L,"-item-disabled"),fe)),title:Cn(se)},n.createElement("span",{className:"".concat(L,"-item-content")},ve),me&&n.createElement(Nt,{className:"".concat(L,"-item-remove"),onMouseDown:Gt,onClick:Ce,customizeIcon:C},"×"))}function P(se,ve,fe,me,Ce){var Ee=function(R){Gt(R),T(!i)};return n.createElement("span",{onMouseDown:Ee},U({label:ve,value:se,disabled:fe,closable:me,onClose:Ce}))}function k(se){var ve=se.disabled,fe=se.label,me=se.value,Ce=!h&&!ve,Ee=fe;if(typeof b=="number"&&(typeof fe=="string"||typeof fe=="number")){var ge=String(Ee);ge.length>b&&(Ee="".concat(ge.slice(0,b),"..."))}var R=function(pe){pe&&pe.stopPropagation(),E(se)};return typeof U=="function"?P(me,Ee,ve,Ce,R):N(se,Ee,ve,Ce,R)}function x(se){var ve=typeof Q=="function"?Q(se):Q;return N({title:ve},ve,!1)}var z=n.createElement("div",{className:"".concat(L,"-search"),style:{width:O},onFocus:function(){oe(!0)},onBlur:function(){oe(!1)}},n.createElement(Kt,{ref:d,open:i,prefixCls:a,id:r,inputElement:null,disabled:h,autoFocus:c,autoComplete:g,editable:W,activeDescendantId:m,value:I,onKeyDown:q,onMouseDown:ae,onChange:D,onPaste:Y,onCompositionStart:_,onCompositionEnd:X,tabIndex:S,attrs:Rt(t,!0)}),n.createElement("span",{ref:te,className:"".concat(L,"-search-mirror"),"aria-hidden":!0},I," ")),le=n.createElement(Un,{prefixCls:"".concat(L,"-overflow"),data:o,renderItem:k,renderRest:x,suffix:z,itemKey:ga,maxCount:p});return n.createElement(n.Fragment,null,le,!o.length&&!I&&n.createElement("span",{className:"".concat(L,"-placeholder")},v))},Sa=function(t){var r=t.inputElement,a=t.prefixCls,o=t.id,i=t.inputRef,l=t.disabled,s=t.autoFocus,d=t.autoComplete,v=t.activeDescendantId,h=t.mode,u=t.open,f=t.values,c=t.placeholder,g=t.tabIndex,m=t.showSearch,S=t.searchValue,C=t.activeValue,p=t.maxLength,b=t.onInputKeyDown,y=t.onInputMouseDown,Q=t.onInputChange,U=t.onInputPaste,T=t.onInputCompositionStart,E=t.onInputCompositionEnd,D=n.useState(!1),Y=ne(D,2),q=Y[0],ae=Y[1],_=h==="combobox",X=_||m,te=f[0],M=S||"";_&&C&&!q&&(M=C),n.useEffect(function(){_&&ae(!1)},[_,C]);var K=h!=="combobox"&&!u&&!m?!1:!!M,O=Cn(te),w=function(){if(te)return null;var $=K?{visibility:"hidden"}:void 0;return n.createElement("span",{className:"".concat(a,"-selection-placeholder"),style:$},c)};return n.createElement(n.Fragment,null,n.createElement("span",{className:"".concat(a,"-selection-search")},n.createElement(Kt,{ref:i,prefixCls:a,id:o,open:u,inputElement:r,disabled:l,autoFocus:s,autoComplete:d,editable:X,activeDescendantId:v,value:M,onKeyDown:b,onMouseDown:y,onChange:function($){ae(!0),Q($)},onPaste:U,onCompositionStart:T,onCompositionEnd:E,tabIndex:g,attrs:Rt(t,!0),maxLength:_?p:void 0})),!_&&te?n.createElement("span",{className:"".concat(a,"-selection-item"),title:O,style:K?{visibility:"hidden"}:void 0},te.label):null,w())};function Ca(e){return![Z.ESC,Z.SHIFT,Z.BACKSPACE,Z.TAB,Z.WIN_KEY,Z.ALT,Z.META,Z.WIN_KEY_RIGHT,Z.CTRL,Z.SEMICOLON,Z.EQUALS,Z.CAPS_LOCK,Z.CONTEXT_MENU,Z.F1,Z.F2,Z.F3,Z.F4,Z.F5,Z.F6,Z.F7,Z.F8,Z.F9,Z.F10,Z.F11,Z.F12].includes(e)}var ba=function(t,r){var a=n.useRef(null),o=n.useRef(!1),i=t.prefixCls,l=t.open,s=t.mode,d=t.showSearch,v=t.tokenWithEnter,h=t.autoClearSearchValue,u=t.onSearch,f=t.onSearchSubmit,c=t.onToggleOpen,g=t.onInputKeyDown,m=t.domRef;n.useImperativeHandle(r,function(){return{focus:function(){a.current.focus()},blur:function(){a.current.blur()}}});var S=pn(0),C=ne(S,2),p=C[0],b=C[1],y=function(K){var O=K.which;(O===Z.UP||O===Z.DOWN)&&K.preventDefault(),g&&g(K),O===Z.ENTER&&s==="tags"&&!o.current&&!l&&(f==null||f(K.target.value)),Ca(O)&&c(!0)},Q=function(){b(!0)},U=n.useRef(null),T=function(K){u(K,!0,o.current)!==!1&&c(!0)},E=function(){o.current=!0},D=function(K){o.current=!1,s!=="combobox"&&T(K.target.value)},Y=function(K){var O=K.target.value;if(v&&U.current&&/[\r\n]/.test(U.current)){var w=U.current.replace(/[\r\n]+$/,"").replace(/\r\n/g," ").replace(/[\r\n]/g," ");O=O.replace(w,U.current)}U.current=null,T(O)},q=function(K){var O=K.clipboardData,w=O.getData("text");U.current=w},ae=function(K){var O=K.target;if(O!==a.current){var w=document.body.style.msTouchAction!==void 0;w?setTimeout(function(){a.current.focus()}):a.current.focus()}},_=function(K){var O=p();K.target!==a.current&&!O&&s!=="combobox"&&K.preventDefault(),(s!=="combobox"&&(!d||!O)||!l)&&(l&&h!==!1&&u("",!0,!1),c())},X={inputRef:a,onInputKeyDown:y,onInputMouseDown:Q,onInputChange:Y,onInputPaste:q,onInputCompositionStart:E,onInputCompositionEnd:D},te=s==="multiple"||s==="tags"?n.createElement(pa,Re({},t,X)):n.createElement(Sa,Re({},t,X));return n.createElement("div",{ref:m,className:"".concat(i,"-selector"),onClick:ae,onMouseDown:_},te)},bn=n.forwardRef(ba);bn.displayName="Selector";var wa=["prefixCls","disabled","visible","children","popupElement","containerWidth","animation","transitionName","dropdownStyle","dropdownClassName","direction","placement","dropdownMatchSelectWidth","dropdownRender","dropdownAlign","getPopupContainer","empty","getTriggerDOMNode","onPopupVisibleChange","onPopupMouseEnter"],ya=function(t){var r=t===!0?0:1;return{bottomLeft:{points:["tl","bl"],offset:[0,4],overflow:{adjustX:r,adjustY:1}},bottomRight:{points:["tr","br"],offset:[0,4],overflow:{adjustX:r,adjustY:1}},topLeft:{points:["bl","tl"],offset:[0,-4],overflow:{adjustX:r,adjustY:1}},topRight:{points:["br","tr"],offset:[0,-4],overflow:{adjustX:r,adjustY:1}}}},Ea=function(t,r){var a=t.prefixCls;t.disabled;var o=t.visible,i=t.children,l=t.popupElement,s=t.containerWidth,d=t.animation,v=t.transitionName,h=t.dropdownStyle,u=t.dropdownClassName,f=t.direction,c=f===void 0?"ltr":f,g=t.placement,m=t.dropdownMatchSelectWidth,S=t.dropdownRender,C=t.dropdownAlign,p=t.getPopupContainer,b=t.empty,y=t.getTriggerDOMNode,Q=t.onPopupVisibleChange,U=t.onPopupMouseEnter,T=ut(t,wa),E="".concat(a,"-dropdown"),D=l;S&&(D=S(l));var Y=n.useMemo(function(){return ya(m)},[m]),q=d?"".concat(E,"-").concat(d):v,ae=n.useRef(null);n.useImperativeHandle(r,function(){return{getPopupElement:function(){return ae.current}}});var _=G({minWidth:s},h);return typeof m=="number"?_.width=m:m&&(_.width=s),n.createElement(Yn,Re({},T,{showAction:Q?["click"]:[],hideAction:Q?["click"]:[],popupPlacement:g||(c==="rtl"?"bottomRight":"bottomLeft"),builtinPlacements:Y,prefixCls:E,popupTransitionName:q,popup:n.createElement("div",{ref:ae,onMouseEnter:U},D),popupAlign:C,popupVisible:o,getPopupContainer:p,popupClassName:ye(u,H({},"".concat(E,"-empty"),b)),popupStyle:_,getTriggerDOMNode:y,onPopupVisibleChange:Q}),i)},wn=n.forwardRef(Ea);wn.displayName="SelectTrigger";function Qt(e,t){var r=e.key,a;return"value"in e&&(a=e.value),r??(a!==void 0?a:"rc-index-key-".concat(t))}function yn(e,t){var r=e||{},a=r.label,o=r.value,i=r.options;return{label:a||(t?"children":"label"),value:o||"value",options:i||"options"}}function Ia(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=t.fieldNames,a=t.childrenAsData,o=[],i=yn(r,!1),l=i.label,s=i.value,d=i.options;function v(h,u){h.forEach(function(f){var c=f[l];if(u||!(d in f)){var g=f[s];o.push({key:Qt(f,o.length),groupOption:u,data:f,label:c,value:g})}else{var m=c;m===void 0&&a&&(m=f.label),o.push({key:Qt(f,o.length),group:!0,data:f,label:m}),v(f[d],!0)}})}return v(e,!1),o}function Vt(e){var t=G({},e);return"props"in t||Object.defineProperty(t,"props",{get:function(){return cn(!1,"Return type is option instead of Option instance. Please read value directly instead of reading from `props`."),t}}),t}function Ra(e,t){if(!t||!t.length)return null;var r=!1;function a(i,l){var s=Vn(l),d=s[0],v=s.slice(1);if(!d)return[i];var h=i.split(d);return r=r||h.length>1,h.reduce(function(u,f){return[].concat(je(u),je(a(f,v)))},[]).filter(function(u){return u})}var o=a(e,t);return r?o:null}var xa=["id","prefixCls","className","showSearch","tagRender","direction","omitDomProps","displayValues","onDisplayValuesChange","emptyOptions","notFoundContent","onClear","mode","disabled","loading","getInputElement","getRawInputElement","open","defaultOpen","onDropdownVisibleChange","activeValue","onActiveValueChange","activeDescendantId","searchValue","autoClearSearchValue","onSearch","onSearchSplit","tokenSeparators","allowClear","showArrow","inputIcon","clearIcon","OptionList","animation","transitionName","dropdownStyle","dropdownClassName","dropdownMatchSelectWidth","dropdownRender","dropdownAlign","placement","getPopupContainer","showAction","onFocus","onBlur","onKeyUp","onKeyDown","onMouseDown"],Ma=["value","onChange","removeIcon","placeholder","autoFocus","maxTagCount","maxTagTextLength","maxTagPlaceholder","choiceTransitionName","onInputKeyDown","onPopupScroll","tabIndex"];function Ft(e){return e==="tags"||e==="multiple"}var Oa=n.forwardRef(function(e,t){var r,a,o=e.id,i=e.prefixCls,l=e.className,s=e.showSearch,d=e.tagRender,v=e.direction,h=e.omitDomProps,u=e.displayValues,f=e.onDisplayValuesChange,c=e.emptyOptions,g=e.notFoundContent,m=g===void 0?"Not Found":g,S=e.onClear,C=e.mode,p=e.disabled,b=e.loading,y=e.getInputElement,Q=e.getRawInputElement,U=e.open,T=e.defaultOpen,E=e.onDropdownVisibleChange,D=e.activeValue,Y=e.onActiveValueChange,q=e.activeDescendantId,ae=e.searchValue,_=e.autoClearSearchValue,X=e.onSearch,te=e.onSearchSplit,M=e.tokenSeparators,K=e.allowClear,O=e.showArrow,w=e.inputIcon,ce=e.clearIcon,$=e.OptionList,de=e.animation,oe=e.transitionName,L=e.dropdownStyle,I=e.dropdownClassName,W=e.dropdownMatchSelectWidth,N=e.dropdownRender,P=e.dropdownAlign,k=e.placement,x=e.getPopupContainer,z=e.showAction,le=z===void 0?[]:z,se=e.onFocus,ve=e.onBlur,fe=e.onKeyUp,me=e.onKeyDown,Ce=e.onMouseDown,Ee=ut(e,xa),ge=Ft(C),R=(s!==void 0?s:ge)||C==="combobox",ie=G({},Ee);Ma.forEach(function(re){delete ie[re]}),h==null||h.forEach(function(re){delete ie[re]});var pe=n.useState(!1),Ie=ne(pe,2),De=Ie[0],Ae=Ie[1];n.useEffect(function(){Ae(Xn())},[]);var be=n.useRef(null),Ne=n.useRef(null),Ve=n.useRef(null),ke=n.useRef(null),Te=n.useRef(null),pt=ca(),qe=ne(pt,3),_e=qe[0],Qe=qe[1],St=qe[2];n.useImperativeHandle(t,function(){var re,J;return{focus:(re=ke.current)===null||re===void 0?void 0:re.focus,blur:(J=ke.current)===null||J===void 0?void 0:J.blur,scrollTo:function(Fe){var Oe;return(Oe=Te.current)===null||Oe===void 0?void 0:Oe.scrollTo(Fe)}}});var Le=n.useMemo(function(){var re;if(C!=="combobox")return ae;var J=(re=u[0])===null||re===void 0?void 0:re.value;return typeof J=="string"||typeof J=="number"?String(J):""},[ae,C,u]),ct=C==="combobox"&&typeof y=="function"&&y()||null,ze=typeof Q=="function"&&Q(),vt=Fn(Ne,ze==null||(r=ze.props)===null||r===void 0?void 0:r.ref),tt=Dt(void 0,{defaultValue:T,value:U}),Ue=ne(tt,2),st=Ue[0],nt=Ue[1],we=st,ft=!m&&c;(p||ft&&we&&C==="combobox")&&(we=!1);var Ye=ft?!1:we,F=n.useCallback(function(re){var J=re!==void 0?re:!we;p||(nt(J),we!==J&&(E==null||E(J)))},[p,we,nt,E]),B=n.useMemo(function(){return(M||[]).some(function(re){return[` +import{r as n,a as ne,c as ye,b7 as _n,i as G,M as Ln,z as gt,b as H,d as Re,K as ut,T as cn,ae as Vn,_ as je,aF as Fn,a6 as An,w as Ze,E as Kn,F as $n,a1 as zn,a4 as jt,t as Ut,Q as Hn,B as Wn,A as Bn,Y as jn,y as sn,L as fn,C as At,S as dn,V as vn,e as Yt}from"./umi-a12c8253.js";import{p as Rt,G as Un,K as Z,c as Yn,x as Xn,u as Dt,j as lt,R as mn,F as Gn,g as Qn,e as Lt,f as Jn,h as Zn,z as qn}from"./TextArea-ec8ab387.js";import{t as ea,u as ta,N as na,W as aa}from"./button-f56a19a0.js";import{o as hn,t as ra}from"./_setToString-ca5ad23e.js";import{E as It,S as oa,P as ia}from"./util-590d1471.js";import{C as la}from"./progress-81ce73da.js";var gn=n.createContext(null);function ua(){return n.useContext(gn)}function ca(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:10,t=n.useState(!1),r=ne(t,2),a=r[0],o=r[1],i=n.useRef(null),l=function(){window.clearTimeout(i.current)};n.useEffect(function(){return l},[]);var s=function(v,h){l(),i.current=window.setTimeout(function(){o(v),h&&h()},e)};return[a,s,l]}function pn(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:250,t=n.useRef(null),r=n.useRef(null);n.useEffect(function(){return function(){window.clearTimeout(r.current)}},[]);function a(o){(o||t.current===null)&&(t.current=o),window.clearTimeout(r.current),r.current=window.setTimeout(function(){t.current=null},e)}return[function(){return t.current},a]}function sa(e,t,r,a){var o=n.useRef(null);o.current={open:t,triggerOpen:r,customizedTrigger:a},n.useEffect(function(){function i(l){var s;if(!((s=o.current)!==null&&s!==void 0&&s.customizedTrigger)){var d=l.target;d.shadowRoot&&l.composed&&(d=l.composedPath()[0]||d),o.current.open&&e().filter(function(v){return v}).every(function(v){return!v.contains(d)&&v!==d})&&o.current.triggerOpen(!1)}}return window.addEventListener("mousedown",i),function(){return window.removeEventListener("mousedown",i)}},[])}var Nt=function(t){var r=t.className,a=t.customizeIcon,o=t.customizeIconProps,i=t.onMouseDown,l=t.onClick,s=t.children,d;return typeof a=="function"?d=a(o):d=a,n.createElement("span",{className:r,onMouseDown:function(h){h.preventDefault(),i&&i(h)},style:{userSelect:"none",WebkitUserSelect:"none"},unselectable:"on",onClick:l,"aria-hidden":!0},d!==void 0?d:n.createElement("span",{className:ye(r.split(/\s+/).map(function(v){return"".concat(v,"-icon")}))},s))},fa=function(t,r){var a,o,i=t.prefixCls,l=t.id,s=t.inputElement,d=t.disabled,v=t.tabIndex,h=t.autoFocus,u=t.autoComplete,f=t.editable,c=t.activeDescendantId,g=t.value,m=t.maxLength,S=t.onKeyDown,C=t.onMouseDown,p=t.onChange,b=t.onPaste,y=t.onCompositionStart,Q=t.onCompositionEnd,U=t.open,T=t.attrs,E=s||n.createElement("input",null),D=E,Y=D.ref,q=D.props,ae=q.onKeyDown,_=q.onChange,X=q.onMouseDown,te=q.onCompositionStart,M=q.onCompositionEnd,K=q.style;return _n(!("maxLength"in E.props)),E=n.cloneElement(E,G(G(G({type:"search"},q),{},{id:l,ref:Ln(r,Y),disabled:d,tabIndex:v,autoComplete:u||"off",autoFocus:h,className:ye("".concat(i,"-selection-search-input"),(a=E)===null||a===void 0||(o=a.props)===null||o===void 0?void 0:o.className),role:"combobox","aria-expanded":U,"aria-haspopup":"listbox","aria-owns":"".concat(l,"_list"),"aria-autocomplete":"list","aria-controls":"".concat(l,"_list"),"aria-activedescendant":c},T),{},{value:f?g:"",maxLength:m,readOnly:!f,unselectable:f?null:"on",style:G(G({},K),{},{opacity:f?null:0}),onKeyDown:function(w){S(w),ae&&ae(w)},onMouseDown:function(w){C(w),X&&X(w)},onChange:function(w){p(w),_&&_(w)},onCompositionStart:function(w){y(w),te&&te(w)},onCompositionEnd:function(w){Q(w),M&&M(w)},onPaste:b})),E},Kt=n.forwardRef(fa);Kt.displayName="Input";function Sn(e){return Array.isArray(e)?e:e!==void 0?[e]:[]}var da=typeof window<"u"&&window.document&&window.document.documentElement,va=da;function ma(e){return e!=null}function Xt(e){return["string","number"].includes(gt(e))}function Cn(e){var t=void 0;return e&&(Xt(e.title)?t=e.title.toString():Xt(e.label)&&(t=e.label.toString())),t}function ha(e,t){va?n.useLayoutEffect(e,t):n.useEffect(e,t)}function ga(e){var t;return(t=e.key)!==null&&t!==void 0?t:e.value}var Gt=function(t){t.preventDefault(),t.stopPropagation()},pa=function(t){var r=t.id,a=t.prefixCls,o=t.values,i=t.open,l=t.searchValue,s=t.autoClearSearchValue,d=t.inputRef,v=t.placeholder,h=t.disabled,u=t.mode,f=t.showSearch,c=t.autoFocus,g=t.autoComplete,m=t.activeDescendantId,S=t.tabIndex,C=t.removeIcon,p=t.maxTagCount,b=t.maxTagTextLength,y=t.maxTagPlaceholder,Q=y===void 0?function(se){return"+ ".concat(se.length," ...")}:y,U=t.tagRender,T=t.onToggleOpen,E=t.onRemove,D=t.onInputChange,Y=t.onInputPaste,q=t.onInputKeyDown,ae=t.onInputMouseDown,_=t.onInputCompositionStart,X=t.onInputCompositionEnd,te=n.useRef(null),M=n.useState(0),K=ne(M,2),O=K[0],w=K[1],ce=n.useState(!1),$=ne(ce,2),de=$[0],oe=$[1],L="".concat(a,"-selection"),I=i||u==="multiple"&&s===!1||u==="tags"?l:"",W=u==="tags"||u==="multiple"&&s===!1||f&&(i||de);ha(function(){w(te.current.scrollWidth)},[I]);function N(se,ve,fe,me,Ce){return n.createElement("span",{className:ye("".concat(L,"-item"),H({},"".concat(L,"-item-disabled"),fe)),title:Cn(se)},n.createElement("span",{className:"".concat(L,"-item-content")},ve),me&&n.createElement(Nt,{className:"".concat(L,"-item-remove"),onMouseDown:Gt,onClick:Ce,customizeIcon:C},"×"))}function P(se,ve,fe,me,Ce){var Ee=function(R){Gt(R),T(!i)};return n.createElement("span",{onMouseDown:Ee},U({label:ve,value:se,disabled:fe,closable:me,onClose:Ce}))}function k(se){var ve=se.disabled,fe=se.label,me=se.value,Ce=!h&&!ve,Ee=fe;if(typeof b=="number"&&(typeof fe=="string"||typeof fe=="number")){var ge=String(Ee);ge.length>b&&(Ee="".concat(ge.slice(0,b),"..."))}var R=function(pe){pe&&pe.stopPropagation(),E(se)};return typeof U=="function"?P(me,Ee,ve,Ce,R):N(se,Ee,ve,Ce,R)}function x(se){var ve=typeof Q=="function"?Q(se):Q;return N({title:ve},ve,!1)}var z=n.createElement("div",{className:"".concat(L,"-search"),style:{width:O},onFocus:function(){oe(!0)},onBlur:function(){oe(!1)}},n.createElement(Kt,{ref:d,open:i,prefixCls:a,id:r,inputElement:null,disabled:h,autoFocus:c,autoComplete:g,editable:W,activeDescendantId:m,value:I,onKeyDown:q,onMouseDown:ae,onChange:D,onPaste:Y,onCompositionStart:_,onCompositionEnd:X,tabIndex:S,attrs:Rt(t,!0)}),n.createElement("span",{ref:te,className:"".concat(L,"-search-mirror"),"aria-hidden":!0},I," ")),le=n.createElement(Un,{prefixCls:"".concat(L,"-overflow"),data:o,renderItem:k,renderRest:x,suffix:z,itemKey:ga,maxCount:p});return n.createElement(n.Fragment,null,le,!o.length&&!I&&n.createElement("span",{className:"".concat(L,"-placeholder")},v))},Sa=function(t){var r=t.inputElement,a=t.prefixCls,o=t.id,i=t.inputRef,l=t.disabled,s=t.autoFocus,d=t.autoComplete,v=t.activeDescendantId,h=t.mode,u=t.open,f=t.values,c=t.placeholder,g=t.tabIndex,m=t.showSearch,S=t.searchValue,C=t.activeValue,p=t.maxLength,b=t.onInputKeyDown,y=t.onInputMouseDown,Q=t.onInputChange,U=t.onInputPaste,T=t.onInputCompositionStart,E=t.onInputCompositionEnd,D=n.useState(!1),Y=ne(D,2),q=Y[0],ae=Y[1],_=h==="combobox",X=_||m,te=f[0],M=S||"";_&&C&&!q&&(M=C),n.useEffect(function(){_&&ae(!1)},[_,C]);var K=h!=="combobox"&&!u&&!m?!1:!!M,O=Cn(te),w=function(){if(te)return null;var $=K?{visibility:"hidden"}:void 0;return n.createElement("span",{className:"".concat(a,"-selection-placeholder"),style:$},c)};return n.createElement(n.Fragment,null,n.createElement("span",{className:"".concat(a,"-selection-search")},n.createElement(Kt,{ref:i,prefixCls:a,id:o,open:u,inputElement:r,disabled:l,autoFocus:s,autoComplete:d,editable:X,activeDescendantId:v,value:M,onKeyDown:b,onMouseDown:y,onChange:function($){ae(!0),Q($)},onPaste:U,onCompositionStart:T,onCompositionEnd:E,tabIndex:g,attrs:Rt(t,!0),maxLength:_?p:void 0})),!_&&te?n.createElement("span",{className:"".concat(a,"-selection-item"),title:O,style:K?{visibility:"hidden"}:void 0},te.label):null,w())};function Ca(e){return![Z.ESC,Z.SHIFT,Z.BACKSPACE,Z.TAB,Z.WIN_KEY,Z.ALT,Z.META,Z.WIN_KEY_RIGHT,Z.CTRL,Z.SEMICOLON,Z.EQUALS,Z.CAPS_LOCK,Z.CONTEXT_MENU,Z.F1,Z.F2,Z.F3,Z.F4,Z.F5,Z.F6,Z.F7,Z.F8,Z.F9,Z.F10,Z.F11,Z.F12].includes(e)}var ba=function(t,r){var a=n.useRef(null),o=n.useRef(!1),i=t.prefixCls,l=t.open,s=t.mode,d=t.showSearch,v=t.tokenWithEnter,h=t.autoClearSearchValue,u=t.onSearch,f=t.onSearchSubmit,c=t.onToggleOpen,g=t.onInputKeyDown,m=t.domRef;n.useImperativeHandle(r,function(){return{focus:function(){a.current.focus()},blur:function(){a.current.blur()}}});var S=pn(0),C=ne(S,2),p=C[0],b=C[1],y=function(K){var O=K.which;(O===Z.UP||O===Z.DOWN)&&K.preventDefault(),g&&g(K),O===Z.ENTER&&s==="tags"&&!o.current&&!l&&(f==null||f(K.target.value)),Ca(O)&&c(!0)},Q=function(){b(!0)},U=n.useRef(null),T=function(K){u(K,!0,o.current)!==!1&&c(!0)},E=function(){o.current=!0},D=function(K){o.current=!1,s!=="combobox"&&T(K.target.value)},Y=function(K){var O=K.target.value;if(v&&U.current&&/[\r\n]/.test(U.current)){var w=U.current.replace(/[\r\n]+$/,"").replace(/\r\n/g," ").replace(/[\r\n]/g," ");O=O.replace(w,U.current)}U.current=null,T(O)},q=function(K){var O=K.clipboardData,w=O.getData("text");U.current=w},ae=function(K){var O=K.target;if(O!==a.current){var w=document.body.style.msTouchAction!==void 0;w?setTimeout(function(){a.current.focus()}):a.current.focus()}},_=function(K){var O=p();K.target!==a.current&&!O&&s!=="combobox"&&K.preventDefault(),(s!=="combobox"&&(!d||!O)||!l)&&(l&&h!==!1&&u("",!0,!1),c())},X={inputRef:a,onInputKeyDown:y,onInputMouseDown:Q,onInputChange:Y,onInputPaste:q,onInputCompositionStart:E,onInputCompositionEnd:D},te=s==="multiple"||s==="tags"?n.createElement(pa,Re({},t,X)):n.createElement(Sa,Re({},t,X));return n.createElement("div",{ref:m,className:"".concat(i,"-selector"),onClick:ae,onMouseDown:_},te)},bn=n.forwardRef(ba);bn.displayName="Selector";var wa=["prefixCls","disabled","visible","children","popupElement","containerWidth","animation","transitionName","dropdownStyle","dropdownClassName","direction","placement","dropdownMatchSelectWidth","dropdownRender","dropdownAlign","getPopupContainer","empty","getTriggerDOMNode","onPopupVisibleChange","onPopupMouseEnter"],ya=function(t){var r=t===!0?0:1;return{bottomLeft:{points:["tl","bl"],offset:[0,4],overflow:{adjustX:r,adjustY:1}},bottomRight:{points:["tr","br"],offset:[0,4],overflow:{adjustX:r,adjustY:1}},topLeft:{points:["bl","tl"],offset:[0,-4],overflow:{adjustX:r,adjustY:1}},topRight:{points:["br","tr"],offset:[0,-4],overflow:{adjustX:r,adjustY:1}}}},Ea=function(t,r){var a=t.prefixCls;t.disabled;var o=t.visible,i=t.children,l=t.popupElement,s=t.containerWidth,d=t.animation,v=t.transitionName,h=t.dropdownStyle,u=t.dropdownClassName,f=t.direction,c=f===void 0?"ltr":f,g=t.placement,m=t.dropdownMatchSelectWidth,S=t.dropdownRender,C=t.dropdownAlign,p=t.getPopupContainer,b=t.empty,y=t.getTriggerDOMNode,Q=t.onPopupVisibleChange,U=t.onPopupMouseEnter,T=ut(t,wa),E="".concat(a,"-dropdown"),D=l;S&&(D=S(l));var Y=n.useMemo(function(){return ya(m)},[m]),q=d?"".concat(E,"-").concat(d):v,ae=n.useRef(null);n.useImperativeHandle(r,function(){return{getPopupElement:function(){return ae.current}}});var _=G({minWidth:s},h);return typeof m=="number"?_.width=m:m&&(_.width=s),n.createElement(Yn,Re({},T,{showAction:Q?["click"]:[],hideAction:Q?["click"]:[],popupPlacement:g||(c==="rtl"?"bottomRight":"bottomLeft"),builtinPlacements:Y,prefixCls:E,popupTransitionName:q,popup:n.createElement("div",{ref:ae,onMouseEnter:U},D),popupAlign:C,popupVisible:o,getPopupContainer:p,popupClassName:ye(u,H({},"".concat(E,"-empty"),b)),popupStyle:_,getTriggerDOMNode:y,onPopupVisibleChange:Q}),i)},wn=n.forwardRef(Ea);wn.displayName="SelectTrigger";function Qt(e,t){var r=e.key,a;return"value"in e&&(a=e.value),r??(a!==void 0?a:"rc-index-key-".concat(t))}function yn(e,t){var r=e||{},a=r.label,o=r.value,i=r.options;return{label:a||(t?"children":"label"),value:o||"value",options:i||"options"}}function Ia(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=t.fieldNames,a=t.childrenAsData,o=[],i=yn(r,!1),l=i.label,s=i.value,d=i.options;function v(h,u){h.forEach(function(f){var c=f[l];if(u||!(d in f)){var g=f[s];o.push({key:Qt(f,o.length),groupOption:u,data:f,label:c,value:g})}else{var m=c;m===void 0&&a&&(m=f.label),o.push({key:Qt(f,o.length),group:!0,data:f,label:m}),v(f[d],!0)}})}return v(e,!1),o}function Vt(e){var t=G({},e);return"props"in t||Object.defineProperty(t,"props",{get:function(){return cn(!1,"Return type is option instead of Option instance. Please read value directly instead of reading from `props`."),t}}),t}function Ra(e,t){if(!t||!t.length)return null;var r=!1;function a(i,l){var s=Vn(l),d=s[0],v=s.slice(1);if(!d)return[i];var h=i.split(d);return r=r||h.length>1,h.reduce(function(u,f){return[].concat(je(u),je(a(f,v)))},[]).filter(function(u){return u})}var o=a(e,t);return r?o:null}var xa=["id","prefixCls","className","showSearch","tagRender","direction","omitDomProps","displayValues","onDisplayValuesChange","emptyOptions","notFoundContent","onClear","mode","disabled","loading","getInputElement","getRawInputElement","open","defaultOpen","onDropdownVisibleChange","activeValue","onActiveValueChange","activeDescendantId","searchValue","autoClearSearchValue","onSearch","onSearchSplit","tokenSeparators","allowClear","showArrow","inputIcon","clearIcon","OptionList","animation","transitionName","dropdownStyle","dropdownClassName","dropdownMatchSelectWidth","dropdownRender","dropdownAlign","placement","getPopupContainer","showAction","onFocus","onBlur","onKeyUp","onKeyDown","onMouseDown"],Ma=["value","onChange","removeIcon","placeholder","autoFocus","maxTagCount","maxTagTextLength","maxTagPlaceholder","choiceTransitionName","onInputKeyDown","onPopupScroll","tabIndex"];function Ft(e){return e==="tags"||e==="multiple"}var Oa=n.forwardRef(function(e,t){var r,a,o=e.id,i=e.prefixCls,l=e.className,s=e.showSearch,d=e.tagRender,v=e.direction,h=e.omitDomProps,u=e.displayValues,f=e.onDisplayValuesChange,c=e.emptyOptions,g=e.notFoundContent,m=g===void 0?"Not Found":g,S=e.onClear,C=e.mode,p=e.disabled,b=e.loading,y=e.getInputElement,Q=e.getRawInputElement,U=e.open,T=e.defaultOpen,E=e.onDropdownVisibleChange,D=e.activeValue,Y=e.onActiveValueChange,q=e.activeDescendantId,ae=e.searchValue,_=e.autoClearSearchValue,X=e.onSearch,te=e.onSearchSplit,M=e.tokenSeparators,K=e.allowClear,O=e.showArrow,w=e.inputIcon,ce=e.clearIcon,$=e.OptionList,de=e.animation,oe=e.transitionName,L=e.dropdownStyle,I=e.dropdownClassName,W=e.dropdownMatchSelectWidth,N=e.dropdownRender,P=e.dropdownAlign,k=e.placement,x=e.getPopupContainer,z=e.showAction,le=z===void 0?[]:z,se=e.onFocus,ve=e.onBlur,fe=e.onKeyUp,me=e.onKeyDown,Ce=e.onMouseDown,Ee=ut(e,xa),ge=Ft(C),R=(s!==void 0?s:ge)||C==="combobox",ie=G({},Ee);Ma.forEach(function(re){delete ie[re]}),h==null||h.forEach(function(re){delete ie[re]});var pe=n.useState(!1),Ie=ne(pe,2),De=Ie[0],Ae=Ie[1];n.useEffect(function(){Ae(Xn())},[]);var be=n.useRef(null),Ne=n.useRef(null),Ve=n.useRef(null),ke=n.useRef(null),Te=n.useRef(null),pt=ca(),qe=ne(pt,3),_e=qe[0],Qe=qe[1],St=qe[2];n.useImperativeHandle(t,function(){var re,J;return{focus:(re=ke.current)===null||re===void 0?void 0:re.focus,blur:(J=ke.current)===null||J===void 0?void 0:J.blur,scrollTo:function(Fe){var Oe;return(Oe=Te.current)===null||Oe===void 0?void 0:Oe.scrollTo(Fe)}}});var Le=n.useMemo(function(){var re;if(C!=="combobox")return ae;var J=(re=u[0])===null||re===void 0?void 0:re.value;return typeof J=="string"||typeof J=="number"?String(J):""},[ae,C,u]),ct=C==="combobox"&&typeof y=="function"&&y()||null,ze=typeof Q=="function"&&Q(),vt=Fn(Ne,ze==null||(r=ze.props)===null||r===void 0?void 0:r.ref),tt=Dt(void 0,{defaultValue:T,value:U}),Ue=ne(tt,2),st=Ue[0],nt=Ue[1],we=st,ft=!m&&c;(p||ft&&we&&C==="combobox")&&(we=!1);var Ye=ft?!1:we,F=n.useCallback(function(re){var J=re!==void 0?re:!we;p||(nt(J),we!==J&&(E==null||E(J)))},[p,we,nt,E]),B=n.useMemo(function(){return(M||[]).some(function(re){return[` `,`\r `].includes(re)})},[M]),A=function(J,Pe,Fe){var Oe=!0,$e=J;Y==null||Y(null);var Ge=Fe?null:Ra(J,M);return C!=="combobox"&&Ge&&($e="",te==null||te(Ge),F(!1),Oe=!1),X&&Le!==$e&&X($e,{source:Pe?"typing":"effect"}),Oe},ee=function(J){!J||!J.trim()||X(J,{source:"submit"})};n.useEffect(function(){!we&&!ge&&C!=="combobox"&&A("",!1,!1)},[we]),n.useEffect(function(){st&&p&&nt(!1),p&&Qe(!1)},[p]);var he=pn(),Se=ne(he,2),Ke=Se[0],He=Se[1],et=function(J){var Pe=Ke(),Fe=J.which;if(Fe===Z.ENTER&&(C!=="combobox"&&J.preventDefault(),we||F(!0)),He(!!Le),Fe===Z.BACKSPACE&&!Pe&&ge&&!Le&&u.length){for(var Oe=je(u),$e=null,Ge=Oe.length-1;Ge>=0;Ge-=1){var Et=Oe[Ge];if(!Et.disabled){Oe.splice(Ge,1),$e=Et;break}}$e&&f(Oe,{type:"remove",values:[$e]})}for(var ot=arguments.length,ht=new Array(ot>1?ot-1:0),it=1;it1?Pe-1:0),Oe=1;Oe1?Ge-1:0),ot=1;ot1&&arguments[1]!==void 0?arguments[1]:!1;return ea(e).map(function(r,a){if(!n.isValidElement(r)||!r.type)return null;var o=r,i=o.type.isSelectOptGroup,l=o.key,s=o.props,d=s.children,v=ut(s,La);return t||!i?Va(r):G(G({key:"__RC_SELECT_GRP__".concat(l===null?a:l,"__"),label:l},v),{},{options:En(d)})}).filter(function(r){return r})}function Fa(e,t,r,a,o){return n.useMemo(function(){var i=e,l=!e;l&&(i=En(t));var s=new Map,d=new Map,v=function(f,c,g){g&&typeof g=="string"&&f.set(c[g],c)};function h(u){for(var f=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,c=0;c"u"?"undefined":gt(navigator))==="object"&&/Firefox/i.test(navigator.userAgent);const Rn=function(e,t,r,a){var o=n.useRef(!1),i=n.useRef(null);function l(){clearTimeout(i.current),o.current=!0,i.current=setTimeout(function(){o.current=!1},50)}var s=n.useRef({top:e,bottom:t,left:r,right:a});return s.current.top=e,s.current.bottom=t,s.current.left=r,s.current.right=a,function(d,v){var h=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,u=d?v<0&&s.current.left||v>0&&s.current.right:v<0&&s.current.top||v>0&&s.current.bottom;return h&&u?(clearTimeout(i.current),o.current=!1):(!u||o.current)&&l(),!o.current&&u}};function Ha(e,t,r,a,o,i,l){var s=n.useRef(0),d=n.useRef(null),v=n.useRef(null),h=n.useRef(!1),u=Rn(t,r,a,o);function f(p,b){Ze.cancel(d.current),s.current+=b,v.current=b,!u(!1,b)&&(qt||p.preventDefault(),d.current=Ze(function(){var y=h.current?10:1;l(s.current*y),s.current=0}))}function c(p,b){l(b,!0),qt||p.preventDefault()}var g=n.useRef(null),m=n.useRef(null);function S(p){if(e){Ze.cancel(m.current),m.current=Ze(function(){g.current=null},2);var b=p.deltaX,y=p.deltaY,Q=p.shiftKey,U=b,T=y;(g.current==="sx"||!g.current&&Q&&y&&!b)&&(U=y,T=0,g.current="sx");var E=Math.abs(U),D=Math.abs(T);g.current===null&&(g.current=i&&E>D?"x":"y"),g.current==="y"?f(p,T):c(p,U)}}function C(p){e&&(h.current=p.detail===v.current)}return[S,C]}function Wa(e,t,r,a){var o=n.useMemo(function(){return[new Map,[]]},[e,r.id,a]),i=ne(o,2),l=i[0],s=i[1],d=function(h){var u=arguments.length>1&&arguments[1]!==void 0?arguments[1]:h,f=l.get(h),c=l.get(u);if(f===void 0||c===void 0)for(var g=e.length,m=s.length;m0&&arguments[0]!==void 0?arguments[0]:!1;h();var g=function(){s.current.forEach(function(S,C){if(S&&S.offsetParent){var p=zn(S),b=p.offsetHeight;d.current.get(C)!==b&&d.current.set(C,p.offsetHeight)}}),l(function(S){return S+1})};c?g():v.current=Ze(g)}function f(c,g){var m=e(c),S=s.current.get(m);g?(s.current.set(m,g),u()):s.current.delete(m),!S!=!g&&(g?t==null||t(c):r==null||r(c))}return n.useEffect(function(){return h},[]),[f,u,d.current,i]}var en=14/15;function Ua(e,t,r){var a=n.useRef(!1),o=n.useRef(0),i=n.useRef(0),l=n.useRef(null),s=n.useRef(null),d,v=function(c){if(a.current){var g=Math.ceil(c.touches[0].pageX),m=Math.ceil(c.touches[0].pageY),S=o.current-g,C=i.current-m,p=Math.abs(S)>Math.abs(C);p?o.current=g:i.current=m,r(p,p?S:C)&&c.preventDefault(),clearInterval(s.current),s.current=setInterval(function(){p?S*=en:C*=en;var b=Math.floor(p?S:C);(!r(p,b,!0)||Math.abs(b)<=.1)&&clearInterval(s.current)},16)}},h=function(){a.current=!1,d()},u=function(c){d(),c.touches.length===1&&!a.current&&(a.current=!0,o.current=Math.ceil(c.touches[0].pageX),i.current=Math.ceil(c.touches[0].pageY),l.current=c.target,l.current.addEventListener("touchmove",v,{passive:!1}),l.current.addEventListener("touchend",h,{passive:!0}))};d=function(){l.current&&(l.current.removeEventListener("touchmove",v),l.current.removeEventListener("touchend",h))},lt(function(){return e&&t.current.addEventListener("touchstart",u,{passive:!0}),function(){var f;(f=t.current)===null||f===void 0||f.removeEventListener("touchstart",u),d(),clearInterval(s.current)}},[e])}var Ya=10;function Xa(e,t,r,a,o,i,l,s){var d=n.useRef(),v=n.useState(null),h=ne(v,2),u=h[0],f=h[1];return lt(function(){if(u&&u.times=0;X-=1){var te=o(t[X]),M=r.get(te);if(M===void 0){p=!0;break}if(_-=M,_<=0)break}switch(Q){case"top":y=T-S;break;case"bottom":y=E-C+S;break;default:{var K=e.current.scrollTop,O=K+C;TO&&(b="bottom")}}y!==null&&l(y),y!==u.lastTop&&(p=!0)}p&&f(G(G({},u),{},{times:u.times+1,targetAlign:b,lastTop:y}))}},[u,e.current]),function(c){if(c==null){s();return}if(Ze.cancel(d.current),typeof c=="number")l(c);else if(c&>(c)==="object"){var g,m=c.align;"index"in c?g=c.index:g=t.findIndex(function(p){return o(p)===c.key});var S=c.offset,C=S===void 0?0:S;f({times:0,index:g,offset:C,originAlign:m})}}}function tn(e,t){var r="touches"in e?e.touches[0]:e;return r[t?"pageX":"pageY"]}var nn=n.forwardRef(function(e,t){var r=e.prefixCls,a=e.rtl,o=e.scrollOffset,i=e.scrollRange,l=e.onStartMove,s=e.onStopMove,d=e.onScroll,v=e.horizontal,h=e.spinSize,u=e.containerSize,f=e.style,c=e.thumbStyle,g=n.useState(!1),m=ne(g,2),S=m[0],C=m[1],p=n.useState(null),b=ne(p,2),y=b[0],Q=b[1],U=n.useState(null),T=ne(U,2),E=T[0],D=T[1],Y=!a,q=n.useRef(),ae=n.useRef(),_=n.useState(!1),X=ne(_,2),te=X[0],M=X[1],K=n.useRef(),O=function(){clearTimeout(K.current),M(!0),K.current=setTimeout(function(){M(!1)},3e3)},w=i-u||0,ce=u-h||0,$=n.useMemo(function(){if(o===0||w===0)return 0;var x=o/w;return x*ce},[o,w,ce]),de=function(z){z.stopPropagation(),z.preventDefault()},oe=n.useRef({top:$,dragging:S,pageY:y,startTop:E});oe.current={top:$,dragging:S,pageY:y,startTop:E};var L=function(z){C(!0),Q(tn(z,v)),D(oe.current.top),l(),z.stopPropagation(),z.preventDefault()};n.useEffect(function(){var x=function(ve){ve.preventDefault()},z=q.current,le=ae.current;return z.addEventListener("touchstart",x,{passive:!1}),le.addEventListener("touchstart",L,{passive:!1}),function(){z.removeEventListener("touchstart",x),le.removeEventListener("touchstart",L)}},[]);var I=n.useRef();I.current=w;var W=n.useRef();W.current=ce,n.useEffect(function(){if(S){var x,z=function(ve){var fe=oe.current,me=fe.dragging,Ce=fe.pageY,Ee=fe.startTop;Ze.cancel(x);var ge=q.current.getBoundingClientRect(),R=u/(v?ge.width:ge.height);if(me){var ie=(tn(ve,v)-Ce)*R,pe=Ee;!Y&&v?pe-=ie:pe+=ie;var Ie=I.current,De=W.current,Ae=De?pe/De:0,be=Math.ceil(Ae*Ie);be=Math.max(be,0),be=Math.min(be,Ie),x=Ze(function(){d(be,v)})}},le=function(){C(!1),s()};return window.addEventListener("mousemove",z,{passive:!0}),window.addEventListener("touchmove",z,{passive:!0}),window.addEventListener("mouseup",le,{passive:!0}),window.addEventListener("touchend",le,{passive:!0}),function(){window.removeEventListener("mousemove",z),window.removeEventListener("touchmove",z),window.removeEventListener("mouseup",le),window.removeEventListener("touchend",le),Ze.cancel(x)}}},[S]),n.useEffect(function(){return O(),function(){clearTimeout(K.current)}},[o]),n.useImperativeHandle(t,function(){return{delayHidden:O}});var N="".concat(r,"-scrollbar"),P={position:"absolute",visibility:te?null:"hidden"},k={position:"absolute",background:"rgba(0, 0, 0, 0.5)",borderRadius:99,cursor:"pointer",userSelect:"none"};return v?(P.height=8,P.left=0,P.right=0,P.bottom=0,k.height="100%",k.width=h,Y?k.left=$:k.right=$):(P.width=8,P.top=0,P.bottom=0,Y?P.right=0:P.left=0,k.width="100%",k.height=h,k.top=$),n.createElement("div",{ref:q,className:ye(N,H(H(H({},"".concat(N,"-horizontal"),v),"".concat(N,"-vertical"),!v),"".concat(N,"-visible"),te)),style:G(G({},P),f),onMouseDown:de,onMouseMove:O},n.createElement("div",{ref:ae,className:ye("".concat(N,"-thumb"),H({},"".concat(N,"-thumb-moving"),S)),style:G(G({},k),c),onMouseDown:L}))}),Ga=20;function an(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=e/t*e;return isNaN(r)&&(r=0),r=Math.max(r,Ga),Math.floor(r)}var Qa=["prefixCls","className","height","itemHeight","fullHeight","style","data","children","itemKey","virtual","direction","scrollWidth","component","onScroll","onVirtualScroll","onVisibleChange","innerProps","extraRender","styles"],Ja=[],Za={overflowY:"auto",overflowAnchor:"none"};function qa(e,t){var r=e.prefixCls,a=r===void 0?"rc-virtual-list":r,o=e.className,i=e.height,l=e.itemHeight,s=e.fullHeight,d=s===void 0?!0:s,v=e.style,h=e.data,u=e.children,f=e.itemKey,c=e.virtual,g=e.direction,m=e.scrollWidth,S=e.component,C=S===void 0?"div":S,p=e.onScroll,b=e.onVirtualScroll,y=e.onVisibleChange,Q=e.innerProps,U=e.extraRender,T=e.styles,E=ut(e,Qa),D=n.useCallback(function(j){return typeof f=="function"?f(j):j==null?void 0:j[f]},[f]),Y=ja(D,null,null),q=ne(Y,4),ae=q[0],_=q[1],X=q[2],te=q[3],M=!!(c!==!1&&i&&l),K=n.useMemo(function(){return Object.values(X.maps).reduce(function(j,V){return j+V},0)},[X.id,X.maps]),O=M&&h&&(Math.max(l*h.length,K)>i||!!m),w=g==="rtl",ce=ye(a,H({},"".concat(a,"-rtl"),w),o),$=h||Ja,de=n.useRef(),oe=n.useRef(),L=n.useRef(),I=n.useState(0),W=ne(I,2),N=W[0],P=W[1],k=n.useState(0),x=ne(k,2),z=x[0],le=x[1],se=n.useState(!1),ve=ne(se,2),fe=ve[0],me=ve[1],Ce=function(){me(!0)},Ee=function(){me(!1)},ge={getKey:D};function R(j){P(function(V){var ue;typeof j=="function"?ue=j(V):ue=j;var Me=st(ue);return de.current.scrollTop=Me,Me})}var ie=n.useRef({start:0,end:$.length}),pe=n.useRef(),Ie=za($,D),De=ne(Ie,1),Ae=De[0];pe.current=Ae;var be=n.useMemo(function(){if(!M)return{scrollHeight:void 0,start:0,end:$.length-1,offset:void 0};if(!O){var j;return{scrollHeight:((j=oe.current)===null||j===void 0?void 0:j.offsetHeight)||0,start:0,end:$.length-1,offset:void 0}}for(var V=0,ue,Me,Je,xt=$.length,dt=0;dt=N&&ue===void 0&&(ue=dt,Me=V),yt>N+i&&Je===void 0&&(Je=dt),V=yt}return ue===void 0&&(ue=0,Me=0,Je=Math.ceil(i/l)),Je===void 0&&(Je=$.length-1),Je=Math.min(Je+1,$.length-1),{scrollHeight:V,start:ue,end:Je,offset:Me}},[O,M,N,$,te,i]),Ne=be.scrollHeight,Ve=be.start,ke=be.end,Te=be.offset;ie.current.start=Ve,ie.current.end=ke;var pt=n.useState({width:0,height:i}),qe=ne(pt,2),_e=qe[0],Qe=qe[1],St=function(V){Qe({width:V.offsetWidth,height:V.offsetHeight})},Le=n.useRef(),ct=n.useRef(),ze=n.useMemo(function(){return an(_e.width,m)},[_e.width,m]),vt=n.useMemo(function(){return an(_e.height,Ne)},[_e.height,Ne]),tt=Ne-i,Ue=n.useRef(tt);Ue.current=tt;function st(j){var V=j;return Number.isNaN(Ue.current)||(V=Math.min(V,Ue.current)),V=Math.max(V,0),V}var nt=N<=0,we=N>=tt,ft=z<=0,Ye=z>=m,F=Rn(nt,we,ft,Ye),B=function(){return{x:w?-z:z,y:N}},A=n.useRef(B()),ee=jt(function(j){if(b){var V=G(G({},B()),j);(A.current.x!==V.x||A.current.y!==V.y)&&(b(V),A.current=V)}});function he(j,V){var ue=j;V?(Ut.flushSync(function(){le(ue)}),ee()):R(ue)}function Se(j){var V=j.currentTarget.scrollTop;V!==N&&R(V),p==null||p(j),ee()}var Ke=function(V){var ue=V,Me=m?m-_e.width:0;return ue=Math.max(ue,0),ue=Math.min(ue,Me),ue},He=jt(function(j,V){V?(Ut.flushSync(function(){le(function(ue){var Me=ue+(w?-j:j);return Ke(Me)})}),ee()):R(function(ue){var Me=ue+j;return Me})}),et=Ha(M,nt,we,ft,Ye,!!m,He),xe=ne(et,2),We=xe[0],at=xe[1];Ua(M,de,function(j,V,ue){return F(j,V,ue)?!1:(We({preventDefault:function(){},deltaX:j?V:0,deltaY:j?0:V}),!0)}),lt(function(){function j(ue){M&&ue.preventDefault()}var V=de.current;return V.addEventListener("wheel",We,{passive:!1}),V.addEventListener("DOMMouseScroll",at,{passive:!0}),V.addEventListener("MozMousePixelScroll",j,{passive:!1}),function(){V.removeEventListener("wheel",We),V.removeEventListener("DOMMouseScroll",at),V.removeEventListener("MozMousePixelScroll",j)}},[M]),lt(function(){if(m){var j=Ke(z);le(j),ee({x:j})}},[_e.width,m]);var mt=function(){var V,ue;(V=Le.current)===null||V===void 0||V.delayHidden(),(ue=ct.current)===null||ue===void 0||ue.delayHidden()},Ct=Xa(de,$,X,l,D,function(){return _(!0)},R,mt);n.useImperativeHandle(t,function(){return{nativeElement:L.current,getScrollInfo:B,scrollTo:function(V){function ue(Me){return Me&>(Me)==="object"&&("left"in Me||"top"in Me)}ue(V)?(V.left!==void 0&&le(Ke(V.left)),Ct(V.top)):Ct(V)}}}),lt(function(){if(y){var j=$.slice(Ve,ke+1);y(j,$)}},[Ve,ke,$]);var Be=Wa($,D,X,l),Xe=U==null?void 0:U({start:Ve,end:ke,virtual:O,offsetX:z,offsetY:Te,rtl:w,getSize:Be}),kt=Ka($,Ve,ke,m,z,ae,u,ge),rt=null;i&&(rt=G(H({},d?"height":"maxHeight",i),Za),M&&(rt.overflowY="hidden",m&&(rt.overflowX="hidden"),fe&&(rt.pointerEvents="none")));var bt={};return w&&(bt.dir="rtl"),n.createElement("div",Re({ref:L,style:G(G({},v),{},{position:"relative"}),className:ce},bt,E),n.createElement(mn,{onResize:St},n.createElement(C,{className:"".concat(a,"-holder"),style:rt,ref:de,onScroll:Se,onMouseEnter:mt},n.createElement(In,{prefixCls:a,height:Ne,offsetX:z,offsetY:Te,scrollWidth:m,onInnerResize:_,ref:oe,innerProps:Q,rtl:w,extra:Xe},kt))),O&&Ne>i&&n.createElement(nn,{ref:Le,prefixCls:a,scrollOffset:N,scrollRange:Ne,rtl:w,onScroll:he,onStartMove:Ce,onStopMove:Ee,spinSize:vt,containerSize:_e.height,style:T==null?void 0:T.verticalScrollBar,thumbStyle:T==null?void 0:T.verticalScrollBarThumb}),O&&m>_e.width&&n.createElement(nn,{ref:ct,prefixCls:a,scrollOffset:z,scrollRange:m,rtl:w,onScroll:he,onStartMove:Ce,onStopMove:Ee,spinSize:ze,containerSize:_e.width,horizontal:!0,style:T==null?void 0:T.horizontalScrollBar,thumbStyle:T==null?void 0:T.horizontalScrollBarThumb}))}var xn=n.forwardRef(qa);xn.displayName="List";function er(){return/(mac\sos|macintosh)/i.test(navigator.appVersion)}var Mn=n.createContext(null),tr=["disabled","title","children","style","className"];function rn(e){return typeof e=="string"||typeof e=="number"}var nr=function(t,r){var a=ua(),o=a.prefixCls,i=a.id,l=a.open,s=a.multiple,d=a.mode,v=a.searchValue,h=a.toggleOpen,u=a.notFoundContent,f=a.onPopupScroll,c=n.useContext(Mn),g=c.flattenOptions,m=c.onActiveValue,S=c.defaultActiveFirstOption,C=c.onSelect,p=c.menuItemSelectedIcon,b=c.rawValues,y=c.fieldNames,Q=c.virtual,U=c.listHeight,T=c.listItemHeight,E="".concat(o,"-item"),D=Hn(function(){return g},[l,g],function(L,I){return I[0]&&L[1]!==I[1]}),Y=n.useRef(null),q=function(I){I.preventDefault()},ae=function(I){Y.current&&Y.current.scrollTo(typeof I=="number"?{index:I}:I)},_=function(I){for(var W=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,N=D.length,P=0;P1&&arguments[1]!==void 0?arguments[1]:!1;K(I);var N={source:W?"keyboard":"mouse"},P=D[I];if(!P){m(null,-1,N);return}m(P.value,I,N)};n.useEffect(function(){O(S!==!1?_(0):-1)},[D.length,v]);var w=n.useCallback(function(L){return b.has(L)&&d!=="combobox"},[d,je(b).toString(),b.size]);n.useEffect(function(){var L=setTimeout(function(){if(!s&&l&&b.size===1){var W=Array.from(b)[0],N=D.findIndex(function(P){var k=P.data;return k.value===W});N!==-1&&(O(N),ae(N))}});if(l){var I;(I=Y.current)===null||I===void 0||I.scrollTo(void 0)}return function(){return clearTimeout(L)}},[l,v]);var ce=function(I){I!==void 0&&C(I,{selected:!b.has(I)}),s||h(!1)};if(n.useImperativeHandle(r,function(){return{onKeyDown:function(I){var W=I.which,N=I.ctrlKey;switch(W){case Z.N:case Z.P:case Z.UP:case Z.DOWN:{var P=0;if(W===Z.UP?P=-1:W===Z.DOWN?P=1:er()&&N&&(W===Z.N?P=1:W===Z.P&&(P=-1)),P!==0){var k=_(M+P,P);ae(k),O(k,!0)}break}case Z.ENTER:{var x=D[M];x&&!x.data.disabled?ce(x.value):ce(void 0),l&&I.preventDefault();break}case Z.ESC:h(!1),l&&I.stopPropagation()}},onKeyUp:function(){},scrollTo:function(I){ae(I)}}}),D.length===0)return n.createElement("div",{role:"listbox",id:"".concat(i,"_list"),className:"".concat(E,"-empty"),onMouseDown:q},u);var $=Object.keys(y).map(function(L){return y[L]}),de=function(I){return I.label},oe=function(I){var W=D[I];if(!W)return null;var N=W.data||{},P=N.value,k=W.group,x=Rt(N,!0),z=de(W);return W?n.createElement("div",Re({"aria-label":typeof z=="string"&&!k?z:null},x,{key:I,role:k?"presentation":"option",id:"".concat(i,"_list_").concat(I),"aria-selected":w(P)}),P):null};return n.createElement(n.Fragment,null,n.createElement("div",{role:"listbox",id:"".concat(i,"_list"),style:{height:0,width:0,overflow:"hidden"}},oe(M-1),oe(M),oe(M+1)),n.createElement(xn,{itemKey:"key",ref:Y,data:D,height:U,itemHeight:T,fullHeight:!1,onMouseDown:q,onScroll:f,virtual:Q},function(L,I){var W,N=L.group,P=L.groupOption,k=L.data,x=L.label,z=L.value,le=k.key;if(N){var se,ve=(se=k.title)!==null&&se!==void 0?se:rn(x)?x.toString():void 0;return n.createElement("div",{className:ye(E,"".concat(E,"-group")),title:ve},x!==void 0?x:le)}var fe=k.disabled,me=k.title;k.children;var Ce=k.style,Ee=k.className,ge=ut(k,tr),R=hn(ge,$),ie=w(z),pe="".concat(E,"-option"),Ie=ye(E,pe,Ee,(W={},H(W,"".concat(pe,"-grouped"),P),H(W,"".concat(pe,"-active"),M===I&&!fe),H(W,"".concat(pe,"-disabled"),fe),H(W,"".concat(pe,"-selected"),ie),W)),De=de(L),Ae=!p||typeof p=="function"||ie,be=typeof De=="number"?De:De||z,Ne=rn(be)?be.toString():void 0;return me!==void 0&&(Ne=me),n.createElement("div",Re({},Rt(R),{"aria-selected":ie,className:Ie,title:Ne,onMouseMove:function(){M===I||fe||O(I)},onClick:function(){fe||ce(z)},style:Ce}),n.createElement("div",{className:"".concat(pe,"-content")},be),n.isValidElement(p)||ie,Ae&&n.createElement(Nt,{className:"".concat(E,"-option-state"),customizeIcon:p,customizeIconProps:{isSelected:ie}},ie?"✓":null))}))},On=n.forwardRef(nr);On.displayName="OptionList";var ar=["id","mode","prefixCls","backfill","fieldNames","inputValue","searchValue","onSearch","autoClearSearchValue","onSelect","onDeselect","dropdownMatchSelectWidth","filterOption","filterSort","optionFilterProp","optionLabelProp","options","children","defaultActiveFirstOption","menuItemSelectedIcon","virtual","listHeight","listItemHeight","value","defaultValue","labelInValue","onChange"],rr=["inputValue"];function or(e){return!e||gt(e)!=="object"}var ir=n.forwardRef(function(e,t){var r=e.id,a=e.mode,o=e.prefixCls,i=o===void 0?"rc-select":o,l=e.backfill,s=e.fieldNames,d=e.inputValue,v=e.searchValue,h=e.onSearch,u=e.autoClearSearchValue,f=u===void 0?!0:u,c=e.onSelect,g=e.onDeselect,m=e.dropdownMatchSelectWidth,S=m===void 0?!0:m,C=e.filterOption,p=e.filterSort,b=e.optionFilterProp,y=e.optionLabelProp,Q=e.options,U=e.children,T=e.defaultActiveFirstOption,E=e.menuItemSelectedIcon,D=e.virtual,Y=e.listHeight,q=Y===void 0?200:Y,ae=e.listItemHeight,_=ae===void 0?20:ae,X=e.value,te=e.defaultValue,M=e.labelInValue,K=e.onChange,O=ut(e,ar),w=Ta(r),ce=Ft(a),$=!!(!Q&&U),de=n.useMemo(function(){return C===void 0&&a==="combobox"?!1:C},[C,a]),oe=n.useMemo(function(){return yn(s,$)},[JSON.stringify(s),$]),L=Dt("",{value:v!==void 0?v:d,postState:function(B){return B||""}}),I=ne(L,2),W=I[0],N=I[1],P=Fa(Q,U,oe,b,y),k=P.valueOptions,x=P.labelOptions,z=P.options,le=n.useCallback(function(F){var B=Sn(F);return B.map(function(A){var ee,he,Se,Ke,He;if(or(A))ee=A;else{var et;Se=A.key,he=A.label,ee=(et=A.value)!==null&&et!==void 0?et:Se}var xe=k.get(ee);if(xe){var We;he===void 0&&(he=xe==null?void 0:xe[y||oe.label]),Se===void 0&&(Se=(We=xe==null?void 0:xe.key)!==null&&We!==void 0?We:ee),Ke=xe==null?void 0:xe.disabled,He=xe==null?void 0:xe.title}return{label:he,value:ee,key:Se,disabled:Ke,title:He}})},[oe,y,k]),se=Dt(te,{value:X}),ve=ne(se,2),fe=ve[0],me=ve[1],Ce=n.useMemo(function(){var F,B=le(fe);return a==="combobox"&&!((F=B[0])!==null&&F!==void 0&&F.value)?[]:B},[fe,le,a]),Ee=Da(Ce,k),ge=ne(Ee,2),R=ge[0],ie=ge[1],pe=n.useMemo(function(){if(!a&&R.length===1){var F=R[0];if(F.value===null&&(F.label===null||F.label===void 0))return[]}return R.map(function(B){var A;return G(G({},B),{},{label:(A=B.label)!==null&&A!==void 0?A:B.value})})},[a,R]),Ie=n.useMemo(function(){return new Set(R.map(function(F){return F.value}))},[R]);n.useEffect(function(){if(a==="combobox"){var F,B=(F=R[0])===null||F===void 0?void 0:F.value;N(ma(B)?String(B):"")}},[R]);var De=Zt(function(F,B){var A,ee=B??F;return A={},H(A,oe.value,F),H(A,oe.label,ee),A}),Ae=n.useMemo(function(){if(a!=="tags")return z;var F=je(z),B=function(ee){return k.has(ee)};return je(R).sort(function(A,ee){return A.value2&&arguments[2]!==void 0?arguments[2]:{},ee=A.source,he=ee===void 0?"keyboard":ee;ze(B),l&&a==="combobox"&&F!==null&&he==="keyboard"&&Qe(String(F))},[l,a]),Ue=function(B,A,ee){var he=function(){var Be,Xe=ie(B);return[M?{label:Xe==null?void 0:Xe[oe.label],value:B,key:(Be=Xe==null?void 0:Xe.key)!==null&&Be!==void 0?Be:B}:B,Vt(Xe)]};if(A&&c){var Se=he(),Ke=ne(Se,2),He=Ke[0],et=Ke[1];c(He,et)}else if(!A&&g&&ee!=="clear"){var xe=he(),We=ne(xe,2),at=We[0],mt=We[1];g(at,mt)}},st=Zt(function(F,B){var A,ee=ce?B.selected:!0;ee?A=ce?[].concat(je(R),[F]):[F]:A=R.filter(function(he){return he.value!==F}),Te(A),Ue(F,ee),a==="combobox"?Qe(""):(!Ft||f)&&(N(""),Qe(""))}),nt=function(B,A){Te(B);var ee=A.type,he=A.values;(ee==="remove"||ee==="clear")&&he.forEach(function(Se){Ue(Se.value,!1,ee)})},we=function(B,A){if(N(B),Qe(null),A.source==="submit"){var ee=(B||"").trim();if(ee){var he=Array.from(new Set([].concat(je(Ie),[ee])));Te(he),Ue(ee,!0),N("")}return}A.source!=="blur"&&(a==="combobox"&&Te(B),h==null||h(B))},ft=function(B){var A=B;a!=="tags"&&(A=B.map(function(he){var Se=x.get(he);return Se==null?void 0:Se.value}).filter(function(he){return he!==void 0}));var ee=Array.from(new Set([].concat(je(Ie),je(A))));Te(ee),ee.forEach(function(he){Ue(he,!0)})},Ye=n.useMemo(function(){var F=D!==!1&&S!==!1;return G(G({},P),{},{flattenOptions:ke,onActiveValue:tt,defaultActiveFirstOption:vt,onSelect:st,menuItemSelectedIcon:E,rawValues:Ie,fieldNames:oe,virtual:F,listHeight:q,listItemHeight:_,childrenAsData:$})},[P,ke,tt,vt,st,E,Ie,oe,D,S,q,_,$]);return n.createElement(Mn.Provider,{value:Ye},n.createElement(Oa,Re({},O,{id:w,prefixCls:i,ref:t,omitDomProps:rr,mode:a,displayValues:pe,onDisplayValuesChange:nt,searchValue:W,onSearch:we,autoClearSearchValue:f,onSearchSplit:ft,dropdownMatchSelectWidth:S,OptionList:On,emptyOptions:!ke.length,activeValue:_e,activeDescendantId:"".concat(w,"_list_").concat(ct)})))}),Ht=ir;Ht.Option=zt;Ht.OptGroup=$t;var lr=function(t){return n.createElement(Wn,null,function(r){var a=r.getPrefixCls,o=a("empty");switch(t){case"Table":case"List":return n.createElement(It,{image:It.PRESENTED_IMAGE_SIMPLE});case"Select":case"TreeSelect":case"Cascader":case"Transfer":case"Mentions":return n.createElement(It,{image:It.PRESENTED_IMAGE_SIMPLE,className:"".concat(o,"-small")});default:return n.createElement(It,null)}})};const ur=lr;var cr={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M884 256h-75c-5.1 0-9.9 2.5-12.9 6.6L512 654.2 227.9 262.6c-3-4.1-7.8-6.6-12.9-6.6h-75c-6.5 0-10.3 7.4-6.5 12.7l352.6 486.1c12.8 17.6 39 17.6 51.7 0l352.6-486.1c3.9-5.3.1-12.7-6.4-12.7z"}}]},name:"down",theme:"outlined"};const sr=cr;var fr=function(t,r){return n.createElement(Bn,G(G({},t),{},{ref:r,icon:sr}))},dr=n.forwardRef(fr);const vr=dr;function mr(e){var t=e.suffixIcon,r=e.clearIcon,a=e.menuItemSelectedIcon,o=e.removeIcon,i=e.loading,l=e.multiple,s=e.hasFeedback,d=e.prefixCls,v=e.showArrow,h=e.feedbackIcon,u=r??n.createElement(jn,null),f=function(p){return n.createElement(n.Fragment,null,v!==!1&&p,s&&h)},c=null;if(t!==void 0)c=f(t);else if(i)c=f(n.createElement(fn,{spin:!0}));else{var g="".concat(d,"-suffix");c=function(p){var b=p.open,y=p.showSearch;return f(b&&y?n.createElement(oa,{className:g}):n.createElement(vr,{className:g}))}}var m=null;a!==void 0?m=a:l?m=n.createElement(la,null):m=null;var S=null;return o!==void 0?S=o:S=n.createElement(sn,null),{clearIcon:u,suffixIcon:c,itemIcon:m,removeIcon:S}}var hr=globalThis&&globalThis.__rest||function(e,t){var r={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.indexOf(a)<0&&(r[a]=e[a]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,a=Object.getOwnPropertySymbols(e);o1?!0:(t.preventDefault&&t.preventDefault(),!1)}var pn=po&&window.navigator&&window.navigator.platform&&/iP(ad|hone|od)/.test(window.navigator.platform),A5=new Map,mn=typeof document=="object"?document:void 0,$t=!1;const S9=mn?function(t,r){t===void 0&&(t=!0);var n=j.useRef(mn.body);r=r||n;var a=function(s){var c=A5.get(s);c?A5.set(s,{counter:c.counter+1,initialOverflow:c.initialOverflow}):(A5.set(s,{counter:1,initialOverflow:s.style.overflow}),pn?$t||(w4(document,"touchmove",dn,{passive:!1}),$t=!0):s.style.overflow="hidden")},i=function(s){var c=A5.get(s);c&&(c.counter===1?(A5.delete(s),pn?(s.ontouchmove=null,$t&&(H4(document,"touchmove",dn),$t=!1)):s.style.overflow=c.initialOverflow):A5.set(s,{counter:c.counter-1,initialOverflow:c.initialOverflow}))};j.useEffect(function(){var s=Vr(r.current);s&&(t?a(s):i(s))},[t,r.current]),j.useEffect(function(){var s=Vr(r.current);if(s)return function(){i(s)}},[])}:function(t,r){};var E9=function(){var e=j.useState(function(){return window.location.hash}),t=e[0],r=e[1],n=j.useCallback(function(){r(window.location.hash)},[]);L9(function(){w4(window,"hashchange",n)},function(){H4(window,"hashchange",n)});var a=j.useCallback(function(i){i!==t&&(window.location.hash=i)},[t]);return[t,a]},Lr={exports:{}},gn={},zn;function _9(){return zn||(zn=1),gn}(function(e,t){(function(r,n){n(t,_9())})(gt,function(r,n){n=n&&n.hasOwnProperty("default")?n.default:n;var a=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(B){return typeof B}:function(B){return B&&typeof Symbol=="function"&&B.constructor===Symbol&&B!==Symbol.prototype?"symbol":typeof B},i=function(B,p){if(!(B instanceof p))throw new TypeError("Cannot call a class as a function")},s=function(){function B(p,w){for(var y=0;y"u")return this.pipes[w];this.pipes[w]=S}if(w&&w.name){if(S=w,S.processor===this)return S;this.pipes[S.name]=S}return S.processor=this,S}},{key:"process",value:function(w,y){var S=w;S.options=this.options();for(var g=y||w.pipe||"default",H=void 0,E=void 0;g;)typeof S.nextAfterChildren<"u"&&(S.next=S.nextAfterChildren,S.nextAfterChildren=null),typeof g=="string"&&(g=this.pipe(g)),g.process(S),E=S,H=g,g=null,S&&S.next&&(S=S.next,g=E.nextPipe||S.pipe||H);return S.hasResult?S.result:void 0}}]),B}(),v=function(){function B(p){i(this,B),this.name=p,this.filters=[]}return s(B,[{key:"process",value:function(w){if(!this.processor)throw new Error("add this pipe to a processor before using it");for(var y=this.debug,S=this.filters.length,g=w,H=0;H"u"?"undefined":a(g))==="object"&&g.exiting){g.exiting=!1;break}}!g.next&&this.resultCheck&&this.resultCheck(g)}},{key:"log",value:function(w){console.log("[jsondiffpatch] "+this.name+" pipe, "+w)}},{key:"append",value:function(){var w;return(w=this.filters).push.apply(w,arguments),this}},{key:"prepend",value:function(){var w;return(w=this.filters).unshift.apply(w,arguments),this}},{key:"indexOf",value:function(w){if(!w)throw new Error("a filter name is required");for(var y=0;y"u"?"undefined":a(B))!=="object")return B;if(B===null)return null;if(d(B))return B.map(m);if(B instanceof Date)return new Date(B.getTime());if(B instanceof RegExp)return z(B);var p={};for(var w in B)Object.prototype.hasOwnProperty.call(B,w)&&(p[w]=m(B[w]));return p}var L=function(B){h(p,B);function p(w,y){i(this,p);var S=u(this,(p.__proto__||Object.getPrototypeOf(p)).call(this));return S.left=w,S.right=y,S.pipe="diff",S}return s(p,[{key:"setResult",value:function(y){if(this.options.cloneDiffValues&&(typeof y>"u"?"undefined":a(y))==="object"){var S=typeof this.options.cloneDiffValues=="function"?this.options.cloneDiffValues:m;a(y[0])==="object"&&(y[0]=S(y[0])),a(y[1])==="object"&&(y[1]=S(y[1]))}return M.prototype.setResult.apply(this,arguments)}}]),p}(M),V=function(B){h(p,B);function p(w,y){i(this,p);var S=u(this,(p.__proto__||Object.getPrototypeOf(p)).call(this));return S.left=w,S.delta=y,S.pipe="patch",S}return p}(M),N=function(B){h(p,B);function p(w){i(this,p);var y=u(this,(p.__proto__||Object.getPrototypeOf(p)).call(this));return y.delta=w,y.pipe="reverse",y}return p}(M),C=typeof Array.isArray=="function"?Array.isArray:function(B){return B instanceof Array},A=function(p){if(p.left===p.right){p.setResult(void 0).exit();return}if(typeof p.left>"u"){if(typeof p.right=="function")throw new Error("functions are not supported");p.setResult([p.right]).exit();return}if(typeof p.right>"u"){p.setResult([p.left,0,0]).exit();return}if(typeof p.left=="function"||typeof p.right=="function")throw new Error("functions are not supported");if(p.leftType=p.left===null?"null":a(p.left),p.rightType=p.right===null?"null":a(p.right),p.leftType!==p.rightType){p.setResult([p.left,p.right]).exit();return}if(p.leftType==="boolean"||p.leftType==="number"){p.setResult([p.left,p.right]).exit();return}if(p.leftType==="object"&&(p.leftIsArray=C(p.left)),p.rightType==="object"&&(p.rightIsArray=C(p.right)),p.leftIsArray!==p.rightIsArray){p.setResult([p.left,p.right]).exit();return}p.left instanceof RegExp&&(p.right instanceof RegExp?p.setResult([p.left.toString(),p.right.toString()]).exit():p.setResult([p.left,p.right]).exit())};A.filterName="trivial";var _=function(p){if(typeof p.delta>"u"){p.setResult(p.left).exit();return}if(p.nested=!C(p.delta),!p.nested){if(p.delta.length===1){p.setResult(p.delta[0]).exit();return}if(p.delta.length===2){if(p.left instanceof RegExp){var w=/^\/(.*)\/([gimyu]+)$/.exec(p.delta[1]);if(w){p.setResult(new RegExp(w[1],w[2])).exit();return}}p.setResult(p.delta[1]).exit();return}p.delta.length===3&&p.delta[2]===0&&p.setResult(void 0).exit()}};_.filterName="trivial";var x=function(p){if(typeof p.delta>"u"){p.setResult(p.delta).exit();return}if(p.nested=!C(p.delta),!p.nested){if(p.delta.length===1){p.setResult([p.delta[0],0,0]).exit();return}if(p.delta.length===2){p.setResult([p.delta[1],p.delta[0]]).exit();return}p.delta.length===3&&p.delta[2]===0&&p.setResult([p.delta[0]]).exit()}};x.filterName="trivial";function R(B){if(!(!B||!B.children)){for(var p=B.children.length,w=void 0,y=B.result,S=0;S"u")&&(y=y||{},y[w.childName]=w.result);y&&B.leftIsArray&&(y._t="a"),B.setResult(y).exit()}}R.filterName="collectChildren";function W(B){if(!(B.leftIsArray||B.leftType!=="object")){var p=void 0,w=void 0,y=B.options.propertyFilter;for(p in B.left)Object.prototype.hasOwnProperty.call(B.left,p)&&(y&&!y(p,B)||(w=new L(B.left[p],B.right[p]),B.push(w,p)));for(p in B.right)Object.prototype.hasOwnProperty.call(B.right,p)&&(y&&!y(p,B)||typeof B.left[p]>"u"&&(w=new L(void 0,B.right[p]),B.push(w,p)));if(!B.children||B.children.length===0){B.setResult(void 0).exit();return}B.exit()}}W.filterName="objects";var K=function(p){if(p.nested&&!p.delta._t){var w=void 0,y=void 0;for(w in p.delta)y=new V(p.left[w],p.delta[w]),p.push(y,w);p.exit()}};K.filterName="objects";var i1=function(p){if(!(!p||!p.children)&&!p.delta._t){for(var w=p.children.length,y=void 0,S=0;Sk?--H:--g}}return E},J=function(p,w,y,S){var g=S||{},H=P(p,w,y||D,g),E=Z(H,p,w,g);return typeof p=="string"&&typeof w=="string"&&(E.sequence=E.sequence.join("")),E},o1={get:J},X=3,a1=typeof Array.isArray=="function"?Array.isArray:function(B){return B instanceof Array},T=typeof Array.prototype.indexOf=="function"?function(B,p){return B.indexOf(p)}:function(B,p){for(var w=B.length,y=0;y"u"?"undefined":a(g))!=="object"||(typeof H>"u"?"undefined":a(H))!=="object")return!1;var E=S.objectHash;if(!E)return S.matchByPosition&&w===y;var O=void 0,I=void 0;return typeof w=="number"?(S.hashCache1=S.hashCache1||[],O=S.hashCache1[w],typeof O>"u"&&(S.hashCache1[w]=O=E(g,w))):O=E(g),typeof O>"u"||(typeof y=="number"?(S.hashCache2=S.hashCache2||[],I=S.hashCache2[y],typeof I>"u"&&(S.hashCache2[y]=I=E(H,y))):I=E(H),typeof I>"u")?!1:O===I}var M1=function(p){if(p.leftIsArray){var w={objectHash:p.options&&p.options.objectHash,matchByPosition:p.options&&p.options.matchByPosition},y=0,S=0,g=void 0,H=void 0,E=void 0,O=p.left,I=p.right,k=O.length,$=I.length,Y=void 0;for(k>0&&$>0&&!w.objectHash&&typeof w.matchByPosition!="boolean"&&(w.matchByPosition=!q(O,I,k,$));y0){for(var t1=0;t1=0;w--){y=H[w];var I=S["_"+y],k=g.splice(y,1)[0];I[2]===X&&E.push({index:I[1],value:k})}E=E.sort(c1.numericallyBy("index"));var $=E.length;for(w=0;w<$;w++){var Y=E[w];g.splice(Y.index,0,Y.value)}var r1=O.length,p1=void 0;if(r1>0)for(w=0;wS?S++:E>=S&&O"u"&&(g=m1(B.delta,w.childName,w.result)),y[g]!==w.result&&(y[g]=w.result)}B.setResult(y).exit()}}H1.filterName="arraysCollectChildren";var L1=function(p){p.left instanceof Date?(p.right instanceof Date?p.left.getTime()!==p.right.getTime()?p.setResult([p.left,p.right]):p.setResult(void 0):p.setResult([p.left,p.right]),p.exit()):p.right instanceof Date&&p.setResult([p.left,p.right]).exit()};L1.filterName="dates";function g1(B,p){return p={exports:{}},B(p,p.exports),p.exports}var V1=g1(function(B){function p(){this.Diff_Timeout=1,this.Diff_EditCost=4,this.Match_Threshold=.5,this.Match_Distance=1e3,this.Patch_DeleteThreshold=.5,this.Patch_Margin=4,this.Match_MaxBits=32}var w=-1,y=1,S=0;p.prototype.diff_main=function(g,H,E,O){typeof O>"u"&&(this.Diff_Timeout<=0?O=Number.MAX_VALUE:O=new Date().getTime()+this.Diff_Timeout*1e3);var I=O;if(g==null||H==null)throw new Error("Null input. (diff_main)");if(g==H)return g?[[S,g]]:[];typeof E>"u"&&(E=!0);var k=E,$=this.diff_commonPrefix(g,H),Y=g.substring(0,$);g=g.substring($),H=H.substring($),$=this.diff_commonSuffix(g,H);var r1=g.substring(g.length-$);g=g.substring(0,g.length-$),H=H.substring(0,H.length-$);var p1=this.diff_compute_(g,H,k,I);return Y&&p1.unshift([S,Y]),r1&&p1.push([S,r1]),this.diff_cleanupMerge(p1),p1},p.prototype.diff_compute_=function(g,H,E,O){var I;if(!g)return[[y,H]];if(!H)return[[w,g]];var k=g.length>H.length?g:H,$=g.length>H.length?H:g,Y=k.indexOf($);if(Y!=-1)return I=[[y,k.substring(0,Y)],[S,$],[y,k.substring(Y+$.length)]],g.length>H.length&&(I[0][0]=I[2][0]=w),I;if($.length==1)return[[w,g],[y,H]];var r1=this.diff_halfMatch_(g,H);if(r1){var p1=r1[0],C1=r1[1],N1=r1[2],U1=r1[3],Y1=r1[4],r0=this.diff_main(p1,N1,E,O),u0=this.diff_main(C1,U1,E,O);return r0.concat([[S,Y1]],u0)}return E&&g.length>100&&H.length>100?this.diff_lineMode_(g,H,O):this.diff_bisect_(g,H,O)},p.prototype.diff_lineMode_=function(g,H,E){var O=this.diff_linesToChars_(g,H);g=O.chars1,H=O.chars2;var I=O.lineArray,k=this.diff_main(g,H,!1,E);this.diff_charsToLines_(k,I),this.diff_cleanupSemantic(k),k.push([S,""]);for(var $=0,Y=0,r1=0,p1="",C1="";$=1&&r1>=1){k.splice($-Y-r1,Y+r1),$=$-Y-r1;for(var O=this.diff_main(p1,C1,!1,E),N1=O.length-1;N1>=0;N1--)k.splice($,0,O[N1]);$=$+O.length}r1=0,Y=0,p1="",C1="";break}$++}return k.pop(),k},p.prototype.diff_bisect_=function(g,H,E){for(var O=g.length,I=H.length,k=Math.ceil((O+I)/2),$=k,Y=2*k,r1=new Array(Y),p1=new Array(Y),C1=0;C1E);U++){for(var t1=-U+Y1;t1<=U-r0;t1+=2){var y1=$+t1,b1;t1==-U||t1!=U&&r1[y1-1]O)r0+=2;else if(j1>I)Y1+=2;else if(U1){var Z1=$+N1-t1;if(Z1>=0&&Z1=K1)return this.diff_bisectSplit_(g,H,b1,j1,E)}}}for(var J1=-U+u0;J1<=U-p0;J1+=2){var Z1=$+J1,K1;J1==-U||J1!=U&&p1[Z1-1]O)p0+=2;else if(q1>I)u0+=2;else if(!U1){var y1=$+N1-J1;if(y1>=0&&y1=K1)return this.diff_bisectSplit_(g,H,b1,j1,E)}}}}return[[w,g],[y,H]]},p.prototype.diff_bisectSplit_=function(g,H,E,O,I){var k=g.substring(0,E),$=H.substring(0,O),Y=g.substring(E),r1=H.substring(O),p1=this.diff_main(k,$,!1,I),C1=this.diff_main(Y,r1,!1,I);return p1.concat(C1)},p.prototype.diff_linesToChars_=function(g,H){var E=[],O={};E[0]="";function I(Y){for(var r1="",p1=0,C1=-1,N1=E.length;C1O?g=g.substring(E-O):EH.length?g:H,O=g.length>H.length?H:g;if(E.length<4||O.length*2=r0.length?[b1,j1,Z1,K1,y1]:null}var $=k(E,O,Math.ceil(E.length/4)),Y=k(E,O,Math.ceil(E.length/2)),r1;if(!$&&!Y)return null;Y?$?r1=$[4].length>Y[4].length?$:Y:r1=Y:r1=$;var p1,C1,N1,U1;g.length>H.length?(p1=r1[0],C1=r1[1],N1=r1[2],U1=r1[3]):(N1=r1[0],U1=r1[1],p1=r1[2],C1=r1[3]);var Y1=r1[4];return[p1,C1,N1,U1,Y1]},p.prototype.diff_cleanupSemantic=function(g){for(var H=!1,E=[],O=0,I=null,k=0,$=0,Y=0,r1=0,p1=0;k0?E[O-1]:-1,$=0,Y=0,r1=0,p1=0,I=null,H=!0)),k++;for(H&&this.diff_cleanupMerge(g),this.diff_cleanupSemanticLossless(g),k=1;k=Y1?(U1>=C1.length/2||U1>=N1.length/2)&&(g.splice(k,0,[S,N1.substring(0,U1)]),g[k-1][1]=C1.substring(0,C1.length-U1),g[k+1][1]=N1.substring(U1),k++):(Y1>=C1.length/2||Y1>=N1.length/2)&&(g.splice(k,0,[S,C1.substring(0,Y1)]),g[k-1][0]=y,g[k-1][1]=N1.substring(0,N1.length-Y1),g[k+1][0]=w,g[k+1][1]=C1.substring(Y1),k++),k++}k++}},p.prototype.diff_cleanupSemanticLossless=function(g){function H(Y1,r0){if(!Y1||!r0)return 6;var u0=Y1.charAt(Y1.length-1),p0=r0.charAt(0),U=u0.match(p.nonAlphaNumericRegex_),t1=p0.match(p.nonAlphaNumericRegex_),y1=U&&u0.match(p.whitespaceRegex_),b1=t1&&p0.match(p.whitespaceRegex_),j1=y1&&u0.match(p.linebreakRegex_),Z1=b1&&p0.match(p.linebreakRegex_),K1=j1&&Y1.match(p.blanklineEndRegex_),J1=Z1&&r0.match(p.blanklineStartRegex_);return K1||J1?5:j1||Z1?4:U&&!y1&&b1?3:y1||b1?2:U||t1?1:0}for(var E=1;E=N1&&(N1=U1,r1=O,p1=I,C1=k)}g[E-1][1]!=r1&&(r1?g[E-1][1]=r1:(g.splice(E-1,1),E--),g[E][1]=p1,C1?g[E+1][1]=C1:(g.splice(E+1,1),E--))}E++}},p.nonAlphaNumericRegex_=/[^a-zA-Z0-9]/,p.whitespaceRegex_=/\s/,p.linebreakRegex_=/[\r\n]/,p.blanklineEndRegex_=/\n\r?\n$/,p.blanklineStartRegex_=/^\r?\n\r?\n/,p.prototype.diff_cleanupEfficiency=function(g){for(var H=!1,E=[],O=0,I=null,k=0,$=!1,Y=!1,r1=!1,p1=!1;k0?E[O-1]:-1,r1=p1=!1),H=!0)),k++;H&&this.diff_cleanupMerge(g)},p.prototype.diff_cleanupMerge=function(g){g.push([S,""]);for(var H=0,E=0,O=0,I="",k="",$;H1?(E!==0&&O!==0&&($=this.diff_commonPrefix(k,I),$!==0&&(H-E-O>0&&g[H-E-O-1][0]==S?g[H-E-O-1][1]+=k.substring(0,$):(g.splice(0,0,[S,k.substring(0,$)]),H++),k=k.substring($),I=I.substring($)),$=this.diff_commonSuffix(k,I),$!==0&&(g[H][1]=k.substring(k.length-$)+g[H][1],k=k.substring(0,k.length-$),I=I.substring(0,I.length-$))),E===0?g.splice(H-O,E+O,[y,k]):O===0?g.splice(H-E,E+O,[w,I]):g.splice(H-E-O,E+O,[w,I],[y,k]),H=H-E-O+(E?1:0)+(O?1:0)+1):H!==0&&g[H-1][0]==S?(g[H-1][1]+=g[H][1],g.splice(H,1)):H++,O=0,E=0,I="",k="";break}g[g.length-1][1]===""&&g.pop();var Y=!1;for(H=1;HH));$++)I=E,k=O;return g.length!=$&&g[$][0]===w?k:k+(H-I)},p.prototype.diff_prettyHtml=function(g){for(var H=[],E=/&/g,O=//g,k=/\n/g,$=0;$");switch(Y){case y:H[$]=''+p1+"";break;case w:H[$]=''+p1+"";break;case S:H[$]=""+p1+"";break}}return H.join("")},p.prototype.diff_text1=function(g){for(var H=[],E=0;Ethis.Match_MaxBits)throw new Error("Pattern too long for this browser.");var O=this.match_alphabet_(H),I=this;function k(b1,j1){var Z1=b1/H.length,K1=Math.abs(E-j1);return I.Match_Distance?Z1+K1/I.Match_Distance:K1?1:Z1}var $=this.Match_Threshold,Y=g.indexOf(H,E);Y!=-1&&($=Math.min(k(0,Y),$),Y=g.lastIndexOf(H,E+H.length),Y!=-1&&($=Math.min(k(0,Y),$)));var r1=1<=r0;U--){var t1=O[g.charAt(U-1)];if(Y1===0?p0[U]=(p0[U+1]<<1|1)&t1:p0[U]=(p0[U+1]<<1|1)&t1|((U1[U+1]|U1[U])<<1|1)|U1[U+1],p0[U]&r1){var y1=k(Y1,U-1);if(y1<=$)if($=y1,Y=U-1,Y>E)r0=Math.max(1,2*E-Y);else break}}if(k(Y1+1,E)>$)break;U1=p0}return Y},p.prototype.match_alphabet_=function(g){for(var H={},E=0;E"u")O=g,I=this.diff_main(O,H,!0),I.length>2&&(this.diff_cleanupSemantic(I),this.diff_cleanupEfficiency(I));else if(g&&typeof g=="object"&&typeof H>"u"&&typeof E>"u")I=g,O=this.diff_text1(I);else if(typeof g=="string"&&H&&typeof H=="object"&&typeof E>"u")O=g,I=H;else if(typeof g=="string"&&typeof H=="string"&&E&&typeof E=="object")O=g,I=E;else throw new Error("Unknown call format to patch_make.");if(I.length===0)return[];for(var k=[],$=new p.patch_obj,Y=0,r1=0,p1=0,C1=O,N1=O,U1=0;U1=2*this.Patch_Margin&&Y&&(this.patch_addContext_($,C1),k.push($),$=new p.patch_obj,Y=0,C1=N1,r1=p1);break}Y1!==y&&(r1+=r0.length),Y1!==w&&(p1+=r0.length)}return Y&&(this.patch_addContext_($,C1),k.push($)),k},p.prototype.patch_deepCopy=function(g){for(var H=[],E=0;Ethis.Match_MaxBits?(r1=this.match_main(H,Y.substring(0,this.Match_MaxBits),$),r1!=-1&&(p1=this.match_main(H,Y.substring(Y.length-this.Match_MaxBits),$+Y.length-this.Match_MaxBits),(p1==-1||r1>=p1)&&(r1=-1))):r1=this.match_main(H,Y,$),r1==-1)I[k]=!1,O-=g[k].length2-g[k].length1;else{I[k]=!0,O=r1-$;var C1;if(p1==-1?C1=H.substring(r1,r1+Y.length):C1=H.substring(r1,p1+this.Match_MaxBits),Y==C1)H=H.substring(0,r1)+this.diff_text2(g[k].diffs)+H.substring(r1+Y.length);else{var N1=this.diff_main(Y,C1,!1);if(Y.length>this.Match_MaxBits&&this.diff_levenshtein(N1)/Y.length>this.Patch_DeleteThreshold)I[k]=!1;else{this.diff_cleanupSemanticLossless(N1);for(var U1=0,Y1,r0=0;r0k[0][1].length){var $=H-k[0][1].length;k[0][1]=E.substring(k[0][1].length)+k[0][1],I.start1-=$,I.start2-=$,I.length1+=$,I.length2+=$}if(I=g[g.length-1],k=I.diffs,k.length==0||k[k.length-1][0]!=S)k.push([S,E]),I.length1+=H,I.length2+=H;else if(H>k[k.length-1][1].length){var $=H-k[k.length-1][1].length;k[k.length-1][1]+=E.substring(0,$),I.length1+=$,I.length2+=$}return E},p.prototype.patch_splitMax=function(g){for(var H=this.Match_MaxBits,E=0;E2*H?(Y.length1+=C1.length,I+=C1.length,r1=!1,Y.diffs.push([p1,C1]),O.diffs.shift()):(C1=C1.substring(0,H-Y.length1-this.Patch_Margin),Y.length1+=C1.length,I+=C1.length,p1===S?(Y.length2+=C1.length,k+=C1.length):r1=!1,Y.diffs.push([p1,C1]),C1==O.diffs[0][1]?O.diffs.shift():O.diffs[0][1]=O.diffs[0][1].substring(C1.length))}$=this.diff_text2(Y.diffs),$=$.substring($.length-this.Patch_Margin);var N1=this.diff_text1(O.diffs).substring(0,this.Patch_Margin);N1!==""&&(Y.length1+=N1.length,Y.length2+=N1.length,Y.diffs.length!==0&&Y.diffs[Y.diffs.length-1][0]===S?Y.diffs[Y.diffs.length-1][1]+=N1:Y.diffs.push([S,N1])),r1||g.splice(++E,0,Y)}}},p.prototype.patch_toText=function(g){for(var H=[],E=0;E"u"&&typeof g>"u")){var $=this.getDeltaType(y,E),Y=$==="node"?y._t==="a"?"array":"object":"";typeof g<"u"?this.nodeBegin(w,g,H,$,Y,O):this.rootBegin(w,$,Y);var r1=void 0;try{r1=this["format_"+$]||this.typeFormattterNotFound(w,$),r1.call(this,w,y,k,g,H,E)}catch(p1){this.typeFormattterErrorFormatter(w,p1,y,k,g,H,E),typeof console<"u"&&console.error&&console.error(p1.stack)}typeof g<"u"?this.nodeEnd(w,g,H,$,Y,O):this.rootEnd(w,$,Y)}}},{key:"formatDeltaChildren",value:function(w,y,S){var g=this;this.forEachDeltaKey(y,S,function(H,E,O,I){g.recurse(w,y[H],S?S[E]:void 0,H,E,O,I)})}},{key:"forEachDeltaKey",value:function(w,y,S){var g=_1(w),H=w._t==="a",E={},O=void 0;if(typeof y<"u")for(O in y)Object.prototype.hasOwnProperty.call(y,O)&&typeof w[O]>"u"&&(!H||typeof w["_"+O]>"u")&&g.push(O);for(O in w)if(Object.prototype.hasOwnProperty.call(w,O)){var I=w[O];z1(I)&&I[2]===3&&(E[I[1].toString()]={key:O,value:y&&y[parseInt(O.substr(1))]},this.includeMoveDestinations!==!1&&typeof y>"u"&&typeof w[I[1]]>"u"&&g.push(I[1].toString()))}H?g.sort(w1):g.sort();for(var k=0,$=g.length;k<$;k++){var Y=g[k];if(!(H&&Y==="_t")){var r1=H?typeof Y=="number"?Y:parseInt(A1(Y),10):Y,p1=k===$-1;S(Y,r1,E[r1],p1)}}}},{key:"getDeltaType",value:function(w,y){if(typeof w>"u")return typeof y<"u"?"movedestination":"unchanged";if(z1(w)){if(w.length===1)return"added";if(w.length===2)return"modified";if(w.length===3&&w[2]===0)return"deleted";if(w.length===3&&w[2]===2)return"textdiff";if(w.length===3&&w[2]===3)return"moved"}else if((typeof w>"u"?"undefined":a(w))==="object")return"node";return"unknown"}},{key:"parseTextDiff",value:function(w){for(var y=[],S=w.split(` -@@ `),g=0,H=S.length;g'+S+"")}},{key:"formatValue",value:function(y,S){y.out("
"+k1(JSON.stringify(S,null,2))+"
")}},{key:"formatTextDiffString",value:function(y,S){var g=this.parseTextDiff(S);y.out('
    ');for(var H=0,E=g.length;H
    '+(''+O.location.line+''+O.location.chr+'
    '));for(var I=O.pieces,k=0,$=I.length;k<$;k++){var Y=I[k];y.out(''+k1(decodeURI(Y.text))+"")}y.out("
    ")}y.out("
")}},{key:"rootBegin",value:function(y,S,g){var H="jsondiffpatch-"+S+(g?" jsondiffpatch-child-node-type-"+g:"");y.out('
')}},{key:"rootEnd",value:function(y){y.out("
"+(y.hasArrows?' - +