diff --git a/backend/omr/dist/gauge-server.js b/backend/omr/dist/gauge-server.js index 7c6d2b6b4396af9ea26e7d68f18f80e2a6a6b04e..7375e8eeff2a5e9f590a1ef376b82728ac4758e7 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-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}`)}(); +"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-09-23T04:29:13.092Z","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.js b/backend/omr/dist/index.js index 332381fca3f28efd605c7fa72e738a20d93c29ee..c1fc4d5172c13c26c7dfd0bbeafd238672f7cfe0 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,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})}})}}; +"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-09-23T04:28:58.168Z","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,[m,d]=[r/2,a/2];n.setTransform(o,l,u,h,m-(o*m+u*d),d-(l*m+h*d)),n.drawImage(s,0,0),n.restore();const f=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/f,h=s.height/2/f,m={x:(t.x+t.staves.phi1)/f-u+e.width/2,y:t.y/f-h+e.height/2};e.systems[i]=ai({page:e,backgroundImage:a.toBufferSync("png"),detection:o,imageSize:l,position:m})}),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.js b/backend/omr/dist/regulator.js index d9fce14eb29f58766b8b77bf05ea38f5743bcb87..0a2cccb8278b465d46672a947f1092feb7c9c83e 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, 7:51:51 PM + * build time: 9/23/2026, 12:28:58 PM * system user: camus * git user name: k.l.lambda * git user email: k.l.lambda@gmail.com @@ -15354,7 +15354,7 @@ const saveEditableMeasures = async (score, measureIndices, saveMeasure, { status }); }; -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;'); +console.info(`%cstarry-omr%c v1.0.0 2026-09-23T04:29:20.956Z`, '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 b62821b655207e8d7adbecd9671181ddd4fbf5e3..3a47eba0dfbfb17379d7a825c183a83a2afb1713 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-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;")})(); +(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-09-23T04:29:16.781Z","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-e5d1e611.js b/dist/assets/DeleteOutlined-7746f7b7.js similarity index 90% rename from dist/assets/DeleteOutlined-e5d1e611.js rename to dist/assets/DeleteOutlined-7746f7b7.js index d138fca7cbde782be484dd3d6844c5af008bda77..81fff752ed6cddf8bd995d3e0c99c102dded0bed 100644 --- a/dist/assets/DeleteOutlined-e5d1e611.js +++ b/dist/assets/DeleteOutlined-7746f7b7.js @@ -1 +1 @@ -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}; +import{r as t,A as a,i as e}from"./umi-7ed0a5d4.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-b3f9ad21.js b/dist/assets/DownloadOutlined-2a2888dc.js similarity index 89% rename from dist/assets/DownloadOutlined-b3f9ad21.js rename to dist/assets/DownloadOutlined-2a2888dc.js index d7297f0c08e31cb0803aa720a2531f513c97f751..e26573fc342b1878555be97bb9d8f17be980d292 100644 --- a/dist/assets/DownloadOutlined-b3f9ad21.js +++ b/dist/assets/DownloadOutlined-2a2888dc.js @@ -1 +1 @@ -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}; +import{r as a,A as n,i as o}from"./umi-7ed0a5d4.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-d468c101.js b/dist/assets/EditOutlined-08f20398.js similarity index 99% rename from dist/assets/EditOutlined-d468c101.js rename to dist/assets/EditOutlined-08f20398.js index ac0ff65130faf6e104aaa07107246feddfd26029..8fb85604adcf746b11d9a06b99fb8b1c4aca3521 100644 --- a/dist/assets/EditOutlined-d468c101.js +++ b/dist/assets/EditOutlined-08f20398.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-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}; +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-7ed0a5d4.js";import{d as Tt,i as zn,K as te,u as Xe,G as Te,c as Vt}from"./TextArea-3c440aa8.js";import{o as Ft}from"./_setToString-406fc146.js";import{t as Un}from"./button-14e56db6.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-1144cdf9.js b/dist/assets/PlaySquareOutlined-390e2d03.js similarity index 94% rename from dist/assets/PlaySquareOutlined-1144cdf9.js rename to dist/assets/PlaySquareOutlined-390e2d03.js index a11b02018f0358921116437aa05b606354acc344..85cf4c3c72ea2261ffa2be19ea06ff0578a99e61 100644 --- a/dist/assets/PlaySquareOutlined-1144cdf9.js +++ b/dist/assets/PlaySquareOutlined-390e2d03.js @@ -1 +1 @@ -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}; +import{r as a,A as c,i as e}from"./umi-7ed0a5d4.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-72da943f.js b/dist/assets/ScoreEncoder-7b0f3cc5.js similarity index 99% rename from dist/assets/ScoreEncoder-72da943f.js rename to dist/assets/ScoreEncoder-7b0f3cc5.js index 65c59d6481db1afc41a4871e23a93b7912cc8be2..e53ea555b14fc319f0251c2589d1451581ae1deb 100644 --- a/dist/assets/ScoreEncoder-72da943f.js +++ b/dist/assets/ScoreEncoder-7b0f3cc5.js @@ -1,4 +1,4 @@ -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={};/** +import{r as nu,ao as iu,g as su,k as R,j as T,R as lu}from"./umi-7ed0a5d4.js";import"./parser-5b49a957.js";import{W as ou,a as I,b as uu,E as un,A as We}from"./index-d1ffe97d.js";const Ol=ou/4,au=40;var Il={exports:{}},nr={},Cl={exports:{}},F={};/** * @license React * scheduler-unstable_mock.production.min.js * diff --git a/dist/assets/Table-d40746fd.js b/dist/assets/Table-05d95f5e.js similarity index 99% rename from dist/assets/Table-d40746fd.js rename to dist/assets/Table-05d95f5e.js index 0bd9cc8bf6ca7e0c8cb6bc22411502b98918527d..13cd0e18a3125bcd3359c770edc07d8717327565 100644 --- a/dist/assets/Table-d40746fd.js +++ b/dist/assets/Table-05d95f5e.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-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. +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-7ed0a5d4.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-3c440aa8.js";import{i as wp,a as Pp,T as pa,C as $f}from"./index-59f30bf4.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-5bdcac60.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-ca3ec7c7.js";import{t as ir,u as el,B as Dn}from"./button-14e56db6.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-406fc146.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-45a3e760.js";import{S as kr,a as Kp,d as Vp}from"./index-0c3a3036.js";import{_ as No,D as To,a as lu,O as zp,P as Bp,M as Hp}from"./index-2cad0e26.js";import{D as Zf}from"./DeleteOutlined-7746f7b7.js";import{C as Wp,P as Qf,a as Up}from"./progress-679e273a.js";import{A as Yp}from"./index-32c308aa.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-957e9e21.js b/dist/assets/Tags-a47086b0.js similarity index 92% rename from dist/assets/Tags-957e9e21.js rename to dist/assets/Tags-a47086b0.js index 3af67bee731d094fe9628066178b8cfbb6998840..590d68a4ec01587db58b178372b9a44ed7351740 100644 --- a/dist/assets/Tags-957e9e21.js +++ b/dist/assets/Tags-a47086b0.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-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}; +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-7ed0a5d4.js";import{t as U,B as w}from"./button-14e56db6.js";import{i as b,o as X}from"./_setToString-406fc146.js";import{a as z,D as F}from"./index-45a3e760.js";import{T as R}from"./useDebounce-5bdcac60.js";import{r as T}from"./index-a37777f5.js";import{i as Q,n as I}from"./util-ca3ec7c7.js";import{u as W}from"./useAsyncFn-7a0c1c0f.js";import{E as Y}from"./EditOutlined-08f20398.js";import{a as Z}from"./progress-679e273a.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-ec8ab387.js b/dist/assets/TextArea-3c440aa8.js similarity index 99% rename from dist/assets/TextArea-ec8ab387.js rename to dist/assets/TextArea-3c440aa8.js index baea08a09e81db4b460f30e63c80f9d56835ded8..7c2462896c6faee1964bed09f3f7ae6226fac016 100644 --- a/dist/assets/TextArea-ec8ab387.js +++ b/dist/assets/TextArea-3c440aa8.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-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 +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-7ed0a5d4.js";import{o as qt,t as xt,i as Ui,A as Bi,c as Lt}from"./_setToString-406fc146.js";import{t as Wn,C as qi,u as Ki,N as ar}from"./button-14e56db6.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-31d12a4f.js b/dist/assets/UploadOutlined-60bf373d.js similarity index 98% rename from dist/assets/UploadOutlined-31d12a4f.js rename to dist/assets/UploadOutlined-60bf373d.js index b7c578096adf98bbdf8990dce8154f9986f5d2ac..0737c01092bd8608c3757cabd42c7fd50c4b465b 100644 --- a/dist/assets/UploadOutlined-31d12a4f.js +++ b/dist/assets/UploadOutlined-60bf373d.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-a12c8253.js";import{p as ft,E as vt,T as mt,k as ht,b as gt,u as wt}from"./TextArea-ec8ab387.js";import{B as qe}from"./button-f56a19a0.js";import{c as We,i as Ke}from"./_setToString-ca5ad23e.js";import{D as yt}from"./DeleteOutlined-e5d1e611.js";import{D as bt}from"./DownloadOutlined-b3f9ad21.js";import{P as It}from"./progress-81ce73da.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-7ed0a5d4.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-f56a19a0.js b/dist/assets/button-14e56db6.js similarity index 98% rename from dist/assets/button-f56a19a0.js rename to dist/assets/button-14e56db6.js index 91264e4bb97946372cf9ad69c62ad778391b7f86..99a2d6a89fba5ab106337a18dc5e951de80e3a32 100644 --- a/dist/assets/button-f56a19a0.js +++ b/dist/assets/button-14e56db6.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-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(` +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-7ed0a5d4.js";import{c as be,t as q,o as Qe,A as Xe}from"./_setToString-406fc146.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-7ed0a5d4.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-822f711f.js b/dist/assets/gauge-34ee29b8.js similarity index 91% rename from dist/assets/gauge-822f711f.js rename to dist/assets/gauge-34ee29b8.js index 3e4660ae254361c91f02aa4866c2096c766b0597..303dbba0a2be7112f5fcd4f769862c2038e5f240 100644 --- a/dist/assets/gauge-822f711f.js +++ b/dist/assets/gauge-34ee29b8.js @@ -1 +1 @@ -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}; +import{r as e,j as r}from"./umi-7ed0a5d4.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-40bfaf7c.js b/dist/assets/index-0c3a3036.js similarity index 96% rename from dist/assets/index-40bfaf7c.js rename to dist/assets/index-0c3a3036.js index 599513dc12ff9e4fa782e3845a54848d9409dea0..cd4449360741e03f404cef694f895f111b1b8b00 100644 --- a/dist/assets/index-40bfaf7c.js +++ b/dist/assets/index-0c3a3036.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-a12c8253.js";import{n as A,t as X,o as q,i as k,c as w}from"./_setToString-ca5ad23e.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);if&&(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-7ed0a5d4.js";import{q as us,a as Lt,v as hs}from"./parser-5b49a957.js";import{f as Qi,D as ps,F as ti,z as gs,B as fs}from"./index-d1ffe97d.js";import{B as $t}from"./button-14e56db6.js";import{o as ms,b as vs,i as Cs,n as ys,I as bs}from"./util-ca3ec7c7.js";import{a as Rn}from"./index-45a3e760.js";import{C as Is,S as ni}from"./TextArea-3c440aa8.js";import{S as As}from"./index-0c3a3036.js";import{t as ws,w as xs,u as Ss,P as Es,x as ks,I as ii}from"./tiny-invariant-59348e05.js";import{f as Rs,c as Ts}from"./index-e3822a6f.js";import{c as Ls,d as qi,g as $s}from"./confirm-ffbe4ca4.js";import{A as Bs,_ as er,u as Hr,r as tr}from"./index-a37777f5.js";import{S as Ds}from"./schedulePool-cc4538c2.js";import{a as Ns}from"./progress-679e273a.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-a2a53045.js b/dist/assets/index-2cad0e26.js similarity index 98% rename from dist/assets/index-a2a53045.js rename to dist/assets/index-2cad0e26.js index 3c87fb1e1d0247cc800638be04ee61c46c88ab8e..11935dac1bdd35460a51e58d50c06e1cbcec3fa4 100644 --- a/dist/assets/index-a2a53045.js +++ b/dist/assets/index-2cad0e26.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-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}; +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-7ed0a5d4.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-3c440aa8.js";import{k as ze,f as $t,D as Ft}from"./util-ca3ec7c7.js";import{t as It,u as jt,B as q,N as Le,c as he}from"./button-14e56db6.js";import{c as ee,i as ce,o as Be,t as Mt}from"./_setToString-406fc146.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-08f20398.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-868eaf8d.js b/dist/assets/index-32c308aa.js similarity index 98% rename from dist/assets/index-868eaf8d.js rename to dist/assets/index-32c308aa.js index 5a731c15967e38a1e8dd05a72889805290f8fb6e..e196026f64b970854cff96cd3b6a2890f4bd282b 100644 --- a/dist/assets/index-868eaf8d.js +++ b/dist/assets/index-32c308aa.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-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}; +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-7ed0a5d4.js";import{z as ue}from"./_setToString-406fc146.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-bec4ae4d.js b/dist/assets/index-3ab852f8.js similarity index 96% rename from dist/assets/index-bec4ae4d.js rename to dist/assets/index-3ab852f8.js index 1046d833da5cd8b24a39f58c8048e198a5a7af91..e466d8b3d9c60477bd2fda09b0bc0018c559683f 100644 --- a/dist/assets/index-bec4ae4d.js +++ b/dist/assets/index-3ab852f8.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-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}; +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-7ed0a5d4.js";import{p as Ee,a as K,v as we,x as Pe}from"./parser-5b49a957.js";import{S as Se}from"./scheduler-a7fa9c3c.js";import{S as je}from"./schedulePool-cc4538c2.js";import{A as Oe}from"./index-32c308aa.js";import{B as de}from"./button-14e56db6.js";import{o as Q}from"./_setToString-406fc146.js";import{T as Te,a as $e}from"./index-59f30bf4.js";import{S as ve,C as ze}from"./TextArea-3c440aa8.js";import{S as Me}from"./index-0c3a3036.js";import{I as Le,U as he,a as _e}from"./UploadOutlined-60bf373d.js";import{J as Re}from"./jszip.min-b603d4cc.js";import{S as Be}from"./index-f5679f1d.js";import{S as Ie}from"./index-d87a95f9.js";import{a as Ae,P as Fe}from"./PlaySquareOutlined-390e2d03.js";import"./EditOutlined-08f20398.js";import"./progress-679e273a.js";import"./DeleteOutlined-7746f7b7.js";import"./DownloadOutlined-2a2888dc.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-daf1cf6b.js b/dist/assets/index-3e5fb14f.js similarity index 79% rename from dist/assets/index-daf1cf6b.js rename to dist/assets/index-3e5fb14f.js index 378a541af36e3bc076d268662d3e3cdc7fea92a9..7080e70ab8dfd834c88b95c41572e8357015ac69 100644 --- a/dist/assets/index-daf1cf6b.js +++ b/dist/assets/index-3e5fb14f.js @@ -1,12 +1,12 @@ -import{r as j,A as Ne,i as N0,k as gt,g as Vt,m as ve,l as h4,j as C,c as B1,p as Lt,n as $s,o as Bs,q as Us,s as Ws,t as Je,v as ft,x as qs,f as Ks,L as Z4,y as Gs}from"./umi-a12c8253.js";import{g as Ys,S as tt,b as Xs,a as _5,v as Qs}from"./parser-b66b074b.js";import{A as Zs,a as Js,u as ec,b as tc,c as rc,d as nc,s as ce,E as ac,S as ic,P as sc,e as cc,f as oc,F as lc}from"./index.less_used_.module-0a64bdd1.js";import{W as $5,C as h2,b as Se,c as na,E as y5,d as Re,m as aa,a as R1,e as ia,f as sa,g as hc,G as uc,h as fc,i as vc,j as dc,r as l5,s as h5,k as pc,l as mc,n as T0,o as J4,S as V2,p as en,T as gc,P as zc,q as yc,t as tn,L as Mc,u as wc}from"./index-43517c6d.js";import{S as bc}from"./scheduler-a7fa9c3c.js";import{S as Hc}from"./schedulePool-cc4538c2.js";import{M as a2,Q as ca,D as zr,P as Cc,q as Vc,L as Lc}from"./index-a2a53045.js";import{S as Sc}from"./ScoreEncoder-72da943f.js";import{u as rn,S as Ec,P as _c,A as nn}from"./Tags-957e9e21.js";import{G as Ac}from"./gaugeRendererGL-41abf4c6.js";import{t as oa,c as l0,p as u4,m as vt,i as an,n as U2,b as xc,e as Nc,s as Oc,a as Tc,d as kc,u as Ic}from"./index-ead1f686.js";import{p as Pc,r as fe,u as H5,a as Rc,e as f4,s as Dc,b as L2,g as S2,c as la,d as jc,f as Fc,h as $c,i as Bc,j as Uc,k as ha,l as Wc,m as qc,o as sn,n as W2,q as Kc,v as Gc,w as Yc,x as Xc}from"./index-5722ce0d.js";import{_ as R5,a as k0,b as a0,i as Qc,r as rt,A as Zc}from"./confirm-57060cff.js";import{u as G5,a as ua,b as v4,c as d4,d as fa,e as E2,f as p4,g as m4,h as va,i as g4,j as z4,k as y4,l as da,P as pa,m as ma,n as ga,o as za,p as Jc,q as eo,r as to,s as q2}from"./tiny-invariant-28d484ad.js";import{B as i0}from"./button-f56a19a0.js";import{D as yr,S as Mr}from"./index-c353c509.js";import{I as cn,R as ro,u as ya,D as nt,S as no,F as te,a as me,b as ao}from"./useDebounce-b5b4777f.js";import{P as wr,a as io}from"./progress-81ce73da.js";import{S as E0,T as br,b as so,C as Ma}from"./TextArea-ec8ab387.js";import{w as co,A as wa}from"./index-868eaf8d.js";import{a as oo,u as ba}from"./useAsyncFn-b4ac32aa.js";import{u as lo,a as on,V as Ha,b as ho,_ as M4,c as uo,M as fo,R as vo}from"./index-0c92fedd.js";import{S as Ca}from"./index-02e1374a.js";import{o as w4,b as b4,i as po,I as d5,R as _2,C as Fe,a as Va,L as ln,E as mo}from"./util-590d1471.js";import{p as go}from"./processCompressedAESFile-04edd242.js";import{S as Hr,d as zo}from"./index-40bfaf7c.js";import{d as lt}from"./download-ef7cdf5d.js";import{u as yo}from"./useIntersection-4e19264c.js";import{S as Mo}from"./index-1d8a15fd.js";import{P as wo,a as bo}from"./PlaySquareOutlined-1144cdf9.js";import{D as Ho}from"./DownloadOutlined-b3f9ad21.js";import{E as Co}from"./EditOutlined-d468c101.js";import"./_setToString-ca5ad23e.js";import"./jszip.min-f65a05ae.js";var Vo={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"defs",attrs:{},children:[{tag:"style",attrs:{}}]},{tag:"path",attrs:{d:"M899.1 869.6l-53-305.6H864c14.4 0 26-11.6 26-26V346c0-14.4-11.6-26-26-26H618V138c0-14.4-11.6-26-26-26H432c-14.4 0-26 11.6-26 26v182H160c-14.4 0-26 11.6-26 26v192c0 14.4 11.6 26 26 26h17.9l-53 305.6a25.95 25.95 0 0025.6 30.4h723c1.5 0 3-.1 4.4-.4a25.88 25.88 0 0021.2-30zM204 390h272V182h72v208h272v104H204V390zm468 440V674c0-4.4-3.6-8-8-8h-48c-4.4 0-8 3.6-8 8v156H416V674c0-4.4-3.6-8-8-8h-48c-4.4 0-8 3.6-8 8v156H202.8l45.1-260H776l45.1 260H672z"}}]},name:"clear",theme:"outlined"};const Lo=Vo;var So=function(t,r){return j.createElement(Ne,N0(N0({},t),{},{ref:r,icon:Lo}))},Eo=j.forwardRef(So);const Cr=Eo;var _o={icon:{tag:"svg",attrs:{"fill-rule":"evenodd",viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M880 912H144c-17.7 0-32-14.3-32-32V144c0-17.7 14.3-32 32-32h360c4.4 0 8 3.6 8 8v56c0 4.4-3.6 8-8 8H184v656h656V520c0-4.4 3.6-8 8-8h56c4.4 0 8 3.6 8 8v360c0 17.7-14.3 32-32 32zM770.87 199.13l-52.2-52.2a8.01 8.01 0 014.7-13.6l179.4-21c5.1-.6 9.5 3.7 8.9 8.9l-21 179.4c-.8 6.6-8.9 9.4-13.6 4.7l-52.4-52.4-256.2 256.2a8.03 8.03 0 01-11.3 0l-42.4-42.4a8.03 8.03 0 010-11.3l256.1-256.3z"}}]},name:"export",theme:"outlined"};const Ao=_o;var xo=function(t,r){return j.createElement(Ne,N0(N0({},t),{},{ref:r,icon:Ao}))},No=j.forwardRef(xo);const Oo=No;var To={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M880.1 154H143.9c-24.5 0-39.8 26.7-27.5 48L349 607.4V838c0 17.7 14.2 32 31.8 32h262.4c17.6 0 31.8-14.3 31.8-32V607.4L907.7 202c12.2-21.3-3.1-48-27.6-48zM603.4 798H420.6V650h182.9v148zm9.6-226.6l-8.4 14.6H419.3l-8.4-14.6L334.4 438h355.2L613 571.4zM726.3 374H297.7l-85-148h598.6l-85 148z"}}]},name:"funnel-plot",theme:"outlined"};const ko=To;var Io=function(t,r){return j.createElement(Ne,N0(N0({},t),{},{ref:r,icon:ko}))},Po=j.forwardRef(Io);const Ro=Po;var Do={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M928 392c8.8 0 16-7.2 16-16V192c0-8.8-7.2-16-16-16H744c-8.8 0-16 7.2-16 16v56H296v-56c0-8.8-7.2-16-16-16H96c-8.8 0-16 7.2-16 16v184c0 8.8 7.2 16 16 16h56v240H96c-8.8 0-16 7.2-16 16v184c0 8.8 7.2 16 16 16h184c8.8 0 16-7.2 16-16v-56h432v56c0 8.8 7.2 16 16 16h184c8.8 0 16-7.2 16-16V648c0-8.8-7.2-16-16-16h-56V392h56zM792 240h88v88h-88v-88zm-648 88v-88h88v88h-88zm88 456h-88v-88h88v88zm648-88v88h-88v-88h88zm-80-64h-56c-8.8 0-16 7.2-16 16v56H296v-56c0-8.8-7.2-16-16-16h-56V392h56c8.8 0 16-7.2 16-16v-56h432v56c0 8.8 7.2 16 16 16h56v240z"}}]},name:"gateway",theme:"outlined"};const jo=Do;var Fo=function(t,r){return j.createElement(Ne,N0(N0({},t),{},{ref:r,icon:jo}))},$o=j.forwardRef(Fo);const La=$o;var Bo={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M696 480H328c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8h368c4.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:"minus-circle",theme:"outlined"};const Uo=Bo;var Wo=function(t,r){return j.createElement(Ne,N0(N0({},t),{},{ref:r,icon:Uo}))},qo=j.forwardRef(Wo);const hn=qo;var Ko={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"defs",attrs:{},children:[{tag:"style",attrs:{}}]},{tag:"path",attrs:{d:"M843.5 737.4c-12.4-75.2-79.2-129.1-155.3-125.4S550.9 676 546 752c-153.5-4.8-208-40.7-199.1-113.7 3.3-27.3 19.8-41.9 50.1-49 18.4-4.3 38.8-4.9 57.3-3.2 1.7.2 3.5.3 5.2.5 11.3 2.7 22.8 5 34.3 6.8 34.1 5.6 68.8 8.4 101.8 6.6 92.8-5 156-45.9 159.2-132.7 3.1-84.1-54.7-143.7-147.9-183.6-29.9-12.8-61.6-22.7-93.3-30.2-14.3-3.4-26.3-5.7-35.2-7.2-7.9-75.9-71.5-133.8-147.8-134.4-76.3-.6-140.9 56.1-150.1 131.9s40 146.3 114.2 163.9c74.2 17.6 149.9-23.3 175.7-95.1 9.4 1.7 18.7 3.6 28 5.8 28.2 6.6 56.4 15.4 82.4 26.6 70.7 30.2 109.3 70.1 107.5 119.9-1.6 44.6-33.6 65.2-96.2 68.6-27.5 1.5-57.6-.9-87.3-5.8-8.3-1.4-15.9-2.8-22.6-4.3-3.9-.8-6.6-1.5-7.8-1.8l-3.1-.6c-2.2-.3-5.9-.8-10.7-1.3-25-2.3-52.1-1.5-78.5 4.6-55.2 12.9-93.9 47.2-101.1 105.8-15.7 126.2 78.6 184.7 276 188.9 29.1 70.4 106.4 107.9 179.6 87 73.3-20.9 119.3-93.4 106.9-168.6zM329.1 345.2a83.3 83.3 0 11.01-166.61 83.3 83.3 0 01-.01 166.61zM695.6 845a83.3 83.3 0 11.01-166.61A83.3 83.3 0 01695.6 845z"}}]},name:"node-index",theme:"outlined"};const Go=Ko;var Yo=function(t,r){return j.createElement(Ne,N0(N0({},t),{},{ref:r,icon:Go}))},Xo=j.forwardRef(Yo);const un=Xo;var Qo={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M864 736c0-111.6-65.4-208-160-252.9V317.3c0-15.1-5.3-29.7-15.1-41.2L536.5 95.4C530.1 87.8 521 84 512 84s-18.1 3.8-24.5 11.4L335.1 276.1a63.97 63.97 0 00-15.1 41.2v165.8C225.4 528 160 624.4 160 736h156.5c-2.3 7.2-3.5 15-3.5 23.8 0 22.1 7.6 43.7 21.4 60.8a97.2 97.2 0 0043.1 30.6c23.1 54 75.6 88.8 134.5 88.8 29.1 0 57.3-8.6 81.4-24.8 23.6-15.8 41.9-37.9 53-64a97 97 0 0043.1-30.5 97.52 97.52 0 0021.4-60.8c0-8.4-1.1-16.4-3.1-23.8H864zM762.3 621.4c9.4 14.6 17 30.3 22.5 46.6H700V558.7a211.6 211.6 0 0162.3 62.7zM388 483.1V318.8l124-147 124 147V668H388V483.1zM239.2 668c5.5-16.3 13.1-32 22.5-46.6 16.3-25.2 37.5-46.5 62.3-62.7V668h-84.8zm388.9 116.2c-5.2 3-11.2 4.2-17.1 3.4l-19.5-2.4-2.8 19.4c-5.4 37.9-38.4 66.5-76.7 66.5-38.3 0-71.3-28.6-76.7-66.5l-2.8-19.5-19.5 2.5a27.7 27.7 0 01-17.1-3.5c-8.7-5-14.1-14.3-14.1-24.4 0-10.6 5.9-19.4 14.6-23.8h231.3c8.8 4.5 14.6 13.3 14.6 23.8-.1 10.2-5.5 19.6-14.2 24.5zM464 400a48 48 0 1096 0 48 48 0 10-96 0z"}}]},name:"rocket",theme:"outlined"};const Zo=Qo;var Jo=function(t,r){return j.createElement(Ne,N0(N0({},t),{},{ref:r,icon:Zo}))},e9=j.forwardRef(Jo);const Sa=e9;var t9={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M567.1 512l318.5-319.3c5-5 1.5-13.7-5.6-13.7h-90.5c-2.1 0-4.2.8-5.6 2.3l-273.3 274-90.2-90.5c12.5-22.1 19.7-47.6 19.7-74.8 0-83.9-68.1-152-152-152s-152 68.1-152 152 68.1 152 152 152c27.7 0 53.6-7.4 75.9-20.3l90 90.3-90.1 90.3A151.04 151.04 0 00288 582c-83.9 0-152 68.1-152 152s68.1 152 152 152 152-68.1 152-152c0-27.2-7.2-52.7-19.7-74.8l90.2-90.5 273.3 274c1.5 1.5 3.5 2.3 5.6 2.3H880c7.1 0 10.7-8.6 5.6-13.7L567.1 512zM288 370c-44.1 0-80-35.9-80-80s35.9-80 80-80 80 35.9 80 80-35.9 80-80 80zm0 444c-44.1 0-80-35.9-80-80s35.9-80 80-80 80 35.9 80 80-35.9 80-80 80z"}}]},name:"scissor",theme:"outlined"};const r9=t9;var n9=function(t,r){return j.createElement(Ne,N0(N0({},t),{},{ref:r,icon:r9}))},a9=j.forwardRef(n9);const i9=a9;var s9={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M839.6 433.8L749 150.5a9.24 9.24 0 00-8.9-6.5h-77.4c-4.1 0-7.6 2.6-8.9 6.5l-91.3 283.3c-.3.9-.5 1.9-.5 2.9 0 5.1 4.2 9.3 9.3 9.3h56.4c4.2 0 7.8-2.8 9-6.8l17.5-61.6h89l17.3 61.5c1.1 4 4.8 6.8 9 6.8h61.2c1 0 1.9-.1 2.8-.4 2.4-.8 4.3-2.4 5.5-4.6 1.1-2.2 1.3-4.7.6-7.1zM663.3 325.5l32.8-116.9h6.3l32.1 116.9h-71.2zm143.5 492.9H677.2v-.4l132.6-188.9c1.1-1.6 1.7-3.4 1.7-5.4v-36.4c0-5.1-4.2-9.3-9.3-9.3h-204c-5.1 0-9.3 4.2-9.3 9.3v43c0 5.1 4.2 9.3 9.3 9.3h122.6v.4L587.7 828.9a9.35 9.35 0 00-1.7 5.4v36.4c0 5.1 4.2 9.3 9.3 9.3h211.4c5.1 0 9.3-4.2 9.3-9.3v-43a9.2 9.2 0 00-9.2-9.3zM416 702h-76V172c0-4.4-3.6-8-8-8h-56c-4.4 0-8 3.6-8 8v530h-76c-6.7 0-10.5 7.8-6.3 13l112 141.9a8 8 0 0012.6 0l112-141.9c4.1-5.2.4-13-6.3-13z"}}]},name:"sort-ascending",theme:"outlined"};const c9=s9;var o9=function(t,r){return j.createElement(Ne,N0(N0({},t),{},{ref:r,icon:c9}))},l9=j.forwardRef(o9);const h9=l9;var u9={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M168 504.2c1-43.7 10-86.1 26.9-126 17.3-41 42.1-77.7 73.7-109.4S337 212.3 378 195c42.4-17.9 87.4-27 133.9-27s91.5 9.1 133.8 27A341.5 341.5 0 01755 268.8c9.9 9.9 19.2 20.4 27.8 31.4l-60.2 47a8 8 0 003 14.1l175.7 43c5 1.2 9.9-2.6 9.9-7.7l.8-180.9c0-6.7-7.7-10.5-12.9-6.3l-56.4 44.1C765.8 155.1 646.2 92 511.8 92 282.7 92 96.3 275.6 92 503.8a8 8 0 008 8.2h60c4.4 0 7.9-3.5 8-7.8zm756 7.8h-60c-4.4 0-7.9 3.5-8 7.8-1 43.7-10 86.1-26.9 126-17.3 41-42.1 77.8-73.7 109.4A342.45 342.45 0 01512.1 856a342.24 342.24 0 01-243.2-100.8c-9.9-9.9-19.2-20.4-27.8-31.4l60.2-47a8 8 0 00-3-14.1l-175.7-43c-5-1.2-9.9 2.6-9.9 7.7l-.7 181c0 6.7 7.7 10.5 12.9 6.3l56.4-44.1C258.2 868.9 377.8 932 512.2 932c229.2 0 415.5-183.7 419.8-411.8a8 8 0 00-8-8.2z"}}]},name:"sync",theme:"outlined"};const f9=u9;var v9=function(t,r){return j.createElement(Ne,N0(N0({},t),{},{ref:r,icon:f9}))},d9=j.forwardRef(v9);const fn=d9;var p9=function(e,t){var r=lo();j.useEffect(function(){if(!r)return e()},t)};const m9=p9;var g9=function(e){e===void 0&&(e={});var t=j.useState(e),r=t[0],n=t[1],a=j.useCallback(function(i){n(function(s){return Object.assign({},s,i instanceof Function?i(s):i)})},[]);return[r,a]};const z9=g9;var y9=function(e,t){e===void 0&&(e=!0);var r=j.useCallback(function(n){var a=typeof e=="function"?e():!0;if(a)return n.preventDefault(),t&&(n.returnValue=t),t},[e,t]);j.useEffect(function(){if(e)return w4(window,"beforeunload",r),function(){return b4(window,"beforeunload",r)}},[e,r])};const M9=y9;var w9=function(){var e=oo(),t=z9({value:void 0,error:void 0,noUserInteraction:!0}),r=t[0],n=t[1],a=j.useCallback(function(i){if(e()){var s,c;try{if(typeof i!="string"&&typeof i!="number"){var h=new Error("Cannot copy typeof "+typeof i+" to clipboard, must be a string");n({value:i,error:h,noUserInteraction:!0});return}else if(i===""){var h=new Error("Cannot copy empty string to clipboard.");n({value:i,error:h,noUserInteraction:!0});return}c=i.toString(),s=co(c),n({value:c,error:void 0,noUserInteraction:s})}catch(u){n({value:c,error:u,noUserInteraction:s})}}},[]);return[r,a]};const b9=w9;var H9=function(e){var t=j.useState([!1,null]),r=t[0],n=t[1];return on(e,function(a){return n([!0,a])},{event:"keydown"},[r]),on(e,function(a){return n([!1,a])},{event:"keyup"},[r]),r};const M5=H9;var C9=function(e,t,r,n){n===void 0&&(n=M5);var a=n(e),i=a[0],s=a[1];m9(function(){!i&&r?r(s):i&&t&&t(s)},[i])};const vn=C9;var V9=function(e,t){j.useEffect(function(){return e&&e(),function(){t&&t()}},[])};const L9=V9;function Vr(e){if(e){if(e.tagName==="BODY")return e;if(e.tagName==="IFRAME"){var t=e.contentDocument;return t?t.body:null}else if(!e.offsetParent)return null}else return null;return Vr(e.offsetParent)}function dn(e){var t=e||window.event;return t.touches.length>1?!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&&(b4(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(){b4(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]=L}if(w&&w.name){if(L=w,L.processor===this)return L;this.pipes[L.name]=L}return L.processor=this,L}},{key:"process",value:function(w,y){var L=w;L.options=this.options();for(var m=y||w.pipe||"default",H=void 0,S=void 0;m;)typeof L.nextAfterChildren<"u"&&(L.next=L.nextAfterChildren,L.nextAfterChildren=null),typeof m=="string"&&(m=this.pipe(m)),m.process(L),S=L,H=m,m=null,L&&L.next&&(L=L.next,m=S.nextPipe||L.pipe||H);return L.hasResult?L.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,L=this.filters.length,m=w,H=0;H"u"?"undefined":a(m))==="object"&&m.exiting){m.exiting=!1;break}}!m.next&&this.resultCheck&&this.resultCheck(m)}},{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(g);if(B instanceof Date)return new Date(B.getTime());if(B instanceof RegExp)return b(B);var p={};for(var w in B)Object.prototype.hasOwnProperty.call(B,w)&&(p[w]=g(B[w]));return p}var E=function(B){h(p,B);function p(w,y){i(this,p);var L=u(this,(p.__proto__||Object.getPrototypeOf(p)).call(this));return L.left=w,L.right=y,L.pipe="diff",L}return s(p,[{key:"setResult",value:function(y){if(this.options.cloneDiffValues&&(typeof y>"u"?"undefined":a(y))==="object"){var L=typeof this.options.cloneDiffValues=="function"?this.options.cloneDiffValues:g;a(y[0])==="object"&&(y[0]=L(y[0])),a(y[1])==="object"&&(y[1]=L(y[1]))}return M.prototype.setResult.apply(this,arguments)}}]),p}(M),z=function(B){h(p,B);function p(w,y){i(this,p);var L=u(this,(p.__proto__||Object.getPrototypeOf(p)).call(this));return L.left=w,L.delta=y,L.pipe="patch",L}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),V=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=V(p.left)),p.rightType==="object"&&(p.rightIsArray=V(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 x=function(p){if(typeof p.delta>"u"){p.setResult(p.left).exit();return}if(p.nested=!V(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()}};x.filterName="trivial";var _=function(p){if(typeof p.delta>"u"){p.setResult(p.delta).exit();return}if(p.nested=!V(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()}};_.filterName="trivial";function k(B){if(!(!B||!B.children)){for(var p=B.children.length,w=void 0,y=B.result,L=0;L"u")&&(y=y||{},y[w.childName]=w.result);y&&B.leftIsArray&&(y._t="a"),B.setResult(y).exit()}}k.filterName="collectChildren";function U(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 E(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 E(void 0,B.right[p]),B.push(w,p)));if(!B.children||B.children.length===0){B.setResult(void 0).exit();return}B.exit()}}U.filterName="objects";var q=function(p){if(p.nested&&!p.delta._t){var w=void 0,y=void 0;for(w in p.delta)y=new z(p.left[w],p.delta[w]),p.push(y,w);p.exit()}};q.filterName="objects";var c1=function(p){if(!(!p||!p.children)&&!p.delta._t){for(var w=p.children.length,y=void 0,L=0;LI?--H:--m}}return S},J=function(p,w,y,L){var m=L||{},H=R(p,w,y||D,m),S=Z(H,p,w,m);return typeof p=="string"&&typeof w=="string"&&(S.sequence=S.sequence.join("")),S},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(m))!=="object"||(typeof H>"u"?"undefined":a(H))!=="object")return!1;var S=L.objectHash;if(!S)return L.matchByPosition&&w===y;var O=void 0,P=void 0;return typeof w=="number"?(L.hashCache1=L.hashCache1||[],O=L.hashCache1[w],typeof O>"u"&&(L.hashCache1[w]=O=S(m,w))):O=S(m),typeof O>"u"||(typeof y=="number"?(L.hashCache2=L.hashCache2||[],P=L.hashCache2[y],typeof P>"u"&&(L.hashCache2[y]=P=S(H,y))):P=S(H),typeof P>"u")?!1:O===P}var C1=function(p){if(p.leftIsArray){var w={objectHash:p.options&&p.options.objectHash,matchByPosition:p.options&&p.options.matchByPosition},y=0,L=0,m=void 0,H=void 0,S=void 0,O=p.left,P=p.right,I=O.length,$=P.length,Y=void 0;for(I>0&&$>0&&!w.objectHash&&typeof w.matchByPosition!="boolean"&&(w.matchByPosition=!K(O,P,I,$));y0){for(var t1=0;t1=0;w--){y=H[w];var P=L["_"+y],I=m.splice(y,1)[0];P[2]===X&&S.push({index:P[1],value:I})}S=S.sort(s1.numericallyBy("index"));var $=S.length;for(w=0;w<$;w++){var Y=S[w];m.splice(Y.index,0,Y.value)}var r1=O.length,p1=void 0;if(r1>0)for(w=0;wL?L++:S>=L&&O"u"&&(m=m1(B.delta,w.childName,w.result)),y[m]!==w.result&&(y[m]=w.result)}B.setResult(y).exit()}}w1.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,L=0;p.prototype.diff_main=function(m,H,S,O){typeof O>"u"&&(this.Diff_Timeout<=0?O=Number.MAX_VALUE:O=new Date().getTime()+this.Diff_Timeout*1e3);var P=O;if(m==null||H==null)throw new Error("Null input. (diff_main)");if(m==H)return m?[[L,m]]:[];typeof S>"u"&&(S=!0);var I=S,$=this.diff_commonPrefix(m,H),Y=m.substring(0,$);m=m.substring($),H=H.substring($),$=this.diff_commonSuffix(m,H);var r1=m.substring(m.length-$);m=m.substring(0,m.length-$),H=H.substring(0,H.length-$);var p1=this.diff_compute_(m,H,I,P);return Y&&p1.unshift([L,Y]),r1&&p1.push([L,r1]),this.diff_cleanupMerge(p1),p1},p.prototype.diff_compute_=function(m,H,S,O){var P;if(!m)return[[y,H]];if(!H)return[[w,m]];var I=m.length>H.length?m:H,$=m.length>H.length?H:m,Y=I.indexOf($);if(Y!=-1)return P=[[y,I.substring(0,Y)],[L,$],[y,I.substring(Y+$.length)]],m.length>H.length&&(P[0][0]=P[2][0]=w),P;if($.length==1)return[[w,m],[y,H]];var r1=this.diff_halfMatch_(m,H);if(r1){var p1=r1[0],H1=r1[1],N1=r1[2],U1=r1[3],Y1=r1[4],r0=this.diff_main(p1,N1,S,O),u0=this.diff_main(H1,U1,S,O);return r0.concat([[L,Y1]],u0)}return S&&m.length>100&&H.length>100?this.diff_lineMode_(m,H,O):this.diff_bisect_(m,H,O)},p.prototype.diff_lineMode_=function(m,H,S){var O=this.diff_linesToChars_(m,H);m=O.chars1,H=O.chars2;var P=O.lineArray,I=this.diff_main(m,H,!1,S);this.diff_charsToLines_(I,P),this.diff_cleanupSemantic(I),I.push([L,""]);for(var $=0,Y=0,r1=0,p1="",H1="";$=1&&r1>=1){I.splice($-Y-r1,Y+r1),$=$-Y-r1;for(var O=this.diff_main(p1,H1,!1,S),N1=O.length-1;N1>=0;N1--)I.splice($,0,O[N1]);$=$+O.length}r1=0,Y=0,p1="",H1="";break}$++}return I.pop(),I},p.prototype.diff_bisect_=function(m,H,S){for(var O=m.length,P=H.length,I=Math.ceil((O+P)/2),$=I,Y=2*I,r1=new Array(Y),p1=new Array(Y),H1=0;H1S);W++){for(var t1=-W+Y1;t1<=W-r0;t1+=2){var y1=$+t1,b1;t1==-W||t1!=W&&r1[y1-1]O)r0+=2;else if(j1>P)Y1+=2;else if(U1){var Z1=$+N1-t1;if(Z1>=0&&Z1=K1)return this.diff_bisectSplit_(m,H,b1,j1,S)}}}for(var J1=-W+u0;J1<=W-p0;J1+=2){var Z1=$+J1,K1;J1==-W||J1!=W&&p1[Z1-1]O)p0+=2;else if(q1>P)u0+=2;else if(!U1){var y1=$+N1-J1;if(y1>=0&&y1=K1)return this.diff_bisectSplit_(m,H,b1,j1,S)}}}}return[[w,m],[y,H]]},p.prototype.diff_bisectSplit_=function(m,H,S,O,P){var I=m.substring(0,S),$=H.substring(0,O),Y=m.substring(S),r1=H.substring(O),p1=this.diff_main(I,$,!1,P),H1=this.diff_main(Y,r1,!1,P);return p1.concat(H1)},p.prototype.diff_linesToChars_=function(m,H){var S=[],O={};S[0]="";function P(Y){for(var r1="",p1=0,H1=-1,N1=S.length;H1O?m=m.substring(S-O):SH.length?m:H,O=m.length>H.length?H:m;if(S.length<4||O.length*2=r0.length?[b1,j1,Z1,K1,y1]:null}var $=I(S,O,Math.ceil(S.length/4)),Y=I(S,O,Math.ceil(S.length/2)),r1;if(!$&&!Y)return null;Y?$?r1=$[4].length>Y[4].length?$:Y:r1=Y:r1=$;var p1,H1,N1,U1;m.length>H.length?(p1=r1[0],H1=r1[1],N1=r1[2],U1=r1[3]):(N1=r1[0],U1=r1[1],p1=r1[2],H1=r1[3]);var Y1=r1[4];return[p1,H1,N1,U1,Y1]},p.prototype.diff_cleanupSemantic=function(m){for(var H=!1,S=[],O=0,P=null,I=0,$=0,Y=0,r1=0,p1=0;I0?S[O-1]:-1,$=0,Y=0,r1=0,p1=0,P=null,H=!0)),I++;for(H&&this.diff_cleanupMerge(m),this.diff_cleanupSemanticLossless(m),I=1;I=Y1?(U1>=H1.length/2||U1>=N1.length/2)&&(m.splice(I,0,[L,N1.substring(0,U1)]),m[I-1][1]=H1.substring(0,H1.length-U1),m[I+1][1]=N1.substring(U1),I++):(Y1>=H1.length/2||Y1>=N1.length/2)&&(m.splice(I,0,[L,H1.substring(0,Y1)]),m[I-1][0]=y,m[I-1][1]=N1.substring(0,N1.length-Y1),m[I+1][0]=w,m[I+1][1]=H1.substring(Y1),I++),I++}I++}},p.prototype.diff_cleanupSemanticLossless=function(m){function H(Y1,r0){if(!Y1||!r0)return 6;var u0=Y1.charAt(Y1.length-1),p0=r0.charAt(0),W=u0.match(p.nonAlphaNumericRegex_),t1=p0.match(p.nonAlphaNumericRegex_),y1=W&&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:W&&!y1&&b1?3:y1||b1?2:W||t1?1:0}for(var S=1;S=N1&&(N1=U1,r1=O,p1=P,H1=I)}m[S-1][1]!=r1&&(r1?m[S-1][1]=r1:(m.splice(S-1,1),S--),m[S][1]=p1,H1?m[S+1][1]=H1:(m.splice(S+1,1),S--))}S++}},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(m){for(var H=!1,S=[],O=0,P=null,I=0,$=!1,Y=!1,r1=!1,p1=!1;I0?S[O-1]:-1,r1=p1=!1),H=!0)),I++;H&&this.diff_cleanupMerge(m)},p.prototype.diff_cleanupMerge=function(m){m.push([L,""]);for(var H=0,S=0,O=0,P="",I="",$;H1?(S!==0&&O!==0&&($=this.diff_commonPrefix(I,P),$!==0&&(H-S-O>0&&m[H-S-O-1][0]==L?m[H-S-O-1][1]+=I.substring(0,$):(m.splice(0,0,[L,I.substring(0,$)]),H++),I=I.substring($),P=P.substring($)),$=this.diff_commonSuffix(I,P),$!==0&&(m[H][1]=I.substring(I.length-$)+m[H][1],I=I.substring(0,I.length-$),P=P.substring(0,P.length-$))),S===0?m.splice(H-O,S+O,[y,I]):O===0?m.splice(H-S,S+O,[w,P]):m.splice(H-S-O,S+O,[w,P],[y,I]),H=H-S-O+(S?1:0)+(O?1:0)+1):H!==0&&m[H-1][0]==L?(m[H-1][1]+=m[H][1],m.splice(H,1)):H++,O=0,S=0,P="",I="";break}m[m.length-1][1]===""&&m.pop();var Y=!1;for(H=1;HH));$++)P=S,I=O;return m.length!=$&&m[$][0]===w?I:I+(H-P)},p.prototype.diff_prettyHtml=function(m){for(var H=[],S=/&/g,O=//g,I=/\n/g,$=0;$");switch(Y){case y:H[$]=''+p1+"";break;case w:H[$]=''+p1+"";break;case L:H[$]=""+p1+"";break}}return H.join("")},p.prototype.diff_text1=function(m){for(var H=[],S=0;Sthis.Match_MaxBits)throw new Error("Pattern too long for this browser.");var O=this.match_alphabet_(H),P=this;function I(b1,j1){var Z1=b1/H.length,K1=Math.abs(S-j1);return P.Match_Distance?Z1+K1/P.Match_Distance:K1?1:Z1}var $=this.Match_Threshold,Y=m.indexOf(H,S);Y!=-1&&($=Math.min(I(0,Y),$),Y=m.lastIndexOf(H,S+H.length),Y!=-1&&($=Math.min(I(0,Y),$)));var r1=1<=r0;W--){var t1=O[m.charAt(W-1)];if(Y1===0?p0[W]=(p0[W+1]<<1|1)&t1:p0[W]=(p0[W+1]<<1|1)&t1|((U1[W+1]|U1[W])<<1|1)|U1[W+1],p0[W]&r1){var y1=I(Y1,W-1);if(y1<=$)if($=y1,Y=W-1,Y>S)r0=Math.max(1,2*S-Y);else break}}if(I(Y1+1,S)>$)break;U1=p0}return Y},p.prototype.match_alphabet_=function(m){for(var H={},S=0;S"u")O=m,P=this.diff_main(O,H,!0),P.length>2&&(this.diff_cleanupSemantic(P),this.diff_cleanupEfficiency(P));else if(m&&typeof m=="object"&&typeof H>"u"&&typeof S>"u")P=m,O=this.diff_text1(P);else if(typeof m=="string"&&H&&typeof H=="object"&&typeof S>"u")O=m,P=H;else if(typeof m=="string"&&typeof H=="string"&&S&&typeof S=="object")O=m,P=S;else throw new Error("Unknown call format to patch_make.");if(P.length===0)return[];for(var I=[],$=new p.patch_obj,Y=0,r1=0,p1=0,H1=O,N1=O,U1=0;U1=2*this.Patch_Margin&&Y&&(this.patch_addContext_($,H1),I.push($),$=new p.patch_obj,Y=0,H1=N1,r1=p1);break}Y1!==y&&(r1+=r0.length),Y1!==w&&(p1+=r0.length)}return Y&&(this.patch_addContext_($,H1),I.push($)),I},p.prototype.patch_deepCopy=function(m){for(var H=[],S=0;Sthis.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)P[I]=!1,O-=m[I].length2-m[I].length1;else{P[I]=!0,O=r1-$;var H1;if(p1==-1?H1=H.substring(r1,r1+Y.length):H1=H.substring(r1,p1+this.Match_MaxBits),Y==H1)H=H.substring(0,r1)+this.diff_text2(m[I].diffs)+H.substring(r1+Y.length);else{var N1=this.diff_main(Y,H1,!1);if(Y.length>this.Match_MaxBits&&this.diff_levenshtein(N1)/Y.length>this.Patch_DeleteThreshold)P[I]=!1;else{this.diff_cleanupSemanticLossless(N1);for(var U1=0,Y1,r0=0;r0I[0][1].length){var $=H-I[0][1].length;I[0][1]=S.substring(I[0][1].length)+I[0][1],P.start1-=$,P.start2-=$,P.length1+=$,P.length2+=$}if(P=m[m.length-1],I=P.diffs,I.length==0||I[I.length-1][0]!=L)I.push([L,S]),P.length1+=H,P.length2+=H;else if(H>I[I.length-1][1].length){var $=H-I[I.length-1][1].length;I[I.length-1][1]+=S.substring(0,$),P.length1+=$,P.length2+=$}return S},p.prototype.patch_splitMax=function(m){for(var H=this.Match_MaxBits,S=0;S2*H?(Y.length1+=H1.length,P+=H1.length,r1=!1,Y.diffs.push([p1,H1]),O.diffs.shift()):(H1=H1.substring(0,H-Y.length1-this.Patch_Margin),Y.length1+=H1.length,P+=H1.length,p1===L?(Y.length2+=H1.length,I+=H1.length):r1=!1,Y.diffs.push([p1,H1]),H1==O.diffs[0][1]?O.diffs.shift():O.diffs[0][1]=O.diffs[0][1].substring(H1.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]===L?Y.diffs[Y.diffs.length-1][1]+=N1:Y.diffs.push([L,N1])),r1||m.splice(++S,0,Y)}}},p.prototype.patch_toText=function(m){for(var H=[],S=0;S"u"&&typeof m>"u")){var $=this.getDeltaType(y,S),Y=$==="node"?y._t==="a"?"array":"object":"";typeof m<"u"?this.nodeBegin(w,m,H,$,Y,O):this.rootBegin(w,$,Y);var r1=void 0;try{r1=this["format_"+$]||this.typeFormattterNotFound(w,$),r1.call(this,w,y,I,m,H,S)}catch(p1){this.typeFormattterErrorFormatter(w,p1,y,I,m,H,S),typeof console<"u"&&console.error&&console.error(p1.stack)}typeof m<"u"?this.nodeEnd(w,m,H,$,Y,O):this.rootEnd(w,$,Y)}}},{key:"formatDeltaChildren",value:function(w,y,L){var m=this;this.forEachDeltaKey(y,L,function(H,S,O,P){m.recurse(w,y[H],L?L[S]:void 0,H,S,O,P)})}},{key:"forEachDeltaKey",value:function(w,y,L){var m=_1(w),H=w._t==="a",S={},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")&&m.push(O);for(O in w)if(Object.prototype.hasOwnProperty.call(w,O)){var P=w[O];z1(P)&&P[2]===3&&(S[P[1].toString()]={key:O,value:y&&y[parseInt(O.substr(1))]},this.includeMoveDestinations!==!1&&typeof y>"u"&&typeof w[P[1]]>"u"&&m.push(P[1].toString()))}H?m.sort(M1):m.sort();for(var I=0,$=m.length;I<$;I++){var Y=m[I];if(!(H&&Y==="_t")){var r1=H?typeof Y=="number"?Y:parseInt(A1(Y),10):Y,p1=I===$-1;L(Y,r1,S[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=[],L=w.split(` -@@ `),m=0,H=L.length;m'+L+"")}},{key:"formatValue",value:function(y,L){y.out("
"+k1(JSON.stringify(L,null,2))+"
")}},{key:"formatTextDiffString",value:function(y,L){var m=this.parseTextDiff(L);y.out('
    ');for(var H=0,S=m.length;H
    '+(''+O.location.line+''+O.location.chr+'
    '));for(var P=O.pieces,I=0,$=P.length;I<$;I++){var Y=P[I];y.out(''+k1(decodeURI(Y.text))+"")}y.out("
    ")}y.out("
")}},{key:"rootBegin",value:function(y,L,m){var H="jsondiffpatch-"+L+(m?" jsondiffpatch-child-node-type-"+m:"");y.out('
')}},{key:"rootEnd",value:function(y){y.out("
"+(y.hasArrows?' - +